[iOS] remove Skia interfaces from iOS platform code. (#163505)
Skia can no longer be enabled on iOS. Remove software and skia surfaces, references to GrContext.
This commit is contained in:
parent
ae100a265b
commit
90d7ced2e7
@ -43431,12 +43431,8 @@ ORIGIN: ../../../flutter/shell/platform/darwin/ios/ios_context.h + ../../../flut
|
||||
ORIGIN: ../../../flutter/shell/platform/darwin/ios/ios_context.mm + ../../../flutter/LICENSE
|
||||
ORIGIN: ../../../flutter/shell/platform/darwin/ios/ios_context_metal_impeller.h + ../../../flutter/LICENSE
|
||||
ORIGIN: ../../../flutter/shell/platform/darwin/ios/ios_context_metal_impeller.mm + ../../../flutter/LICENSE
|
||||
ORIGIN: ../../../flutter/shell/platform/darwin/ios/ios_context_metal_skia.h + ../../../flutter/LICENSE
|
||||
ORIGIN: ../../../flutter/shell/platform/darwin/ios/ios_context_metal_skia.mm + ../../../flutter/LICENSE
|
||||
ORIGIN: ../../../flutter/shell/platform/darwin/ios/ios_context_noop.h + ../../../flutter/LICENSE
|
||||
ORIGIN: ../../../flutter/shell/platform/darwin/ios/ios_context_noop.mm + ../../../flutter/LICENSE
|
||||
ORIGIN: ../../../flutter/shell/platform/darwin/ios/ios_context_software.h + ../../../flutter/LICENSE
|
||||
ORIGIN: ../../../flutter/shell/platform/darwin/ios/ios_context_software.mm + ../../../flutter/LICENSE
|
||||
ORIGIN: ../../../flutter/shell/platform/darwin/ios/ios_external_texture_metal.h + ../../../flutter/LICENSE
|
||||
ORIGIN: ../../../flutter/shell/platform/darwin/ios/ios_external_texture_metal.mm + ../../../flutter/LICENSE
|
||||
ORIGIN: ../../../flutter/shell/platform/darwin/ios/ios_external_view_embedder.h + ../../../flutter/LICENSE
|
||||
@ -43445,12 +43441,8 @@ ORIGIN: ../../../flutter/shell/platform/darwin/ios/ios_surface.h + ../../../flut
|
||||
ORIGIN: ../../../flutter/shell/platform/darwin/ios/ios_surface.mm + ../../../flutter/LICENSE
|
||||
ORIGIN: ../../../flutter/shell/platform/darwin/ios/ios_surface_metal_impeller.h + ../../../flutter/LICENSE
|
||||
ORIGIN: ../../../flutter/shell/platform/darwin/ios/ios_surface_metal_impeller.mm + ../../../flutter/LICENSE
|
||||
ORIGIN: ../../../flutter/shell/platform/darwin/ios/ios_surface_metal_skia.h + ../../../flutter/LICENSE
|
||||
ORIGIN: ../../../flutter/shell/platform/darwin/ios/ios_surface_metal_skia.mm + ../../../flutter/LICENSE
|
||||
ORIGIN: ../../../flutter/shell/platform/darwin/ios/ios_surface_noop.h + ../../../flutter/LICENSE
|
||||
ORIGIN: ../../../flutter/shell/platform/darwin/ios/ios_surface_noop.mm + ../../../flutter/LICENSE
|
||||
ORIGIN: ../../../flutter/shell/platform/darwin/ios/ios_surface_software.h + ../../../flutter/LICENSE
|
||||
ORIGIN: ../../../flutter/shell/platform/darwin/ios/ios_surface_software.mm + ../../../flutter/LICENSE
|
||||
ORIGIN: ../../../flutter/shell/platform/darwin/ios/platform_message_handler_ios.h + ../../../flutter/LICENSE
|
||||
ORIGIN: ../../../flutter/shell/platform/darwin/ios/platform_message_handler_ios.mm + ../../../flutter/LICENSE
|
||||
ORIGIN: ../../../flutter/shell/platform/darwin/ios/platform_message_handler_ios_test.mm + ../../../flutter/LICENSE
|
||||
@ -46420,12 +46412,8 @@ FILE: ../../../flutter/shell/platform/darwin/ios/ios_context.h
|
||||
FILE: ../../../flutter/shell/platform/darwin/ios/ios_context.mm
|
||||
FILE: ../../../flutter/shell/platform/darwin/ios/ios_context_metal_impeller.h
|
||||
FILE: ../../../flutter/shell/platform/darwin/ios/ios_context_metal_impeller.mm
|
||||
FILE: ../../../flutter/shell/platform/darwin/ios/ios_context_metal_skia.h
|
||||
FILE: ../../../flutter/shell/platform/darwin/ios/ios_context_metal_skia.mm
|
||||
FILE: ../../../flutter/shell/platform/darwin/ios/ios_context_noop.h
|
||||
FILE: ../../../flutter/shell/platform/darwin/ios/ios_context_noop.mm
|
||||
FILE: ../../../flutter/shell/platform/darwin/ios/ios_context_software.h
|
||||
FILE: ../../../flutter/shell/platform/darwin/ios/ios_context_software.mm
|
||||
FILE: ../../../flutter/shell/platform/darwin/ios/ios_external_texture_metal.h
|
||||
FILE: ../../../flutter/shell/platform/darwin/ios/ios_external_texture_metal.mm
|
||||
FILE: ../../../flutter/shell/platform/darwin/ios/ios_external_view_embedder.h
|
||||
@ -46434,12 +46422,8 @@ FILE: ../../../flutter/shell/platform/darwin/ios/ios_surface.h
|
||||
FILE: ../../../flutter/shell/platform/darwin/ios/ios_surface.mm
|
||||
FILE: ../../../flutter/shell/platform/darwin/ios/ios_surface_metal_impeller.h
|
||||
FILE: ../../../flutter/shell/platform/darwin/ios/ios_surface_metal_impeller.mm
|
||||
FILE: ../../../flutter/shell/platform/darwin/ios/ios_surface_metal_skia.h
|
||||
FILE: ../../../flutter/shell/platform/darwin/ios/ios_surface_metal_skia.mm
|
||||
FILE: ../../../flutter/shell/platform/darwin/ios/ios_surface_noop.h
|
||||
FILE: ../../../flutter/shell/platform/darwin/ios/ios_surface_noop.mm
|
||||
FILE: ../../../flutter/shell/platform/darwin/ios/ios_surface_software.h
|
||||
FILE: ../../../flutter/shell/platform/darwin/ios/ios_surface_software.mm
|
||||
FILE: ../../../flutter/shell/platform/darwin/ios/platform_message_handler_ios.h
|
||||
FILE: ../../../flutter/shell/platform/darwin/ios/platform_message_handler_ios.mm
|
||||
FILE: ../../../flutter/shell/platform/darwin/ios/platform_message_handler_ios_test.mm
|
||||
|
@ -130,12 +130,8 @@ source_set("flutter_framework_source") {
|
||||
"ios_context.mm",
|
||||
"ios_context_metal_impeller.h",
|
||||
"ios_context_metal_impeller.mm",
|
||||
"ios_context_metal_skia.h",
|
||||
"ios_context_metal_skia.mm",
|
||||
"ios_context_noop.h",
|
||||
"ios_context_noop.mm",
|
||||
"ios_context_software.h",
|
||||
"ios_context_software.mm",
|
||||
"ios_external_texture_metal.h",
|
||||
"ios_external_texture_metal.mm",
|
||||
"ios_external_view_embedder.h",
|
||||
@ -144,12 +140,8 @@ source_set("flutter_framework_source") {
|
||||
"ios_surface.mm",
|
||||
"ios_surface_metal_impeller.h",
|
||||
"ios_surface_metal_impeller.mm",
|
||||
"ios_surface_metal_skia.h",
|
||||
"ios_surface_metal_skia.mm",
|
||||
"ios_surface_noop.h",
|
||||
"ios_surface_noop.mm",
|
||||
"ios_surface_software.h",
|
||||
"ios_surface_software.mm",
|
||||
"platform_message_handler_ios.h",
|
||||
"platform_message_handler_ios.mm",
|
||||
"platform_view_ios.h",
|
||||
@ -260,7 +252,6 @@ shared_library("ios_test_flutter") {
|
||||
"//flutter/shell/platform/darwin/common:framework_common",
|
||||
"//flutter/shell/platform/embedder:embedder_as_internal_library",
|
||||
"//flutter/shell/platform/embedder:embedder_test_utils",
|
||||
"//flutter/skia",
|
||||
"//flutter/third_party/ocmock:ocmock_shared",
|
||||
"//flutter/third_party/rapidjson",
|
||||
"//flutter/third_party/spring_animation",
|
||||
|
@ -14,7 +14,6 @@
|
||||
#include "flutter/fml/task_runner.h"
|
||||
#include "flutter/fml/trace_event.h"
|
||||
#include "impeller/base/thread_safety.h"
|
||||
#include "third_party/skia/include/core/SkRect.h"
|
||||
|
||||
#import "flutter/shell/platform/darwin/common/framework/Headers/FlutterChannels.h"
|
||||
#import "flutter/shell/platform/darwin/ios/framework/Headers/FlutterPlatformViews.h"
|
||||
@ -99,8 +98,7 @@ NS_ASSUME_NONNULL_BEGIN
|
||||
///
|
||||
/// Called from the raster thread.
|
||||
- (BOOL)submitFrame:(std::unique_ptr<flutter::SurfaceFrame>)frame
|
||||
withIosContext:(const std::shared_ptr<flutter::IOSContext>&)iosContext
|
||||
grContext:(GrDirectContext* _Nullable)grContext;
|
||||
withIosContext:(const std::shared_ptr<flutter::IOSContext>&)iosContext;
|
||||
|
||||
/// @brief Handler for platform view message channels.
|
||||
- (void)onMethodCall:(FlutterMethodCall*)call result:(FlutterResult)result;
|
||||
|
@ -15,12 +15,6 @@
|
||||
#include "flutter/shell/platform/darwin/ios/framework/Source/overlay_layer_pool.h"
|
||||
#import "flutter/shell/platform/darwin/ios/ios_surface.h"
|
||||
|
||||
// The number of frames the rasterizer task runner will continue
|
||||
// to run on the platform thread after no platform view is rendered.
|
||||
//
|
||||
// Note: this is an arbitrary number.
|
||||
static constexpr int kDefaultMergedLeaseDuration = 10;
|
||||
|
||||
static constexpr NSUInteger kFlutterClippingMaskViewPoolCapacity = 5;
|
||||
|
||||
struct LayerData {
|
||||
@ -202,8 +196,7 @@ static bool ClipRRectContainsPlatformViewBoundingRect(const SkRRect& clip_rrect,
|
||||
///
|
||||
/// This requires posting a task to the platform thread and blocking on its completion.
|
||||
- (void)createMissingOverlays:(size_t)requiredOverlayLayers
|
||||
withIosContext:(const std::shared_ptr<flutter::IOSContext>&)iosContext
|
||||
grContext:(GrDirectContext*)grContext;
|
||||
withIosContext:(const std::shared_ptr<flutter::IOSContext>&)iosContext;
|
||||
|
||||
/// Update the buffers and mutate the platform views in CATransaction on the platform thread.
|
||||
- (void)performSubmit:(const LayersMap&)platformViewLayers
|
||||
@ -248,7 +241,6 @@ static bool ClipRRectContainsPlatformViewBoundingRect(const SkRRect& clip_rrect,
|
||||
|
||||
/// Runs on the platform thread.
|
||||
- (void)createLayerWithIosContext:(const std::shared_ptr<flutter::IOSContext>&)iosContext
|
||||
grContext:(GrDirectContext*)grContext
|
||||
pixelFormat:(MTLPixelFormat)pixelFormat
|
||||
screenScale:(CGFloat)screenScale;
|
||||
|
||||
@ -458,49 +450,12 @@ static bool ClipRRectContainsPlatformViewBoundingRect(const SkRRect& clip_rrect,
|
||||
- (flutter::PostPrerollResult)postPrerollActionWithThreadMerger:
|
||||
(const fml::RefPtr<fml::RasterThreadMerger>&)rasterThreadMerger
|
||||
impellerEnabled:(BOOL)impellerEnabled {
|
||||
// TODO(jonahwilliams): remove this once Software backend is removed for iOS Sim.
|
||||
#ifdef FML_OS_IOS_SIMULATOR
|
||||
const bool mergeThreads = true;
|
||||
#else
|
||||
const bool mergeThreads = !impellerEnabled;
|
||||
#endif // FML_OS_IOS_SIMULATOR
|
||||
|
||||
if (mergeThreads) {
|
||||
if (self.compositionOrder.empty()) {
|
||||
return flutter::PostPrerollResult::kSuccess;
|
||||
}
|
||||
if (!rasterThreadMerger->IsMerged()) {
|
||||
// The raster thread merger may be disabled if the rasterizer is being
|
||||
// created or teared down.
|
||||
//
|
||||
// In such cases, the current frame is dropped, and a new frame is attempted
|
||||
// with the same layer tree.
|
||||
//
|
||||
// Eventually, the frame is submitted once this method returns `kSuccess`.
|
||||
// At that point, the raster tasks are handled on the platform thread.
|
||||
[self cancelFrame];
|
||||
return flutter::PostPrerollResult::kSkipAndRetryFrame;
|
||||
}
|
||||
// If the post preroll action is successful, we will display platform views in the current
|
||||
// frame. In order to sync the rendering of the platform views (quartz) with skia's rendering,
|
||||
// We need to begin an explicit CATransaction. This transaction needs to be submitted
|
||||
// after the current frame is submitted.
|
||||
rasterThreadMerger->ExtendLeaseTo(kDefaultMergedLeaseDuration);
|
||||
}
|
||||
return flutter::PostPrerollResult::kSuccess;
|
||||
}
|
||||
|
||||
- (void)endFrameWithResubmit:(BOOL)shouldResubmitFrame
|
||||
threadMerger:(const fml::RefPtr<fml::RasterThreadMerger>&)rasterThreadMerger
|
||||
impellerEnabled:(BOOL)impellerEnabled {
|
||||
#if FML_OS_IOS_SIMULATOR
|
||||
BOOL runCheck = YES;
|
||||
#else
|
||||
BOOL runCheck = !impellerEnabled;
|
||||
#endif // FML_OS_IOS_SIMULATOR
|
||||
if (runCheck && shouldResubmitFrame) {
|
||||
rasterThreadMerger->MergeWithLease(kDefaultMergedLeaseDuration);
|
||||
}
|
||||
}
|
||||
|
||||
- (void)pushFilterToVisitedPlatformViews:(const std::shared_ptr<flutter::DlImageFilter>&)filter
|
||||
@ -733,8 +688,7 @@ static bool ClipRRectContainsPlatformViewBoundingRect(const SkRRect& clip_rrect,
|
||||
}
|
||||
|
||||
- (BOOL)submitFrame:(std::unique_ptr<flutter::SurfaceFrame>)background_frame
|
||||
withIosContext:(const std::shared_ptr<flutter::IOSContext>&)iosContext
|
||||
grContext:(GrDirectContext*)grContext {
|
||||
withIosContext:(const std::shared_ptr<flutter::IOSContext>&)iosContext {
|
||||
TRACE_EVENT0("flutter", "PlatformViewsController::SubmitFrame");
|
||||
|
||||
// No platform views to render; we're done.
|
||||
@ -769,7 +723,7 @@ static bool ClipRRectContainsPlatformViewBoundingRect(const SkRRect& clip_rrect,
|
||||
// If there are not sufficient overlay layers, we must construct them on the platform
|
||||
// thread, at least until we've refactored iOS surface creation to use IOSurfaces
|
||||
// instead of CALayers.
|
||||
[self createMissingOverlays:requiredOverlayLayers withIosContext:iosContext grContext:grContext];
|
||||
[self createMissingOverlays:requiredOverlayLayers withIosContext:iosContext];
|
||||
|
||||
int64_t overlayId = 0;
|
||||
for (int64_t viewId : self.compositionOrder) {
|
||||
@ -847,8 +801,7 @@ static bool ClipRRectContainsPlatformViewBoundingRect(const SkRRect& clip_rrect,
|
||||
}
|
||||
|
||||
- (void)createMissingOverlays:(size_t)requiredOverlayLayers
|
||||
withIosContext:(const std::shared_ptr<flutter::IOSContext>&)iosContext
|
||||
grContext:(GrDirectContext*)grContext {
|
||||
withIosContext:(const std::shared_ptr<flutter::IOSContext>&)iosContext {
|
||||
TRACE_EVENT0("flutter", "PlatformViewsController::CreateMissingLayers");
|
||||
|
||||
if (requiredOverlayLayers <= self.layerPool->size()) {
|
||||
@ -860,10 +813,9 @@ static bool ClipRRectContainsPlatformViewBoundingRect(const SkRRect& clip_rrect,
|
||||
// complete.
|
||||
auto latch = std::make_shared<fml::CountDownLatch>(1u);
|
||||
fml::TaskRunner::RunNowOrPostTask(
|
||||
self.platformTaskRunner, [self, missingLayerCount, iosContext, grContext, latch]() {
|
||||
self.platformTaskRunner, [self, missingLayerCount, iosContext, latch]() {
|
||||
for (auto i = 0u; i < missingLayerCount; i++) {
|
||||
[self createLayerWithIosContext:iosContext
|
||||
grContext:grContext
|
||||
pixelFormat:((FlutterView*)self.flutterView).pixelFormat
|
||||
screenScale:((FlutterView*)self.flutterView).screen.scale];
|
||||
}
|
||||
@ -969,10 +921,9 @@ static bool ClipRRectContainsPlatformViewBoundingRect(const SkRRect& clip_rrect,
|
||||
}
|
||||
|
||||
- (void)createLayerWithIosContext:(const std::shared_ptr<flutter::IOSContext>&)iosContext
|
||||
grContext:(GrDirectContext*)grContext
|
||||
pixelFormat:(MTLPixelFormat)pixelFormat
|
||||
screenScale:(CGFloat)screenScale {
|
||||
self.layerPool->CreateLayer(grContext, iosContext, pixelFormat, screenScale);
|
||||
self.layerPool->CreateLayer(iosContext, pixelFormat, screenScale);
|
||||
}
|
||||
|
||||
- (void)removeUnusedLayers:(const std::vector<std::shared_ptr<flutter::OverlayLayer>>&)unusedLayers
|
||||
|
@ -3573,8 +3573,7 @@ fml::RefPtr<fml::TaskRunner> GetDefaultTaskRunner() {
|
||||
/*frame_size=*/SkISize::Make(800, 600));
|
||||
XCTAssertFalse([flutterPlatformViewsController
|
||||
submitFrame:std::move(mock_surface)
|
||||
withIosContext:std::make_shared<flutter::IOSContextNoop>()
|
||||
grContext:nil]);
|
||||
withIosContext:std::make_shared<flutter::IOSContextNoop>()]);
|
||||
|
||||
auto embeddedViewParams_2 =
|
||||
std::make_unique<flutter::EmbeddedViewParams>(finalMatrix, SkSize::Make(300, 300), stack);
|
||||
@ -3591,8 +3590,7 @@ fml::RefPtr<fml::TaskRunner> GetDefaultTaskRunner() {
|
||||
/*frame_size=*/SkISize::Make(800, 600));
|
||||
XCTAssertTrue([flutterPlatformViewsController
|
||||
submitFrame:std::move(mock_surface_submit_true)
|
||||
withIosContext:std::make_shared<flutter::IOSContextNoop>()
|
||||
grContext:nil]);
|
||||
withIosContext:std::make_shared<flutter::IOSContextNoop>()]);
|
||||
}
|
||||
|
||||
- (void)
|
||||
@ -3645,7 +3643,7 @@ fml::RefPtr<fml::TaskRunner> GetDefaultTaskRunner() {
|
||||
[flutterPlatformViewsController prerollCompositeEmbeddedView:2
|
||||
withParams:std::move(embeddedViewParams)];
|
||||
|
||||
// Not calling |[flutterPlatformViewsController submitFrame:withIosContext:grContext:]| so that
|
||||
// Not calling |[flutterPlatformViewsController submitFrame:withIosContext:]| so that
|
||||
// the platform views are not added to flutter_view_.
|
||||
|
||||
XCTAssertNotNil(gMockPlatformView);
|
||||
@ -3806,8 +3804,7 @@ fml::RefPtr<fml::TaskRunner> GetDefaultTaskRunner() {
|
||||
/*frame_size=*/SkISize::Make(800, 600));
|
||||
XCTAssertTrue([flutterPlatformViewsController
|
||||
submitFrame:std::move(mock_surface)
|
||||
withIosContext:std::make_shared<flutter::IOSContextNoop>()
|
||||
grContext:nil]);
|
||||
withIosContext:std::make_shared<flutter::IOSContextNoop>()]);
|
||||
|
||||
// platform view is wrapped by touch interceptor, which itself is wrapped by clipping view.
|
||||
UIView* clippingView1 = view1.superview.superview;
|
||||
@ -3837,8 +3834,7 @@ fml::RefPtr<fml::TaskRunner> GetDefaultTaskRunner() {
|
||||
/*frame_size=*/SkISize::Make(800, 600));
|
||||
XCTAssertTrue([flutterPlatformViewsController
|
||||
submitFrame:std::move(mock_surface)
|
||||
withIosContext:std::make_shared<flutter::IOSContextNoop>()
|
||||
grContext:nil]);
|
||||
withIosContext:std::make_shared<flutter::IOSContextNoop>()]);
|
||||
|
||||
XCTAssertTrue([flutterView.subviews indexOfObject:clippingView1] >
|
||||
[flutterView.subviews indexOfObject:clippingView2],
|
||||
@ -3924,8 +3920,7 @@ fml::RefPtr<fml::TaskRunner> GetDefaultTaskRunner() {
|
||||
/*frame_size=*/SkISize::Make(800, 600));
|
||||
XCTAssertTrue([flutterPlatformViewsController
|
||||
submitFrame:std::move(mock_surface)
|
||||
withIosContext:std::make_shared<flutter::IOSContextNoop>()
|
||||
grContext:nil]);
|
||||
withIosContext:std::make_shared<flutter::IOSContextNoop>()]);
|
||||
|
||||
// platform view is wrapped by touch interceptor, which itself is wrapped by clipping view.
|
||||
UIView* clippingView1 = view1.superview.superview;
|
||||
@ -3955,8 +3950,7 @@ fml::RefPtr<fml::TaskRunner> GetDefaultTaskRunner() {
|
||||
/*frame_size=*/SkISize::Make(800, 600));
|
||||
XCTAssertTrue([flutterPlatformViewsController
|
||||
submitFrame:std::move(mock_surface)
|
||||
withIosContext:std::make_shared<flutter::IOSContextNoop>()
|
||||
grContext:nil]);
|
||||
withIosContext:std::make_shared<flutter::IOSContextNoop>()]);
|
||||
|
||||
XCTAssertTrue([flutterView.subviews indexOfObject:clippingView1] <
|
||||
[flutterView.subviews indexOfObject:clippingView2],
|
||||
@ -4439,8 +4433,7 @@ fml::RefPtr<fml::TaskRunner> GetDefaultTaskRunner() {
|
||||
/*frame_size=*/SkISize::Make(800, 600));
|
||||
XCTAssertTrue([flutterPlatformViewsController
|
||||
submitFrame:std::move(mock_surface)
|
||||
withIosContext:std::make_shared<flutter::IOSContextNoop>()
|
||||
grContext:nil]);
|
||||
withIosContext:std::make_shared<flutter::IOSContextNoop>()]);
|
||||
|
||||
// Disposing won't remove embedded views until the view is removed from the composition_order_
|
||||
XCTAssertEqual(flutterPlatformViewsController.embeddedViewCount, 2UL);
|
||||
@ -4469,8 +4462,7 @@ fml::RefPtr<fml::TaskRunner> GetDefaultTaskRunner() {
|
||||
/*frame_size=*/SkISize::Make(800, 600));
|
||||
XCTAssertTrue([flutterPlatformViewsController
|
||||
submitFrame:std::move(mock_surface)
|
||||
withIosContext:std::make_shared<flutter::IOSContextNoop>()
|
||||
grContext:nil]);
|
||||
withIosContext:std::make_shared<flutter::IOSContextNoop>()]);
|
||||
|
||||
// Disposing won't remove embedded views until the view is removed from the composition_order_
|
||||
XCTAssertEqual(flutterPlatformViewsController.embeddedViewCount, 1UL);
|
||||
@ -4547,8 +4539,7 @@ fml::RefPtr<fml::TaskRunner> GetDefaultTaskRunner() {
|
||||
[](const flutter::SurfaceFrame& surface_frame) { return true; },
|
||||
/*frame_size=*/SkISize::Make(800, 600));
|
||||
[flutterPlatformViewsController submitFrame:std::move(mock_surface)
|
||||
withIosContext:std::make_shared<flutter::IOSContextNoop>()
|
||||
grContext:nil];
|
||||
withIosContext:std::make_shared<flutter::IOSContextNoop>()];
|
||||
|
||||
UIView* someView = [[UIView alloc] init];
|
||||
[flutterView addSubview:someView];
|
||||
@ -4628,8 +4619,7 @@ fml::RefPtr<fml::TaskRunner> GetDefaultTaskRunner() {
|
||||
[](const flutter::SurfaceFrame& surface_frame) { return true; },
|
||||
/*frame_size=*/SkISize::Make(800, 600));
|
||||
[flutterPlatformViewsController submitFrame:std::move(mock_surface)
|
||||
withIosContext:std::make_shared<flutter::IOSContextNoop>()
|
||||
grContext:nil];
|
||||
withIosContext:std::make_shared<flutter::IOSContextNoop>()];
|
||||
|
||||
XCTAssertEqual(flutterView.subviews.count, 1u);
|
||||
}
|
||||
@ -4642,19 +4632,18 @@ fml::RefPtr<fml::TaskRunner> GetDefaultTaskRunner() {
|
||||
}
|
||||
|
||||
- (void)testLayerPool {
|
||||
// Create an IOSContext and GrDirectContext.
|
||||
// Create an IOSContext.
|
||||
FlutterEngine* engine = [[FlutterEngine alloc] initWithName:@"foobar"];
|
||||
[engine run];
|
||||
XCTAssertTrue(engine.platformView != nullptr);
|
||||
auto ios_context = engine.platformView->GetIosContext();
|
||||
auto gr_context = ios_context->GetMainContext();
|
||||
|
||||
auto pool = flutter::OverlayLayerPool{};
|
||||
|
||||
// Add layers to the pool.
|
||||
pool.CreateLayer(gr_context.get(), ios_context, MTLPixelFormatBGRA8Unorm, 1);
|
||||
pool.CreateLayer(ios_context, MTLPixelFormatBGRA8Unorm, 1);
|
||||
XCTAssertEqual(pool.size(), 1u);
|
||||
pool.CreateLayer(gr_context.get(), ios_context, MTLPixelFormatBGRA8Unorm, 1);
|
||||
pool.CreateLayer(ios_context, MTLPixelFormatBGRA8Unorm, 1);
|
||||
XCTAssertEqual(pool.size(), 2u);
|
||||
|
||||
// Mark all layers as unused.
|
||||
@ -4751,8 +4740,7 @@ fml::RefPtr<fml::TaskRunner> GetDefaultTaskRunner() {
|
||||
});
|
||||
|
||||
[flutterPlatformViewsController submitFrame:std::move(mock_surface)
|
||||
withIosContext:std::make_shared<flutter::IOSContextNoop>()
|
||||
grContext:nil];
|
||||
withIosContext:std::make_shared<flutter::IOSContextNoop>()];
|
||||
|
||||
XCTAssertTrue(submit_info.has_value());
|
||||
XCTAssertEqual(*submit_info->frame_damage, SkIRect::MakeWH(800, 600));
|
||||
|
@ -19,7 +19,6 @@
|
||||
#import "flutter/shell/platform/darwin/ios/framework/Source/FlutterPlatformViewsController.h"
|
||||
#import "flutter/shell/platform/darwin/ios/framework/Source/FlutterViewResponder.h"
|
||||
#include "flutter/shell/platform/darwin/ios/ios_context.h"
|
||||
#include "third_party/skia/include/core/SkRect.h"
|
||||
|
||||
// A UIView that acts as a clipping mask for the |ChildClippingView|.
|
||||
//
|
||||
|
@ -22,7 +22,6 @@
|
||||
#import "flutter/shell/platform/darwin/ios/framework/Source/FlutterViewController_Internal.h"
|
||||
#import "flutter/shell/platform/darwin/ios/framework/Source/SemanticsObject.h"
|
||||
#import "flutter/shell/platform/darwin/ios/framework/Source/accessibility_bridge_ios.h"
|
||||
#include "third_party/skia/include/core/SkRect.h"
|
||||
|
||||
namespace flutter {
|
||||
class PlatformViewIOS;
|
||||
|
@ -35,11 +35,6 @@ struct OverlayLayer {
|
||||
// Whether a frame for this layer was submitted.
|
||||
bool did_submit_last_frame;
|
||||
|
||||
// The GrContext that is currently used by the overlay surfaces.
|
||||
// We track this to know when the GrContext for the Flutter app has changed
|
||||
// so we can update the overlay with the new context.
|
||||
GrDirectContext* gr_context;
|
||||
|
||||
void UpdateViewState(UIView* flutter_view, SkRect rect, int64_t view_id, int64_t overlay_id);
|
||||
};
|
||||
|
||||
@ -63,8 +58,7 @@ class OverlayLayerPool {
|
||||
/// @brief Create a new overlay layer.
|
||||
///
|
||||
/// This method can only be called on the Platform thread.
|
||||
void CreateLayer(GrDirectContext* gr_context,
|
||||
const std::shared_ptr<IOSContext>& ios_context,
|
||||
void CreateLayer(const std::shared_ptr<IOSContext>& ios_context,
|
||||
MTLPixelFormat pixel_format,
|
||||
CGFloat screenScale);
|
||||
|
||||
|
@ -53,8 +53,7 @@ std::shared_ptr<OverlayLayer> OverlayLayerPool::GetNextLayer() {
|
||||
return result;
|
||||
}
|
||||
|
||||
void OverlayLayerPool::CreateLayer(GrDirectContext* gr_context,
|
||||
const std::shared_ptr<IOSContext>& ios_context,
|
||||
void OverlayLayerPool::CreateLayer(const std::shared_ptr<IOSContext>& ios_context,
|
||||
MTLPixelFormat pixel_format,
|
||||
CGFloat screenScale) {
|
||||
FML_DCHECK([[NSThread currentThread] isMainThread]);
|
||||
@ -62,31 +61,17 @@ void OverlayLayerPool::CreateLayer(GrDirectContext* gr_context,
|
||||
UIView* overlay_view;
|
||||
UIView* overlay_view_wrapper;
|
||||
|
||||
bool impeller_enabled = !!ios_context->GetImpellerContext();
|
||||
if (!gr_context && !impeller_enabled) {
|
||||
overlay_view = [[FlutterOverlayView alloc] init];
|
||||
overlay_view_wrapper = [[FlutterOverlayView alloc] init];
|
||||
overlay_view = [[FlutterOverlayView alloc] initWithContentsScale:screenScale
|
||||
pixelFormat:pixel_format];
|
||||
overlay_view_wrapper = [[FlutterOverlayView alloc] initWithContentsScale:screenScale
|
||||
pixelFormat:pixel_format];
|
||||
|
||||
CALayer* ca_layer = overlay_view.layer;
|
||||
std::unique_ptr<IOSSurface> ios_surface = IOSSurface::Create(ios_context, ca_layer);
|
||||
std::unique_ptr<Surface> surface = ios_surface->CreateGPUSurface();
|
||||
CALayer* ca_layer = overlay_view.layer;
|
||||
std::unique_ptr<IOSSurface> ios_surface = IOSSurface::Create(ios_context, ca_layer);
|
||||
std::unique_ptr<Surface> surface = ios_surface->CreateGPUSurface();
|
||||
|
||||
layer = std::make_shared<OverlayLayer>(overlay_view, overlay_view_wrapper,
|
||||
std::move(ios_surface), std::move(surface));
|
||||
} else {
|
||||
overlay_view = [[FlutterOverlayView alloc] initWithContentsScale:screenScale
|
||||
pixelFormat:pixel_format];
|
||||
overlay_view_wrapper = [[FlutterOverlayView alloc] initWithContentsScale:screenScale
|
||||
pixelFormat:pixel_format];
|
||||
|
||||
CALayer* ca_layer = overlay_view.layer;
|
||||
std::unique_ptr<IOSSurface> ios_surface = IOSSurface::Create(ios_context, ca_layer);
|
||||
std::unique_ptr<Surface> surface = ios_surface->CreateGPUSurface(gr_context);
|
||||
|
||||
layer = std::make_shared<OverlayLayer>(overlay_view, overlay_view_wrapper,
|
||||
std::move(ios_surface), std::move(surface));
|
||||
layer->gr_context = gr_context;
|
||||
}
|
||||
layer = std::make_shared<OverlayLayer>(overlay_view, overlay_view_wrapper, std::move(ios_surface),
|
||||
std::move(surface));
|
||||
// The overlay view wrapper masks the overlay view.
|
||||
// This is required to keep the backing surface size unchanged between frames.
|
||||
//
|
||||
|
@ -15,7 +15,6 @@
|
||||
#import "flutter/shell/platform/darwin/common/framework/Headers/FlutterTexture.h"
|
||||
#import "flutter/shell/platform/darwin/ios/rendering_api_selection.h"
|
||||
#include "impeller/display_list/aiks_context.h"
|
||||
#include "third_party/skia/include/gpu/ganesh/GrDirectContext.h"
|
||||
|
||||
namespace impeller {
|
||||
class Context;
|
||||
@ -70,46 +69,6 @@ class IOSContext {
|
||||
///
|
||||
virtual IOSRenderingBackend GetBackend() const;
|
||||
|
||||
//----------------------------------------------------------------------------
|
||||
/// @brief Create a resource context for use on the IO task runner. This
|
||||
/// resource context is used by Skia to upload texture to
|
||||
/// asynchronously and collect resources that are no longer needed
|
||||
/// on the render task runner.
|
||||
///
|
||||
/// @attention Client rendering APIs for which a GrDirectContext cannot be realized
|
||||
/// (software rendering), this method will always return null.
|
||||
///
|
||||
/// @return A non-null Skia context on success. `nullptr` on failure.
|
||||
///
|
||||
virtual sk_sp<GrDirectContext> CreateResourceContext() = 0;
|
||||
|
||||
//----------------------------------------------------------------------------
|
||||
/// @brief When using client rendering APIs whose contexts need to be
|
||||
/// bound to a specific thread, the engine will call this method
|
||||
/// to give the on-screen context a chance to bind to the current
|
||||
/// thread.
|
||||
///
|
||||
/// @attention Client rendering APIs that have no-concept of thread local
|
||||
/// bindings (anything that is not OpenGL) will always return
|
||||
/// `true`.
|
||||
///
|
||||
/// @attention Client rendering APIs for which a GrDirectContext cannot be created
|
||||
/// (software rendering) will always return `false`.
|
||||
///
|
||||
/// @attention This binds the on-screen context to the current thread. To
|
||||
/// bind the off-screen context to the thread, use the
|
||||
/// `ResoruceMakeCurrent` method instead.
|
||||
///
|
||||
/// @attention Only one context may be bound to a thread at any given time.
|
||||
/// Making a binding on a thread, clears the old binding.
|
||||
///
|
||||
/// @return A GLContextResult that represents the result of the method.
|
||||
/// The GetResult() returns a bool that indicates If the on-screen context could be
|
||||
/// bound to the current
|
||||
/// thread.
|
||||
///
|
||||
virtual std::unique_ptr<GLContextResult> MakeCurrent() = 0;
|
||||
|
||||
//----------------------------------------------------------------------------
|
||||
/// @brief Creates an external texture proxy of the appropriate client
|
||||
/// rendering API.
|
||||
@ -123,20 +82,6 @@ class IOSContext {
|
||||
virtual std::unique_ptr<Texture> CreateExternalTexture(int64_t texture_id,
|
||||
NSObject<FlutterTexture>* texture) = 0;
|
||||
|
||||
//----------------------------------------------------------------------------
|
||||
/// @brief Accessor for the Skia context associated with IOSSurfaces and
|
||||
/// the raster thread.
|
||||
/// @details There can be any number of resource contexts but this is the
|
||||
/// one context that will be used by surfaces to draw to the
|
||||
/// screen from the raster thread.
|
||||
/// @returns `nullptr` on failure.
|
||||
/// @attention The software context doesn't have a Skia context, so this
|
||||
/// value will be nullptr.
|
||||
/// @see For contexts which are used for offscreen work like loading
|
||||
/// textures see IOSContext::CreateResourceContext.
|
||||
///
|
||||
virtual sk_sp<GrDirectContext> GetMainContext() const = 0;
|
||||
|
||||
virtual std::shared_ptr<impeller::Context> GetImpellerContext() const;
|
||||
|
||||
virtual std::shared_ptr<impeller::AiksContext> GetAiksContext() const;
|
||||
|
@ -8,9 +8,7 @@
|
||||
|
||||
#include "flutter/fml/logging.h"
|
||||
#include "flutter/shell/platform/darwin/ios/ios_context_metal_impeller.h"
|
||||
#include "flutter/shell/platform/darwin/ios/ios_context_metal_skia.h"
|
||||
#include "flutter/shell/platform/darwin/ios/ios_context_noop.h"
|
||||
#include "flutter/shell/platform/darwin/ios/ios_context_software.h"
|
||||
|
||||
FLUTTER_ASSERT_ARC
|
||||
|
||||
@ -26,25 +24,18 @@ std::unique_ptr<IOSContext> IOSContext::Create(
|
||||
const std::shared_ptr<const fml::SyncSwitch>& is_gpu_disabled_sync_switch) {
|
||||
switch (api) {
|
||||
case IOSRenderingAPI::kSoftware:
|
||||
if (backend == IOSRenderingBackend::kImpeller) {
|
||||
FML_LOG(IMPORTANT)
|
||||
<< "Software rendering is incompatible with Impeller.\n"
|
||||
"Software rendering may have been automatically selected when running on a "
|
||||
"simulator "
|
||||
"in an environment that does not support Metal. Enabling GPU passthrough in your "
|
||||
"environment may fix this.";
|
||||
return std::make_unique<IOSContextNoop>();
|
||||
}
|
||||
return std::make_unique<IOSContextSoftware>();
|
||||
FML_LOG(IMPORTANT)
|
||||
<< "Software rendering is incompatible with Impeller.\n"
|
||||
"Software rendering may have been automatically selected when running on a "
|
||||
"simulator "
|
||||
"in an environment that does not support Metal. Enabling GPU passthrough in your "
|
||||
"environment may fix this.";
|
||||
return std::make_unique<IOSContextNoop>();
|
||||
case IOSRenderingAPI::kMetal:
|
||||
switch (backend) {
|
||||
case IOSRenderingBackend::kSkia:
|
||||
#if !SLIMPELLER
|
||||
return std::make_unique<IOSContextMetalSkia>();
|
||||
#else // !SLIMPELLER
|
||||
FML_LOG(FATAL) << "Impeller opt-out unavailable.";
|
||||
return nullptr;
|
||||
#endif // !SLIMPELLER
|
||||
case IOSRenderingBackend::kImpeller:
|
||||
return std::make_unique<IOSContextMetalImpeller>(is_gpu_disabled_sync_switch);
|
||||
}
|
||||
|
@ -28,21 +28,10 @@ class IOSContextMetalImpeller final : public IOSContext {
|
||||
|
||||
IOSRenderingBackend GetBackend() const override;
|
||||
|
||||
// |IOSContext|
|
||||
sk_sp<GrDirectContext> GetMainContext() const override;
|
||||
|
||||
sk_sp<GrDirectContext> GetResourceContext() const;
|
||||
|
||||
private:
|
||||
FlutterDarwinContextMetalImpeller* darwin_context_metal_impeller_;
|
||||
std::shared_ptr<impeller::AiksContext> aiks_context_;
|
||||
|
||||
// |IOSContext|
|
||||
sk_sp<GrDirectContext> CreateResourceContext() override;
|
||||
|
||||
// |IOSContext|
|
||||
std::unique_ptr<GLContextResult> MakeCurrent() override;
|
||||
|
||||
// |IOSContext|
|
||||
std::unique_ptr<Texture> CreateExternalTexture(int64_t texture_id,
|
||||
NSObject<FlutterTexture>* texture) override;
|
||||
|
@ -29,19 +29,6 @@ IOSRenderingBackend IOSContextMetalImpeller::GetBackend() const {
|
||||
return IOSRenderingBackend::kImpeller;
|
||||
}
|
||||
|
||||
sk_sp<GrDirectContext> IOSContextMetalImpeller::GetMainContext() const {
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
sk_sp<GrDirectContext> IOSContextMetalImpeller::GetResourceContext() const {
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
// |IOSContext|
|
||||
sk_sp<GrDirectContext> IOSContextMetalImpeller::CreateResourceContext() {
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
// |IOSContext|
|
||||
std::shared_ptr<impeller::Context> IOSContextMetalImpeller::GetImpellerContext() const {
|
||||
return darwin_context_metal_impeller_.context;
|
||||
@ -52,12 +39,6 @@ std::shared_ptr<impeller::AiksContext> IOSContextMetalImpeller::GetAiksContext()
|
||||
return aiks_context_;
|
||||
}
|
||||
|
||||
// |IOSContext|
|
||||
std::unique_ptr<GLContextResult> IOSContextMetalImpeller::MakeCurrent() {
|
||||
// This only makes sense for contexts that need to be bound to a specific thread.
|
||||
return std::make_unique<GLContextDefaultResult>(true);
|
||||
}
|
||||
|
||||
// |IOSContext|
|
||||
std::unique_ptr<Texture> IOSContextMetalImpeller::CreateExternalTexture(
|
||||
int64_t texture_id,
|
||||
|
@ -1,56 +0,0 @@
|
||||
// Copyright 2013 The Flutter Authors. All rights reserved.
|
||||
// Use of this source code is governed by a BSD-style license that can be
|
||||
// found in the LICENSE file.
|
||||
|
||||
#ifndef FLUTTER_SHELL_PLATFORM_DARWIN_IOS_IOS_CONTEXT_METAL_SKIA_H_
|
||||
#define FLUTTER_SHELL_PLATFORM_DARWIN_IOS_IOS_CONTEXT_METAL_SKIA_H_
|
||||
|
||||
#if !SLIMPELLER
|
||||
|
||||
#include <Metal/Metal.h>
|
||||
|
||||
#include "flutter/fml/macros.h"
|
||||
#include "flutter/fml/platform/darwin/cf_utils.h"
|
||||
#import "flutter/shell/platform/darwin/graphics/FlutterDarwinContextMetalSkia.h"
|
||||
#import "flutter/shell/platform/darwin/ios/ios_context.h"
|
||||
#include "third_party/skia/include/gpu/ganesh/GrDirectContext.h"
|
||||
|
||||
namespace flutter {
|
||||
|
||||
class IOSContextMetalSkia final : public IOSContext {
|
||||
public:
|
||||
explicit IOSContextMetalSkia();
|
||||
|
||||
~IOSContextMetalSkia();
|
||||
|
||||
FlutterDarwinContextMetalSkia* GetDarwinContext() const;
|
||||
|
||||
// |IOSContext|
|
||||
IOSRenderingBackend GetBackend() const override;
|
||||
|
||||
// |IOSContext|
|
||||
sk_sp<GrDirectContext> GetMainContext() const override;
|
||||
|
||||
sk_sp<GrDirectContext> GetResourceContext() const;
|
||||
|
||||
private:
|
||||
FlutterDarwinContextMetalSkia* darwin_context_metal_;
|
||||
|
||||
// |IOSContext|
|
||||
sk_sp<GrDirectContext> CreateResourceContext() override;
|
||||
|
||||
// |IOSContext|
|
||||
std::unique_ptr<GLContextResult> MakeCurrent() override;
|
||||
|
||||
// |IOSContext|
|
||||
std::unique_ptr<Texture> CreateExternalTexture(int64_t texture_id,
|
||||
NSObject<FlutterTexture>* texture) override;
|
||||
|
||||
FML_DISALLOW_COPY_AND_ASSIGN(IOSContextMetalSkia);
|
||||
};
|
||||
|
||||
} // namespace flutter
|
||||
|
||||
#endif // !SLIMPELLER
|
||||
|
||||
#endif // FLUTTER_SHELL_PLATFORM_DARWIN_IOS_IOS_CONTEXT_METAL_SKIA_H_
|
@ -1,62 +0,0 @@
|
||||
// Copyright 2013 The Flutter Authors. All rights reserved.
|
||||
// Use of this source code is governed by a BSD-style license that can be
|
||||
// found in the LICENSE file.
|
||||
|
||||
#if !SLIMPELLER
|
||||
|
||||
#import "flutter/shell/platform/darwin/ios/ios_context_metal_skia.h"
|
||||
|
||||
#include "flutter/common/graphics/persistent_cache.h"
|
||||
#include "flutter/fml/logging.h"
|
||||
#import "flutter/shell/platform/darwin/graphics/FlutterDarwinContextMetalSkia.h"
|
||||
#import "flutter/shell/platform/darwin/ios/ios_external_texture_metal.h"
|
||||
#include "third_party/skia/include/gpu/ganesh/GrContextOptions.h"
|
||||
|
||||
FLUTTER_ASSERT_ARC
|
||||
|
||||
namespace flutter {
|
||||
|
||||
IOSContextMetalSkia::IOSContextMetalSkia() {
|
||||
darwin_context_metal_ = [[FlutterDarwinContextMetalSkia alloc] initWithDefaultMTLDevice];
|
||||
}
|
||||
|
||||
IOSContextMetalSkia::~IOSContextMetalSkia() = default;
|
||||
|
||||
FlutterDarwinContextMetalSkia* IOSContextMetalSkia::GetDarwinContext() const {
|
||||
return darwin_context_metal_;
|
||||
}
|
||||
|
||||
IOSRenderingBackend IOSContextMetalSkia::GetBackend() const {
|
||||
return IOSRenderingBackend::kSkia;
|
||||
}
|
||||
|
||||
sk_sp<GrDirectContext> IOSContextMetalSkia::GetMainContext() const {
|
||||
return darwin_context_metal_.mainContext;
|
||||
}
|
||||
|
||||
sk_sp<GrDirectContext> IOSContextMetalSkia::GetResourceContext() const {
|
||||
return darwin_context_metal_.resourceContext;
|
||||
}
|
||||
|
||||
// |IOSContext|
|
||||
sk_sp<GrDirectContext> IOSContextMetalSkia::CreateResourceContext() {
|
||||
return darwin_context_metal_.resourceContext;
|
||||
}
|
||||
|
||||
// |IOSContext|
|
||||
std::unique_ptr<GLContextResult> IOSContextMetalSkia::MakeCurrent() {
|
||||
// This only makes sense for context that need to be bound to a specific thread.
|
||||
return std::make_unique<GLContextDefaultResult>(true);
|
||||
}
|
||||
|
||||
// |IOSContext|
|
||||
std::unique_ptr<Texture> IOSContextMetalSkia::CreateExternalTexture(
|
||||
int64_t texture_id,
|
||||
NSObject<FlutterTexture>* texture) {
|
||||
return std::make_unique<IOSExternalTextureMetal>(
|
||||
[darwin_context_metal_ createExternalTextureWithIdentifier:texture_id texture:texture]);
|
||||
}
|
||||
|
||||
} // namespace flutter
|
||||
|
||||
#endif // !SLIMPELLER
|
@ -17,15 +17,6 @@ class IOSContextNoop final : public IOSContext {
|
||||
// |IOSContext|
|
||||
~IOSContextNoop();
|
||||
|
||||
// |IOSContext|
|
||||
sk_sp<GrDirectContext> CreateResourceContext() override;
|
||||
|
||||
// |IOSContext|
|
||||
sk_sp<GrDirectContext> GetMainContext() const override;
|
||||
|
||||
// |IOSContext|
|
||||
std::unique_ptr<GLContextResult> MakeCurrent() override;
|
||||
|
||||
// |IOSContext|
|
||||
std::unique_ptr<Texture> CreateExternalTexture(int64_t texture_id,
|
||||
NSObject<FlutterTexture>* texture) override;
|
||||
|
@ -15,27 +15,11 @@ IOSContextNoop::IOSContextNoop() = default;
|
||||
// |IOSContext|
|
||||
IOSContextNoop::~IOSContextNoop() = default;
|
||||
|
||||
// |IOSContext|
|
||||
sk_sp<GrDirectContext> IOSContextNoop::CreateResourceContext() {
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
// |IOSContext|
|
||||
sk_sp<GrDirectContext> IOSContextNoop::GetMainContext() const {
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
// |IOSContext|
|
||||
IOSRenderingBackend IOSContextNoop::GetBackend() const {
|
||||
return IOSRenderingBackend::kImpeller;
|
||||
}
|
||||
|
||||
// |IOSContext|
|
||||
std::unique_ptr<GLContextResult> IOSContextNoop::MakeCurrent() {
|
||||
// This only makes sense for context that need to be bound to a specific thread.
|
||||
return std::make_unique<GLContextDefaultResult>(false);
|
||||
}
|
||||
|
||||
// |IOSContext|
|
||||
std::unique_ptr<Texture> IOSContextNoop::CreateExternalTexture(int64_t texture_id,
|
||||
NSObject<FlutterTexture>* texture) {
|
||||
|
@ -1,39 +0,0 @@
|
||||
// Copyright 2013 The Flutter Authors. All rights reserved.
|
||||
// Use of this source code is governed by a BSD-style license that can be
|
||||
// found in the LICENSE file.
|
||||
|
||||
#ifndef FLUTTER_SHELL_PLATFORM_DARWIN_IOS_IOS_CONTEXT_SOFTWARE_H_
|
||||
#define FLUTTER_SHELL_PLATFORM_DARWIN_IOS_IOS_CONTEXT_SOFTWARE_H_
|
||||
|
||||
#include "flutter/fml/macros.h"
|
||||
#import "flutter/shell/platform/darwin/ios/ios_context.h"
|
||||
|
||||
namespace flutter {
|
||||
|
||||
class IOSContextSoftware final : public IOSContext {
|
||||
public:
|
||||
IOSContextSoftware();
|
||||
|
||||
// |IOSContext|
|
||||
~IOSContextSoftware();
|
||||
|
||||
// |IOSContext|
|
||||
sk_sp<GrDirectContext> CreateResourceContext() override;
|
||||
|
||||
// |IOSContext|
|
||||
sk_sp<GrDirectContext> GetMainContext() const override;
|
||||
|
||||
// |IOSContext|
|
||||
std::unique_ptr<GLContextResult> MakeCurrent() override;
|
||||
|
||||
// |IOSContext|
|
||||
std::unique_ptr<Texture> CreateExternalTexture(int64_t texture_id,
|
||||
NSObject<FlutterTexture>* texture) override;
|
||||
|
||||
private:
|
||||
FML_DISALLOW_COPY_AND_ASSIGN(IOSContextSoftware);
|
||||
};
|
||||
|
||||
} // namespace flutter
|
||||
|
||||
#endif // FLUTTER_SHELL_PLATFORM_DARWIN_IOS_IOS_CONTEXT_SOFTWARE_H_
|
@ -1,47 +0,0 @@
|
||||
// Copyright 2013 The Flutter Authors. All rights reserved.
|
||||
// Use of this source code is governed by a BSD-style license that can be
|
||||
// found in the LICENSE file.
|
||||
|
||||
#import "flutter/shell/platform/darwin/ios/ios_context_software.h"
|
||||
#include "ios_context.h"
|
||||
|
||||
FLUTTER_ASSERT_ARC
|
||||
|
||||
namespace flutter {
|
||||
|
||||
IOSContextSoftware::IOSContextSoftware() = default;
|
||||
|
||||
// |IOSContext|
|
||||
IOSContextSoftware::~IOSContextSoftware() = default;
|
||||
|
||||
// |IOSContext|
|
||||
sk_sp<GrDirectContext> IOSContextSoftware::CreateResourceContext() {
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
// |IOSContext|
|
||||
sk_sp<GrDirectContext> IOSContextSoftware::GetMainContext() const {
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
// |IOSContext|
|
||||
std::unique_ptr<GLContextResult> IOSContextSoftware::MakeCurrent() {
|
||||
// This only makes sense for context that need to be bound to a specific thread.
|
||||
return std::make_unique<GLContextDefaultResult>(false);
|
||||
}
|
||||
|
||||
// |IOSContext|
|
||||
std::unique_ptr<Texture> IOSContextSoftware::CreateExternalTexture(
|
||||
int64_t texture_id,
|
||||
NSObject<FlutterTexture>* texture) {
|
||||
// Don't use FML for logging as it will contain engine specific details. This is a user facing
|
||||
// message.
|
||||
NSLog(@"Flutter: Attempted to composite external texture sources using the software backend. "
|
||||
@"This backend is only used on simulators. This feature is only available on actual "
|
||||
@"devices where Metal is used for rendering.");
|
||||
|
||||
// Not supported in this backend.
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
} // namespace flutter
|
@ -85,9 +85,7 @@ void IOSExternalViewEmbedder::SubmitFlutterView(
|
||||
// Properly support multi-view in the future.
|
||||
FML_DCHECK(flutter_view_id == kFlutterImplicitViewId);
|
||||
FML_CHECK(platform_views_controller_);
|
||||
[platform_views_controller_ submitFrame:std::move(frame)
|
||||
withIosContext:ios_context_
|
||||
grContext:context];
|
||||
[platform_views_controller_ submitFrame:std::move(frame) withIosContext:ios_context_];
|
||||
TRACE_EVENT0("flutter", "IOSExternalViewEmbedder::DidSubmitFrame");
|
||||
}
|
||||
|
||||
@ -104,12 +102,7 @@ void IOSExternalViewEmbedder::EndFrame(
|
||||
|
||||
// |ExternalViewEmbedder|
|
||||
bool IOSExternalViewEmbedder::SupportsDynamicThreadMerging() {
|
||||
// TODO(jonahwilliams): remove this once Software backend is removed for iOS Sim.
|
||||
#if FML_OS_IOS_SIMULATOR
|
||||
return true;
|
||||
#else
|
||||
return ios_context_->GetBackend() == IOSRenderingBackend::kSkia;
|
||||
#endif // FML_OS_IOS_SIMULATOR
|
||||
return false;
|
||||
}
|
||||
|
||||
// |ExternalViewEmbedder|
|
||||
|
@ -29,12 +29,7 @@ class IOSSurface {
|
||||
|
||||
virtual void UpdateStorageSizeIfNecessary() = 0;
|
||||
|
||||
// Creates a GPU surface. If no GrDirectContext is supplied and the rendering mode
|
||||
// supports one, a new one will be created; otherwise, the software backend
|
||||
// will be used.
|
||||
//
|
||||
// If a GrDirectContext is supplied, creates a secondary surface.
|
||||
virtual std::unique_ptr<Surface> CreateGPUSurface(GrDirectContext* gr_context = nullptr) = 0;
|
||||
virtual std::unique_ptr<Surface> CreateGPUSurface() = 0;
|
||||
|
||||
protected:
|
||||
explicit IOSSurface(std::shared_ptr<IOSContext> ios_context);
|
||||
|
@ -7,9 +7,7 @@
|
||||
#include <memory>
|
||||
|
||||
#import "flutter/shell/platform/darwin/ios/ios_surface_metal_impeller.h"
|
||||
#import "flutter/shell/platform/darwin/ios/ios_surface_metal_skia.h"
|
||||
#import "flutter/shell/platform/darwin/ios/ios_surface_noop.h"
|
||||
#import "flutter/shell/platform/darwin/ios/ios_surface_software.h"
|
||||
#include "flutter/shell/platform/darwin/ios/rendering_api_selection.h"
|
||||
|
||||
FLUTTER_ASSERT_ARC
|
||||
@ -25,16 +23,8 @@ std::unique_ptr<IOSSurface> IOSSurface::Create(std::shared_ptr<IOSContext> conte
|
||||
if ([layer isKindOfClass:[CAMetalLayer class]]) {
|
||||
switch (context->GetBackend()) {
|
||||
case IOSRenderingBackend::kSkia:
|
||||
#if !SLIMPELLER
|
||||
return std::make_unique<IOSSurfaceMetalSkia>(
|
||||
static_cast<CAMetalLayer*>(layer), // Metal layer
|
||||
std::move(context) // context
|
||||
);
|
||||
#else // !SLIMPELLER
|
||||
FML_LOG(FATAL) << "Impeller opt-out unavailable.";
|
||||
return nullptr;
|
||||
#endif // !SLIMPELLER
|
||||
break;
|
||||
case IOSRenderingBackend::kImpeller:
|
||||
return std::make_unique<IOSSurfaceMetalImpeller>(
|
||||
static_cast<CAMetalLayer*>(layer), // Metal layer
|
||||
@ -43,13 +33,7 @@ std::unique_ptr<IOSSurface> IOSSurface::Create(std::shared_ptr<IOSContext> conte
|
||||
}
|
||||
}
|
||||
}
|
||||
if (context->GetBackend() == IOSRenderingBackend::kImpeller) {
|
||||
return std::make_unique<IOSSurfaceNoop>(std::move(context));
|
||||
}
|
||||
|
||||
return std::make_unique<IOSSurfaceSoftware>(layer, // layer
|
||||
std::move(context) // context
|
||||
);
|
||||
return std::make_unique<IOSSurfaceNoop>(std::move(context));
|
||||
}
|
||||
|
||||
IOSSurface::IOSSurface(std::shared_ptr<IOSContext> ios_context)
|
||||
|
@ -39,7 +39,7 @@ class SK_API_AVAILABLE_CA_METAL_LAYER IOSSurfaceMetalImpeller final
|
||||
void UpdateStorageSizeIfNecessary() override;
|
||||
|
||||
// |IOSSurface|
|
||||
std::unique_ptr<Surface> CreateGPUSurface(GrDirectContext* gr_context) override;
|
||||
std::unique_ptr<Surface> CreateGPUSurface() override;
|
||||
|
||||
// |GPUSurfaceMetalDelegate|
|
||||
GPUCAMetalLayerHandle GetCAMetalLayer(const SkISize& frame_info) const override
|
||||
|
@ -42,7 +42,7 @@ void IOSSurfaceMetalImpeller::UpdateStorageSizeIfNecessary() {
|
||||
}
|
||||
|
||||
// |IOSSurface|
|
||||
std::unique_ptr<Surface> IOSSurfaceMetalImpeller::CreateGPUSurface(GrDirectContext*) {
|
||||
std::unique_ptr<Surface> IOSSurfaceMetalImpeller::CreateGPUSurface() {
|
||||
impeller_context_->UpdateOffscreenLayerPixelFormat(
|
||||
impeller::FromMTLPixelFormat(layer_.pixelFormat));
|
||||
return std::make_unique<GPUSurfaceMetalImpeller>(this, //
|
||||
|
@ -1,70 +0,0 @@
|
||||
// Copyright 2013 The Flutter Authors. All rights reserved.
|
||||
// Use of this source code is governed by a BSD-style license that can be
|
||||
// found in the LICENSE file.
|
||||
|
||||
#ifndef FLUTTER_SHELL_PLATFORM_DARWIN_IOS_IOS_SURFACE_METAL_SKIA_H_
|
||||
#define FLUTTER_SHELL_PLATFORM_DARWIN_IOS_IOS_SURFACE_METAL_SKIA_H_
|
||||
|
||||
#if !SLIMPELLER
|
||||
|
||||
#include "flutter/fml/macros.h"
|
||||
#include "flutter/shell/gpu/gpu_surface_metal_delegate.h"
|
||||
#import "flutter/shell/platform/darwin/ios/ios_surface.h"
|
||||
#include "third_party/skia/include/gpu/ganesh/mtl/GrMtlTypes.h"
|
||||
|
||||
@class CAMetalLayer;
|
||||
|
||||
namespace flutter {
|
||||
|
||||
class SK_API_AVAILABLE_CA_METAL_LAYER IOSSurfaceMetalSkia final : public IOSSurface,
|
||||
public GPUSurfaceMetalDelegate {
|
||||
public:
|
||||
IOSSurfaceMetalSkia(CAMetalLayer* layer, std::shared_ptr<IOSContext> context);
|
||||
|
||||
// |IOSSurface|
|
||||
~IOSSurfaceMetalSkia();
|
||||
|
||||
private:
|
||||
CAMetalLayer* layer_;
|
||||
id<MTLDevice> device_;
|
||||
id<MTLCommandQueue> command_queue_;
|
||||
bool is_valid_ = false;
|
||||
|
||||
// |IOSSurface|
|
||||
bool IsValid() const override;
|
||||
|
||||
// |IOSSurface|
|
||||
void UpdateStorageSizeIfNecessary() override;
|
||||
|
||||
// |IOSSurface|
|
||||
std::unique_ptr<Surface> CreateGPUSurface(GrDirectContext* gr_context) override;
|
||||
|
||||
// |GPUSurfaceMetalDelegate|
|
||||
GPUCAMetalLayerHandle GetCAMetalLayer(const SkISize& frame_info) const override
|
||||
__attribute__((cf_audited_transfer));
|
||||
|
||||
// |GPUSurfaceMetalDelegate|
|
||||
bool PresentDrawable(GrMTLHandle drawable) const override __attribute__((cf_audited_transfer));
|
||||
|
||||
// |GPUSurfaceMetalDelegate|
|
||||
bool PreparePresent(GrMTLHandle drawable) const override;
|
||||
|
||||
// |GPUSurfaceMetalDelegate|
|
||||
GPUMTLTextureInfo GetMTLTexture(const SkISize& frame_info) const override
|
||||
__attribute__((cf_audited_transfer));
|
||||
|
||||
// |GPUSurfaceMetalDelegate|
|
||||
bool PresentTexture(GPUMTLTextureInfo texture) const override
|
||||
__attribute__((cf_audited_transfer));
|
||||
|
||||
// |GPUSurfaceMetalDelegate|
|
||||
bool AllowsDrawingWhenGpuDisabled() const override;
|
||||
|
||||
FML_DISALLOW_COPY_AND_ASSIGN(IOSSurfaceMetalSkia);
|
||||
};
|
||||
|
||||
} // namespace flutter
|
||||
|
||||
#endif // !SLIMPELLER
|
||||
|
||||
#endif // FLUTTER_SHELL_PLATFORM_DARWIN_IOS_IOS_SURFACE_METAL_SKIA_H_
|
@ -1,118 +0,0 @@
|
||||
// Copyright 2013 The Flutter Authors. All rights reserved.
|
||||
// Use of this source code is governed by a BSD-style license that can be
|
||||
// found in the LICENSE file.
|
||||
|
||||
#if !SLIMPELLER
|
||||
|
||||
#import "flutter/shell/platform/darwin/ios/ios_surface_metal_skia.h"
|
||||
|
||||
#include "flutter/shell/gpu/gpu_surface_metal_delegate.h"
|
||||
#include "flutter/shell/gpu/gpu_surface_metal_skia.h"
|
||||
#include "flutter/shell/platform/darwin/ios/ios_context_metal_skia.h"
|
||||
|
||||
FLUTTER_ASSERT_ARC
|
||||
|
||||
@protocol FlutterMetalDrawable <MTLDrawable>
|
||||
- (void)flutterPrepareForPresent:(nonnull id<MTLCommandBuffer>)commandBuffer;
|
||||
@end
|
||||
|
||||
namespace flutter {
|
||||
|
||||
IOSSurfaceMetalSkia::IOSSurfaceMetalSkia(CAMetalLayer* layer, std::shared_ptr<IOSContext> context)
|
||||
: IOSSurface(std::move(context)),
|
||||
GPUSurfaceMetalDelegate(MTLRenderTargetType::kCAMetalLayer),
|
||||
layer_(layer) {
|
||||
is_valid_ = layer_;
|
||||
IOSContextMetalSkia* metal_context = static_cast<IOSContextMetalSkia*>(GetContext().get());
|
||||
FlutterDarwinContextMetalSkia* darwin_context = metal_context->GetDarwinContext();
|
||||
command_queue_ = darwin_context.commandQueue;
|
||||
device_ = darwin_context.device;
|
||||
}
|
||||
|
||||
// |IOSSurface|
|
||||
IOSSurfaceMetalSkia::~IOSSurfaceMetalSkia() = default;
|
||||
|
||||
// |IOSSurface|
|
||||
bool IOSSurfaceMetalSkia::IsValid() const {
|
||||
return is_valid_;
|
||||
}
|
||||
|
||||
// |IOSSurface|
|
||||
void IOSSurfaceMetalSkia::UpdateStorageSizeIfNecessary() {
|
||||
// Nothing to do.
|
||||
}
|
||||
|
||||
// |IOSSurface|
|
||||
std::unique_ptr<Surface> IOSSurfaceMetalSkia::CreateGPUSurface(GrDirectContext* context) {
|
||||
FML_DCHECK(context);
|
||||
return std::make_unique<GPUSurfaceMetalSkia>(this, // delegate
|
||||
sk_ref_sp(context) // context
|
||||
);
|
||||
}
|
||||
|
||||
// |GPUSurfaceMetalDelegate|
|
||||
GPUCAMetalLayerHandle IOSSurfaceMetalSkia::GetCAMetalLayer(const SkISize& frame_info) const {
|
||||
layer_.device = device_;
|
||||
|
||||
layer_.pixelFormat = MTLPixelFormatBGRA8Unorm;
|
||||
// Flutter needs to read from the color attachment in cases where there are effects such as
|
||||
// backdrop filters. Flutter plugins that create platform views may also read from the layer.
|
||||
layer_.framebufferOnly = NO;
|
||||
|
||||
const auto drawable_size = CGSizeMake(frame_info.width(), frame_info.height());
|
||||
if (!CGSizeEqualToSize(drawable_size, layer_.drawableSize)) {
|
||||
layer_.drawableSize = drawable_size;
|
||||
}
|
||||
|
||||
// When there are platform views in the scene, the drawable needs to be presented in the same
|
||||
// transaction as the one created for platform views. When the drawable are being presented from
|
||||
// the raster thread, there is no such transaction.
|
||||
layer_.presentsWithTransaction = [[NSThread currentThread] isMainThread];
|
||||
|
||||
return (__bridge GPUCAMetalLayerHandle)layer_;
|
||||
}
|
||||
|
||||
// |GPUSurfaceMetalDelegate|
|
||||
bool IOSSurfaceMetalSkia::PreparePresent(GrMTLHandle drawable) const {
|
||||
id<MTLCommandBuffer> command_buffer = [command_queue_ commandBuffer];
|
||||
id<CAMetalDrawable> metal_drawable = (__bridge id<CAMetalDrawable>)drawable;
|
||||
if ([metal_drawable conformsToProtocol:@protocol(FlutterMetalDrawable)]) {
|
||||
[(id<FlutterMetalDrawable>)metal_drawable flutterPrepareForPresent:command_buffer];
|
||||
}
|
||||
[command_buffer commit];
|
||||
[command_buffer waitUntilScheduled];
|
||||
return true;
|
||||
}
|
||||
|
||||
// |GPUSurfaceMetalDelegate|
|
||||
bool IOSSurfaceMetalSkia::PresentDrawable(GrMTLHandle drawable) const {
|
||||
if (drawable == nullptr) {
|
||||
FML_DLOG(ERROR) << "Could not acquire next Metal drawable from the SkSurface.";
|
||||
return false;
|
||||
}
|
||||
|
||||
id<CAMetalDrawable> metal_drawable = (__bridge id<CAMetalDrawable>)drawable;
|
||||
[metal_drawable present];
|
||||
return true;
|
||||
}
|
||||
|
||||
// |GPUSurfaceMetalDelegate|
|
||||
GPUMTLTextureInfo IOSSurfaceMetalSkia::GetMTLTexture(const SkISize& frame_info) const {
|
||||
FML_CHECK(false) << "render to texture not supported on ios";
|
||||
return {.texture_id = -1, .texture = nullptr};
|
||||
}
|
||||
|
||||
// |GPUSurfaceMetalDelegate|
|
||||
bool IOSSurfaceMetalSkia::PresentTexture(GPUMTLTextureInfo texture) const {
|
||||
FML_CHECK(false) << "render to texture not supported on ios";
|
||||
return false;
|
||||
}
|
||||
|
||||
// |GPUSurfaceMetalDelegate|
|
||||
bool IOSSurfaceMetalSkia::AllowsDrawingWhenGpuDisabled() const {
|
||||
return false;
|
||||
}
|
||||
|
||||
} // namespace flutter
|
||||
|
||||
#endif // !SLIMPELLER
|
@ -8,8 +8,6 @@
|
||||
#import "flutter/shell/platform/darwin/ios/ios_context.h"
|
||||
#import "flutter/shell/platform/darwin/ios/ios_surface.h"
|
||||
|
||||
#include "third_party/skia/include/core/SkSurface.h"
|
||||
|
||||
@class CALayer;
|
||||
|
||||
namespace flutter {
|
||||
@ -32,7 +30,7 @@ class IOSSurfaceNoop final : public IOSSurface {
|
||||
void UpdateStorageSizeIfNecessary() override;
|
||||
|
||||
// |IOSSurface|
|
||||
std::unique_ptr<Surface> CreateGPUSurface(GrDirectContext* gr_context = nullptr) override;
|
||||
std::unique_ptr<Surface> CreateGPUSurface() override;
|
||||
|
||||
private:
|
||||
IOSSurfaceNoop(const IOSSurfaceNoop&) = delete;
|
||||
|
@ -13,9 +13,6 @@
|
||||
#include "flutter/fml/platform/darwin/cf_utils.h"
|
||||
#include "flutter/fml/trace_event.h"
|
||||
|
||||
#include "third_party/skia/include/core/SkSurface.h"
|
||||
#include "third_party/skia/include/utils/mac/SkCGUtils.h"
|
||||
|
||||
FLUTTER_ASSERT_ARC
|
||||
|
||||
namespace flutter {
|
||||
@ -31,7 +28,7 @@ bool IOSSurfaceNoop::IsValid() const {
|
||||
|
||||
void IOSSurfaceNoop::UpdateStorageSizeIfNecessary() {}
|
||||
|
||||
std::unique_ptr<Surface> IOSSurfaceNoop::CreateGPUSurface(GrDirectContext* gr_context) {
|
||||
std::unique_ptr<Surface> IOSSurfaceNoop::CreateGPUSurface() {
|
||||
return std::make_unique<GPUSurfaceNoop>();
|
||||
}
|
||||
|
||||
|
@ -1,50 +0,0 @@
|
||||
// Copyright 2013 The Flutter Authors. All rights reserved.
|
||||
// Use of this source code is governed by a BSD-style license that can be
|
||||
// found in the LICENSE file.
|
||||
|
||||
#ifndef FLUTTER_SHELL_PLATFORM_DARWIN_IOS_IOS_SURFACE_SOFTWARE_H_
|
||||
#define FLUTTER_SHELL_PLATFORM_DARWIN_IOS_IOS_SURFACE_SOFTWARE_H_
|
||||
|
||||
#include "flutter/flow/embedded_views.h"
|
||||
#include "flutter/fml/macros.h"
|
||||
#include "flutter/shell/gpu/gpu_surface_software.h"
|
||||
#import "flutter/shell/platform/darwin/ios/ios_context.h"
|
||||
#import "flutter/shell/platform/darwin/ios/ios_surface.h"
|
||||
|
||||
#include "third_party/skia/include/core/SkSurface.h"
|
||||
|
||||
@class CALayer;
|
||||
|
||||
namespace flutter {
|
||||
|
||||
class IOSSurfaceSoftware final : public IOSSurface, public GPUSurfaceSoftwareDelegate {
|
||||
public:
|
||||
IOSSurfaceSoftware(CALayer* layer, std::shared_ptr<IOSContext> context);
|
||||
|
||||
~IOSSurfaceSoftware() override;
|
||||
|
||||
// |IOSSurface|
|
||||
bool IsValid() const override;
|
||||
|
||||
// |IOSSurface|
|
||||
void UpdateStorageSizeIfNecessary() override;
|
||||
|
||||
// |IOSSurface|
|
||||
std::unique_ptr<Surface> CreateGPUSurface(GrDirectContext* gr_context = nullptr) override;
|
||||
|
||||
// |GPUSurfaceSoftwareDelegate|
|
||||
sk_sp<SkSurface> AcquireBackingStore(const SkISize& size) override;
|
||||
|
||||
// |GPUSurfaceSoftwareDelegate|
|
||||
bool PresentBackingStore(sk_sp<SkSurface> backing_store) override;
|
||||
|
||||
private:
|
||||
CALayer* layer_;
|
||||
sk_sp<SkSurface> sk_surface_;
|
||||
|
||||
FML_DISALLOW_COPY_AND_ASSIGN(IOSSurfaceSoftware);
|
||||
};
|
||||
|
||||
} // namespace flutter
|
||||
|
||||
#endif // FLUTTER_SHELL_PLATFORM_DARWIN_IOS_IOS_SURFACE_SOFTWARE_H_
|
@ -1,128 +0,0 @@
|
||||
// Copyright 2013 The Flutter Authors. All rights reserved.
|
||||
// Use of this source code is governed by a BSD-style license that can be
|
||||
// found in the LICENSE file.
|
||||
|
||||
#import "flutter/shell/platform/darwin/ios/ios_surface_software.h"
|
||||
|
||||
#include <QuartzCore/CALayer.h>
|
||||
|
||||
#include <memory>
|
||||
|
||||
#include "flutter/fml/logging.h"
|
||||
#include "flutter/fml/platform/darwin/cf_utils.h"
|
||||
#include "flutter/fml/trace_event.h"
|
||||
|
||||
#include "third_party/skia/include/core/SkColorSpace.h"
|
||||
#include "third_party/skia/include/core/SkSurface.h"
|
||||
#include "third_party/skia/include/utils/mac/SkCGUtils.h"
|
||||
|
||||
FLUTTER_ASSERT_ARC
|
||||
|
||||
namespace flutter {
|
||||
|
||||
IOSSurfaceSoftware::IOSSurfaceSoftware(CALayer* layer, std::shared_ptr<IOSContext> context)
|
||||
: IOSSurface(std::move(context)), layer_(layer) {}
|
||||
|
||||
IOSSurfaceSoftware::~IOSSurfaceSoftware() = default;
|
||||
|
||||
bool IOSSurfaceSoftware::IsValid() const {
|
||||
return layer_;
|
||||
}
|
||||
|
||||
void IOSSurfaceSoftware::UpdateStorageSizeIfNecessary() {
|
||||
// Nothing to do here. We don't need an external entity to tell us when our
|
||||
// backing store needs to be updated. Instead, we let the frame tell us its
|
||||
// size so we can update to match. This method was added to work around
|
||||
// Android oddities.
|
||||
}
|
||||
|
||||
std::unique_ptr<Surface> IOSSurfaceSoftware::CreateGPUSurface(GrDirectContext* gr_context) {
|
||||
if (!IsValid()) {
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
auto surface = std::make_unique<GPUSurfaceSoftware>(this, true /* render to surface */);
|
||||
|
||||
if (!surface->IsValid()) {
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
return surface;
|
||||
}
|
||||
|
||||
sk_sp<SkSurface> IOSSurfaceSoftware::AcquireBackingStore(const SkISize& size) {
|
||||
TRACE_EVENT0("flutter", "IOSSurfaceSoftware::AcquireBackingStore");
|
||||
if (!IsValid()) {
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
if (sk_surface_ != nullptr &&
|
||||
SkISize::Make(sk_surface_->width(), sk_surface_->height()) == size) {
|
||||
// The old and new surface sizes are the same. Nothing to do here.
|
||||
return sk_surface_;
|
||||
}
|
||||
|
||||
SkImageInfo info = SkImageInfo::MakeN32(size.fWidth, size.fHeight, kPremul_SkAlphaType,
|
||||
SkColorSpace::MakeSRGB());
|
||||
sk_surface_ = SkSurfaces::Raster(info, nullptr);
|
||||
return sk_surface_;
|
||||
}
|
||||
|
||||
bool IOSSurfaceSoftware::PresentBackingStore(sk_sp<SkSurface> backing_store) {
|
||||
TRACE_EVENT0("flutter", "IOSSurfaceSoftware::PresentBackingStore");
|
||||
if (!IsValid() || backing_store == nullptr) {
|
||||
return false;
|
||||
}
|
||||
|
||||
SkPixmap pixmap;
|
||||
if (!backing_store->peekPixels(&pixmap)) {
|
||||
return false;
|
||||
}
|
||||
|
||||
// Some basic sanity checking.
|
||||
uint64_t expected_pixmap_data_size = pixmap.width() * pixmap.height() * 4;
|
||||
|
||||
const size_t pixmap_size = pixmap.computeByteSize();
|
||||
|
||||
if (expected_pixmap_data_size != pixmap_size) {
|
||||
return false;
|
||||
}
|
||||
|
||||
fml::CFRef<CGColorSpaceRef> colorspace(CGColorSpaceCreateDeviceRGB());
|
||||
|
||||
// Setup the data provider that gives CG a view into the pixmap.
|
||||
fml::CFRef<CGDataProviderRef> pixmap_data_provider(CGDataProviderCreateWithData(
|
||||
nullptr, // info
|
||||
pixmap.addr32(), // data
|
||||
pixmap_size, // size
|
||||
nullptr // release callback
|
||||
));
|
||||
|
||||
if (!pixmap_data_provider) {
|
||||
return false;
|
||||
}
|
||||
|
||||
// Create the CGImageRef representation on the pixmap.
|
||||
fml::CFRef<CGImageRef> pixmap_image(CGImageCreate(pixmap.width(), // width
|
||||
pixmap.height(), // height
|
||||
8, // bits per component
|
||||
32, // bits per pixel
|
||||
pixmap.rowBytes(), // bytes per row
|
||||
colorspace, // colorspace
|
||||
kCGImageAlphaPremultipliedLast, // bitmap info
|
||||
pixmap_data_provider, // data provider
|
||||
nullptr, // decode array
|
||||
false, // should interpolate
|
||||
kCGRenderingIntentDefault // rendering intent
|
||||
));
|
||||
|
||||
if (!pixmap_image) {
|
||||
return false;
|
||||
}
|
||||
|
||||
layer_.contents = (__bridge id) static_cast<CGImageRef>(pixmap_image);
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
} // namespace flutter
|
@ -96,9 +96,6 @@ class PlatformViewIOS final : public PlatformView {
|
||||
// |PlatformView|
|
||||
std::shared_ptr<ExternalViewEmbedder> CreateExternalViewEmbedder() override;
|
||||
|
||||
// |PlatformView|
|
||||
sk_sp<GrDirectContext> CreateResourceContext() const override;
|
||||
|
||||
// |PlatformView|
|
||||
std::shared_ptr<impeller::Context> GetImpellerContext() const override;
|
||||
|
||||
|
@ -145,7 +145,7 @@ std::unique_ptr<Surface> PlatformViewIOS::CreateRenderingSurface() {
|
||||
"has no ViewController.";
|
||||
return nullptr;
|
||||
}
|
||||
return ios_surface_->CreateGPUSurface(ios_context_->GetMainContext().get());
|
||||
return ios_surface_->CreateGPUSurface();
|
||||
}
|
||||
|
||||
// |PlatformView|
|
||||
@ -153,11 +153,6 @@ std::shared_ptr<ExternalViewEmbedder> PlatformViewIOS::CreateExternalViewEmbedde
|
||||
return std::make_shared<IOSExternalViewEmbedder>(platform_views_controller_, ios_context_);
|
||||
}
|
||||
|
||||
// |PlatformView|
|
||||
sk_sp<GrDirectContext> PlatformViewIOS::CreateResourceContext() const {
|
||||
return ios_context_->CreateResourceContext();
|
||||
}
|
||||
|
||||
// |PlatformView|
|
||||
std::shared_ptr<impeller::Context> PlatformViewIOS::GetImpellerContext() const {
|
||||
return ios_context_->GetImpellerContext();
|
||||
|
Loading…
x
Reference in New Issue
Block a user