diff --git a/shell/common/shell_test_platform_view_metal.mm b/shell/common/shell_test_platform_view_metal.mm index 94345527bcc31..41322490f8252 100644 --- a/shell/common/shell_test_platform_view_metal.mm +++ b/shell/common/shell_test_platform_view_metal.mm @@ -113,9 +113,8 @@ GPUMTLTextureInfo offscreen_texture_info() const { // |PlatformView| std::unique_ptr ShellTestPlatformViewMetal::CreateRenderingSurface() { if (GetSettings().enable_impeller) { - auto context = [metal_context_->impeller_context() context]; - return std::make_unique( - this, std::make_shared(context, nullptr)); + return std::make_unique(this, + [metal_context_->impeller_context() context]); } return std::make_unique(this, [metal_context_->context() mainContext]); } diff --git a/shell/gpu/gpu_surface_metal_impeller.h b/shell/gpu/gpu_surface_metal_impeller.h index 02407fd63971b..893390090aaf9 100644 --- a/shell/gpu/gpu_surface_metal_impeller.h +++ b/shell/gpu/gpu_surface_metal_impeller.h @@ -21,7 +21,7 @@ class IMPELLER_CA_METAL_LAYER_AVAILABLE GPUSurfaceMetalImpeller : public Surface { public: GPUSurfaceMetalImpeller(GPUSurfaceMetalDelegate* delegate, - const std::shared_ptr& context, + const std::shared_ptr& context, bool render_to_surface = true); // |Surface| diff --git a/shell/gpu/gpu_surface_metal_impeller.mm b/shell/gpu/gpu_surface_metal_impeller.mm index 79b6c20a3effc..ff765afc21d8d 100644 --- a/shell/gpu/gpu_surface_metal_impeller.mm +++ b/shell/gpu/gpu_surface_metal_impeller.mm @@ -8,7 +8,6 @@ #import #include "flow/surface.h" #include "flow/surface_frame.h" -#include "impeller/aiks/aiks_context.h" #include "flutter/common/settings.h" #include "flutter/fml/make_copyable.h" @@ -22,13 +21,14 @@ namespace flutter { -GPUSurfaceMetalImpeller::GPUSurfaceMetalImpeller( - GPUSurfaceMetalDelegate* delegate, - const std::shared_ptr& context, - bool render_to_surface) +GPUSurfaceMetalImpeller::GPUSurfaceMetalImpeller(GPUSurfaceMetalDelegate* delegate, + const std::shared_ptr& context, + bool render_to_surface) : delegate_(delegate), render_target_type_(delegate->GetRenderTargetType()), - aiks_context_(context), + aiks_context_( + std::make_shared(context, + impeller::TypographerContextSkia::Make())), render_to_surface_(render_to_surface) { // If this preference is explicitly set, we allow for disabling partial repaint. NSNumber* disablePartialRepaint = @@ -167,14 +167,12 @@ impeller::IRect cull_rect = surface->coverage(); SkIRect sk_cull_rect = SkIRect::MakeWH(cull_rect.GetWidth(), cull_rect.GetHeight()); surface->SetFrameBoundary(surface_frame.submit_info().frame_boundary); - - const bool reset_host_buffer = surface_frame.submit_info().frame_boundary; auto render_result = impeller::RenderToOnscreen(aiks_context->GetContentContext(), // surface->GetTargetRenderPassDescriptor(), // display_list, // sk_cull_rect, // - /*reset_host_buffer=*/reset_host_buffer // + /*reset_host_buffer=*/true // ); if (!render_result) { return false; diff --git a/shell/gpu/gpu_surface_metal_impeller_unittests.mm b/shell/gpu/gpu_surface_metal_impeller_unittests.mm index 4c37c83c027d7..16632279ebaac 100644 --- a/shell/gpu/gpu_surface_metal_impeller_unittests.mm +++ b/shell/gpu/gpu_surface_metal_impeller_unittests.mm @@ -7,12 +7,10 @@ #include "flutter/shell/gpu/gpu_surface_metal_impeller.h" #include "gtest/gtest.h" -#include "impeller/aiks/aiks_context.h" #include "impeller/entity/mtl/entity_shaders.h" #include "impeller/entity/mtl/framebuffer_blend_shaders.h" #include "impeller/entity/mtl/modern_shaders.h" #include "impeller/renderer/backend/metal/context_mtl.h" -#include "impeller/typographer/typographer_context.h" namespace flutter { namespace testing { @@ -66,16 +64,15 @@ GPUCAMetalLayerHandle GetCAMetalLayer(const SkISize& frame_info) const override TEST(GPUSurfaceMetalImpeller, CanCreateValidSurface) { auto delegate = std::make_shared(); - auto surface = std::make_shared( - delegate.get(), std::make_shared(CreateImpellerContext(), nullptr)); + auto surface = std::make_shared(delegate.get(), CreateImpellerContext()); ASSERT_TRUE(surface->IsValid()); } TEST(GPUSurfaceMetalImpeller, AcquireFrameFromCAMetalLayerNullChecksDrawable) { auto delegate = std::make_shared(); - std::shared_ptr surface = std::make_shared( - delegate.get(), std::make_shared(CreateImpellerContext(), nullptr)); + std::shared_ptr surface = + std::make_shared(delegate.get(), CreateImpellerContext()); ASSERT_TRUE(surface->IsValid()); @@ -86,8 +83,8 @@ GPUCAMetalLayerHandle GetCAMetalLayer(const SkISize& frame_info) const override TEST(GPUSurfaceMetalImpeller, AcquireFrameFromCAMetalLayerDoesNotRetainThis) { auto delegate = std::make_shared(); delegate->SetDevice(); - std::unique_ptr surface = std::make_unique( - delegate.get(), std::make_shared(CreateImpellerContext(), nullptr)); + std::unique_ptr surface = + std::make_unique(delegate.get(), CreateImpellerContext()); ASSERT_TRUE(surface->IsValid()); @@ -100,13 +97,14 @@ GPUCAMetalLayerHandle GetCAMetalLayer(const SkISize& frame_info) const override ASSERT_TRUE(frame->Submit()); } -TEST(GPUSurfaceMetalImpeller, ResetHostBufferBasedOnFrameBoundary) { +// Because each overlay surface gets its own HostBuffer, we always need to reset. +TEST(GPUSurfaceMetalImpeller, DoesNotResetHostBufferBasedOnFrameBoundary) { auto delegate = std::make_shared(); delegate->SetDevice(); auto context = CreateImpellerContext(); - std::unique_ptr surface = std::make_unique( - delegate.get(), std::make_shared(context, nullptr)); + std::unique_ptr surface = + std::make_unique(delegate.get(), context); ASSERT_TRUE(surface->IsValid()); @@ -118,13 +116,13 @@ GPUCAMetalLayerHandle GetCAMetalLayer(const SkISize& frame_info) const override frame->set_submit_info({.frame_boundary = false}); ASSERT_TRUE(frame->Submit()); - EXPECT_EQ(host_buffer.GetStateForTest().current_frame, 0u); + EXPECT_EQ(host_buffer.GetStateForTest().current_frame, 1u); frame = surface->AcquireFrame(SkISize::Make(100, 100)); frame->set_submit_info({.frame_boundary = true}); ASSERT_TRUE(frame->Submit()); - EXPECT_EQ(host_buffer.GetStateForTest().current_frame, 1u); + EXPECT_EQ(host_buffer.GetStateForTest().current_frame, 2u); } #ifdef IMPELLER_DEBUG @@ -133,19 +131,18 @@ GPUCAMetalLayerHandle GetCAMetalLayer(const SkISize& frame_info) const override delegate->SetDevice(); auto context = CreateImpellerContext(); - auto aiks_context = std::make_shared(context, nullptr); EXPECT_FALSE(context->GetCaptureManager()->CaptureScopeActive()); std::unique_ptr surface = - std::make_unique(delegate.get(), aiks_context); + std::make_unique(delegate.get(), context); auto frame_1 = surface->AcquireFrame(SkISize::Make(100, 100)); frame_1->set_submit_info({.frame_boundary = false}); EXPECT_TRUE(context->GetCaptureManager()->CaptureScopeActive()); std::unique_ptr surface_2 = - std::make_unique(delegate.get(), aiks_context); + std::make_unique(delegate.get(), context); auto frame_2 = surface->AcquireFrame(SkISize::Make(100, 100)); frame_2->set_submit_info({.frame_boundary = true}); diff --git a/shell/platform/darwin/ios/ios_context.h b/shell/platform/darwin/ios/ios_context.h index e2c789d0b1975..ef9dcca778df7 100644 --- a/shell/platform/darwin/ios/ios_context.h +++ b/shell/platform/darwin/ios/ios_context.h @@ -15,7 +15,6 @@ #include "flutter/fml/synchronization/sync_switch.h" #import "flutter/shell/platform/darwin/common/framework/Headers/FlutterTexture.h" #import "flutter/shell/platform/darwin/ios/rendering_api_selection.h" -#include "impeller/aiks/aiks_context.h" #include "third_party/skia/include/gpu/ganesh/GrDirectContext.h" namespace impeller { @@ -141,8 +140,6 @@ class IOSContext { virtual std::shared_ptr GetImpellerContext() const; - virtual std::shared_ptr GetAiksContext() const; - protected: explicit IOSContext(); diff --git a/shell/platform/darwin/ios/ios_context.mm b/shell/platform/darwin/ios/ios_context.mm index 762847e8af780..ac6db41aa57b7 100644 --- a/shell/platform/darwin/ios/ios_context.mm +++ b/shell/platform/darwin/ios/ios_context.mm @@ -63,8 +63,4 @@ return nullptr; } -std::shared_ptr IOSContext::GetAiksContext() const { - return nullptr; -} - } // namespace flutter diff --git a/shell/platform/darwin/ios/ios_context_metal_impeller.h b/shell/platform/darwin/ios/ios_context_metal_impeller.h index b5293da6e56a1..5e2ed7a32dee9 100644 --- a/shell/platform/darwin/ios/ios_context_metal_impeller.h +++ b/shell/platform/darwin/ios/ios_context_metal_impeller.h @@ -9,7 +9,6 @@ #include "flutter/shell/platform/darwin/graphics/FlutterDarwinContextMetalImpeller.h" #include "flutter/shell/platform/darwin/graphics/FlutterDarwinContextMetalSkia.h" #include "flutter/shell/platform/darwin/ios/ios_context.h" -#include "impeller/aiks/aiks_context.h" namespace impeller { @@ -35,7 +34,6 @@ class IOSContextMetalImpeller final : public IOSContext { private: fml::scoped_nsobject darwin_context_metal_impeller_; - std::shared_ptr aiks_context_; // |IOSContext| sk_sp CreateResourceContext() override; @@ -51,9 +49,6 @@ class IOSContextMetalImpeller final : public IOSContext { // |IOSContext| std::shared_ptr GetImpellerContext() const override; - // |IOSContext| - std::shared_ptr GetAiksContext() const override; - FML_DISALLOW_COPY_AND_ASSIGN(IOSContextMetalImpeller); }; diff --git a/shell/platform/darwin/ios/ios_context_metal_impeller.mm b/shell/platform/darwin/ios/ios_context_metal_impeller.mm index b3846b1988740..92a59a8326c96 100644 --- a/shell/platform/darwin/ios/ios_context_metal_impeller.mm +++ b/shell/platform/darwin/ios/ios_context_metal_impeller.mm @@ -3,11 +3,8 @@ // found in the LICENSE file. #import "flutter/shell/platform/darwin/ios/ios_context_metal_impeller.h" - #include "flutter/impeller/entity/mtl/entity_shaders.h" #import "flutter/shell/platform/darwin/ios/ios_external_texture_metal.h" -#include "impeller/aiks/aiks_context.h" -#include "impeller/typographer/backends/skia/typographer_context_skia.h" FLUTTER_ASSERT_ARC @@ -16,12 +13,7 @@ IOSContextMetalImpeller::IOSContextMetalImpeller( const std::shared_ptr& is_gpu_disabled_sync_switch) : darwin_context_metal_impeller_(fml::scoped_nsobject{ - [[FlutterDarwinContextMetalImpeller alloc] init:is_gpu_disabled_sync_switch]}) { - if (darwin_context_metal_impeller_.get().context) { - aiks_context_ = std::make_shared( - darwin_context_metal_impeller_.get().context, impeller::TypographerContextSkia::Make()); - } -} + [[FlutterDarwinContextMetalImpeller alloc] init:is_gpu_disabled_sync_switch]}) {} IOSContextMetalImpeller::~IOSContextMetalImpeller() = default; @@ -47,11 +39,6 @@ return darwin_context_metal_impeller_.get().context; } -// |IOSContext| -std::shared_ptr IOSContextMetalImpeller::GetAiksContext() const { - return aiks_context_; -} - // |IOSContext| std::unique_ptr IOSContextMetalImpeller::MakeCurrent() { // This only makes sense for contexts that need to be bound to a specific thread. diff --git a/shell/platform/darwin/ios/ios_surface.h b/shell/platform/darwin/ios/ios_surface.h index 96970a465b531..78394f25781c6 100644 --- a/shell/platform/darwin/ios/ios_surface.h +++ b/shell/platform/darwin/ios/ios_surface.h @@ -18,6 +18,10 @@ namespace flutter { +// Returns true if the app explicitly specified to use the iOS view embedding +// mechanism which is still in a release preview. +bool IsIosEmbeddedViewsPreviewEnabled(); + class IOSSurface { public: static std::unique_ptr Create(std::shared_ptr context, diff --git a/shell/platform/darwin/ios/ios_surface_metal_impeller.h b/shell/platform/darwin/ios/ios_surface_metal_impeller.h index 86c5171caac23..888f3935355e3 100644 --- a/shell/platform/darwin/ios/ios_surface_metal_impeller.h +++ b/shell/platform/darwin/ios/ios_surface_metal_impeller.h @@ -30,7 +30,6 @@ class SK_API_AVAILABLE_CA_METAL_LAYER IOSSurfaceMetalImpeller final private: fml::scoped_nsobject layer_; const std::shared_ptr impeller_context_; - std::shared_ptr aiks_context_; bool is_valid_ = false; // |IOSSurface| diff --git a/shell/platform/darwin/ios/ios_surface_metal_impeller.mm b/shell/platform/darwin/ios/ios_surface_metal_impeller.mm index 89b7e729108f5..8d1a75d6f1893 100644 --- a/shell/platform/darwin/ios/ios_surface_metal_impeller.mm +++ b/shell/platform/darwin/ios/ios_surface_metal_impeller.mm @@ -7,9 +7,6 @@ #include "flutter/impeller/renderer/backend/metal/formats_mtl.h" #include "flutter/impeller/renderer/context.h" #include "flutter/shell/gpu/gpu_surface_metal_impeller.h" -#include "impeller/aiks/aiks_context.h" -#include "impeller/typographer/backends/skia/typographer_context_skia.h" -#include "impeller/typographer/typographer_context.h" FLUTTER_ASSERT_ARC @@ -20,9 +17,8 @@ : IOSSurface(context), GPUSurfaceMetalDelegate(MTLRenderTargetType::kCAMetalLayer), layer_(layer), - impeller_context_(context ? context->GetImpellerContext() : nullptr), - aiks_context_(context ? context->GetAiksContext() : nullptr) { - if (!impeller_context_ || !aiks_context_) { + impeller_context_(context ? context->GetImpellerContext() : nullptr) { + if (!impeller_context_) { return; } is_valid_ = true; @@ -45,8 +41,8 @@ std::unique_ptr IOSSurfaceMetalImpeller::CreateGPUSurface(GrDirectContext*) { impeller_context_->UpdateOffscreenLayerPixelFormat( impeller::FromMTLPixelFormat(layer_.get().pixelFormat)); - return std::make_unique(this, // - aiks_context_ // + return std::make_unique(this, // + impeller_context_ // ); } diff --git a/shell/platform/embedder/embedder_surface_metal_impeller.h b/shell/platform/embedder/embedder_surface_metal_impeller.h index 3589f7facddd9..109870aa6f129 100644 --- a/shell/platform/embedder/embedder_surface_metal_impeller.h +++ b/shell/platform/embedder/embedder_surface_metal_impeller.h @@ -12,7 +12,6 @@ #include "flutter/shell/platform/embedder/embedder_external_view_embedder.h" #include "flutter/shell/platform/embedder/embedder_surface.h" #include "fml/concurrent_message_loop.h" -#include "impeller/aiks/aiks_context.h" namespace impeller { class Context; @@ -42,7 +41,6 @@ class EmbedderSurfaceMetalImpeller final : public EmbedderSurface, MetalDispatchTable metal_dispatch_table_; std::shared_ptr external_view_embedder_; std::shared_ptr context_; - std::shared_ptr aiks_context_; // |EmbedderSurface| bool IsValid() const override; diff --git a/shell/platform/embedder/embedder_surface_metal_impeller.mm b/shell/platform/embedder/embedder_surface_metal_impeller.mm index 63653888618cc..d1d1265dd99d7 100644 --- a/shell/platform/embedder/embedder_surface_metal_impeller.mm +++ b/shell/platform/embedder/embedder_surface_metal_impeller.mm @@ -12,13 +12,10 @@ #include "flutter/shell/gpu/gpu_surface_metal_delegate.h" #include "flutter/shell/gpu/gpu_surface_metal_impeller.h" #import "flutter/shell/platform/darwin/graphics/FlutterDarwinContextMetalImpeller.h" -#include "impeller/aiks/aiks_context.h" #include "impeller/entity/mtl/entity_shaders.h" #include "impeller/entity/mtl/framebuffer_blend_shaders.h" #include "impeller/entity/mtl/modern_shaders.h" #include "impeller/renderer/backend/metal/context_mtl.h" -#include "impeller/typographer/backends/skia/typographer_context_skia.h" -#include "impeller/typographer/typographer_context.h" FLUTTER_ASSERT_NOT_ARC @@ -63,13 +60,9 @@ if (!IsValid()) { return nullptr; } - if (!aiks_context_) { - aiks_context_ = - std::make_shared(context_, impeller::TypographerContextSkia::Make()); - } const bool render_to_surface = !external_view_embedder_; - auto surface = std::make_unique(this, aiks_context_, render_to_surface); + auto surface = std::make_unique(this, context_, render_to_surface); if (!surface->IsValid()) { return nullptr;