diff --git a/shell/platform/android/android_surface_gl.cc b/shell/platform/android/android_surface_gl.cc index c9a9a130c59c4..d7a630c345099 100644 --- a/shell/platform/android/android_surface_gl.cc +++ b/shell/platform/android/android_surface_gl.cc @@ -22,11 +22,8 @@ constexpr char kEmulatorRendererPrefix[] = AndroidSurfaceGL::AndroidSurfaceGL( std::shared_ptr android_context, std::shared_ptr jni_facade, - const AndroidSurface::Factory& surface_factory) - : external_view_embedder_( - std::make_unique(android_context, - jni_facade, - surface_factory)), + std::shared_ptr external_view_embedder) + : external_view_embedder_(external_view_embedder), android_context_( std::static_pointer_cast(android_context)), native_window_(nullptr), diff --git a/shell/platform/android/android_surface_gl.h b/shell/platform/android/android_surface_gl.h index 771fbfea41a80..ca9aead26b4c5 100644 --- a/shell/platform/android/android_surface_gl.h +++ b/shell/platform/android/android_surface_gl.h @@ -22,9 +22,10 @@ namespace flutter { class AndroidSurfaceGL final : public GPUSurfaceGLDelegate, public AndroidSurface { public: - AndroidSurfaceGL(std::shared_ptr android_context, - std::shared_ptr jni_facade, - const AndroidSurface::Factory& surface_factory); + AndroidSurfaceGL( + std::shared_ptr android_context, + std::shared_ptr jni_facade, + std::shared_ptr external_view_embedder); ~AndroidSurfaceGL() override; @@ -69,7 +70,7 @@ class AndroidSurfaceGL final : public GPUSurfaceGLDelegate, sk_sp GetGLInterface() const override; private: - const std::unique_ptr external_view_embedder_; + const std::shared_ptr external_view_embedder_; const std::shared_ptr android_context_; fml::RefPtr native_window_; diff --git a/shell/platform/android/android_surface_software.cc b/shell/platform/android/android_surface_software.cc index 126f127bd2b8c..ab116f79048fa 100644 --- a/shell/platform/android/android_surface_software.cc +++ b/shell/platform/android/android_surface_software.cc @@ -40,11 +40,8 @@ bool GetSkColorType(int32_t buffer_format, AndroidSurfaceSoftware::AndroidSurfaceSoftware( std::shared_ptr android_context, std::shared_ptr jni_facade, - AndroidSurface::Factory surface_factory) - : external_view_embedder_( - std::make_unique(android_context, - jni_facade, - surface_factory)) { + std::shared_ptr external_view_embedder) + : external_view_embedder_(external_view_embedder) { GetSkColorType(WINDOW_FORMAT_RGBA_8888, &target_color_type_, &target_alpha_type_); } diff --git a/shell/platform/android/android_surface_software.h b/shell/platform/android/android_surface_software.h index ec9fdb63f131d..fc54ce2091778 100644 --- a/shell/platform/android/android_surface_software.h +++ b/shell/platform/android/android_surface_software.h @@ -18,9 +18,10 @@ namespace flutter { class AndroidSurfaceSoftware final : public AndroidSurface, public GPUSurfaceSoftwareDelegate { public: - AndroidSurfaceSoftware(std::shared_ptr android_context, - std::shared_ptr jni_facade, - AndroidSurface::Factory surface_factory); + AndroidSurfaceSoftware( + std::shared_ptr android_context, + std::shared_ptr jni_facade, + std::shared_ptr external_view_embedder); ~AndroidSurfaceSoftware() override; @@ -56,7 +57,7 @@ class AndroidSurfaceSoftware final : public AndroidSurface, ExternalViewEmbedder* GetExternalViewEmbedder() override; private: - const std::unique_ptr external_view_embedder_; + const std::shared_ptr external_view_embedder_; sk_sp sk_surface_; fml::RefPtr native_window_; diff --git a/shell/platform/android/android_surface_vulkan.cc b/shell/platform/android/android_surface_vulkan.cc index 4ff32b70a12c5..f31faf3716493 100644 --- a/shell/platform/android/android_surface_vulkan.cc +++ b/shell/platform/android/android_surface_vulkan.cc @@ -15,11 +15,8 @@ namespace flutter { AndroidSurfaceVulkan::AndroidSurfaceVulkan( std::shared_ptr android_context, std::shared_ptr jni_facade, - AndroidSurface::Factory surface_factory) - : external_view_embedder_( - std::make_unique(android_context, - jni_facade, - surface_factory)), + std::shared_ptr external_view_embedder) + : external_view_embedder_(external_view_embedder), proc_table_(fml::MakeRefCounted()) {} AndroidSurfaceVulkan::~AndroidSurfaceVulkan() = default; diff --git a/shell/platform/android/android_surface_vulkan.h b/shell/platform/android/android_surface_vulkan.h index 27b7164e5ba91..b91248b96c76a 100644 --- a/shell/platform/android/android_surface_vulkan.h +++ b/shell/platform/android/android_surface_vulkan.h @@ -21,9 +21,10 @@ namespace flutter { class AndroidSurfaceVulkan : public AndroidSurface, public GPUSurfaceVulkanDelegate { public: - AndroidSurfaceVulkan(std::shared_ptr android_context, - std::shared_ptr jni_facade, - AndroidSurface::Factory surface_factory); + AndroidSurfaceVulkan( + std::shared_ptr android_context, + std::shared_ptr jni_facade, + std::shared_ptr external_view_embedder); ~AndroidSurfaceVulkan() override; @@ -56,8 +57,7 @@ class AndroidSurfaceVulkan : public AndroidSurface, fml::RefPtr vk() override; private: - const std::unique_ptr external_view_embedder_; - + const std::shared_ptr external_view_embedder_; fml::RefPtr proc_table_; fml::RefPtr native_window_; diff --git a/shell/platform/android/external_view_embedder/BUILD.gn b/shell/platform/android/external_view_embedder/BUILD.gn index a757cd0d2aab1..44bcdaddae280 100644 --- a/shell/platform/android/external_view_embedder/BUILD.gn +++ b/shell/platform/android/external_view_embedder/BUILD.gn @@ -44,6 +44,7 @@ executable("android_external_view_embedder_unittests") { "//flutter/flow", "//flutter/shell/gpu:gpu_surface_gl", "//flutter/shell/platform/android/jni:jni_mock", + "//flutter/shell/platform/android/surface", "//flutter/shell/platform/android/surface:surface_mock", "//flutter/testing", "//flutter/testing:dart", diff --git a/shell/platform/android/external_view_embedder/external_view_embedder.cc b/shell/platform/android/external_view_embedder/external_view_embedder.cc index a45a8ae897ed1..6ea00128f5112 100644 --- a/shell/platform/android/external_view_embedder/external_view_embedder.cc +++ b/shell/platform/android/external_view_embedder/external_view_embedder.cc @@ -5,13 +5,14 @@ #include "flutter/shell/platform/android/external_view_embedder/external_view_embedder.h" #include "flutter/fml/trace_event.h" +#include "flutter/shell/platform/android/surface/android_surface.h" namespace flutter { AndroidExternalViewEmbedder::AndroidExternalViewEmbedder( std::shared_ptr android_context, std::shared_ptr jni_facade, - const AndroidSurface::Factory& surface_factory) + std::shared_ptr surface_factory) : ExternalViewEmbedder(), android_context_(android_context), jni_facade_(jni_facade), diff --git a/shell/platform/android/external_view_embedder/external_view_embedder.h b/shell/platform/android/external_view_embedder/external_view_embedder.h index adb5137e2edb1..b8cf718a5ad45 100644 --- a/shell/platform/android/external_view_embedder/external_view_embedder.h +++ b/shell/platform/android/external_view_embedder/external_view_embedder.h @@ -12,6 +12,7 @@ #include "flutter/shell/platform/android/context/android_context.h" #include "flutter/shell/platform/android/external_view_embedder/surface_pool.h" #include "flutter/shell/platform/android/jni/platform_view_android_jni.h" +#include "flutter/shell/platform/android/surface/android_surface.h" #include "third_party/skia/include/core/SkPictureRecorder.h" namespace flutter { @@ -31,7 +32,7 @@ class AndroidExternalViewEmbedder final : public ExternalViewEmbedder { AndroidExternalViewEmbedder( std::shared_ptr android_context, std::shared_ptr jni_facade, - const AndroidSurface::Factory& surface_factory); + std::shared_ptr surface_factory); // |ExternalViewEmbedder| void PrerollCompositeEmbeddedView( @@ -93,7 +94,7 @@ class AndroidExternalViewEmbedder final : public ExternalViewEmbedder { const std::shared_ptr jni_facade_; // Allows to create surfaces. - const AndroidSurface::Factory surface_factory_; + const std::shared_ptr surface_factory_; // Holds surfaces. Allows to recycle surfaces or allocate new ones. const std::unique_ptr surface_pool_; diff --git a/shell/platform/android/external_view_embedder/external_view_embedder_unittests.cc b/shell/platform/android/external_view_embedder/external_view_embedder_unittests.cc index f69645f33dcf2..dff6e685bb1fd 100644 --- a/shell/platform/android/external_view_embedder/external_view_embedder_unittests.cc +++ b/shell/platform/android/external_view_embedder/external_view_embedder_unittests.cc @@ -13,6 +13,7 @@ #include "flutter/shell/platform/android/surface/android_surface_mock.h" #include "gmock/gmock.h" #include "gtest/gtest.h" +#include "shell/platform/android/surface/android_surface.h" #include "third_party/skia/include/gpu/GrDirectContext.h" namespace flutter { @@ -21,6 +22,24 @@ namespace testing { using ::testing::ByMove; using ::testing::Return; +class TestAndroidSurfaceFactory : public AndroidSurfaceFactory { + public: + using TestSurfaceProducer = + std::function(void)>; + explicit TestAndroidSurfaceFactory(TestSurfaceProducer&& surface_producer) { + surface_producer_ = surface_producer; + } + + ~TestAndroidSurfaceFactory() override = default; + + std::unique_ptr CreateSurface() override { + return surface_producer_(); + } + + private: + TestSurfaceProducer surface_producer_; +}; + class SurfaceMock : public Surface { public: MOCK_METHOD(bool, IsValid, (), (override)); @@ -263,10 +282,8 @@ TEST(AndroidExternalViewEmbedder, SubmitFrame) { auto window = fml::MakeRefCounted(nullptr); auto gr_context = GrDirectContext::MakeMock(nullptr); auto frame_size = SkISize::Make(1000, 1000); - auto surface_factory = - [gr_context, window, frame_size]( - std::shared_ptr android_context, - std::shared_ptr jni_facade) { + auto surface_factory = std::make_shared( + [gr_context, window, frame_size]() { auto surface_frame_1 = std::make_unique( SkSurface::MakeNull(1000, 1000), false, [](const SurfaceFrame& surface_frame, SkCanvas* canvas) { @@ -293,7 +310,7 @@ TEST(AndroidExternalViewEmbedder, SubmitFrame) { EXPECT_CALL(*android_surface_mock, SetNativeWindow(window)); return android_surface_mock; - }; + }); auto embedder = std::make_unique( android_context, jni_mock, surface_factory); @@ -482,10 +499,8 @@ TEST(AndroidExternalViewEmbedder, DestroyOverlayLayersOnSizeChange) { auto window = fml::MakeRefCounted(nullptr); auto gr_context = GrDirectContext::MakeMock(nullptr); auto frame_size = SkISize::Make(1000, 1000); - auto surface_factory = - [gr_context, window, frame_size]( - std::shared_ptr android_context, - std::shared_ptr jni_facade) { + auto surface_factory = std::make_shared( + [gr_context, window, frame_size]() { auto surface_frame_1 = std::make_unique( SkSurface::MakeNull(1000, 1000), false, [](const SurfaceFrame& surface_frame, SkCanvas* canvas) { @@ -505,7 +520,7 @@ TEST(AndroidExternalViewEmbedder, DestroyOverlayLayersOnSizeChange) { EXPECT_CALL(*android_surface_mock, SetNativeWindow(window)); return android_surface_mock; - }; + }); auto embedder = std::make_unique( android_context, jni_mock, surface_factory); @@ -565,10 +580,8 @@ TEST(AndroidExternalViewEmbedder, DoesNotDestroyOverlayLayersOnSizeChange) { auto window = fml::MakeRefCounted(nullptr); auto gr_context = GrDirectContext::MakeMock(nullptr); auto frame_size = SkISize::Make(1000, 1000); - auto surface_factory = - [gr_context, window, frame_size]( - std::shared_ptr android_context, - std::shared_ptr jni_facade) { + auto surface_factory = std::make_shared( + [gr_context, window, frame_size]() { auto surface_frame_1 = std::make_unique( SkSurface::MakeNull(1000, 1000), false, [](const SurfaceFrame& surface_frame, SkCanvas* canvas) { @@ -588,7 +601,7 @@ TEST(AndroidExternalViewEmbedder, DoesNotDestroyOverlayLayersOnSizeChange) { EXPECT_CALL(*android_surface_mock, SetNativeWindow(window)); return android_surface_mock; - }; + }); auto embedder = std::make_unique( android_context, jni_mock, surface_factory); diff --git a/shell/platform/android/external_view_embedder/surface_pool.cc b/shell/platform/android/external_view_embedder/surface_pool.cc index eccd2d671da5c..b07a8d1ec27c6 100644 --- a/shell/platform/android/external_view_embedder/surface_pool.cc +++ b/shell/platform/android/external_view_embedder/surface_pool.cc @@ -23,7 +23,7 @@ std::shared_ptr SurfacePool::GetLayer( GrDirectContext* gr_context, std::shared_ptr android_context, std::shared_ptr jni_facade, - const AndroidSurface::Factory& surface_factory) { + std::shared_ptr surface_factory) { // Destroy current layers in the pool if the frame size has changed. if (requested_frame_size_ != current_frame_size_) { DestroyLayers(jni_facade); @@ -33,7 +33,7 @@ std::shared_ptr SurfacePool::GetLayer( // Allocate a new surface if there isn't one available. if (available_layer_index_ >= layers_.size()) { std::unique_ptr android_surface = - surface_factory(android_context, jni_facade); + surface_factory->CreateSurface(); FML_CHECK(android_surface && android_surface->IsValid()) << "Could not create an OpenGL, Vulkan or Software surface to setup " diff --git a/shell/platform/android/external_view_embedder/surface_pool.h b/shell/platform/android/external_view_embedder/surface_pool.h index 44236747f9331..afdb6b6a35b9c 100644 --- a/shell/platform/android/external_view_embedder/surface_pool.h +++ b/shell/platform/android/external_view_embedder/surface_pool.h @@ -55,7 +55,7 @@ class SurfacePool { GrDirectContext* gr_context, std::shared_ptr android_context, std::shared_ptr jni_facade, - const AndroidSurface::Factory& surface_factory); + std::shared_ptr surface_factory); // Gets the layers in the pool that aren't currently used. // This method doesn't mark the layers as unused. diff --git a/shell/platform/android/external_view_embedder/surface_pool_unittests.cc b/shell/platform/android/external_view_embedder/surface_pool_unittests.cc index 6940c8c75e048..7d393832eb1f1 100644 --- a/shell/platform/android/external_view_embedder/surface_pool_unittests.cc +++ b/shell/platform/android/external_view_embedder/surface_pool_unittests.cc @@ -18,6 +18,24 @@ namespace testing { using ::testing::ByMove; using ::testing::Return; +class TestAndroidSurfaceFactory : public AndroidSurfaceFactory { + public: + using TestSurfaceProducer = + std::function(void)>; + explicit TestAndroidSurfaceFactory(TestSurfaceProducer&& surface_producer) { + surface_producer_ = surface_producer; + } + + ~TestAndroidSurfaceFactory() override = default; + + std::unique_ptr CreateSurface() override { + return surface_producer_(); + } + + private: + TestSurfaceProducer surface_producer_; +}; + TEST(SurfacePool, GetLayer__AllocateOneLayer) { auto pool = std::make_unique(); @@ -33,14 +51,13 @@ TEST(SurfacePool, GetLayer__AllocateOneLayer) { 0, window)))); auto surface_factory = - [gr_context, window](std::shared_ptr android_context, - std::shared_ptr jni_facade) { + std::make_shared([gr_context, window]() { auto android_surface_mock = std::make_unique(); EXPECT_CALL(*android_surface_mock, CreateGPUSurface(gr_context.get())); EXPECT_CALL(*android_surface_mock, SetNativeWindow(window)); EXPECT_CALL(*android_surface_mock, IsValid()).WillOnce(Return(true)); return android_surface_mock; - }; + }); auto layer = pool->GetLayer(gr_context.get(), android_context, jni_mock, surface_factory); @@ -64,14 +81,13 @@ TEST(SurfacePool, GetUnusedLayers) { 0, window)))); auto surface_factory = - [gr_context, window](std::shared_ptr android_context, - std::shared_ptr jni_facade) { + std::make_shared([gr_context, window]() { auto android_surface_mock = std::make_unique(); EXPECT_CALL(*android_surface_mock, CreateGPUSurface(gr_context.get())); EXPECT_CALL(*android_surface_mock, SetNativeWindow(window)); EXPECT_CALL(*android_surface_mock, IsValid()).WillOnce(Return(true)); return android_surface_mock; - }; + }); auto layer = pool->GetLayer(gr_context.get(), android_context, jni_mock, surface_factory); ASSERT_EQ(0UL, pool->GetUnusedLayers().size()); @@ -97,10 +113,8 @@ TEST(SurfacePool, GetLayer__Recycle) { std::make_shared(AndroidRenderingAPI::kSoftware); auto gr_context_2 = GrDirectContext::MakeMock(nullptr); - auto surface_factory = - [gr_context_1, gr_context_2, window]( - std::shared_ptr android_context, - std::shared_ptr jni_facade) { + auto surface_factory = std::make_shared( + [gr_context_1, gr_context_2, window]() { auto android_surface_mock = std::make_unique(); // Allocate two GPU surfaces for each gr context. EXPECT_CALL(*android_surface_mock, @@ -111,7 +125,7 @@ TEST(SurfacePool, GetLayer__Recycle) { EXPECT_CALL(*android_surface_mock, SetNativeWindow(window)); EXPECT_CALL(*android_surface_mock, IsValid()).WillOnce(Return(true)); return android_surface_mock; - }; + }); auto layer_1 = pool->GetLayer(gr_context_1.get(), android_context, jni_mock, surface_factory); @@ -147,14 +161,13 @@ TEST(SurfacePool, GetLayer__AllocateTwoLayers) { 1, window)))); auto surface_factory = - [gr_context, window](std::shared_ptr android_context, - std::shared_ptr jni_facade) { + std::make_shared([gr_context, window]() { auto android_surface_mock = std::make_unique(); EXPECT_CALL(*android_surface_mock, CreateGPUSurface(gr_context.get())); EXPECT_CALL(*android_surface_mock, SetNativeWindow(window)); EXPECT_CALL(*android_surface_mock, IsValid()).WillOnce(Return(true)); return android_surface_mock; - }; + }); auto layer_1 = pool->GetLayer(gr_context.get(), android_context, jni_mock, surface_factory); auto layer_2 = pool->GetLayer(gr_context.get(), android_context, jni_mock, @@ -185,14 +198,13 @@ TEST(SurfacePool, DestroyLayers) { 0, window)))); auto surface_factory = - [gr_context, window](std::shared_ptr android_context, - std::shared_ptr jni_facade) { + std::make_shared([gr_context, window]() { auto android_surface_mock = std::make_unique(); EXPECT_CALL(*android_surface_mock, CreateGPUSurface(gr_context.get())); EXPECT_CALL(*android_surface_mock, SetNativeWindow(window)); EXPECT_CALL(*android_surface_mock, IsValid()).WillOnce(Return(true)); return android_surface_mock; - }; + }); pool->GetLayer(gr_context.get(), android_context, jni_mock, surface_factory); EXPECT_CALL(*jni_mock, FlutterViewDestroyOverlaySurfaces()); @@ -213,14 +225,13 @@ TEST(SurfacePool, DestroyLayers__frameSizeChanged) { auto window = fml::MakeRefCounted(nullptr); auto surface_factory = - [gr_context, window](std::shared_ptr android_context, - std::shared_ptr jni_facade) { + std::make_shared([gr_context, window]() { auto android_surface_mock = std::make_unique(); EXPECT_CALL(*android_surface_mock, CreateGPUSurface(gr_context.get())); EXPECT_CALL(*android_surface_mock, SetNativeWindow(window)); EXPECT_CALL(*android_surface_mock, IsValid()).WillOnce(Return(true)); return android_surface_mock; - }; + }); pool->SetFrameSize(SkISize::Make(10, 10)); EXPECT_CALL(*jni_mock, FlutterViewDestroyOverlaySurfaces()).Times(0); EXPECT_CALL(*jni_mock, FlutterViewCreateOverlaySurface()) diff --git a/shell/platform/android/platform_view_android.cc b/shell/platform/android/platform_view_android.cc index 2c887b638a060..7bde2a45144a3 100644 --- a/shell/platform/android/platform_view_android.cc +++ b/shell/platform/android/platform_view_android.cc @@ -14,6 +14,8 @@ #include "flutter/shell/platform/android/android_external_texture_gl.h" #include "flutter/shell/platform/android/android_surface_gl.h" #include "flutter/shell/platform/android/android_surface_software.h" +#include "shell/platform/android/external_view_embedder/external_view_embedder.h" +#include "shell/platform/android/surface/android_surface.h" #if SHELL_ENABLE_VULKAN #include "flutter/shell/platform/android/android_surface_vulkan.h" @@ -26,22 +28,35 @@ namespace flutter { -std::unique_ptr SurfaceFactory( - std::shared_ptr android_context, +AndroidSurfaceFactoryImpl::AndroidSurfaceFactoryImpl( + std::shared_ptr context, std::shared_ptr jni_facade) { - FML_CHECK(SurfaceFactory); - switch (android_context->RenderingApi()) { + android_context_ = context; + jni_facade_ = jni_facade; +} + +AndroidSurfaceFactoryImpl::~AndroidSurfaceFactoryImpl() = default; + +void AndroidSurfaceFactoryImpl::SetExternalViewEmbedder( + std::shared_ptr external_view_embedder) { + external_view_embedder_ = external_view_embedder; +} + +std::unique_ptr AndroidSurfaceFactoryImpl::CreateSurface() { + FML_CHECK(external_view_embedder_); + switch (android_context_->RenderingApi()) { case AndroidRenderingAPI::kSoftware: return std::make_unique( - android_context, jni_facade, SurfaceFactory); + android_context_, jni_facade_, external_view_embedder_); case AndroidRenderingAPI::kOpenGLES: - return std::make_unique(android_context, jni_facade, - SurfaceFactory); + return std::make_unique(android_context_, jni_facade_, + external_view_embedder_); case AndroidRenderingAPI::kVulkan: #if SHELL_ENABLE_VULKAN - return std::make_unique(android_context, jni_facade, - SurfaceFactory); + return std::make_unique( + android_context_, jni_facade_, external_view_embedder_); #endif // SHELL_ENABLE_VULKAN + default: return nullptr; } return nullptr; @@ -72,7 +87,13 @@ PlatformViewAndroid::PlatformViewAndroid( FML_CHECK(android_context && android_context->IsValid()) << "Could not create an Android context."; - android_surface_ = SurfaceFactory(std::move(android_context), jni_facade); + surface_factory_ = + std::make_shared(android_context, jni_facade); + surface_factory_->SetExternalViewEmbedder( + std::make_shared(android_context, jni_facade, + surface_factory_)); + + android_surface_ = surface_factory_->CreateSurface(); FML_CHECK(android_surface_ && android_surface_->IsValid()) << "Could not create an OpenGL, Vulkan or Software surface to setup " "rendering."; diff --git a/shell/platform/android/platform_view_android.h b/shell/platform/android/platform_view_android.h index 618b0413a572f..317784c729a96 100644 --- a/shell/platform/android/platform_view_android.h +++ b/shell/platform/android/platform_view_android.h @@ -22,6 +22,25 @@ namespace flutter { +class AndroidSurfaceFactoryImpl : public AndroidSurfaceFactory { + public: + AndroidSurfaceFactoryImpl(std::shared_ptr context, + std::shared_ptr jni_facade); + + ~AndroidSurfaceFactoryImpl() override; + + std::unique_ptr CreateSurface() override; + + void SetExternalViewEmbedder( + std::shared_ptr external_view_embedder); + + private: + std::shared_ptr android_context_; + std::shared_ptr jni_facade_; + std::shared_ptr external_view_embedder_; + +}; + class PlatformViewAndroid final : public PlatformView { public: static bool Register(JNIEnv* env); @@ -80,6 +99,7 @@ class PlatformViewAndroid final : public PlatformView { private: const std::shared_ptr jni_facade_; + std::shared_ptr surface_factory_; PlatformViewAndroidDelegate platform_view_android_delegate_; diff --git a/shell/platform/android/surface/android_surface.h b/shell/platform/android/surface/android_surface.h index 98c4f629414ae..1fd4847fae27b 100644 --- a/shell/platform/android/surface/android_surface.h +++ b/shell/platform/android/surface/android_surface.h @@ -5,6 +5,7 @@ #ifndef FLUTTER_SHELL_PLATFORM_ANDROID_ANDROID_SURFACE_H_ #define FLUTTER_SHELL_PLATFORM_ANDROID_ANDROID_SURFACE_H_ +#include "flutter/flow/embedded_views.h" #include "flutter/flow/surface.h" #include "flutter/fml/macros.h" #include "flutter/shell/platform/android/context/android_context.h" @@ -14,12 +15,10 @@ namespace flutter { +class AndroidExternalViewEmbedder; + class AndroidSurface { public: - using Factory = std::function( - std::shared_ptr android_context, - std::shared_ptr jni_facade)>; - virtual ~AndroidSurface(); virtual bool IsValid() const = 0; @@ -38,6 +37,15 @@ class AndroidSurface { virtual bool SetNativeWindow(fml::RefPtr window) = 0; }; +class AndroidSurfaceFactory { + public: + AndroidSurfaceFactory() = default; + + virtual ~AndroidSurfaceFactory() = default; + + virtual std::unique_ptr CreateSurface() = 0; +}; + } // namespace flutter #endif // FLUTTER_SHELL_PLATFORM_ANDROID_ANDROID_SURFACE_H_