From 2caa55eb6a02f84f1d22b3a3feed638bdc2e97d7 Mon Sep 17 00:00:00 2001 From: Chinmay Garde Date: Tue, 30 Jul 2024 11:07:45 -0700 Subject: [PATCH] Rename //flutter/shell/gpu to //flutter/shell/surface. This component only contains surface subclasses of the abstract surface in flow. It used to be more related to other GPU related configuration but that is now no longer the case. No change in functionality. Just renames internal TUs. Attempts to reland https://github.com/flutter/engine/pull/54195 --- BUILD.gn | 2 +- shell/common/BUILD.gn | 8 +-- shell/common/shell_test_platform_view_gl.cc | 18 ++--- shell/common/shell_test_platform_view_gl.h | 14 ++-- shell/common/shell_test_platform_view_metal.h | 12 ++-- .../common/shell_test_platform_view_metal.mm | 20 +++--- .../common/shell_test_platform_view_vulkan.h | 2 +- shell/platform/android/BUILD.gn | 6 +- .../android/android_surface_gl_impeller.cc | 18 ++--- .../android/android_surface_gl_impeller.h | 18 ++--- .../android/android_surface_gl_skia.cc | 15 ++-- .../android/android_surface_gl_skia.h | 18 ++--- .../android/android_surface_software.cc | 2 +- .../android/android_surface_software.h | 8 +-- .../android/android_surface_vk_impeller.cc | 8 +-- .../android/android_surface_vk_impeller.h | 4 +- .../android/external_view_embedder/BUILD.gn | 2 +- .../platform/android/platform_view_android.cc | 4 +- shell/platform/android/surface/BUILD.gn | 2 +- .../android/surface/android_surface_mock.h | 12 ++-- shell/platform/darwin/ios/BUILD.gn | 12 ++-- .../darwin/ios/ios_surface_metal_impeller.h | 17 +++-- .../darwin/ios/ios_surface_metal_impeller.mm | 18 ++--- .../darwin/ios/ios_surface_metal_skia.h | 14 ++-- .../darwin/ios/ios_surface_metal_skia.mm | 20 +++--- .../darwin/ios/ios_surface_software.h | 8 +-- .../darwin/ios/ios_surface_software.mm | 2 +- shell/platform/darwin/macos/BUILD.gn | 6 +- shell/platform/embedder/BUILD.gn | 20 +++--- shell/platform/embedder/embedder.cc | 4 +- .../embedder/embedder_surface_gl_impeller.cc | 20 +++--- .../embedder/embedder_surface_gl_impeller.h | 20 +++--- .../embedder/embedder_surface_gl_skia.cc | 21 +++--- .../embedder/embedder_surface_gl_skia.h | 20 +++--- .../embedder_surface_metal_impeller.h | 14 ++-- .../embedder_surface_metal_impeller.mm | 8 +-- .../embedder/embedder_surface_metal_skia.h | 14 ++-- .../embedder/embedder_surface_metal_skia.mm | 6 +- .../embedder/embedder_surface_software.cc | 6 +- .../embedder/embedder_surface_software.h | 8 +-- .../embedder/embedder_surface_vulkan.cc | 14 ++-- .../embedder/embedder_surface_vulkan.h | 12 ++-- shell/platform/fuchsia/flutter/BUILD.gn | 6 +- shell/{gpu => surface}/BUILD.gn | 70 +++++++++---------- shell/surface/README.md | 3 + shell/{gpu/gpu.gni => surface/surface.gni} | 10 +-- .../surface_gl_delegate.cc} | 26 ++++--- .../surface_gl_delegate.h} | 10 +-- .../surface_gl_impeller.cc} | 30 ++++---- .../surface_gl_impeller.h} | 24 +++---- .../surface_gl_skia.cc} | 45 ++++++------ .../surface_gl_skia.h} | 28 ++++---- .../surface_metal_delegate.cc} | 10 +-- .../surface_metal_delegate.h} | 18 ++--- .../surface_metal_impeller.h} | 23 +++--- .../surface_metal_impeller.mm} | 34 ++++----- .../surface_metal_impeller_unittests.mm} | 46 ++++++------ .../surface_metal_skia.h} | 22 +++--- .../surface_metal_skia.mm} | 30 ++++---- .../surface_software.cc} | 16 ++--- .../surface_software.h} | 21 +++--- .../surface_software_delegate.cc} | 4 +- .../surface_software_delegate.h} | 10 +-- .../surface_vulkan.cc} | 24 +++---- .../surface_vulkan.h} | 31 ++++---- .../surface_vulkan_delegate.cc} | 4 +- .../surface_vulkan_delegate.h} | 10 +-- .../surface_vulkan_impeller.cc} | 22 +++--- .../surface_vulkan_impeller.h} | 16 ++--- shell/testing/BUILD.gn | 8 +-- shell/testing/tester_main.cc | 23 +++--- 71 files changed, 548 insertions(+), 553 deletions(-) rename shell/{gpu => surface}/BUILD.gn (52%) create mode 100644 shell/surface/README.md rename shell/{gpu/gpu.gni => surface/surface.gni} (80%) rename shell/{gpu/gpu_surface_gl_delegate.cc => surface/surface_gl_delegate.cc} (80%) rename shell/{gpu/gpu_surface_gl_delegate.h => surface/surface_gl_delegate.h} (94%) rename shell/{gpu/gpu_surface_gl_impeller.cc => surface/surface_gl_impeller.cc} (85%) rename shell/{gpu/gpu_surface_gl_impeller.h => surface/surface_gl_impeller.h} (65%) rename shell/{gpu/gpu_surface_gl_skia.cc => surface/surface_gl_skia.cc} (88%) rename shell/{gpu/gpu_surface_gl_skia.h => surface/surface_gl_skia.h} (74%) rename shell/{gpu/gpu_surface_metal_delegate.cc => surface/surface_metal_delegate.cc} (53%) rename shell/{gpu/gpu_surface_metal_delegate.h => surface/surface_metal_delegate.h} (88%) rename shell/{gpu/gpu_surface_metal_impeller.h => surface/surface_metal_impeller.h} (76%) rename shell/{gpu/gpu_surface_metal_impeller.mm => surface/surface_metal_impeller.mm} (92%) rename shell/{gpu/gpu_surface_metal_impeller_unittests.mm => surface/surface_metal_impeller_unittests.mm} (71%) rename shell/{gpu/gpu_surface_metal_skia.h => surface/surface_metal_skia.h} (74%) rename shell/{gpu/gpu_surface_metal_skia.mm => surface/surface_metal_skia.mm} (90%) rename shell/{gpu/gpu_surface_software.cc => surface/surface_software.cc} (84%) rename shell/{gpu/gpu_surface_software.h => surface/surface_software.h} (61%) rename shell/{gpu/gpu_surface_vulkan_delegate.cc => surface/surface_software_delegate.cc} (63%) rename shell/{gpu/gpu_surface_software_delegate.h => surface/surface_software_delegate.h} (89%) rename shell/{gpu/gpu_surface_vulkan.cc => surface/surface_vulkan.cc} (85%) rename shell/{gpu/gpu_surface_vulkan.h => surface/surface_vulkan.h} (65%) rename shell/{gpu/gpu_surface_software_delegate.cc => surface/surface_vulkan_delegate.cc} (61%) rename shell/{gpu/gpu_surface_vulkan_delegate.h => surface/surface_vulkan_delegate.h} (87%) rename shell/{gpu/gpu_surface_vulkan_impeller.cc => surface/surface_vulkan_impeller.cc} (87%) rename shell/{gpu/gpu_surface_vulkan_impeller.h => surface/surface_vulkan_impeller.h} (71%) diff --git a/BUILD.gn b/BUILD.gn index ac8d81872d19a..147701784501c 100644 --- a/BUILD.gn +++ b/BUILD.gn @@ -216,9 +216,9 @@ group("unittests") { if (is_mac) { public_deps += [ "//flutter/impeller/golden_tests:impeller_golden_tests", - "//flutter/shell/gpu:gpu_surface_metal_unittests", "//flutter/shell/platform/darwin/common:availability_version_check_unittests", "//flutter/shell/platform/darwin/common:framework_common_unittests", + "//flutter/shell/surface:metal_unittests", "//flutter/third_party/spring_animation:spring_animation_unittests", ] } diff --git a/shell/common/BUILD.gn b/shell/common/BUILD.gn index 8e2d9f2174b3a..078939a6481df 100644 --- a/shell/common/BUILD.gn +++ b/shell/common/BUILD.gn @@ -4,7 +4,7 @@ import("//flutter/common/config.gni") import("//flutter/impeller/tools/impeller.gni") -import("//flutter/shell/gpu/gpu.gni") +import("//flutter/shell/surface/surface.gni") import("//flutter/testing/testing.gni") if (is_fuchsia) { @@ -192,7 +192,7 @@ template("shell_host_executable") { } if (enable_unittests) { - shell_gpu_configuration("shell_unittests_gpu_configuration") { + surface_configuration("shell_unittests_surface_configuration") { enable_software = test_enable_software enable_vulkan = test_enable_vulkan enable_gl = test_enable_gl @@ -255,7 +255,7 @@ if (enable_unittests) { ] deps = [ - ":shell_unittests_gpu_configuration", + ":shell_unittests_surface_configuration", "//flutter/assets", "//flutter/common", "//flutter/lib/ui", @@ -271,7 +271,7 @@ if (enable_unittests) { public_configs = [ ":shell_test_fixture_sources_config", - ":shell_unittests_gpu_configuration_config", + ":shell_unittests_surface_configuration_config", ] if (test_enable_gl) { diff --git a/shell/common/shell_test_platform_view_gl.cc b/shell/common/shell_test_platform_view_gl.cc index 3a52772d0a0f7..0027257e63da7 100644 --- a/shell/common/shell_test_platform_view_gl.cc +++ b/shell/common/shell_test_platform_view_gl.cc @@ -8,7 +8,7 @@ #include -#include "flutter/shell/gpu/gpu_surface_gl_skia.h" +#include "flutter/shell/surface/surface_gl_skia.h" #include "impeller/entity/gles/entity_shaders_gles.h" #if IMPELLER_ENABLE_3D @@ -73,7 +73,7 @@ void ShellTestPlatformViewGL::SimulateVSync() { // |PlatformView| std::unique_ptr ShellTestPlatformViewGL::CreateRenderingSurface() { - return std::make_unique(this, true); + return std::make_unique(this, true); } // |PlatformView| @@ -89,33 +89,33 @@ PointerDataDispatcherMaker ShellTestPlatformViewGL::GetDispatcherMaker() { }; } -// |GPUSurfaceGLDelegate| +// |SurfaceGLDelegate| std::unique_ptr ShellTestPlatformViewGL::GLContextMakeCurrent() { return std::make_unique(gl_surface_.MakeCurrent()); } -// |GPUSurfaceGLDelegate| +// |SurfaceGLDelegate| bool ShellTestPlatformViewGL::GLContextClearCurrent() { return gl_surface_.ClearCurrent(); } -// |GPUSurfaceGLDelegate| +// |SurfaceGLDelegate| bool ShellTestPlatformViewGL::GLContextPresent( const GLPresentInfo& present_info) { return gl_surface_.Present(); } -// |GPUSurfaceGLDelegate| +// |SurfaceGLDelegate| GLFBOInfo ShellTestPlatformViewGL::GLContextFBO(GLFrameInfo frame_info) const { return GLFBOInfo{ .fbo_id = gl_surface_.GetFramebuffer(frame_info.width, frame_info.height), }; } -// |GPUSurfaceGLDelegate| -GPUSurfaceGLDelegate::GLProcResolver -ShellTestPlatformViewGL::GetGLProcResolver() const { +// |SurfaceGLDelegate| +SurfaceGLDelegate::GLProcResolver ShellTestPlatformViewGL::GetGLProcResolver() + const { return [surface = &gl_surface_](const char* name) -> void* { return surface->GetProcAddress(name); }; diff --git a/shell/common/shell_test_platform_view_gl.h b/shell/common/shell_test_platform_view_gl.h index 12aa92d7f9674..2510e76a93084 100644 --- a/shell/common/shell_test_platform_view_gl.h +++ b/shell/common/shell_test_platform_view_gl.h @@ -7,7 +7,7 @@ #include "flutter/shell/common/shell_test_external_view_embedder.h" #include "flutter/shell/common/shell_test_platform_view.h" -#include "flutter/shell/gpu/gpu_surface_gl_delegate.h" +#include "flutter/shell/surface/surface_gl_delegate.h" #include "flutter/testing/test_gl_surface.h" #include "impeller/renderer/backend/gles/context_gles.h" @@ -15,7 +15,7 @@ namespace flutter { namespace testing { class ShellTestPlatformViewGL : public ShellTestPlatformView, - public GPUSurfaceGLDelegate { + public SurfaceGLDelegate { public: ShellTestPlatformViewGL(PlatformView::Delegate& delegate, const TaskRunners& task_runners, @@ -59,19 +59,19 @@ class ShellTestPlatformViewGL : public ShellTestPlatformView, // |PlatformView| PointerDataDispatcherMaker GetDispatcherMaker() override; - // |GPUSurfaceGLDelegate| + // |SurfaceGLDelegate| std::unique_ptr GLContextMakeCurrent() override; - // |GPUSurfaceGLDelegate| + // |SurfaceGLDelegate| bool GLContextClearCurrent() override; - // |GPUSurfaceGLDelegate| + // |SurfaceGLDelegate| bool GLContextPresent(const GLPresentInfo& present_info) override; - // |GPUSurfaceGLDelegate| + // |SurfaceGLDelegate| GLFBOInfo GLContextFBO(GLFrameInfo frame_info) const override; - // |GPUSurfaceGLDelegate| + // |SurfaceGLDelegate| GLProcResolver GetGLProcResolver() const override; FML_DISALLOW_COPY_AND_ASSIGN(ShellTestPlatformViewGL); diff --git a/shell/common/shell_test_platform_view_metal.h b/shell/common/shell_test_platform_view_metal.h index c5c0a8d454d04..4e0e4034c0fb0 100644 --- a/shell/common/shell_test_platform_view_metal.h +++ b/shell/common/shell_test_platform_view_metal.h @@ -7,7 +7,7 @@ #include "flutter/fml/macros.h" #include "flutter/shell/common/shell_test_platform_view.h" -#include "flutter/shell/gpu/gpu_surface_metal_delegate.h" +#include "flutter/shell/surface/surface_metal_delegate.h" namespace flutter { namespace testing { @@ -15,7 +15,7 @@ namespace testing { class DarwinContextMetal; class ShellTestPlatformViewMetal final : public ShellTestPlatformView, - public GPUSurfaceMetalDelegate { + public SurfaceMetalDelegate { public: ShellTestPlatformViewMetal(PlatformView::Delegate& delegate, const TaskRunners& task_runners, @@ -54,17 +54,17 @@ class ShellTestPlatformViewMetal final : public ShellTestPlatformView, // |PlatformView| std::shared_ptr GetImpellerContext() const override; - // |GPUSurfaceMetalDelegate| + // |SurfaceMetalDelegate| GPUCAMetalLayerHandle GetCAMetalLayer( const SkISize& frame_info) const override; - // |GPUSurfaceMetalDelegate| + // |SurfaceMetalDelegate| bool PresentDrawable(GrMTLHandle drawable) const override; - // |GPUSurfaceMetalDelegate| + // |SurfaceMetalDelegate| GPUMTLTextureInfo GetMTLTexture(const SkISize& frame_info) const override; - // |GPUSurfaceMetalDelegate| + // |SurfaceMetalDelegate| bool PresentTexture(GPUMTLTextureInfo texture) const override; FML_DISALLOW_COPY_AND_ASSIGN(ShellTestPlatformViewMetal); diff --git a/shell/common/shell_test_platform_view_metal.mm b/shell/common/shell_test_platform_view_metal.mm index 41322490f8252..ad8c3e2137f39 100644 --- a/shell/common/shell_test_platform_view_metal.mm +++ b/shell/common/shell_test_platform_view_metal.mm @@ -9,10 +9,10 @@ #include #include "flutter/fml/platform/darwin/scoped_nsobject.h" -#include "flutter/shell/gpu/gpu_surface_metal_impeller.h" -#include "flutter/shell/gpu/gpu_surface_metal_skia.h" #include "flutter/shell/platform/darwin/graphics/FlutterDarwinContextMetalImpeller.h" #include "flutter/shell/platform/darwin/graphics/FlutterDarwinContextMetalSkia.h" +#include "flutter/shell/surface/surface_metal_impeller.h" +#include "flutter/shell/surface/surface_metal_skia.h" namespace flutter { namespace testing { @@ -74,7 +74,7 @@ GPUMTLTextureInfo offscreen_texture_info() const { std::shared_ptr shell_test_external_view_embedder, const std::shared_ptr& is_gpu_disabled_sync_switch) : ShellTestPlatformView(delegate, task_runners), - GPUSurfaceMetalDelegate(MTLRenderTargetType::kMTLTexture), + SurfaceMetalDelegate(MTLRenderTargetType::kMTLTexture), metal_context_(std::make_unique(GetSettings().enable_impeller, is_gpu_disabled_sync_switch)), create_vsync_waiter_(std::move(create_vsync_waiter)), @@ -113,10 +113,10 @@ GPUMTLTextureInfo offscreen_texture_info() const { // |PlatformView| std::unique_ptr ShellTestPlatformViewMetal::CreateRenderingSurface() { if (GetSettings().enable_impeller) { - return std::make_unique(this, - [metal_context_->impeller_context() context]); + return std::make_unique(this, + [metal_context_->impeller_context() context]); } - return std::make_unique(this, [metal_context_->context() mainContext]); + return std::make_unique(this, [metal_context_->context() mainContext]); } // |PlatformView| @@ -124,26 +124,26 @@ GPUMTLTextureInfo offscreen_texture_info() const { return [metal_context_->impeller_context() context]; } -// |GPUSurfaceMetalDelegate| +// |SurfaceMetalDelegate| GPUCAMetalLayerHandle ShellTestPlatformViewMetal::GetCAMetalLayer(const SkISize& frame_info) const { FML_CHECK(false) << "A Metal Delegate configured with MTLRenderTargetType::kMTLTexture was asked " "to acquire a layer."; return nullptr; } -// |GPUSurfaceMetalDelegate| +// |SurfaceMetalDelegate| bool ShellTestPlatformViewMetal::PresentDrawable(GrMTLHandle drawable) const { FML_CHECK(false) << "A Metal Delegate configured with MTLRenderTargetType::kMTLTexture was asked " "to present a layer drawable."; return true; } -// |GPUSurfaceMetalDelegate| +// |SurfaceMetalDelegate| GPUMTLTextureInfo ShellTestPlatformViewMetal::GetMTLTexture(const SkISize& frame_info) const { return metal_context_->offscreen_texture_info(); } -// |GPUSurfaceMetalDelegate| +// |SurfaceMetalDelegate| bool ShellTestPlatformViewMetal::PresentTexture(GPUMTLTextureInfo texture) const { // The texture resides offscreen. There is nothing to render to. return true; diff --git a/shell/common/shell_test_platform_view_vulkan.h b/shell/common/shell_test_platform_view_vulkan.h index 7ee3f3ed0420d..7e4314973d00e 100644 --- a/shell/common/shell_test_platform_view_vulkan.h +++ b/shell/common/shell_test_platform_view_vulkan.h @@ -7,7 +7,7 @@ #include "flutter/shell/common/shell_test_external_view_embedder.h" #include "flutter/shell/common/shell_test_platform_view.h" -#include "flutter/shell/gpu/gpu_surface_vulkan_delegate.h" +#include "flutter/shell/surface/surface_vulkan_delegate.h" #include "flutter/vulkan/vulkan_application.h" #include "flutter/vulkan/vulkan_device.h" #include "flutter/vulkan/vulkan_skia_proc_table.h" diff --git a/shell/platform/android/BUILD.gn b/shell/platform/android/BUILD.gn index 433af900f8cbf..045ea0d681e77 100644 --- a/shell/platform/android/BUILD.gn +++ b/shell/platform/android/BUILD.gn @@ -9,11 +9,11 @@ import("//flutter/build/zip_bundle.gni") import("//flutter/common/config.gni") import("//flutter/impeller/tools/impeller.gni") import("//flutter/shell/config.gni") -import("//flutter/shell/gpu/gpu.gni") +import("//flutter/shell/surface/surface.gni") import("//flutter/shell/version/version.gni") import("//flutter/vulkan/config.gni") -shell_gpu_configuration("android_gpu_configuration") { +surface_configuration("android_surface_configuration") { enable_software = true enable_gl = true enable_vulkan = true @@ -142,7 +142,7 @@ source_set("flutter_shell_native_src") { sources += get_target_outputs(":icudtl_asm") public_deps = [ - ":android_gpu_configuration", + ":android_surface_configuration", ":icudtl_asm", ":image_generator", "//flutter/assets", diff --git a/shell/platform/android/android_surface_gl_impeller.cc b/shell/platform/android/android_surface_gl_impeller.cc index b2d0b69d9a9cf..a4bbddcfc4197 100644 --- a/shell/platform/android/android_surface_gl_impeller.cc +++ b/shell/platform/android/android_surface_gl_impeller.cc @@ -6,7 +6,7 @@ #include "flutter/fml/logging.h" #include "flutter/impeller/toolkit/egl/surface.h" -#include "flutter/shell/gpu/gpu_surface_gl_impeller.h" +#include "flutter/shell/surface/surface_gl_impeller.h" namespace flutter { @@ -35,7 +35,7 @@ bool AndroidSurfaceGLImpeller::IsValid() const { // |AndroidSurface| std::unique_ptr AndroidSurfaceGLImpeller::CreateGPUSurface( GrDirectContext* gr_context) { - auto surface = std::make_unique( + auto surface = std::make_unique( this, // delegate android_context_->GetImpellerContext(), // context true // render to surface @@ -90,7 +90,7 @@ AndroidSurfaceGLImpeller::GetImpellerContext() { return android_context_->GetImpellerContext(); } -// |GPUSurfaceGLDelegate| +// |SurfaceGLDelegate| std::unique_ptr AndroidSurfaceGLImpeller::GLContextMakeCurrent() { return std::make_unique(OnGLContextMakeCurrent()); @@ -104,7 +104,7 @@ bool AndroidSurfaceGLImpeller::OnGLContextMakeCurrent() { return android_context_->OnscreenContextMakeCurrent(onscreen_surface_.get()); } -// |GPUSurfaceGLDelegate| +// |SurfaceGLDelegate| bool AndroidSurfaceGLImpeller::GLContextClearCurrent() { if (!onscreen_surface_) { return false; @@ -113,7 +113,7 @@ bool AndroidSurfaceGLImpeller::GLContextClearCurrent() { return android_context_->OnscreenContextClearCurrent(); } -// |GPUSurfaceGLDelegate| +// |SurfaceGLDelegate| SurfaceFrame::FramebufferInfo AndroidSurfaceGLImpeller::GLContextFramebufferInfo() const { auto info = SurfaceFrame::FramebufferInfo{}; @@ -122,13 +122,13 @@ AndroidSurfaceGLImpeller::GLContextFramebufferInfo() const { return info; } -// |GPUSurfaceGLDelegate| +// |SurfaceGLDelegate| void AndroidSurfaceGLImpeller::GLContextSetDamageRegion( const std::optional& region) { // Not supported. } -// |GPUSurfaceGLDelegate| +// |SurfaceGLDelegate| bool AndroidSurfaceGLImpeller::GLContextPresent( const GLPresentInfo& present_info) { // The FBO ID is superfluous and was introduced for iOS where the default @@ -139,7 +139,7 @@ bool AndroidSurfaceGLImpeller::GLContextPresent( return onscreen_surface_->Present(); } -// |GPUSurfaceGLDelegate| +// |SurfaceGLDelegate| GLFBOInfo AndroidSurfaceGLImpeller::GLContextFBO(GLFrameInfo frame_info) const { // FBO0 is the default window bound framebuffer in EGL environments. return GLFBOInfo{ @@ -147,7 +147,7 @@ GLFBOInfo AndroidSurfaceGLImpeller::GLContextFBO(GLFrameInfo frame_info) const { }; } -// |GPUSurfaceGLDelegate| +// |SurfaceGLDelegate| sk_sp AndroidSurfaceGLImpeller::GetGLInterface() const { return nullptr; } diff --git a/shell/platform/android/android_surface_gl_impeller.h b/shell/platform/android/android_surface_gl_impeller.h index 3066a8552ee25..4001733cec9cc 100644 --- a/shell/platform/android/android_surface_gl_impeller.h +++ b/shell/platform/android/android_surface_gl_impeller.h @@ -7,14 +7,14 @@ #include "flutter/fml/macros.h" #include "flutter/impeller/renderer/context.h" -#include "flutter/shell/gpu/gpu_surface_gl_delegate.h" #include "flutter/shell/platform/android/android_context_gl_impeller.h" #include "flutter/shell/platform/android/surface/android_native_window.h" #include "flutter/shell/platform/android/surface/android_surface.h" +#include "flutter/shell/surface/surface_gl_delegate.h" namespace flutter { -class AndroidSurfaceGLImpeller final : public GPUSurfaceGLDelegate, +class AndroidSurfaceGLImpeller final : public SurfaceGLDelegate, public AndroidSurface { public: explicit AndroidSurfaceGLImpeller( @@ -51,25 +51,25 @@ class AndroidSurfaceGLImpeller final : public GPUSurfaceGLDelegate, // |AndroidSurface| std::shared_ptr GetImpellerContext() override; - // |GPUSurfaceGLDelegate| + // |SurfaceGLDelegate| std::unique_ptr GLContextMakeCurrent() override; - // |GPUSurfaceGLDelegate| + // |SurfaceGLDelegate| bool GLContextClearCurrent() override; - // |GPUSurfaceGLDelegate| + // |SurfaceGLDelegate| SurfaceFrame::FramebufferInfo GLContextFramebufferInfo() const override; - // |GPUSurfaceGLDelegate| + // |SurfaceGLDelegate| void GLContextSetDamageRegion(const std::optional& region) override; - // |GPUSurfaceGLDelegate| + // |SurfaceGLDelegate| bool GLContextPresent(const GLPresentInfo& present_info) override; - // |GPUSurfaceGLDelegate| + // |SurfaceGLDelegate| GLFBOInfo GLContextFBO(GLFrameInfo frame_info) const override; - // |GPUSurfaceGLDelegate| + // |SurfaceGLDelegate| sk_sp GetGLInterface() const override; private: diff --git a/shell/platform/android/android_surface_gl_skia.cc b/shell/platform/android/android_surface_gl_skia.cc index 6a5dda8a06082..0d4ef7b732231 100644 --- a/shell/platform/android/android_surface_gl_skia.cc +++ b/shell/platform/android/android_surface_gl_skia.cc @@ -50,16 +50,15 @@ bool AndroidSurfaceGLSkia::IsValid() const { std::unique_ptr AndroidSurfaceGLSkia::CreateGPUSurface( GrDirectContext* gr_context) { if (gr_context) { - return std::make_unique(sk_ref_sp(gr_context), this, - true); + return std::make_unique(sk_ref_sp(gr_context), this, true); } else { sk_sp main_skia_context = android_context_->GetMainSkiaContext(); if (!main_skia_context) { - main_skia_context = GPUSurfaceGLSkia::MakeGLContext(this); + main_skia_context = SurfaceGLSkia::MakeGLContext(this); android_context_->SetMainSkiaContext(main_skia_context); } - return std::make_unique(main_skia_context, this, true); + return std::make_unique(main_skia_context, this, true); } } @@ -170,7 +169,7 @@ GLFBOInfo AndroidSurfaceGLSkia::GLContextFBO(GLFrameInfo frame_info) const { }; } -// |GPUSurfaceGLDelegate| +// |SurfaceGLDelegate| sk_sp AndroidSurfaceGLSkia::GetGLInterface() const { // This is a workaround for a bug in the Android emulator EGL/GLES // implementation. Some versions of the emulator will not update the @@ -200,7 +199,7 @@ sk_sp AndroidSurfaceGLSkia::GetGLInterface() const { } } - return GPUSurfaceGLDelegate::GetGLInterface(); + return SurfaceGLDelegate::GetGLInterface(); } std::unique_ptr AndroidSurfaceGLSkia::CreateSnapshotSurface() { @@ -210,11 +209,11 @@ std::unique_ptr AndroidSurfaceGLSkia::CreateSnapshotSurface() { sk_sp main_skia_context = android_context_->GetMainSkiaContext(); if (!main_skia_context) { - main_skia_context = GPUSurfaceGLSkia::MakeGLContext(this); + main_skia_context = SurfaceGLSkia::MakeGLContext(this); android_context_->SetMainSkiaContext(main_skia_context); } - return std::make_unique(main_skia_context, this, true); + return std::make_unique(main_skia_context, this, true); } } // namespace flutter diff --git a/shell/platform/android/android_surface_gl_skia.h b/shell/platform/android/android_surface_gl_skia.h index 1c35692dc3a0e..fb53253e954c7 100644 --- a/shell/platform/android/android_surface_gl_skia.h +++ b/shell/platform/android/android_surface_gl_skia.h @@ -10,15 +10,15 @@ #include #include "flutter/fml/macros.h" -#include "flutter/shell/gpu/gpu_surface_gl_skia.h" #include "flutter/shell/platform/android/android_context_gl_skia.h" #include "flutter/shell/platform/android/android_environment_gl.h" #include "flutter/shell/platform/android/jni/platform_view_android_jni.h" #include "flutter/shell/platform/android/surface/android_surface.h" +#include "flutter/shell/surface/surface_gl_skia.h" namespace flutter { -class AndroidSurfaceGLSkia final : public GPUSurfaceGLDelegate, +class AndroidSurfaceGLSkia final : public SurfaceGLDelegate, public AndroidSurface { public: explicit AndroidSurfaceGLSkia( @@ -51,25 +51,25 @@ class AndroidSurfaceGLSkia final : public GPUSurfaceGLDelegate, // |AndroidSurface| virtual std::unique_ptr CreateSnapshotSurface() override; - // |GPUSurfaceGLDelegate| + // |SurfaceGLDelegate| std::unique_ptr GLContextMakeCurrent() override; - // |GPUSurfaceGLDelegate| + // |SurfaceGLDelegate| bool GLContextClearCurrent() override; - // |GPUSurfaceGLDelegate| + // |SurfaceGLDelegate| SurfaceFrame::FramebufferInfo GLContextFramebufferInfo() const override; - // |GPUSurfaceGLDelegate| + // |SurfaceGLDelegate| void GLContextSetDamageRegion(const std::optional& region) override; - // |GPUSurfaceGLDelegate| + // |SurfaceGLDelegate| bool GLContextPresent(const GLPresentInfo& present_info) override; - // |GPUSurfaceGLDelegate| + // |SurfaceGLDelegate| GLFBOInfo GLContextFBO(GLFrameInfo frame_info) const override; - // |GPUSurfaceGLDelegate| + // |SurfaceGLDelegate| sk_sp GetGLInterface() const override; // Obtain a raw pointer to the on-screen AndroidEGLSurface. diff --git a/shell/platform/android/android_surface_software.cc b/shell/platform/android/android_surface_software.cc index db5881c684b88..778a197358ea1 100644 --- a/shell/platform/android/android_surface_software.cc +++ b/shell/platform/android/android_surface_software.cc @@ -69,7 +69,7 @@ std::unique_ptr AndroidSurfaceSoftware::CreateGPUSurface( } auto surface = - std::make_unique(this, true /* render to surface */); + std::make_unique(this, true /* render to surface */); if (!surface->IsValid()) { return nullptr; diff --git a/shell/platform/android/android_surface_software.h b/shell/platform/android/android_surface_software.h index 1b7083aa7dda1..650bf7d2857df 100644 --- a/shell/platform/android/android_surface_software.h +++ b/shell/platform/android/android_surface_software.h @@ -8,16 +8,16 @@ #include "flutter/fml/macros.h" #include "flutter/fml/platform/android/jni_weak_ref.h" #include "flutter/fml/platform/android/scoped_java_ref.h" -#include "flutter/shell/gpu/gpu_surface_software.h" #include "flutter/shell/platform/android/jni/platform_view_android_jni.h" #include "flutter/shell/platform/android/surface/android_surface.h" +#include "flutter/shell/surface/surface_software.h" #include "third_party/skia/include/core/SkSurface.h" namespace flutter { class AndroidSurfaceSoftware final : public AndroidSurface, - public GPUSurfaceSoftwareDelegate { + public SurfaceSoftwareDelegate { public: AndroidSurfaceSoftware(); @@ -45,10 +45,10 @@ class AndroidSurfaceSoftware final : public AndroidSurface, // |AndroidSurface| bool SetNativeWindow(fml::RefPtr window) override; - // |GPUSurfaceSoftwareDelegate| + // |SurfaceSoftwareDelegate| sk_sp AcquireBackingStore(const SkISize& size) override; - // |GPUSurfaceSoftwareDelegate| + // |SurfaceSoftwareDelegate| bool PresentBackingStore(sk_sp backing_store) override; private: diff --git a/shell/platform/android/android_surface_vk_impeller.cc b/shell/platform/android/android_surface_vk_impeller.cc index 8dc12a78ac479..22b5c95444c65 100644 --- a/shell/platform/android/android_surface_vk_impeller.cc +++ b/shell/platform/android/android_surface_vk_impeller.cc @@ -12,7 +12,7 @@ #include "flutter/fml/memory/ref_ptr.h" #include "flutter/impeller/renderer/backend/vulkan/context_vk.h" #include "flutter/impeller/renderer/backend/vulkan/swapchain/swapchain_vk.h" -#include "flutter/shell/gpu/gpu_surface_vulkan_impeller.h" +#include "flutter/shell/surface/surface_vulkan_impeller.h" #include "flutter/vulkan/vulkan_native_surface_android.h" namespace flutter { @@ -25,7 +25,7 @@ AndroidSurfaceVKImpeller::AndroidSurfaceVKImpeller( impeller::ContextVK::Cast(*android_context->GetImpellerContext()); surface_context_vk_ = context_vk.CreateSurfaceContext(); eager_gpu_surface_ = - std::make_unique(surface_context_vk_); + std::make_unique(surface_context_vk_); } AndroidSurfaceVKImpeller::~AndroidSurfaceVKImpeller() = default; @@ -56,8 +56,8 @@ std::unique_ptr AndroidSurfaceVKImpeller::CreateGPUSurface( return gpu_surface; } - std::unique_ptr gpu_surface = - std::make_unique(surface_context_vk_); + std::unique_ptr gpu_surface = + std::make_unique(surface_context_vk_); if (!gpu_surface->IsValid()) { return nullptr; diff --git a/shell/platform/android/android_surface_vk_impeller.h b/shell/platform/android/android_surface_vk_impeller.h index 01dde0844020b..34cfbb29ac8df 100644 --- a/shell/platform/android/android_surface_vk_impeller.h +++ b/shell/platform/android/android_surface_vk_impeller.h @@ -11,7 +11,7 @@ #include "flutter/shell/platform/android/android_context_vk_impeller.h" #include "flutter/shell/platform/android/surface/android_native_window.h" #include "flutter/shell/platform/android/surface/android_surface.h" -#include "shell/gpu/gpu_surface_vulkan_impeller.h" +#include "shell/surface/surface_vulkan_impeller.h" namespace flutter { @@ -53,7 +53,7 @@ class AndroidSurfaceVKImpeller : public AndroidSurface { // The first GPU Surface is initialized as soon as the // AndroidSurfaceVulkanImpeller is created. This ensures that the pipelines // are bootstrapped as early as possible. - std::unique_ptr eager_gpu_surface_; + std::unique_ptr eager_gpu_surface_; bool is_valid_ = false; diff --git a/shell/platform/android/external_view_embedder/BUILD.gn b/shell/platform/android/external_view_embedder/BUILD.gn index 44ae1106df182..620dc2b99d962 100644 --- a/shell/platform/android/external_view_embedder/BUILD.gn +++ b/shell/platform/android/external_view_embedder/BUILD.gn @@ -42,10 +42,10 @@ executable("android_external_view_embedder_unittests") { ":external_view_embedder", ":external_view_embedder_fixtures", "//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/shell/surface:gl", "//flutter/testing", "//flutter/testing:dart", "//flutter/testing:skia", diff --git a/shell/platform/android/platform_view_android.cc b/shell/platform/android/platform_view_android.cc index 926c99928b694..469133454c071 100644 --- a/shell/platform/android/platform_view_android.cc +++ b/shell/platform/android/platform_view_android.cc @@ -11,7 +11,6 @@ #include "flutter/common/graphics/texture.h" #include "flutter/fml/synchronization/waitable_event.h" #include "flutter/shell/common/shell_io_manager.h" -#include "flutter/shell/gpu/gpu_surface_gl_delegate.h" #include "flutter/shell/platform/android/android_context_gl_impeller.h" #include "flutter/shell/platform/android/android_context_gl_skia.h" #include "flutter/shell/platform/android/android_context_vk_impeller.h" @@ -23,6 +22,7 @@ #include "flutter/shell/platform/android/surface_texture_external_texture_gl_impeller.h" #include "flutter/shell/platform/android/surface_texture_external_texture_gl_skia.h" #include "flutter/shell/platform/android/surface_texture_external_texture_vk_impeller.h" +#include "flutter/shell/surface/surface_gl_delegate.h" #include "fml/logging.h" #if IMPELLER_ENABLE_VULKAN // b/258506856 for why this is behind an if #include "flutter/shell/platform/android/android_surface_vk_impeller.h" @@ -384,7 +384,7 @@ sk_sp PlatformViewAndroid::CreateResourceContext() const { // this changes, this assumption breaks. Handle the same. resource_context = ShellIOManager::CreateCompatibleResourceLoadingContext( GrBackendApi::kOpenGL, - GPUSurfaceGLDelegate::GetDefaultPlatformGLInterface()); + SurfaceGLDelegate::GetDefaultPlatformGLInterface()); } else { FML_DLOG(ERROR) << "Could not make the resource context current."; } diff --git a/shell/platform/android/surface/BUILD.gn b/shell/platform/android/surface/BUILD.gn index ecc46d1145f6e..78d7d810bbaa7 100644 --- a/shell/platform/android/surface/BUILD.gn +++ b/shell/platform/android/surface/BUILD.gn @@ -52,7 +52,7 @@ source_set("surface_mock") { deps = [ ":surface", "//flutter/flow", - "//flutter/shell/gpu:gpu_surface_gl", + "//flutter/shell/surface:gl", "//flutter/third_party/googletest:gmock", "//flutter/third_party/googletest:gtest", ] diff --git a/shell/platform/android/surface/android_surface_mock.h b/shell/platform/android/surface/android_surface_mock.h index 6bb1628e7dd85..12b98160dd7c7 100644 --- a/shell/platform/android/surface/android_surface_mock.h +++ b/shell/platform/android/surface/android_surface_mock.h @@ -5,8 +5,8 @@ #ifndef FLUTTER_SHELL_PLATFORM_ANDROID_SURFACE_ANDROID_SURFACE_MOCK_H_ #define FLUTTER_SHELL_PLATFORM_ANDROID_SURFACE_ANDROID_SURFACE_MOCK_H_ -#include "flutter/shell/gpu/gpu_surface_gl_skia.h" #include "flutter/shell/platform/android/surface/android_surface.h" +#include "flutter/shell/surface/surface_gl_skia.h" #include "gmock/gmock.h" namespace flutter { @@ -15,7 +15,7 @@ namespace flutter { /// Mock for |AndroidSurface|. This implementation can be used in unit /// tests without requiring the Android toolchain. /// -class AndroidSurfaceMock final : public GPUSurfaceGLDelegate, +class AndroidSurfaceMock final : public SurfaceGLDelegate, public AndroidSurface { public: MOCK_METHOD(bool, IsValid, (), (const, override)); @@ -38,16 +38,16 @@ class AndroidSurfaceMock final : public GPUSurfaceGLDelegate, (fml::RefPtr window), (override)); - // |GPUSurfaceGLDelegate| + // |SurfaceGLDelegate| std::unique_ptr GLContextMakeCurrent() override; - // |GPUSurfaceGLDelegate| + // |SurfaceGLDelegate| bool GLContextClearCurrent() override; - // |GPUSurfaceGLDelegate| + // |SurfaceGLDelegate| bool GLContextPresent(const GLPresentInfo& present_info) override; - // |GPUSurfaceGLDelegate| + // |SurfaceGLDelegate| GLFBOInfo GLContextFBO(GLFrameInfo frame_info) const override; }; diff --git a/shell/platform/darwin/ios/BUILD.gn b/shell/platform/darwin/ios/BUILD.gn index f3e3389a3df2f..4c80be5dc365b 100644 --- a/shell/platform/darwin/ios/BUILD.gn +++ b/shell/platform/darwin/ios/BUILD.gn @@ -9,13 +9,13 @@ import("//build/toolchain/clang.gni") import("//build/toolchain/toolchain.gni") import("//flutter/common/config.gni") import("//flutter/shell/config.gni") -import("//flutter/shell/gpu/gpu.gni") import("//flutter/shell/platform/darwin/common/framework_common.gni") +import("//flutter/shell/surface/surface.gni") import("//flutter/testing/testing.gni") _flutter_framework_dir = "$root_out_dir/Flutter.framework" -shell_gpu_configuration("ios_gpu_configuration") { +surface_configuration("ios_surface_configuration") { enable_software = true enable_gl = false enable_vulkan = false @@ -148,7 +148,7 @@ source_set("flutter_framework_source_arc") { ] deps += [ - ":ios_gpu_configuration", + ":ios_surface_configuration", "//flutter/common:common", "//flutter/common/graphics", "//flutter/lib/ui", @@ -206,7 +206,7 @@ source_set("flutter_framework_source") { ] public_configs = [ - ":ios_gpu_configuration_config", + ":ios_surface_configuration_config", "//flutter:config", ] @@ -287,7 +287,7 @@ shared_library("ios_test_flutter") { ":flutter_framework", ":flutter_framework_source", ":flutter_framework_source_arc", - ":ios_gpu_configuration", + ":ios_surface_configuration", "//flutter/common:common", "//flutter/lib/ui:ui", "//flutter/shell/platform/darwin/common:framework_common", @@ -301,7 +301,7 @@ shared_library("ios_test_flutter") { "//flutter/third_party/txt", ] public_configs = [ - ":ios_gpu_configuration_config", + ":ios_surface_configuration_config", "//flutter:config", ] diff --git a/shell/platform/darwin/ios/ios_surface_metal_impeller.h b/shell/platform/darwin/ios/ios_surface_metal_impeller.h index 888f3935355e3..d00391badcf7e 100644 --- a/shell/platform/darwin/ios/ios_surface_metal_impeller.h +++ b/shell/platform/darwin/ios/ios_surface_metal_impeller.h @@ -6,8 +6,8 @@ #define FLUTTER_SHELL_PLATFORM_DARWIN_IOS_IOS_SURFACE_METAL_IMPELLER_H_ #include "flutter/fml/macros.h" -#include "flutter/shell/gpu/gpu_surface_metal_delegate.h" #include "flutter/shell/platform/darwin/ios/ios_surface.h" +#include "flutter/shell/surface/surface_metal_delegate.h" @class CAMetalLayer; @@ -17,9 +17,8 @@ class Context; namespace flutter { -class SK_API_AVAILABLE_CA_METAL_LAYER IOSSurfaceMetalImpeller final - : public IOSSurface, - public GPUSurfaceMetalDelegate { +class SK_API_AVAILABLE_CA_METAL_LAYER IOSSurfaceMetalImpeller final : public IOSSurface, + public SurfaceMetalDelegate { public: IOSSurfaceMetalImpeller(const fml::scoped_nsobject& layer, const std::shared_ptr& context); @@ -41,22 +40,22 @@ class SK_API_AVAILABLE_CA_METAL_LAYER IOSSurfaceMetalImpeller final // |IOSSurface| std::unique_ptr CreateGPUSurface(GrDirectContext* gr_context) override; - // |GPUSurfaceMetalDelegate| + // |SurfaceMetalDelegate| GPUCAMetalLayerHandle GetCAMetalLayer(const SkISize& frame_info) const override __attribute__((cf_audited_transfer)); - // |GPUSurfaceMetalDelegate| + // |SurfaceMetalDelegate| bool PresentDrawable(GrMTLHandle drawable) const override __attribute__((cf_audited_transfer)); - // |GPUSurfaceMetalDelegate| + // |SurfaceMetalDelegate| GPUMTLTextureInfo GetMTLTexture(const SkISize& frame_info) const override __attribute__((cf_audited_transfer)); - // |GPUSurfaceMetalDelegate| + // |SurfaceMetalDelegate| bool PresentTexture(GPUMTLTextureInfo texture) const override __attribute__((cf_audited_transfer)); - // |GPUSurfaceMetalDelegate| + // |SurfaceMetalDelegate| bool AllowsDrawingWhenGpuDisabled() const override; FML_DISALLOW_COPY_AND_ASSIGN(IOSSurfaceMetalImpeller); diff --git a/shell/platform/darwin/ios/ios_surface_metal_impeller.mm b/shell/platform/darwin/ios/ios_surface_metal_impeller.mm index edf0e6c886192..68635908b6cfc 100644 --- a/shell/platform/darwin/ios/ios_surface_metal_impeller.mm +++ b/shell/platform/darwin/ios/ios_surface_metal_impeller.mm @@ -6,7 +6,7 @@ #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 "flutter/shell/surface/surface_metal_impeller.h" FLUTTER_ASSERT_ARC @@ -15,7 +15,7 @@ IOSSurfaceMetalImpeller::IOSSurfaceMetalImpeller(const fml::scoped_nsobject& layer, const std::shared_ptr& context) : IOSSurface(context), - GPUSurfaceMetalDelegate(MTLRenderTargetType::kCAMetalLayer), + SurfaceMetalDelegate(MTLRenderTargetType::kCAMetalLayer), layer_(layer), impeller_context_(context ? context->GetImpellerContext() : nullptr) { if (!impeller_context_) { @@ -41,12 +41,12 @@ std::unique_ptr IOSSurfaceMetalImpeller::CreateGPUSurface(GrDirectContext*) { impeller_context_->UpdateOffscreenLayerPixelFormat( impeller::FromMTLPixelFormat(layer_.get().pixelFormat)); - return std::make_unique(this, // - impeller_context_ // + return std::make_unique(this, // + impeller_context_ // ); } -// |GPUSurfaceMetalDelegate| +// |SurfaceMetalDelegate| GPUCAMetalLayerHandle IOSSurfaceMetalImpeller::GetCAMetalLayer(const SkISize& frame_info) const { CAMetalLayer* layer = layer_.get(); const auto drawable_size = CGSizeMake(frame_info.width(), frame_info.height()); @@ -69,13 +69,13 @@ return (__bridge GPUCAMetalLayerHandle)layer; } -// |GPUSurfaceMetalDelegate| +// |SurfaceMetalDelegate| bool IOSSurfaceMetalImpeller::PresentDrawable(GrMTLHandle drawable) const { FML_DCHECK(false); return false; } -// |GPUSurfaceMetalDelegate| +// |SurfaceMetalDelegate| GPUMTLTextureInfo IOSSurfaceMetalImpeller::GetMTLTexture(const SkISize& frame_info) const { FML_CHECK(false); return GPUMTLTextureInfo{ @@ -84,13 +84,13 @@ }; } -// |GPUSurfaceMetalDelegate| +// |SurfaceMetalDelegate| bool IOSSurfaceMetalImpeller::PresentTexture(GPUMTLTextureInfo texture) const { FML_CHECK(false); return false; } -// |GPUSurfaceMetalDelegate| +// |SurfaceMetalDelegate| bool IOSSurfaceMetalImpeller::AllowsDrawingWhenGpuDisabled() const { return false; } diff --git a/shell/platform/darwin/ios/ios_surface_metal_skia.h b/shell/platform/darwin/ios/ios_surface_metal_skia.h index 65549762c4949..87bfed97888c8 100644 --- a/shell/platform/darwin/ios/ios_surface_metal_skia.h +++ b/shell/platform/darwin/ios/ios_surface_metal_skia.h @@ -8,8 +8,8 @@ #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 "flutter/shell/surface/surface_metal_delegate.h" #include "third_party/skia/include/gpu/ganesh/mtl/GrMtlTypes.h" @class CAMetalLayer; @@ -17,7 +17,7 @@ namespace flutter { class SK_API_AVAILABLE_CA_METAL_LAYER IOSSurfaceMetalSkia final : public IOSSurface, - public GPUSurfaceMetalDelegate { + public SurfaceMetalDelegate { public: IOSSurfaceMetalSkia(const fml::scoped_nsobject& layer, std::shared_ptr context); @@ -40,22 +40,22 @@ class SK_API_AVAILABLE_CA_METAL_LAYER IOSSurfaceMetalSkia final : public IOSSurf // |IOSSurface| std::unique_ptr CreateGPUSurface(GrDirectContext* gr_context) override; - // |GPUSurfaceMetalDelegate| + // |SurfaceMetalDelegate| GPUCAMetalLayerHandle GetCAMetalLayer(const SkISize& frame_info) const override __attribute__((cf_audited_transfer)); - // |GPUSurfaceMetalDelegate| + // |SurfaceMetalDelegate| bool PresentDrawable(GrMTLHandle drawable) const override __attribute__((cf_audited_transfer)); - // |GPUSurfaceMetalDelegate| + // |SurfaceMetalDelegate| GPUMTLTextureInfo GetMTLTexture(const SkISize& frame_info) const override __attribute__((cf_audited_transfer)); - // |GPUSurfaceMetalDelegate| + // |SurfaceMetalDelegate| bool PresentTexture(GPUMTLTextureInfo texture) const override __attribute__((cf_audited_transfer)); - // |GPUSurfaceMetalDelegate| + // |SurfaceMetalDelegate| bool AllowsDrawingWhenGpuDisabled() const override; FML_DISALLOW_COPY_AND_ASSIGN(IOSSurfaceMetalSkia); diff --git a/shell/platform/darwin/ios/ios_surface_metal_skia.mm b/shell/platform/darwin/ios/ios_surface_metal_skia.mm index 32465e2153201..cf95a93c358dc 100644 --- a/shell/platform/darwin/ios/ios_surface_metal_skia.mm +++ b/shell/platform/darwin/ios/ios_surface_metal_skia.mm @@ -6,9 +6,9 @@ #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" +#include "flutter/shell/surface/surface_metal_delegate.h" +#include "flutter/shell/surface/surface_metal_skia.h" FLUTTER_ASSERT_ARC @@ -26,7 +26,7 @@ - (void)flutterPrepareForPresent:(nonnull id)commandBuffer; IOSSurfaceMetalSkia::IOSSurfaceMetalSkia(const fml::scoped_nsobject& layer, std::shared_ptr context) : IOSSurface(std::move(context)), - GPUSurfaceMetalDelegate(MTLRenderTargetType::kCAMetalLayer), + SurfaceMetalDelegate(MTLRenderTargetType::kCAMetalLayer), layer_(layer) { is_valid_ = layer_; auto metal_context = CastToMetalContext(GetContext()); @@ -51,12 +51,12 @@ - (void)flutterPrepareForPresent:(nonnull id)commandBuffer; // |IOSSurface| std::unique_ptr IOSSurfaceMetalSkia::CreateGPUSurface(GrDirectContext* context) { FML_DCHECK(context); - return std::make_unique(this, // delegate - sk_ref_sp(context) // context + return std::make_unique(this, // delegate + sk_ref_sp(context) // context ); } -// |GPUSurfaceMetalDelegate| +// |SurfaceMetalDelegate| GPUCAMetalLayerHandle IOSSurfaceMetalSkia::GetCAMetalLayer(const SkISize& frame_info) const { CAMetalLayer* layer = layer_.get(); layer.device = device_; @@ -79,7 +79,7 @@ - (void)flutterPrepareForPresent:(nonnull id)commandBuffer; return (__bridge GPUCAMetalLayerHandle)layer; } -// |GPUSurfaceMetalDelegate| +// |SurfaceMetalDelegate| bool IOSSurfaceMetalSkia::PresentDrawable(GrMTLHandle drawable) const { if (drawable == nullptr) { FML_DLOG(ERROR) << "Could not acquire next Metal drawable from the SkSurface."; @@ -100,19 +100,19 @@ - (void)flutterPrepareForPresent:(nonnull id)commandBuffer; return true; } -// |GPUSurfaceMetalDelegate| +// |SurfaceMetalDelegate| 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| +// |SurfaceMetalDelegate| bool IOSSurfaceMetalSkia::PresentTexture(GPUMTLTextureInfo texture) const { FML_CHECK(false) << "render to texture not supported on ios"; return false; } -// |GPUSurfaceMetalDelegate| +// |SurfaceMetalDelegate| bool IOSSurfaceMetalSkia::AllowsDrawingWhenGpuDisabled() const { return false; } diff --git a/shell/platform/darwin/ios/ios_surface_software.h b/shell/platform/darwin/ios/ios_surface_software.h index e1ed6b69518c0..abe91530a859a 100644 --- a/shell/platform/darwin/ios/ios_surface_software.h +++ b/shell/platform/darwin/ios/ios_surface_software.h @@ -8,9 +8,9 @@ #include "flutter/flow/embedded_views.h" #include "flutter/fml/macros.h" #include "flutter/fml/platform/darwin/scoped_nsobject.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 "flutter/shell/surface/surface_software.h" #include "third_party/skia/include/core/SkSurface.h" @@ -18,7 +18,7 @@ namespace flutter { -class IOSSurfaceSoftware final : public IOSSurface, public GPUSurfaceSoftwareDelegate { +class IOSSurfaceSoftware final : public IOSSurface, public SurfaceSoftwareDelegate { public: IOSSurfaceSoftware(const fml::scoped_nsobject& layer, std::shared_ptr context); @@ -34,10 +34,10 @@ class IOSSurfaceSoftware final : public IOSSurface, public GPUSurfaceSoftwareDel // |IOSSurface| std::unique_ptr CreateGPUSurface(GrDirectContext* gr_context = nullptr) override; - // |GPUSurfaceSoftwareDelegate| + // |SurfaceSoftwareDelegate| sk_sp AcquireBackingStore(const SkISize& size) override; - // |GPUSurfaceSoftwareDelegate| + // |SurfaceSoftwareDelegate| bool PresentBackingStore(sk_sp backing_store) override; private: diff --git a/shell/platform/darwin/ios/ios_surface_software.mm b/shell/platform/darwin/ios/ios_surface_software.mm index c67facb1931c2..21981737cc335 100644 --- a/shell/platform/darwin/ios/ios_surface_software.mm +++ b/shell/platform/darwin/ios/ios_surface_software.mm @@ -41,7 +41,7 @@ return nullptr; } - auto surface = std::make_unique(this, true /* render to surface */); + auto surface = std::make_unique(this, true /* render to surface */); if (!surface->IsValid()) { return nullptr; diff --git a/shell/platform/darwin/macos/BUILD.gn b/shell/platform/darwin/macos/BUILD.gn index 401b63bc0b8b6..9aeb8c9f25525 100644 --- a/shell/platform/darwin/macos/BUILD.gn +++ b/shell/platform/darwin/macos/BUILD.gn @@ -6,12 +6,12 @@ assert(is_mac) import("//build/config/mac/mac_sdk.gni") import("//flutter/build/zip_bundle.gni") -import("//flutter/shell/gpu/gpu.gni") import("//flutter/shell/platform/darwin/common/framework_common.gni") import("//flutter/shell/platform/glfw/config.gni") +import("//flutter/shell/surface/surface.gni") import("//flutter/testing/testing.gni") -shell_gpu_configuration("macos_gpu_configuration") { +surface_configuration("macos_surface_configuration") { enable_software = true enable_gl = true enable_vulkan = false @@ -120,7 +120,7 @@ source_set("flutter_framework_source") { sources += _flutter_framework_headers deps = [ - ":macos_gpu_configuration", + ":macos_surface_configuration", "//flutter/flow:flow", "//flutter/fml", "//flutter/shell/platform/common:common_cpp_accessibility", diff --git a/shell/platform/embedder/BUILD.gn b/shell/platform/embedder/BUILD.gn index 39ca8dc757ae7..817e1ab1dc08b 100644 --- a/shell/platform/embedder/BUILD.gn +++ b/shell/platform/embedder/BUILD.gn @@ -6,8 +6,8 @@ import("//build/toolchain/clang.gni") import("//flutter/build/zip_bundle.gni") import("//flutter/common/config.gni") import("//flutter/impeller/tools/impeller.gni") -import("//flutter/shell/gpu/gpu.gni") import("//flutter/shell/platform/embedder/embedder.gni") +import("//flutter/shell/surface/surface.gni") import("//flutter/testing/testing.gni") declare_args() { @@ -17,7 +17,7 @@ declare_args() { embedder_enable_metal = shell_enable_metal } -shell_gpu_configuration("embedder_gpu_configuration") { +surface_configuration("embedder_surface_configuration") { enable_software = embedder_enable_software enable_vulkan = embedder_enable_vulkan enable_gl = embedder_enable_gl @@ -99,7 +99,7 @@ template("embedder_source_set") { public_deps = [ ":embedder_headers" ] deps = [ - ":embedder_gpu_configuration", + ":embedder_surface_configuration", "$dart_src/runtime/bin:dart_io_api", "$dart_src/runtime/bin:elf_loader", "//flutter/assets", @@ -184,7 +184,7 @@ template("embedder_source_set") { } public_configs += [ - ":embedder_gpu_configuration_config", + ":embedder_surface_configuration_config", ":embedder_header_config", "//flutter:config", "//flutter/impeller:impeller_public_config", @@ -261,7 +261,7 @@ if (enable_unittests) { testonly = true configs += [ - ":embedder_gpu_configuration_config", + ":embedder_surface_configuration_config", "//flutter:export_dynamic_symbols", ] @@ -289,7 +289,7 @@ if (enable_unittests) { public_deps = [ ":embedder", - ":embedder_gpu_configuration", + ":embedder_surface_configuration", ":fixtures", "$dart_src/runtime/bin:elf_loader", "//flutter/flow", @@ -349,7 +349,7 @@ if (enable_unittests) { configs += [ ":embedder_jit_snapshot_setup", - ":embedder_gpu_configuration_config", + ":embedder_surface_configuration_config", "//flutter:export_dynamic_symbols", ] @@ -379,7 +379,7 @@ if (enable_unittests) { testonly = true configs += [ - ":embedder_gpu_configuration_config", + ":embedder_surface_configuration_config", "//flutter:export_dynamic_symbols", ] @@ -395,7 +395,7 @@ if (enable_unittests) { testonly = true configs += [ - ":embedder_gpu_configuration_config", + ":embedder_surface_configuration_config", "//flutter:export_dynamic_symbols", ] @@ -408,7 +408,7 @@ if (enable_unittests) { deps = [ ":embedder", - ":embedder_gpu_configuration", + ":embedder_surface_configuration", ":fixtures", "//flutter/lib/snapshot", "//flutter/testing", diff --git a/shell/platform/embedder/embedder.cc b/shell/platform/embedder/embedder.cc index 6631c2582c9a1..73eebc8a73881 100644 --- a/shell/platform/embedder/embedder.cc +++ b/shell/platform/embedder/embedder.cc @@ -433,7 +433,7 @@ InferOpenGLPlatformViewCreationCallback( } } - flutter::GPUSurfaceGLDelegate::GLProcResolver gl_proc_resolver = nullptr; + flutter::SurfaceGLDelegate::GLProcResolver gl_proc_resolver = nullptr; if (SAFE_ACCESS(open_gl_config, gl_proc_resolver, nullptr) != nullptr) { gl_proc_resolver = [ptr = config->open_gl.gl_proc_resolver, user_data](const char* gl_proc_name) { @@ -1132,7 +1132,7 @@ static sk_sp MakeSkSurfaceFromBackingStore( backend_texture, // back-end texture kTopLeft_GrSurfaceOrigin, // surface origin 1, // sample count - flutter::GPUSurfaceVulkan::ColorTypeFromFormat( + flutter::SurfaceVulkan::ColorTypeFromFormat( static_cast(vulkan->image->format)), // color type SkColorSpace::MakeSRGB(), // color space &surface_properties, // surface properties diff --git a/shell/platform/embedder/embedder_surface_gl_impeller.cc b/shell/platform/embedder/embedder_surface_gl_impeller.cc index cc5b62c8efa33..e1549a561b0fb 100644 --- a/shell/platform/embedder/embedder_surface_gl_impeller.cc +++ b/shell/platform/embedder/embedder_surface_gl_impeller.cc @@ -113,7 +113,7 @@ bool EmbedderSurfaceGLImpeller::IsValid() const { return valid_; } -// |GPUSurfaceGLDelegate| +// |SurfaceGLDelegate| std::unique_ptr EmbedderSurfaceGLImpeller::GLContextMakeCurrent() { worker_->SetReactionsAllowedOnCurrentThread(true); @@ -121,20 +121,20 @@ EmbedderSurfaceGLImpeller::GLContextMakeCurrent() { gl_dispatch_table_.gl_make_current_callback()); } -// |GPUSurfaceGLDelegate| +// |SurfaceGLDelegate| bool EmbedderSurfaceGLImpeller::GLContextClearCurrent() { worker_->SetReactionsAllowedOnCurrentThread(false); return gl_dispatch_table_.gl_clear_current_callback(); } -// |GPUSurfaceGLDelegate| +// |SurfaceGLDelegate| bool EmbedderSurfaceGLImpeller::GLContextPresent( const GLPresentInfo& present_info) { // Pass the present information to the embedder present callback. return gl_dispatch_table_.gl_present_callback(present_info); } -// |GPUSurfaceGLDelegate| +// |SurfaceGLDelegate| GLFBOInfo EmbedderSurfaceGLImpeller::GLContextFBO( GLFrameInfo frame_info) const { // Get the FBO ID using the gl_fbo_callback and then get exiting damage by @@ -143,12 +143,12 @@ GLFBOInfo EmbedderSurfaceGLImpeller::GLContextFBO( gl_dispatch_table_.gl_fbo_callback(frame_info)); } -// |GPUSurfaceGLDelegate| +// |SurfaceGLDelegate| bool EmbedderSurfaceGLImpeller::GLContextFBOResetAfterPresent() const { return fbo_reset_after_present_; } -// |GPUSurfaceGLDelegate| +// |SurfaceGLDelegate| SkMatrix EmbedderSurfaceGLImpeller::GLContextSurfaceTransformation() const { auto callback = gl_dispatch_table_.gl_surface_transformation_callback; if (!callback) { @@ -159,13 +159,13 @@ SkMatrix EmbedderSurfaceGLImpeller::GLContextSurfaceTransformation() const { return callback(); } -// |GPUSurfaceGLDelegate| +// |SurfaceGLDelegate| EmbedderSurfaceGLSkia::GLProcResolver EmbedderSurfaceGLImpeller::GetGLProcResolver() const { return gl_dispatch_table_.gl_proc_resolver; } -// |GPUSurfaceGLDelegate| +// |SurfaceGLDelegate| SurfaceFrame::FramebufferInfo EmbedderSurfaceGLImpeller::GLContextFramebufferInfo() const { // Enable partial repaint by default on the embedders. @@ -179,11 +179,11 @@ EmbedderSurfaceGLImpeller::GLContextFramebufferInfo() const { // |EmbedderSurface| std::unique_ptr EmbedderSurfaceGLImpeller::CreateGPUSurface() { // Ensure that the GL context is current before creating the GPU surface. - // GPUSurfaceGLImpeller initialization will set up shader pipelines, and the + // SurfaceGLImpeller initialization will set up shader pipelines, and the // current thread needs to be able to execute reactor operations. GLContextMakeCurrent(); - return std::make_unique( + return std::make_unique( this, // GPU surface GL delegate impeller_context_, // Impeller context !external_view_embedder_ // render to surface diff --git a/shell/platform/embedder/embedder_surface_gl_impeller.h b/shell/platform/embedder/embedder_surface_gl_impeller.h index bc4d80e759e2d..fd199ae15e557 100644 --- a/shell/platform/embedder/embedder_surface_gl_impeller.h +++ b/shell/platform/embedder/embedder_surface_gl_impeller.h @@ -6,10 +6,10 @@ #define FLUTTER_SHELL_PLATFORM_EMBEDDER_EMBEDDER_SURFACE_GL_IMPELLER_H_ #include "flutter/fml/macros.h" -#include "flutter/shell/gpu/gpu_surface_gl_impeller.h" #include "flutter/shell/platform/embedder/embedder_external_view_embedder.h" #include "flutter/shell/platform/embedder/embedder_surface.h" #include "flutter/shell/platform/embedder/embedder_surface_gl_skia.h" +#include "flutter/shell/surface/surface_gl_impeller.h" namespace impeller { class ContextGLES; @@ -20,7 +20,7 @@ namespace flutter { class ReactorWorker; class EmbedderSurfaceGLImpeller final : public EmbedderSurface, - public GPUSurfaceGLDelegate { + public SurfaceGLDelegate { public: EmbedderSurfaceGLImpeller( EmbedderSurfaceGLSkia::GLDispatchTable gl_dispatch_table, @@ -46,28 +46,28 @@ class EmbedderSurfaceGLImpeller final : public EmbedderSurface, // |EmbedderSurface| std::shared_ptr CreateImpellerContext() const override; - // |GPUSurfaceGLDelegate| + // |SurfaceGLDelegate| std::unique_ptr GLContextMakeCurrent() override; - // |GPUSurfaceGLDelegate| + // |SurfaceGLDelegate| bool GLContextClearCurrent() override; - // |GPUSurfaceGLDelegate| + // |SurfaceGLDelegate| bool GLContextPresent(const GLPresentInfo& present_info) override; - // |GPUSurfaceGLDelegate| + // |SurfaceGLDelegate| GLFBOInfo GLContextFBO(GLFrameInfo frame_info) const override; - // |GPUSurfaceGLDelegate| + // |SurfaceGLDelegate| bool GLContextFBOResetAfterPresent() const override; - // |GPUSurfaceGLDelegate| + // |SurfaceGLDelegate| SkMatrix GLContextSurfaceTransformation() const override; - // |GPUSurfaceGLDelegate| + // |SurfaceGLDelegate| GLProcResolver GetGLProcResolver() const override; - // |GPUSurfaceGLDelegate| + // |SurfaceGLDelegate| SurfaceFrame::FramebufferInfo GLContextFramebufferInfo() const override; // |EmbedderSurface| diff --git a/shell/platform/embedder/embedder_surface_gl_skia.cc b/shell/platform/embedder/embedder_surface_gl_skia.cc index 05ea4c5a057b8..b26869a0eeffe 100644 --- a/shell/platform/embedder/embedder_surface_gl_skia.cc +++ b/shell/platform/embedder/embedder_surface_gl_skia.cc @@ -36,25 +36,25 @@ bool EmbedderSurfaceGLSkia::IsValid() const { return valid_; } -// |GPUSurfaceGLDelegate| +// |SurfaceGLDelegate| std::unique_ptr EmbedderSurfaceGLSkia::GLContextMakeCurrent() { return std::make_unique( gl_dispatch_table_.gl_make_current_callback()); } -// |GPUSurfaceGLDelegate| +// |SurfaceGLDelegate| bool EmbedderSurfaceGLSkia::GLContextClearCurrent() { return gl_dispatch_table_.gl_clear_current_callback(); } -// |GPUSurfaceGLDelegate| +// |SurfaceGLDelegate| bool EmbedderSurfaceGLSkia::GLContextPresent( const GLPresentInfo& present_info) { // Pass the present information to the embedder present callback. return gl_dispatch_table_.gl_present_callback(present_info); } -// |GPUSurfaceGLDelegate| +// |SurfaceGLDelegate| GLFBOInfo EmbedderSurfaceGLSkia::GLContextFBO(GLFrameInfo frame_info) const { // Get the FBO ID using the gl_fbo_callback and then get exiting damage by // passing that ID to the gl_populate_existing_damage. @@ -62,12 +62,12 @@ GLFBOInfo EmbedderSurfaceGLSkia::GLContextFBO(GLFrameInfo frame_info) const { gl_dispatch_table_.gl_fbo_callback(frame_info)); } -// |GPUSurfaceGLDelegate| +// |SurfaceGLDelegate| bool EmbedderSurfaceGLSkia::GLContextFBOResetAfterPresent() const { return fbo_reset_after_present_; } -// |GPUSurfaceGLDelegate| +// |SurfaceGLDelegate| SkMatrix EmbedderSurfaceGLSkia::GLContextSurfaceTransformation() const { auto callback = gl_dispatch_table_.gl_surface_transformation_callback; if (!callback) { @@ -78,13 +78,13 @@ SkMatrix EmbedderSurfaceGLSkia::GLContextSurfaceTransformation() const { return callback(); } -// |GPUSurfaceGLDelegate| +// |SurfaceGLDelegate| EmbedderSurfaceGLSkia::GLProcResolver EmbedderSurfaceGLSkia::GetGLProcResolver() const { return gl_dispatch_table_.gl_proc_resolver; } -// |GPUSurfaceGLDelegate| +// |SurfaceGLDelegate| SurfaceFrame::FramebufferInfo EmbedderSurfaceGLSkia::GLContextFramebufferInfo() const { // Enable partial repaint by default on the embedders. @@ -98,9 +98,8 @@ SurfaceFrame::FramebufferInfo EmbedderSurfaceGLSkia::GLContextFramebufferInfo() // |EmbedderSurface| std::unique_ptr EmbedderSurfaceGLSkia::CreateGPUSurface() { const bool render_to_surface = !external_view_embedder_; - return std::make_unique( - this, // GPU surface GL delegate - render_to_surface // render to surface + return std::make_unique(this, // GPU surface GL delegate + render_to_surface // render to surface ); } diff --git a/shell/platform/embedder/embedder_surface_gl_skia.h b/shell/platform/embedder/embedder_surface_gl_skia.h index 0fb39828d972c..f2777d69ebeec 100644 --- a/shell/platform/embedder/embedder_surface_gl_skia.h +++ b/shell/platform/embedder/embedder_surface_gl_skia.h @@ -6,14 +6,14 @@ #define FLUTTER_SHELL_PLATFORM_EMBEDDER_EMBEDDER_SURFACE_GL_SKIA_H_ #include "flutter/fml/macros.h" -#include "flutter/shell/gpu/gpu_surface_gl_skia.h" #include "flutter/shell/platform/embedder/embedder_external_view_embedder.h" #include "flutter/shell/platform/embedder/embedder_surface.h" +#include "flutter/shell/surface/surface_gl_skia.h" namespace flutter { class EmbedderSurfaceGLSkia final : public EmbedderSurface, - public GPUSurfaceGLDelegate { + public SurfaceGLDelegate { public: struct GLDispatchTable { std::function gl_make_current_callback; // required @@ -50,28 +50,28 @@ class EmbedderSurfaceGLSkia final : public EmbedderSurface, // |EmbedderSurface| sk_sp CreateResourceContext() const override; - // |GPUSurfaceGLDelegate| + // |SurfaceGLDelegate| std::unique_ptr GLContextMakeCurrent() override; - // |GPUSurfaceGLDelegate| + // |SurfaceGLDelegate| bool GLContextClearCurrent() override; - // |GPUSurfaceGLDelegate| + // |SurfaceGLDelegate| bool GLContextPresent(const GLPresentInfo& present_info) override; - // |GPUSurfaceGLDelegate| + // |SurfaceGLDelegate| GLFBOInfo GLContextFBO(GLFrameInfo frame_info) const override; - // |GPUSurfaceGLDelegate| + // |SurfaceGLDelegate| bool GLContextFBOResetAfterPresent() const override; - // |GPUSurfaceGLDelegate| + // |SurfaceGLDelegate| SkMatrix GLContextSurfaceTransformation() const override; - // |GPUSurfaceGLDelegate| + // |SurfaceGLDelegate| GLProcResolver GetGLProcResolver() const override; - // |GPUSurfaceGLDelegate| + // |SurfaceGLDelegate| SurfaceFrame::FramebufferInfo GLContextFramebufferInfo() const override; FML_DISALLOW_COPY_AND_ASSIGN(EmbedderSurfaceGLSkia); diff --git a/shell/platform/embedder/embedder_surface_metal_impeller.h b/shell/platform/embedder/embedder_surface_metal_impeller.h index 109870aa6f129..c40cecdfb76cc 100644 --- a/shell/platform/embedder/embedder_surface_metal_impeller.h +++ b/shell/platform/embedder/embedder_surface_metal_impeller.h @@ -7,10 +7,10 @@ #include #include "flutter/fml/macros.h" -#include "flutter/shell/gpu/gpu_surface_metal_delegate.h" -#include "flutter/shell/gpu/gpu_surface_metal_skia.h" #include "flutter/shell/platform/embedder/embedder_external_view_embedder.h" #include "flutter/shell/platform/embedder/embedder_surface.h" +#include "flutter/shell/surface/surface_metal_delegate.h" +#include "flutter/shell/surface/surface_metal_skia.h" #include "fml/concurrent_message_loop.h" namespace impeller { @@ -20,7 +20,7 @@ class Context; namespace flutter { class EmbedderSurfaceMetalImpeller final : public EmbedderSurface, - public GPUSurfaceMetalDelegate { + public SurfaceMetalDelegate { public: struct MetalDispatchTable { std::function present; // required @@ -48,17 +48,17 @@ class EmbedderSurfaceMetalImpeller final : public EmbedderSurface, // |EmbedderSurface| std::unique_ptr CreateGPUSurface() override; - // |GPUSurfaceMetalDelegate| + // |SurfaceMetalDelegate| GPUCAMetalLayerHandle GetCAMetalLayer( const SkISize& frame_size) const override; - // |GPUSurfaceMetalDelegate| + // |SurfaceMetalDelegate| bool PresentDrawable(GrMTLHandle drawable) const override; - // |GPUSurfaceMetalDelegate| + // |SurfaceMetalDelegate| GPUMTLTextureInfo GetMTLTexture(const SkISize& frame_size) const override; - // |GPUSurfaceMetalDelegate| + // |SurfaceMetalDelegate| bool PresentTexture(GPUMTLTextureInfo texture) const override; // |EmbedderSurface| diff --git a/shell/platform/embedder/embedder_surface_metal_impeller.mm b/shell/platform/embedder/embedder_surface_metal_impeller.mm index c36199a2a3fc0..96af46723bcab 100644 --- a/shell/platform/embedder/embedder_surface_metal_impeller.mm +++ b/shell/platform/embedder/embedder_surface_metal_impeller.mm @@ -9,9 +9,9 @@ #include "flutter/fml/logging.h" #include "flutter/fml/synchronization/sync_switch.h" -#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 "flutter/shell/surface/surface_metal_delegate.h" +#include "flutter/shell/surface/surface_metal_impeller.h" #include "impeller/entity/mtl/entity_shaders.h" #include "impeller/entity/mtl/framebuffer_blend_shaders.h" #include "impeller/entity/mtl/modern_shaders.h" @@ -30,7 +30,7 @@ GPUMTLCommandQueueHandle command_queue, MetalDispatchTable metal_dispatch_table, std::shared_ptr external_view_embedder) - : GPUSurfaceMetalDelegate(MTLRenderTargetType::kMTLTexture), + : SurfaceMetalDelegate(MTLRenderTargetType::kMTLTexture), metal_dispatch_table_(std::move(metal_dispatch_table)), external_view_embedder_(std::move(external_view_embedder)) { std::vector> shader_mappings = { @@ -70,7 +70,7 @@ } const bool render_to_surface = !external_view_embedder_; - auto surface = std::make_unique(this, context_, render_to_surface); + auto surface = std::make_unique(this, context_, render_to_surface); if (!surface->IsValid()) { return nullptr; diff --git a/shell/platform/embedder/embedder_surface_metal_skia.h b/shell/platform/embedder/embedder_surface_metal_skia.h index b03a17c6e6f67..2860aa5c905c7 100644 --- a/shell/platform/embedder/embedder_surface_metal_skia.h +++ b/shell/platform/embedder/embedder_surface_metal_skia.h @@ -8,10 +8,10 @@ #if !SLIMPELLER #include "flutter/fml/macros.h" -#include "flutter/shell/gpu/gpu_surface_metal_delegate.h" -#include "flutter/shell/gpu/gpu_surface_metal_skia.h" #include "flutter/shell/platform/embedder/embedder_external_view_embedder.h" #include "flutter/shell/platform/embedder/embedder_surface.h" +#include "flutter/shell/surface/surface_metal_delegate.h" +#include "flutter/shell/surface/surface_metal_skia.h" #include "third_party/skia/include/core/SkSurface.h" @@ -21,7 +21,7 @@ namespace flutter { // specifically for Impeller called EmbedderSurfaceMetalImpeller. Rename this to // EmbedderSurfaceMetalSkia to avoid confusion. class EmbedderSurfaceMetalSkia final : public EmbedderSurface, - public GPUSurfaceMetalDelegate { + public SurfaceMetalDelegate { public: struct MetalDispatchTable { std::function present; // required @@ -54,17 +54,17 @@ class EmbedderSurfaceMetalSkia final : public EmbedderSurface, // |EmbedderSurface| sk_sp CreateResourceContext() const override; - // |GPUSurfaceMetalDelegate| + // |SurfaceMetalDelegate| GPUCAMetalLayerHandle GetCAMetalLayer( const SkISize& frame_size) const override; - // |GPUSurfaceMetalDelegate| + // |SurfaceMetalDelegate| bool PresentDrawable(GrMTLHandle drawable) const override; - // |GPUSurfaceMetalDelegate| + // |SurfaceMetalDelegate| GPUMTLTextureInfo GetMTLTexture(const SkISize& frame_size) const override; - // |GPUSurfaceMetalDelegate| + // |SurfaceMetalDelegate| bool PresentTexture(GPUMTLTextureInfo texture) const override; FML_DISALLOW_COPY_AND_ASSIGN(EmbedderSurfaceMetalSkia); diff --git a/shell/platform/embedder/embedder_surface_metal_skia.mm b/shell/platform/embedder/embedder_surface_metal_skia.mm index 244dcb05da5d2..b7063647d81aa 100644 --- a/shell/platform/embedder/embedder_surface_metal_skia.mm +++ b/shell/platform/embedder/embedder_surface_metal_skia.mm @@ -9,8 +9,8 @@ #include "flutter/shell/platform/embedder/embedder_surface_metal_skia.h" #include "flutter/fml/logging.h" -#include "flutter/shell/gpu/gpu_surface_metal_delegate.h" #include "flutter/shell/platform/darwin/graphics/FlutterDarwinContextMetalSkia.h" +#include "flutter/shell/surface/surface_metal_delegate.h" #include "third_party/skia/include/gpu/GrDirectContext.h" FLUTTER_ASSERT_NOT_ARC @@ -21,7 +21,7 @@ GPUMTLCommandQueueHandle command_queue, MetalDispatchTable metal_dispatch_table, std::shared_ptr external_view_embedder) - : GPUSurfaceMetalDelegate(MTLRenderTargetType::kMTLTexture), + : SurfaceMetalDelegate(MTLRenderTargetType::kMTLTexture), metal_dispatch_table_(std::move(metal_dispatch_table)), external_view_embedder_(std::move(external_view_embedder)) { main_context_ = @@ -49,7 +49,7 @@ } const bool render_to_surface = !external_view_embedder_; - auto surface = std::make_unique(this, main_context_, render_to_surface); + auto surface = std::make_unique(this, main_context_, render_to_surface); if (!surface->IsValid()) { return nullptr; diff --git a/shell/platform/embedder/embedder_surface_software.cc b/shell/platform/embedder/embedder_surface_software.cc index 7f6d445aa054c..7e0e1bb20054c 100644 --- a/shell/platform/embedder/embedder_surface_software.cc +++ b/shell/platform/embedder/embedder_surface_software.cc @@ -39,7 +39,7 @@ std::unique_ptr EmbedderSurfaceSoftware::CreateGPUSurface() { return nullptr; } const bool render_to_surface = !external_view_embedder_; - auto surface = std::make_unique(this, render_to_surface); + auto surface = std::make_unique(this, render_to_surface); if (!surface->IsValid()) { return nullptr; @@ -53,7 +53,7 @@ sk_sp EmbedderSurfaceSoftware::CreateResourceContext() const { return nullptr; } -// |GPUSurfaceSoftwareDelegate| +// |SurfaceSoftwareDelegate| sk_sp EmbedderSurfaceSoftware::AcquireBackingStore( const SkISize& size) { TRACE_EVENT0("flutter", "EmbedderSurfaceSoftware::AcquireBackingStore"); @@ -81,7 +81,7 @@ sk_sp EmbedderSurfaceSoftware::AcquireBackingStore( return sk_surface_; } -// |GPUSurfaceSoftwareDelegate| +// |SurfaceSoftwareDelegate| bool EmbedderSurfaceSoftware::PresentBackingStore( sk_sp backing_store) { if (!IsValid()) { diff --git a/shell/platform/embedder/embedder_surface_software.h b/shell/platform/embedder/embedder_surface_software.h index 5d52e63d76528..956ee114d32c9 100644 --- a/shell/platform/embedder/embedder_surface_software.h +++ b/shell/platform/embedder/embedder_surface_software.h @@ -6,16 +6,16 @@ #define FLUTTER_SHELL_PLATFORM_EMBEDDER_EMBEDDER_SURFACE_SOFTWARE_H_ #include "flutter/fml/macros.h" -#include "flutter/shell/gpu/gpu_surface_software.h" #include "flutter/shell/platform/embedder/embedder_external_view_embedder.h" #include "flutter/shell/platform/embedder/embedder_surface.h" +#include "flutter/shell/surface/surface_software.h" #include "third_party/skia/include/core/SkSurface.h" namespace flutter { class EmbedderSurfaceSoftware final : public EmbedderSurface, - public GPUSurfaceSoftwareDelegate { + public SurfaceSoftwareDelegate { public: struct SoftwareDispatchTable { std::function @@ -43,10 +43,10 @@ class EmbedderSurfaceSoftware final : public EmbedderSurface, // |EmbedderSurface| sk_sp CreateResourceContext() const override; - // |GPUSurfaceSoftwareDelegate| + // |SurfaceSoftwareDelegate| sk_sp AcquireBackingStore(const SkISize& size) override; - // |GPUSurfaceSoftwareDelegate| + // |SurfaceSoftwareDelegate| bool PresentBackingStore(sk_sp backing_store) override; FML_DISALLOW_COPY_AND_ASSIGN(EmbedderSurfaceSoftware); diff --git a/shell/platform/embedder/embedder_surface_vulkan.cc b/shell/platform/embedder/embedder_surface_vulkan.cc index 7b8e4ac511b67..a85958fc140df 100644 --- a/shell/platform/embedder/embedder_surface_vulkan.cc +++ b/shell/platform/embedder/embedder_surface_vulkan.cc @@ -8,8 +8,8 @@ #include "flutter/flutter_vma/flutter_skia_vma.h" #include "flutter/shell/common/shell_io_manager.h" -#include "flutter/shell/gpu/gpu_surface_vulkan.h" -#include "flutter/shell/gpu/gpu_surface_vulkan_delegate.h" +#include "flutter/shell/surface/surface_vulkan.h" +#include "flutter/shell/surface/surface_vulkan_delegate.h" #include "flutter/vulkan/vulkan_skia_proc_table.h" #include "include/gpu/GrDirectContext.h" #include "include/gpu/vk/VulkanBackendContext.h" @@ -88,17 +88,17 @@ EmbedderSurfaceVulkan::~EmbedderSurfaceVulkan() { } } -// |GPUSurfaceVulkanDelegate| +// |SurfaceVulkanDelegate| const vulkan::VulkanProcTable& EmbedderSurfaceVulkan::vk() { return *vk_; } -// |GPUSurfaceVulkanDelegate| +// |SurfaceVulkanDelegate| FlutterVulkanImage EmbedderSurfaceVulkan::AcquireImage(const SkISize& size) { return vulkan_dispatch_table_.get_next_image(size); } -// |GPUSurfaceVulkanDelegate| +// |SurfaceVulkanDelegate| bool EmbedderSurfaceVulkan::PresentImage(VkImage image, VkFormat format) { return vulkan_dispatch_table_.present_image(image, format); } @@ -111,8 +111,8 @@ bool EmbedderSurfaceVulkan::IsValid() const { // |EmbedderSurface| std::unique_ptr EmbedderSurfaceVulkan::CreateGPUSurface() { const bool render_to_surface = !external_view_embedder_; - return std::make_unique(this, main_context_, - render_to_surface); + return std::make_unique(this, main_context_, + render_to_surface); } // |EmbedderSurface| diff --git a/shell/platform/embedder/embedder_surface_vulkan.h b/shell/platform/embedder/embedder_surface_vulkan.h index 0e972d3723b74..1edf685b52a1e 100644 --- a/shell/platform/embedder/embedder_surface_vulkan.h +++ b/shell/platform/embedder/embedder_surface_vulkan.h @@ -7,17 +7,17 @@ #include "flutter/fml/macros.h" #include "flutter/shell/common/context_options.h" -#include "flutter/shell/gpu/gpu_surface_vulkan.h" -#include "flutter/shell/gpu/gpu_surface_vulkan_delegate.h" #include "flutter/shell/platform/embedder/embedder.h" #include "flutter/shell/platform/embedder/embedder_external_view_embedder.h" #include "flutter/shell/platform/embedder/embedder_surface.h" +#include "flutter/shell/surface/surface_vulkan.h" +#include "flutter/shell/surface/surface_vulkan_delegate.h" #include "flutter/vulkan/procs/vulkan_proc_table.h" namespace flutter { class EmbedderSurfaceVulkan final : public EmbedderSurface, - public GPUSurfaceVulkanDelegate { + public SurfaceVulkanDelegate { public: struct VulkanDispatchTable { PFN_vkGetInstanceProcAddr get_instance_proc_address; // required @@ -43,13 +43,13 @@ class EmbedderSurfaceVulkan final : public EmbedderSurface, ~EmbedderSurfaceVulkan() override; - // |GPUSurfaceVulkanDelegate| + // |SurfaceVulkanDelegate| const vulkan::VulkanProcTable& vk() override; - // |GPUSurfaceVulkanDelegate| + // |SurfaceVulkanDelegate| FlutterVulkanImage AcquireImage(const SkISize& size) override; - // |GPUSurfaceVulkanDelegate| + // |SurfaceVulkanDelegate| bool PresentImage(VkImage image, VkFormat format) override; private: diff --git a/shell/platform/fuchsia/flutter/BUILD.gn b/shell/platform/fuchsia/flutter/BUILD.gn index ad4e3426a1c80..feeeec44ae170 100644 --- a/shell/platform/fuchsia/flutter/BUILD.gn +++ b/shell/platform/fuchsia/flutter/BUILD.gn @@ -6,7 +6,7 @@ assert(is_fuchsia) import("//flutter/common/config.gni") import("//flutter/shell/config.gni") -import("//flutter/shell/gpu/gpu.gni") +import("//flutter/shell/surface/surface.gni") import("//flutter/testing/testing.gni") import("//flutter/tools/fuchsia/dart.gni") import("//flutter/tools/fuchsia/fuchsia_archive.gni") @@ -15,7 +15,7 @@ import("//flutter/tools/fuchsia/gn-sdk/src/gn_configs.gni") import("//flutter/vulkan/config.gni") # Fuchsia uses its own custom Surface implementation. -shell_gpu_configuration("fuchsia_gpu_configuration") { +surface_configuration("fuchsia_surface_configuration") { enable_software = false enable_gl = false @@ -128,7 +128,7 @@ template("runner_sources") { ] flutter_deps = [ - ":fuchsia_gpu_configuration", + ":fuchsia_surface_configuration", "//flutter/assets", "//flutter/common", "//flutter/flutter_vma:flutter_skia_vma", diff --git a/shell/gpu/BUILD.gn b/shell/surface/BUILD.gn similarity index 52% rename from shell/gpu/BUILD.gn rename to shell/surface/BUILD.gn index 0e7e68670551f..5e0858e097507 100644 --- a/shell/gpu/BUILD.gn +++ b/shell/surface/BUILD.gn @@ -6,7 +6,7 @@ import("//flutter/common/config.gni") import("//flutter/impeller/tools/impeller.gni") import("//flutter/shell/config.gni") -gpu_common_deps = [ +common_deps = [ "//flutter/common", "//flutter/common/graphics", "//flutter/flow", @@ -15,45 +15,45 @@ gpu_common_deps = [ "//flutter/skia", ] -source_set("gpu_surface_software") { +source_set("software") { sources = [ - "gpu_surface_software.cc", - "gpu_surface_software.h", - "gpu_surface_software_delegate.cc", - "gpu_surface_software_delegate.h", + "surface_software.cc", + "surface_software.h", + "surface_software_delegate.cc", + "surface_software_delegate.h", ] - public_deps = gpu_common_deps + public_deps = common_deps } -source_set("gpu_surface_gl") { +source_set("gl") { sources = [ - "gpu_surface_gl_delegate.cc", - "gpu_surface_gl_delegate.h", - "gpu_surface_gl_skia.cc", - "gpu_surface_gl_skia.h", + "surface_gl_delegate.cc", + "surface_gl_delegate.h", + "surface_gl_skia.cc", + "surface_gl_skia.h", ] - public_deps = gpu_common_deps + public_deps = common_deps if (impeller_enable_opengles) { sources += [ - "gpu_surface_gl_impeller.cc", - "gpu_surface_gl_impeller.h", + "surface_gl_impeller.cc", + "surface_gl_impeller.h", ] public_deps += [ "//flutter/impeller" ] } } -source_set("gpu_surface_vulkan") { +source_set("vulkan") { sources = [ - "gpu_surface_vulkan.cc", - "gpu_surface_vulkan.h", - "gpu_surface_vulkan_delegate.cc", - "gpu_surface_vulkan_delegate.h", + "surface_vulkan.cc", + "surface_vulkan.h", + "surface_vulkan_delegate.cc", + "surface_vulkan_delegate.h", ] - public_deps = gpu_common_deps + [ + public_deps = common_deps + [ "//flutter/shell/platform/embedder:embedder_headers", "//flutter/vulkan", "//flutter/vulkan/procs", @@ -61,28 +61,28 @@ source_set("gpu_surface_vulkan") { if (impeller_enable_vulkan) { sources += [ - "gpu_surface_vulkan_impeller.cc", - "gpu_surface_vulkan_impeller.h", + "surface_vulkan_impeller.cc", + "surface_vulkan_impeller.h", ] public_deps += [ "//flutter/impeller" ] } } -source_set("gpu_surface_metal") { +source_set("metal") { sources = [ - "gpu_surface_metal_delegate.cc", - "gpu_surface_metal_delegate.h", - "gpu_surface_metal_skia.h", - "gpu_surface_metal_skia.mm", + "surface_metal_delegate.cc", + "surface_metal_delegate.h", + "surface_metal_skia.h", + "surface_metal_skia.mm", ] - public_deps = gpu_common_deps + public_deps = common_deps if (impeller_enable_metal) { sources += [ - "gpu_surface_metal_impeller.h", - "gpu_surface_metal_impeller.mm", + "surface_metal_impeller.h", + "surface_metal_impeller.mm", ] public_deps += [ "//flutter/impeller" ] @@ -90,10 +90,10 @@ source_set("gpu_surface_metal") { } if (is_mac) { - impeller_component("gpu_surface_metal_unittests") { + impeller_component("metal_unittests") { testonly = true target_type = "executable" - sources = [ "gpu_surface_metal_impeller_unittests.mm" ] + sources = [ "surface_metal_impeller_unittests.mm" ] frameworks = [ "AppKit.framework", @@ -102,12 +102,12 @@ if (is_mac) { deps = [ "//flutter/testing", - ":gpu_surface_metal", + ":metal", "//flutter/impeller/fixtures", "//flutter/fml", "//flutter/runtime", "//flutter/runtime:libdart", "//flutter/testing", - ] + gpu_common_deps + ] + common_deps } } diff --git a/shell/surface/README.md b/shell/surface/README.md new file mode 100644 index 0000000000000..46946b1907200 --- /dev/null +++ b/shell/surface/README.md @@ -0,0 +1,3 @@ +# Surface + +Concrete implementations of the flow Surfaces used to wrap platform specific render targets to render to. diff --git a/shell/gpu/gpu.gni b/shell/surface/surface.gni similarity index 80% rename from shell/gpu/gpu.gni rename to shell/surface/surface.gni index 8e09b4f465783..adc554834dc8c 100644 --- a/shell/gpu/gpu.gni +++ b/shell/surface/surface.gni @@ -4,7 +4,7 @@ import("//flutter/shell/config.gni") -template("shell_gpu_configuration") { +template("surface_configuration") { assert(defined(invoker.enable_software), "Caller must declare if the Software backend must be enabled.") assert(defined(invoker.enable_vulkan), @@ -18,19 +18,19 @@ template("shell_gpu_configuration") { public_deps = [] if (invoker.enable_software) { - public_deps += [ "//flutter/shell/gpu:gpu_surface_software" ] + public_deps += [ "//flutter/shell/surface:software" ] } if (invoker.enable_gl) { - public_deps += [ "//flutter/shell/gpu:gpu_surface_gl" ] + public_deps += [ "//flutter/shell/surface:gl" ] } if (invoker.enable_vulkan) { - public_deps += [ "//flutter/shell/gpu:gpu_surface_vulkan" ] + public_deps += [ "//flutter/shell/surface:vulkan" ] } if (invoker.enable_metal) { - public_deps += [ "//flutter/shell/gpu:gpu_surface_metal" ] + public_deps += [ "//flutter/shell/surface:metal" ] } } diff --git a/shell/gpu/gpu_surface_gl_delegate.cc b/shell/surface/surface_gl_delegate.cc similarity index 80% rename from shell/gpu/gpu_surface_gl_delegate.cc rename to shell/surface/surface_gl_delegate.cc index 61631b028fc0f..840cf95c0494e 100644 --- a/shell/gpu/gpu_surface_gl_delegate.cc +++ b/shell/surface/surface_gl_delegate.cc @@ -2,7 +2,7 @@ // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. -#include "flutter/shell/gpu/gpu_surface_gl_delegate.h" +#include "flutter/shell/surface/surface_gl_delegate.h" #include "flutter/fml/build_config.h" @@ -29,32 +29,31 @@ namespace flutter { -GPUSurfaceGLDelegate::~GPUSurfaceGLDelegate() = default; +SurfaceGLDelegate::~SurfaceGLDelegate() = default; -bool GPUSurfaceGLDelegate::GLContextFBOResetAfterPresent() const { +bool SurfaceGLDelegate::GLContextFBOResetAfterPresent() const { return false; } -SurfaceFrame::FramebufferInfo GPUSurfaceGLDelegate::GLContextFramebufferInfo() +SurfaceFrame::FramebufferInfo SurfaceGLDelegate::GLContextFramebufferInfo() const { SurfaceFrame::FramebufferInfo res; res.supports_readback = true; return res; } -SkMatrix GPUSurfaceGLDelegate::GLContextSurfaceTransformation() const { +SkMatrix SurfaceGLDelegate::GLContextSurfaceTransformation() const { SkMatrix matrix; matrix.setIdentity(); return matrix; } -GPUSurfaceGLDelegate::GLProcResolver GPUSurfaceGLDelegate::GetGLProcResolver() - const { +SurfaceGLDelegate::GLProcResolver SurfaceGLDelegate::GetGLProcResolver() const { return nullptr; } static bool IsProcResolverOpenGLES( - const GPUSurfaceGLDelegate::GLProcResolver& proc_resolver) { + const SurfaceGLDelegate::GLProcResolver& proc_resolver) { // Version string prefix that identifies an OpenGL ES implementation. #define GPU_GL_VERSION 0x1F02 constexpr char kGLESVersionPrefix[] = "OpenGL ES"; @@ -81,7 +80,7 @@ static bool IsProcResolverOpenGLES( } static sk_sp CreateGLInterface( - const GPUSurfaceGLDelegate::GLProcResolver& proc_resolver) { + const SurfaceGLDelegate::GLProcResolver& proc_resolver) { if (proc_resolver == nullptr) { #if defined(FML_OS_ANDROID) return GrGLInterfaces::MakeEGL(); @@ -104,7 +103,7 @@ static sk_sp CreateGLInterface( } struct ProcResolverContext { - GPUSurfaceGLDelegate::GLProcResolver resolver; + SurfaceGLDelegate::GLProcResolver resolver; }; ProcResolverContext context = {proc_resolver}; @@ -131,16 +130,15 @@ static sk_sp CreateGLInterface( return nullptr; } -sk_sp GPUSurfaceGLDelegate::GetGLInterface() const { +sk_sp SurfaceGLDelegate::GetGLInterface() const { return CreateGLInterface(GetGLProcResolver()); } -sk_sp -GPUSurfaceGLDelegate::GetDefaultPlatformGLInterface() { +sk_sp SurfaceGLDelegate::GetDefaultPlatformGLInterface() { return CreateGLInterface(nullptr); } -bool GPUSurfaceGLDelegate::AllowsDrawingWhenGpuDisabled() const { +bool SurfaceGLDelegate::AllowsDrawingWhenGpuDisabled() const { return true; } diff --git a/shell/gpu/gpu_surface_gl_delegate.h b/shell/surface/surface_gl_delegate.h similarity index 94% rename from shell/gpu/gpu_surface_gl_delegate.h rename to shell/surface/surface_gl_delegate.h index 39a58e6a708a6..edde31799e324 100644 --- a/shell/gpu/gpu_surface_gl_delegate.h +++ b/shell/surface/surface_gl_delegate.h @@ -2,8 +2,8 @@ // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. -#ifndef FLUTTER_SHELL_GPU_GPU_SURFACE_GL_DELEGATE_H_ -#define FLUTTER_SHELL_GPU_GPU_SURFACE_GL_DELEGATE_H_ +#ifndef FLUTTER_SHELL_SURFACE_SURFACE_GL_DELEGATE_H_ +#define FLUTTER_SHELL_SURFACE_SURFACE_GL_DELEGATE_H_ #include @@ -48,9 +48,9 @@ struct GLPresentInfo { const std::optional& buffer_damage; }; -class GPUSurfaceGLDelegate { +class SurfaceGLDelegate { public: - ~GPUSurfaceGLDelegate(); + ~SurfaceGLDelegate(); // Called to make the main GL context current on the current thread. virtual std::unique_ptr GLContextMakeCurrent() = 0; @@ -108,4 +108,4 @@ class GPUSurfaceGLDelegate { } // namespace flutter -#endif // FLUTTER_SHELL_GPU_GPU_SURFACE_GL_DELEGATE_H_ +#endif // FLUTTER_SHELL_SURFACE_SURFACE_GL_DELEGATE_H_ diff --git a/shell/gpu/gpu_surface_gl_impeller.cc b/shell/surface/surface_gl_impeller.cc similarity index 85% rename from shell/gpu/gpu_surface_gl_impeller.cc rename to shell/surface/surface_gl_impeller.cc index b9f3f7ba1a5ff..4b2fc75102763 100644 --- a/shell/gpu/gpu_surface_gl_impeller.cc +++ b/shell/surface/surface_gl_impeller.cc @@ -2,7 +2,7 @@ // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. -#include "flutter/shell/gpu/gpu_surface_gl_impeller.h" +#include "flutter/shell/surface/surface_gl_impeller.h" #include "flutter/fml/make_copyable.h" #include "impeller/display_list/dl_dispatcher.h" @@ -11,10 +11,9 @@ namespace flutter { -GPUSurfaceGLImpeller::GPUSurfaceGLImpeller( - GPUSurfaceGLDelegate* delegate, - std::shared_ptr context, - bool render_to_surface) +SurfaceGLImpeller::SurfaceGLImpeller(SurfaceGLDelegate* delegate, + std::shared_ptr context, + bool render_to_surface) : weak_factory_(this) { if (delegate == nullptr) { return; @@ -39,15 +38,15 @@ GPUSurfaceGLImpeller::GPUSurfaceGLImpeller( } // |Surface| -GPUSurfaceGLImpeller::~GPUSurfaceGLImpeller() = default; +SurfaceGLImpeller::~SurfaceGLImpeller() = default; // |Surface| -bool GPUSurfaceGLImpeller::IsValid() { +bool SurfaceGLImpeller::IsValid() { return is_valid_; } // |Surface| -std::unique_ptr GPUSurfaceGLImpeller::AcquireFrame( +std::unique_ptr SurfaceGLImpeller::AcquireFrame( const SkISize& size) { if (!IsValid()) { FML_LOG(ERROR) << "OpenGL surface was invalid."; @@ -141,40 +140,39 @@ std::unique_ptr GPUSurfaceGLImpeller::AcquireFrame( } // |Surface| -SkMatrix GPUSurfaceGLImpeller::GetRootTransformation() const { +SkMatrix SurfaceGLImpeller::GetRootTransformation() const { // This backend does not currently support root surface transformations. Just // return identity. return {}; } // |Surface| -GrDirectContext* GPUSurfaceGLImpeller::GetContext() { +GrDirectContext* SurfaceGLImpeller::GetContext() { // Impeller != Skia. return nullptr; } // |Surface| -std::unique_ptr -GPUSurfaceGLImpeller::MakeRenderContextCurrent() { +std::unique_ptr SurfaceGLImpeller::MakeRenderContextCurrent() { return delegate_->GLContextMakeCurrent(); } // |Surface| -bool GPUSurfaceGLImpeller::ClearRenderContext() { +bool SurfaceGLImpeller::ClearRenderContext() { return delegate_->GLContextClearCurrent(); } -bool GPUSurfaceGLImpeller::AllowsDrawingWhenGpuDisabled() const { +bool SurfaceGLImpeller::AllowsDrawingWhenGpuDisabled() const { return delegate_->AllowsDrawingWhenGpuDisabled(); } // |Surface| -bool GPUSurfaceGLImpeller::EnableRasterCache() const { +bool SurfaceGLImpeller::EnableRasterCache() const { return false; } // |Surface| -std::shared_ptr GPUSurfaceGLImpeller::GetAiksContext() +std::shared_ptr SurfaceGLImpeller::GetAiksContext() const { return aiks_context_; } diff --git a/shell/gpu/gpu_surface_gl_impeller.h b/shell/surface/surface_gl_impeller.h similarity index 65% rename from shell/gpu/gpu_surface_gl_impeller.h rename to shell/surface/surface_gl_impeller.h index 5d6e63b1ad48e..7c484d4603c55 100644 --- a/shell/gpu/gpu_surface_gl_impeller.h +++ b/shell/surface/surface_gl_impeller.h @@ -2,8 +2,8 @@ // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. -#ifndef FLUTTER_SHELL_GPU_GPU_SURFACE_GL_IMPELLER_H_ -#define FLUTTER_SHELL_GPU_GPU_SURFACE_GL_IMPELLER_H_ +#ifndef FLUTTER_SHELL_SURFACE_SURFACE_GL_IMPELLER_H_ +#define FLUTTER_SHELL_SURFACE_SURFACE_GL_IMPELLER_H_ #include "flutter/common/graphics/gl_context_switch.h" #include "flutter/flow/surface.h" @@ -11,29 +11,29 @@ #include "flutter/fml/memory/weak_ptr.h" #include "flutter/impeller/aiks/aiks_context.h" #include "flutter/impeller/renderer/context.h" -#include "flutter/shell/gpu/gpu_surface_gl_delegate.h" +#include "flutter/shell/surface/surface_gl_delegate.h" namespace flutter { -class GPUSurfaceGLImpeller final : public Surface { +class SurfaceGLImpeller final : public Surface { public: - explicit GPUSurfaceGLImpeller(GPUSurfaceGLDelegate* delegate, - std::shared_ptr context, - bool render_to_surface); + explicit SurfaceGLImpeller(SurfaceGLDelegate* delegate, + std::shared_ptr context, + bool render_to_surface); // |Surface| - ~GPUSurfaceGLImpeller() override; + ~SurfaceGLImpeller() override; // |Surface| bool IsValid() override; private: - GPUSurfaceGLDelegate* delegate_ = nullptr; + SurfaceGLDelegate* delegate_ = nullptr; std::shared_ptr impeller_context_; bool render_to_surface_ = true; std::shared_ptr aiks_context_; bool is_valid_ = false; - fml::TaskRunnerAffineWeakPtrFactory weak_factory_; + fml::TaskRunnerAffineWeakPtrFactory weak_factory_; // |Surface| std::unique_ptr AcquireFrame(const SkISize& size) override; @@ -59,9 +59,9 @@ class GPUSurfaceGLImpeller final : public Surface { // |Surface| std::shared_ptr GetAiksContext() const override; - FML_DISALLOW_COPY_AND_ASSIGN(GPUSurfaceGLImpeller); + FML_DISALLOW_COPY_AND_ASSIGN(SurfaceGLImpeller); }; } // namespace flutter -#endif // FLUTTER_SHELL_GPU_GPU_SURFACE_GL_IMPELLER_H_ +#endif // FLUTTER_SHELL_SURFACE_SURFACE_GL_IMPELLER_H_ diff --git a/shell/gpu/gpu_surface_gl_skia.cc b/shell/surface/surface_gl_skia.cc similarity index 88% rename from shell/gpu/gpu_surface_gl_skia.cc rename to shell/surface/surface_gl_skia.cc index 04c708808e0a9..0484ebf014d4a 100644 --- a/shell/gpu/gpu_surface_gl_skia.cc +++ b/shell/surface/surface_gl_skia.cc @@ -2,7 +2,7 @@ // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. -#include "flutter/shell/gpu/gpu_surface_gl_skia.h" +#include "flutter/shell/surface/surface_gl_skia.h" #include "flutter/common/graphics/persistent_cache.h" #include "flutter/fml/base32.h" @@ -10,7 +10,7 @@ #include "flutter/fml/size.h" #include "flutter/fml/trace_event.h" #include "flutter/shell/common/context_options.h" -#include "flutter/shell/gpu/gpu_surface_gl_delegate.h" +#include "flutter/shell/surface/surface_gl_delegate.h" #include "third_party/skia/include/core/SkAlphaType.h" #include "third_party/skia/include/core/SkColorFilter.h" #include "third_party/skia/include/core/SkColorSpace.h" @@ -40,8 +40,8 @@ namespace flutter { // system channel. static const size_t kGrCacheMaxByteSize = 24 * (1 << 20); -sk_sp GPUSurfaceGLSkia::MakeGLContext( - GPUSurfaceGLDelegate* delegate) { +sk_sp SurfaceGLSkia::MakeGLContext( + SurfaceGLDelegate* delegate) { auto context_switch = delegate->GLContextMakeCurrent(); if (!context_switch->GetResult()) { FML_LOG(ERROR) @@ -66,15 +66,15 @@ sk_sp GPUSurfaceGLSkia::MakeGLContext( return context; } -GPUSurfaceGLSkia::GPUSurfaceGLSkia(GPUSurfaceGLDelegate* delegate, - bool render_to_surface) - : GPUSurfaceGLSkia(MakeGLContext(delegate), delegate, render_to_surface) { +SurfaceGLSkia::SurfaceGLSkia(SurfaceGLDelegate* delegate, + bool render_to_surface) + : SurfaceGLSkia(MakeGLContext(delegate), delegate, render_to_surface) { context_owner_ = true; } -GPUSurfaceGLSkia::GPUSurfaceGLSkia(const sk_sp& gr_context, - GPUSurfaceGLDelegate* delegate, - bool render_to_surface) +SurfaceGLSkia::SurfaceGLSkia(const sk_sp& gr_context, + SurfaceGLDelegate* delegate, + bool render_to_surface) : delegate_(delegate), context_(gr_context), @@ -92,7 +92,7 @@ GPUSurfaceGLSkia::GPUSurfaceGLSkia(const sk_sp& gr_context, valid_ = gr_context != nullptr; } -GPUSurfaceGLSkia::~GPUSurfaceGLSkia() { +SurfaceGLSkia::~SurfaceGLSkia() { if (!valid_) { return; } @@ -114,7 +114,7 @@ GPUSurfaceGLSkia::~GPUSurfaceGLSkia() { } // |Surface| -bool GPUSurfaceGLSkia::IsValid() { +bool SurfaceGLSkia::IsValid() { return valid_; } @@ -162,7 +162,7 @@ static sk_sp WrapOnscreenSurface(GrDirectContext* context, ); } -bool GPUSurfaceGLSkia::CreateOrUpdateSurfaces(const SkISize& size) { +bool SurfaceGLSkia::CreateOrUpdateSurfaces(const SkISize& size) { if (onscreen_surface_ != nullptr && size == SkISize::Make(onscreen_surface_->width(), onscreen_surface_->height())) { @@ -207,13 +207,12 @@ bool GPUSurfaceGLSkia::CreateOrUpdateSurfaces(const SkISize& size) { } // |Surface| -SkMatrix GPUSurfaceGLSkia::GetRootTransformation() const { +SkMatrix SurfaceGLSkia::GetRootTransformation() const { return delegate_->GLContextSurfaceTransformation(); } // |Surface| -std::unique_ptr GPUSurfaceGLSkia::AcquireFrame( - const SkISize& size) { +std::unique_ptr SurfaceGLSkia::AcquireFrame(const SkISize& size) { if (delegate_ == nullptr) { return nullptr; } @@ -263,8 +262,8 @@ std::unique_ptr GPUSurfaceGLSkia::AcquireFrame( std::move(context_switch)); } -bool GPUSurfaceGLSkia::PresentSurface(const SurfaceFrame& frame, - DlCanvas* canvas) { +bool SurfaceGLSkia::PresentSurface(const SurfaceFrame& frame, + DlCanvas* canvas) { if (delegate_ == nullptr || canvas == nullptr || context_ == nullptr) { return false; } @@ -314,7 +313,7 @@ bool GPUSurfaceGLSkia::PresentSurface(const SurfaceFrame& frame, return true; } -sk_sp GPUSurfaceGLSkia::AcquireRenderSurface( +sk_sp SurfaceGLSkia::AcquireRenderSurface( const SkISize& untransformed_size, const SkMatrix& root_surface_transformation) { const auto transformed_rect = root_surface_transformation.mapRect( @@ -331,22 +330,22 @@ sk_sp GPUSurfaceGLSkia::AcquireRenderSurface( } // |Surface| -GrDirectContext* GPUSurfaceGLSkia::GetContext() { +GrDirectContext* SurfaceGLSkia::GetContext() { return context_.get(); } // |Surface| -std::unique_ptr GPUSurfaceGLSkia::MakeRenderContextCurrent() { +std::unique_ptr SurfaceGLSkia::MakeRenderContextCurrent() { return delegate_->GLContextMakeCurrent(); } // |Surface| -bool GPUSurfaceGLSkia::ClearRenderContext() { +bool SurfaceGLSkia::ClearRenderContext() { return delegate_->GLContextClearCurrent(); } // |Surface| -bool GPUSurfaceGLSkia::AllowsDrawingWhenGpuDisabled() const { +bool SurfaceGLSkia::AllowsDrawingWhenGpuDisabled() const { return delegate_->AllowsDrawingWhenGpuDisabled(); } diff --git a/shell/gpu/gpu_surface_gl_skia.h b/shell/surface/surface_gl_skia.h similarity index 74% rename from shell/gpu/gpu_surface_gl_skia.h rename to shell/surface/surface_gl_skia.h index ae6cdaf52d13f..5875204787c2b 100644 --- a/shell/gpu/gpu_surface_gl_skia.h +++ b/shell/surface/surface_gl_skia.h @@ -2,8 +2,8 @@ // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. -#ifndef FLUTTER_SHELL_GPU_GPU_SURFACE_GL_SKIA_H_ -#define FLUTTER_SHELL_GPU_GPU_SURFACE_GL_SKIA_H_ +#ifndef FLUTTER_SHELL_SURFACE_SURFACE_GL_SKIA_H_ +#define FLUTTER_SHELL_SURFACE_SURFACE_GL_SKIA_H_ #include #include @@ -13,26 +13,26 @@ #include "flutter/flow/surface.h" #include "flutter/fml/macros.h" #include "flutter/fml/memory/weak_ptr.h" -#include "flutter/shell/gpu/gpu_surface_gl_delegate.h" +#include "flutter/shell/surface/surface_gl_delegate.h" #include "third_party/skia/include/core/SkSurface.h" #include "third_party/skia/include/gpu/GrDirectContext.h" namespace flutter { -class GPUSurfaceGLSkia : public Surface { +class SurfaceGLSkia : public Surface { public: - static sk_sp MakeGLContext(GPUSurfaceGLDelegate* delegate); + static sk_sp MakeGLContext(SurfaceGLDelegate* delegate); - GPUSurfaceGLSkia(GPUSurfaceGLDelegate* delegate, bool render_to_surface); + SurfaceGLSkia(SurfaceGLDelegate* delegate, bool render_to_surface); // Creates a new GL surface reusing an existing GrDirectContext. - GPUSurfaceGLSkia(const sk_sp& gr_context, - GPUSurfaceGLDelegate* delegate, - bool render_to_surface); + SurfaceGLSkia(const sk_sp& gr_context, + SurfaceGLDelegate* delegate, + bool render_to_surface); // |Surface| - ~GPUSurfaceGLSkia() override; + ~SurfaceGLSkia() override; // |Surface| bool IsValid() override; @@ -64,7 +64,7 @@ class GPUSurfaceGLSkia : public Surface { bool PresentSurface(const SurfaceFrame& frame, DlCanvas* canvas); - GPUSurfaceGLDelegate* delegate_; + SurfaceGLDelegate* delegate_; sk_sp context_; sk_sp onscreen_surface_; /// FBO backing the current `onscreen_surface_`. @@ -82,10 +82,10 @@ class GPUSurfaceGLSkia : public Surface { bool valid_ = false; // WeakPtrFactory must be the last member. - fml::TaskRunnerAffineWeakPtrFactory weak_factory_; - FML_DISALLOW_COPY_AND_ASSIGN(GPUSurfaceGLSkia); + fml::TaskRunnerAffineWeakPtrFactory weak_factory_; + FML_DISALLOW_COPY_AND_ASSIGN(SurfaceGLSkia); }; } // namespace flutter -#endif // FLUTTER_SHELL_GPU_GPU_SURFACE_GL_SKIA_H_ +#endif // FLUTTER_SHELL_SURFACE_SURFACE_GL_SKIA_H_ diff --git a/shell/gpu/gpu_surface_metal_delegate.cc b/shell/surface/surface_metal_delegate.cc similarity index 53% rename from shell/gpu/gpu_surface_metal_delegate.cc rename to shell/surface/surface_metal_delegate.cc index 7a22d8de88a89..6db21547500c8 100644 --- a/shell/gpu/gpu_surface_metal_delegate.cc +++ b/shell/surface/surface_metal_delegate.cc @@ -2,21 +2,21 @@ // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. -#include "flutter/shell/gpu/gpu_surface_metal_delegate.h" +#include "flutter/shell/surface/surface_metal_delegate.h" namespace flutter { -GPUSurfaceMetalDelegate::GPUSurfaceMetalDelegate( +SurfaceMetalDelegate::SurfaceMetalDelegate( MTLRenderTargetType render_target_type) : render_target_type_(render_target_type) {} -GPUSurfaceMetalDelegate::~GPUSurfaceMetalDelegate() = default; +SurfaceMetalDelegate::~SurfaceMetalDelegate() = default; -MTLRenderTargetType GPUSurfaceMetalDelegate::GetRenderTargetType() { +MTLRenderTargetType SurfaceMetalDelegate::GetRenderTargetType() { return render_target_type_; } -bool GPUSurfaceMetalDelegate::AllowsDrawingWhenGpuDisabled() const { +bool SurfaceMetalDelegate::AllowsDrawingWhenGpuDisabled() const { return true; } diff --git a/shell/gpu/gpu_surface_metal_delegate.h b/shell/surface/surface_metal_delegate.h similarity index 88% rename from shell/gpu/gpu_surface_metal_delegate.h rename to shell/surface/surface_metal_delegate.h index f20b0507231c9..5b46730809b0b 100644 --- a/shell/gpu/gpu_surface_metal_delegate.h +++ b/shell/surface/surface_metal_delegate.h @@ -2,8 +2,8 @@ // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. -#ifndef FLUTTER_SHELL_GPU_GPU_SURFACE_METAL_DELEGATE_H_ -#define FLUTTER_SHELL_GPU_GPU_SURFACE_METAL_DELEGATE_H_ +#ifndef FLUTTER_SHELL_SURFACE_SURFACE_METAL_DELEGATE_H_ +#define FLUTTER_SHELL_SURFACE_SURFACE_METAL_DELEGATE_H_ #include @@ -49,17 +49,17 @@ enum class MTLRenderTargetType { kMTLTexture, kCAMetalLayer }; /// /// @see |IOSurfaceMetal| and |EmbedderSurfaceMetal|. /// -class GPUSurfaceMetalDelegate { +class SurfaceMetalDelegate { public: //------------------------------------------------------------------------------ - /// @brief Construct a new GPUSurfaceMetalDelegate object with the specified + /// @brief Construct a new SurfaceMetalDelegate object with the specified /// render_target type. /// /// @see |MTLRenderTargetType| /// - explicit GPUSurfaceMetalDelegate(MTLRenderTargetType render_target); + explicit SurfaceMetalDelegate(MTLRenderTargetType render_target); - virtual ~GPUSurfaceMetalDelegate(); + virtual ~SurfaceMetalDelegate(); //------------------------------------------------------------------------------ /// @brief Returns the handle to the CAMetalLayer to render to. This is only @@ -73,7 +73,7 @@ class GPUSurfaceMetalDelegate { /// from the CAMetalLayer that given by `GetCAMetalLayer` call. This is only /// called when the specified render target type in `kCAMetalLayer`. /// - /// @see |GPUSurfaceMetalDelegate::GetCAMetalLayer| + /// @see |SurfaceMetalDelegate::GetCAMetalLayer| /// virtual bool PresentDrawable(GrMTLHandle drawable) const = 0; @@ -89,7 +89,7 @@ class GPUSurfaceMetalDelegate { /// call to `GetMTLTexture`. This is only called when the specified render /// target type is `kMTLTexture`. /// - /// @see |GPUSurfaceMetalDelegate::GetMTLTexture| + /// @see |SurfaceMetalDelegate::GetMTLTexture| /// virtual bool PresentTexture(GPUMTLTextureInfo texture) const = 0; @@ -106,4 +106,4 @@ class GPUSurfaceMetalDelegate { } // namespace flutter -#endif // FLUTTER_SHELL_GPU_GPU_SURFACE_METAL_DELEGATE_H_ +#endif // FLUTTER_SHELL_SURFACE_SURFACE_METAL_DELEGATE_H_ diff --git a/shell/gpu/gpu_surface_metal_impeller.h b/shell/surface/surface_metal_impeller.h similarity index 76% rename from shell/gpu/gpu_surface_metal_impeller.h rename to shell/surface/surface_metal_impeller.h index 58a269dee20c2..c92d20d793244 100644 --- a/shell/gpu/gpu_surface_metal_impeller.h +++ b/shell/surface/surface_metal_impeller.h @@ -2,8 +2,8 @@ // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. -#ifndef FLUTTER_SHELL_GPU_GPU_SURFACE_METAL_IMPELLER_H_ -#define FLUTTER_SHELL_GPU_GPU_SURFACE_METAL_IMPELLER_H_ +#ifndef FLUTTER_SHELL_SURFACE_SURFACE_METAL_IMPELLER_H_ +#define FLUTTER_SHELL_SURFACE_SURFACE_METAL_IMPELLER_H_ #include @@ -12,20 +12,19 @@ #include "flutter/fml/platform/darwin/scoped_nsobject.h" #include "flutter/impeller/aiks/aiks_context.h" #include "flutter/impeller/renderer/backend/metal/context_mtl.h" -#include "flutter/shell/gpu/gpu_surface_metal_delegate.h" +#include "flutter/shell/surface/surface_metal_delegate.h" #include "third_party/skia/include/gpu/ganesh/mtl/GrMtlTypes.h" namespace flutter { -class IMPELLER_CA_METAL_LAYER_AVAILABLE GPUSurfaceMetalImpeller - : public Surface { +class IMPELLER_CA_METAL_LAYER_AVAILABLE SurfaceMetalImpeller : public Surface { public: - GPUSurfaceMetalImpeller(GPUSurfaceMetalDelegate* delegate, - const std::shared_ptr& context, - bool render_to_surface = true); + SurfaceMetalImpeller(SurfaceMetalDelegate* delegate, + const std::shared_ptr& context, + bool render_to_surface = true); // |Surface| - ~GPUSurfaceMetalImpeller(); + ~SurfaceMetalImpeller(); // |Surface| bool IsValid() override; @@ -33,7 +32,7 @@ class IMPELLER_CA_METAL_LAYER_AVAILABLE GPUSurfaceMetalImpeller virtual Surface::SurfaceData GetSurfaceData() const override; private: - const GPUSurfaceMetalDelegate* delegate_; + const SurfaceMetalDelegate* delegate_; const MTLRenderTargetType render_target_type_; std::shared_ptr aiks_context_; fml::scoped_nsprotocol> last_texture_; @@ -76,9 +75,9 @@ class IMPELLER_CA_METAL_LAYER_AVAILABLE GPUSurfaceMetalImpeller // |Surface| std::shared_ptr GetAiksContext() const override; - FML_DISALLOW_COPY_AND_ASSIGN(GPUSurfaceMetalImpeller); + FML_DISALLOW_COPY_AND_ASSIGN(SurfaceMetalImpeller); }; } // namespace flutter -#endif // FLUTTER_SHELL_GPU_GPU_SURFACE_METAL_IMPELLER_H_ +#endif // FLUTTER_SHELL_SURFACE_SURFACE_METAL_IMPELLER_H_ diff --git a/shell/gpu/gpu_surface_metal_impeller.mm b/shell/surface/surface_metal_impeller.mm similarity index 92% rename from shell/gpu/gpu_surface_metal_impeller.mm rename to shell/surface/surface_metal_impeller.mm index 20c54bd307816..995647e5967f8 100644 --- a/shell/gpu/gpu_surface_metal_impeller.mm +++ b/shell/surface/surface_metal_impeller.mm @@ -2,7 +2,7 @@ // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. -#include "flutter/shell/gpu/gpu_surface_metal_impeller.h" +#include "flutter/shell/surface/surface_metal_impeller.h" #import #import @@ -19,9 +19,9 @@ namespace flutter { -GPUSurfaceMetalImpeller::GPUSurfaceMetalImpeller(GPUSurfaceMetalDelegate* delegate, - const std::shared_ptr& context, - bool render_to_surface) +SurfaceMetalImpeller::SurfaceMetalImpeller(SurfaceMetalDelegate* delegate, + const std::shared_ptr& context, + bool render_to_surface) : delegate_(delegate), render_target_type_(delegate->GetRenderTargetType()), aiks_context_( @@ -36,16 +36,16 @@ } } -GPUSurfaceMetalImpeller::~GPUSurfaceMetalImpeller() = default; +SurfaceMetalImpeller::~SurfaceMetalImpeller() = default; // |Surface| -bool GPUSurfaceMetalImpeller::IsValid() { +bool SurfaceMetalImpeller::IsValid() { return !!aiks_context_ && aiks_context_->IsValid(); } // |Surface| -std::unique_ptr GPUSurfaceMetalImpeller::AcquireFrame(const SkISize& frame_size) { - TRACE_EVENT0("impeller", "GPUSurfaceMetalImpeller::AcquireFrame"); +std::unique_ptr SurfaceMetalImpeller::AcquireFrame(const SkISize& frame_size) { + TRACE_EVENT0("impeller", "SurfaceMetalImpeller::AcquireFrame"); if (!IsValid()) { FML_LOG(ERROR) << "Metal surface was invalid."; @@ -75,7 +75,7 @@ return nullptr; } -std::unique_ptr GPUSurfaceMetalImpeller::AcquireFrameFromCAMetalLayer( +std::unique_ptr SurfaceMetalImpeller::AcquireFrameFromCAMetalLayer( const SkISize& frame_size) { auto layer = delegate_->GetCAMetalLayer(frame_size); @@ -208,7 +208,7 @@ ); } -std::unique_ptr GPUSurfaceMetalImpeller::AcquireFrameFromMTLTexture( +std::unique_ptr SurfaceMetalImpeller::AcquireFrameFromMTLTexture( const SkISize& frame_size) { GPUMTLTextureInfo texture_info = delegate_->GetMTLTexture(frame_size); id mtl_texture = (id)(texture_info.texture); @@ -330,38 +330,38 @@ } // |Surface| -SkMatrix GPUSurfaceMetalImpeller::GetRootTransformation() const { +SkMatrix SurfaceMetalImpeller::GetRootTransformation() const { // This backend does not currently support root surface transformations. Just // return identity. return {}; } // |Surface| -GrDirectContext* GPUSurfaceMetalImpeller::GetContext() { +GrDirectContext* SurfaceMetalImpeller::GetContext() { return nullptr; } // |Surface| -std::unique_ptr GPUSurfaceMetalImpeller::MakeRenderContextCurrent() { +std::unique_ptr SurfaceMetalImpeller::MakeRenderContextCurrent() { // This backend has no such concept. return std::make_unique(true); } -bool GPUSurfaceMetalImpeller::AllowsDrawingWhenGpuDisabled() const { +bool SurfaceMetalImpeller::AllowsDrawingWhenGpuDisabled() const { return delegate_->AllowsDrawingWhenGpuDisabled(); } // |Surface| -bool GPUSurfaceMetalImpeller::EnableRasterCache() const { +bool SurfaceMetalImpeller::EnableRasterCache() const { return false; } // |Surface| -std::shared_ptr GPUSurfaceMetalImpeller::GetAiksContext() const { +std::shared_ptr SurfaceMetalImpeller::GetAiksContext() const { return aiks_context_; } -Surface::SurfaceData GPUSurfaceMetalImpeller::GetSurfaceData() const { +Surface::SurfaceData SurfaceMetalImpeller::GetSurfaceData() const { if (!(last_texture_ && [last_texture_ conformsToProtocol:@protocol(MTLTexture)])) { return {}; } diff --git a/shell/gpu/gpu_surface_metal_impeller_unittests.mm b/shell/surface/surface_metal_impeller_unittests.mm similarity index 71% rename from shell/gpu/gpu_surface_metal_impeller_unittests.mm rename to shell/surface/surface_metal_impeller_unittests.mm index a5927ff035783..71c1e12a830a9 100644 --- a/shell/gpu/gpu_surface_metal_impeller_unittests.mm +++ b/shell/surface/surface_metal_impeller_unittests.mm @@ -5,7 +5,7 @@ #include #include -#include "flutter/shell/gpu/gpu_surface_metal_impeller.h" +#include "flutter/shell/surface/surface_metal_impeller.h" #include "gtest/gtest.h" #include "impeller/entity/mtl/entity_shaders.h" #include "impeller/entity/mtl/framebuffer_blend_shaders.h" @@ -15,13 +15,13 @@ namespace flutter { namespace testing { -class TestGPUSurfaceMetalDelegate : public GPUSurfaceMetalDelegate { +class TestSurfaceMetalDelegate : public SurfaceMetalDelegate { public: - TestGPUSurfaceMetalDelegate() : GPUSurfaceMetalDelegate(MTLRenderTargetType::kCAMetalLayer) { + TestSurfaceMetalDelegate() : SurfaceMetalDelegate(MTLRenderTargetType::kCAMetalLayer) { layer_ = [[CAMetalLayer alloc] init]; } - ~TestGPUSurfaceMetalDelegate() = default; + ~TestSurfaceMetalDelegate() = default; GPUCAMetalLayerHandle GetCAMetalLayer(const SkISize& frame_info) const override { layer_.drawableSize = CGSizeMake(frame_info.width(), frame_info.height()); @@ -55,24 +55,24 @@ GPUCAMetalLayerHandle GetCAMetalLayer(const SkISize& frame_info) const override return impeller::ContextMTL::Create(shader_mappings, sync_switch, "Impeller Library"); } -TEST(GPUSurfaceMetalImpeller, InvalidImpellerContextCreatesCausesSurfaceToBeInvalid) { - auto delegate = std::make_shared(); - auto surface = std::make_shared(delegate.get(), nullptr); +TEST(SurfaceMetalImpeller, InvalidImpellerContextCreatesCausesSurfaceToBeInvalid) { + auto delegate = std::make_shared(); + auto surface = std::make_shared(delegate.get(), nullptr); ASSERT_FALSE(surface->IsValid()); } -TEST(GPUSurfaceMetalImpeller, CanCreateValidSurface) { - auto delegate = std::make_shared(); - auto surface = std::make_shared(delegate.get(), CreateImpellerContext()); +TEST(SurfaceMetalImpeller, CanCreateValidSurface) { + auto delegate = std::make_shared(); + auto surface = std::make_shared(delegate.get(), CreateImpellerContext()); ASSERT_TRUE(surface->IsValid()); } -TEST(GPUSurfaceMetalImpeller, AcquireFrameFromCAMetalLayerNullChecksDrawable) { - auto delegate = std::make_shared(); +TEST(SurfaceMetalImpeller, AcquireFrameFromCAMetalLayerNullChecksDrawable) { + auto delegate = std::make_shared(); std::shared_ptr surface = - std::make_shared(delegate.get(), CreateImpellerContext()); + std::make_shared(delegate.get(), CreateImpellerContext()); ASSERT_TRUE(surface->IsValid()); @@ -80,11 +80,11 @@ GPUCAMetalLayerHandle GetCAMetalLayer(const SkISize& frame_info) const override ASSERT_EQ(frame, nullptr); } -TEST(GPUSurfaceMetalImpeller, AcquireFrameFromCAMetalLayerDoesNotRetainThis) { - auto delegate = std::make_shared(); +TEST(SurfaceMetalImpeller, AcquireFrameFromCAMetalLayerDoesNotRetainThis) { + auto delegate = std::make_shared(); delegate->SetDevice(); std::unique_ptr surface = - std::make_unique(delegate.get(), CreateImpellerContext()); + std::make_unique(delegate.get(), CreateImpellerContext()); ASSERT_TRUE(surface->IsValid()); @@ -97,13 +97,13 @@ GPUCAMetalLayerHandle GetCAMetalLayer(const SkISize& frame_info) const override ASSERT_TRUE(frame->Submit()); } -TEST(GPUSurfaceMetalImpeller, ResetHostBufferBasedOnFrameBoundary) { - auto delegate = std::make_shared(); +TEST(SurfaceMetalImpeller, ResetHostBufferBasedOnFrameBoundary) { + auto delegate = std::make_shared(); delegate->SetDevice(); auto context = CreateImpellerContext(); std::unique_ptr surface = - std::make_unique(delegate.get(), context); + std::make_unique(delegate.get(), context); ASSERT_TRUE(surface->IsValid()); @@ -125,8 +125,8 @@ GPUCAMetalLayerHandle GetCAMetalLayer(const SkISize& frame_info) const override } #ifdef IMPELLER_DEBUG -TEST(GPUSurfaceMetalImpeller, CreatesImpellerCaptureScope) { - auto delegate = std::make_shared(); +TEST(SurfaceMetalImpeller, CreatesImpellerCaptureScope) { + auto delegate = std::make_shared(); delegate->SetDevice(); auto context = CreateImpellerContext(); @@ -134,14 +134,14 @@ GPUCAMetalLayerHandle GetCAMetalLayer(const SkISize& frame_info) const override EXPECT_FALSE(context->GetCaptureManager()->CaptureScopeActive()); std::unique_ptr surface = - std::make_unique(delegate.get(), 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(), 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/gpu/gpu_surface_metal_skia.h b/shell/surface/surface_metal_skia.h similarity index 74% rename from shell/gpu/gpu_surface_metal_skia.h rename to shell/surface/surface_metal_skia.h index ab7ec9512fe70..2dd962b181002 100644 --- a/shell/gpu/gpu_surface_metal_skia.h +++ b/shell/surface/surface_metal_skia.h @@ -2,32 +2,32 @@ // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. -#ifndef FLUTTER_SHELL_GPU_GPU_SURFACE_METAL_SKIA_H_ -#define FLUTTER_SHELL_GPU_GPU_SURFACE_METAL_SKIA_H_ +#ifndef FLUTTER_SHELL_SURFACE_SURFACE_METAL_SKIA_H_ +#define FLUTTER_SHELL_SURFACE_SURFACE_METAL_SKIA_H_ #if !SLIMPELLER #include "flutter/flow/surface.h" #include "flutter/fml/macros.h" -#include "flutter/shell/gpu/gpu_surface_metal_delegate.h" +#include "flutter/shell/surface/surface_metal_delegate.h" #include "third_party/skia/include/gpu/GrDirectContext.h" namespace flutter { -class SK_API_AVAILABLE_CA_METAL_LAYER GPUSurfaceMetalSkia : public Surface { +class SK_API_AVAILABLE_CA_METAL_LAYER SurfaceMetalSkia : public Surface { public: - GPUSurfaceMetalSkia(GPUSurfaceMetalDelegate* delegate, - sk_sp context, - bool render_to_surface = true); + SurfaceMetalSkia(SurfaceMetalDelegate* delegate, + sk_sp context, + bool render_to_surface = true); // |Surface| - ~GPUSurfaceMetalSkia(); + ~SurfaceMetalSkia(); // |Surface| bool IsValid() override; private: - const GPUSurfaceMetalDelegate* delegate_; + const SurfaceMetalDelegate* delegate_; const MTLRenderTargetType render_target_type_; sk_sp context_; GrDirectContext* precompiled_sksl_context_ = nullptr; @@ -65,11 +65,11 @@ class SK_API_AVAILABLE_CA_METAL_LAYER GPUSurfaceMetalSkia : public Surface { void PrecompileKnownSkSLsIfNecessary(); - FML_DISALLOW_COPY_AND_ASSIGN(GPUSurfaceMetalSkia); + FML_DISALLOW_COPY_AND_ASSIGN(SurfaceMetalSkia); }; } // namespace flutter #endif // !SLIMPELLER -#endif // FLUTTER_SHELL_GPU_GPU_SURFACE_METAL_SKIA_H_ +#endif // FLUTTER_SHELL_SURFACE_SURFACE_METAL_SKIA_H_ diff --git a/shell/gpu/gpu_surface_metal_skia.mm b/shell/surface/surface_metal_skia.mm similarity index 90% rename from shell/gpu/gpu_surface_metal_skia.mm rename to shell/surface/surface_metal_skia.mm index c945c8894a70c..7a301bc920545 100644 --- a/shell/gpu/gpu_surface_metal_skia.mm +++ b/shell/surface/surface_metal_skia.mm @@ -4,7 +4,7 @@ #if !SLIMPELLER -#include "flutter/shell/gpu/gpu_surface_metal_skia.h" +#include "flutter/shell/surface/surface_metal_skia.h" #import #import @@ -16,7 +16,7 @@ #include "flutter/fml/platform/darwin/cf_utils.h" #include "flutter/fml/platform/darwin/scoped_nsobject.h" #include "flutter/fml/trace_event.h" -#include "flutter/shell/gpu/gpu_surface_metal_delegate.h" +#include "flutter/shell/surface/surface_metal_delegate.h" #include "third_party/skia/include/core/SkCanvas.h" #include "third_party/skia/include/core/SkColorSpace.h" #include "third_party/skia/include/core/SkColorType.h" @@ -56,9 +56,9 @@ } } // namespace -GPUSurfaceMetalSkia::GPUSurfaceMetalSkia(GPUSurfaceMetalDelegate* delegate, - sk_sp context, - bool render_to_surface) +SurfaceMetalSkia::SurfaceMetalSkia(SurfaceMetalDelegate* delegate, + sk_sp context, + bool render_to_surface) : delegate_(delegate), render_target_type_(delegate->GetRenderTargetType()), context_(std::move(context)), @@ -71,14 +71,14 @@ } } -GPUSurfaceMetalSkia::~GPUSurfaceMetalSkia() = default; +SurfaceMetalSkia::~SurfaceMetalSkia() = default; // |Surface| -bool GPUSurfaceMetalSkia::IsValid() { +bool SurfaceMetalSkia::IsValid() { return context_ != nullptr; } -void GPUSurfaceMetalSkia::PrecompileKnownSkSLsIfNecessary() { +void SurfaceMetalSkia::PrecompileKnownSkSLsIfNecessary() { auto* current_context = GetContext(); if (current_context == precompiled_sksl_context_) { // Known SkSLs have already been prepared in this context. @@ -89,7 +89,7 @@ } // |Surface| -std::unique_ptr GPUSurfaceMetalSkia::AcquireFrame(const SkISize& frame_size) { +std::unique_ptr SurfaceMetalSkia::AcquireFrame(const SkISize& frame_size) { if (!IsValid()) { FML_LOG(ERROR) << "Metal surface was invalid."; return nullptr; @@ -120,7 +120,7 @@ return nullptr; } -std::unique_ptr GPUSurfaceMetalSkia::AcquireFrameFromCAMetalLayer( +std::unique_ptr SurfaceMetalSkia::AcquireFrameFromCAMetalLayer( const SkISize& frame_info) { auto layer = delegate_->GetCAMetalLayer(frame_info); if (!layer) { @@ -200,7 +200,7 @@ frame_info); } -std::unique_ptr GPUSurfaceMetalSkia::AcquireFrameFromMTLTexture( +std::unique_ptr SurfaceMetalSkia::AcquireFrameFromMTLTexture( const SkISize& frame_info) { GPUMTLTextureInfo texture = delegate_->GetMTLTexture(frame_info); id mtl_texture = (id)(texture.texture); @@ -244,19 +244,19 @@ } // |Surface| -SkMatrix GPUSurfaceMetalSkia::GetRootTransformation() const { +SkMatrix SurfaceMetalSkia::GetRootTransformation() const { // This backend does not currently support root surface transformations. Just // return identity. return {}; } // |Surface| -GrDirectContext* GPUSurfaceMetalSkia::GetContext() { +GrDirectContext* SurfaceMetalSkia::GetContext() { return context_.get(); } // |Surface| -std::unique_ptr GPUSurfaceMetalSkia::MakeRenderContextCurrent() { +std::unique_ptr SurfaceMetalSkia::MakeRenderContextCurrent() { // A context may either be necessary to render to the surface or to snapshot an offscreen // surface. Either way, SkSL precompilation must be attempted. PrecompileKnownSkSLsIfNecessary(); @@ -265,7 +265,7 @@ return std::make_unique(true); } -bool GPUSurfaceMetalSkia::AllowsDrawingWhenGpuDisabled() const { +bool SurfaceMetalSkia::AllowsDrawingWhenGpuDisabled() const { return delegate_->AllowsDrawingWhenGpuDisabled(); } diff --git a/shell/gpu/gpu_surface_software.cc b/shell/surface/surface_software.cc similarity index 84% rename from shell/gpu/gpu_surface_software.cc rename to shell/surface/surface_software.cc index efb905ba24ecb..a976d058ab655 100644 --- a/shell/gpu/gpu_surface_software.cc +++ b/shell/surface/surface_software.cc @@ -2,7 +2,7 @@ // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. -#include "flutter/shell/gpu/gpu_surface_software.h" +#include "flutter/shell/surface/surface_software.h" #include @@ -12,21 +12,21 @@ namespace flutter { -GPUSurfaceSoftware::GPUSurfaceSoftware(GPUSurfaceSoftwareDelegate* delegate, - bool render_to_surface) +SurfaceSoftware::SurfaceSoftware(SurfaceSoftwareDelegate* delegate, + bool render_to_surface) : delegate_(delegate), render_to_surface_(render_to_surface), weak_factory_(this) {} -GPUSurfaceSoftware::~GPUSurfaceSoftware() = default; +SurfaceSoftware::~SurfaceSoftware() = default; // |Surface| -bool GPUSurfaceSoftware::IsValid() { +bool SurfaceSoftware::IsValid() { return delegate_ != nullptr; } // |Surface| -std::unique_ptr GPUSurfaceSoftware::AcquireFrame( +std::unique_ptr SurfaceSoftware::AcquireFrame( const SkISize& logical_size) { SurfaceFrame::FramebufferInfo framebuffer_info; framebuffer_info.supports_readback = true; @@ -82,7 +82,7 @@ std::unique_ptr GPUSurfaceSoftware::AcquireFrame( } // |Surface| -SkMatrix GPUSurfaceSoftware::GetRootTransformation() const { +SkMatrix SurfaceSoftware::GetRootTransformation() const { // This backend does not currently support root surface transformations. Just // return identity. SkMatrix matrix; @@ -91,7 +91,7 @@ SkMatrix GPUSurfaceSoftware::GetRootTransformation() const { } // |Surface| -GrDirectContext* GPUSurfaceSoftware::GetContext() { +GrDirectContext* SurfaceSoftware::GetContext() { // There is no GrContext associated with a software surface. return nullptr; } diff --git a/shell/gpu/gpu_surface_software.h b/shell/surface/surface_software.h similarity index 61% rename from shell/gpu/gpu_surface_software.h rename to shell/surface/surface_software.h index 18bc8d5b41446..dd62468b882c1 100644 --- a/shell/gpu/gpu_surface_software.h +++ b/shell/surface/surface_software.h @@ -2,22 +2,21 @@ // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. -#ifndef FLUTTER_SHELL_GPU_GPU_SURFACE_SOFTWARE_H_ -#define FLUTTER_SHELL_GPU_GPU_SURFACE_SOFTWARE_H_ +#ifndef FLUTTER_SHELL_SURFACE_SURFACE_SOFTWARE_H_ +#define FLUTTER_SHELL_SURFACE_SURFACE_SOFTWARE_H_ #include "flutter/flow/surface.h" #include "flutter/fml/macros.h" #include "flutter/fml/memory/weak_ptr.h" -#include "flutter/shell/gpu/gpu_surface_software_delegate.h" +#include "flutter/shell/surface/surface_software_delegate.h" namespace flutter { -class GPUSurfaceSoftware : public Surface { +class SurfaceSoftware : public Surface { public: - GPUSurfaceSoftware(GPUSurfaceSoftwareDelegate* delegate, - bool render_to_surface); + SurfaceSoftware(SurfaceSoftwareDelegate* delegate, bool render_to_surface); - ~GPUSurfaceSoftware() override; + ~SurfaceSoftware() override; // |Surface| bool IsValid() override; @@ -32,16 +31,16 @@ class GPUSurfaceSoftware : public Surface { GrDirectContext* GetContext() override; private: - GPUSurfaceSoftwareDelegate* delegate_; + SurfaceSoftwareDelegate* delegate_; // TODO(38466): Refactor GPU surface APIs take into account the fact that an // external view embedder may want to render to the root surface. This is a // hack to make avoid allocating resources for the root surface when an // external view embedder is present. const bool render_to_surface_; - fml::TaskRunnerAffineWeakPtrFactory weak_factory_; - FML_DISALLOW_COPY_AND_ASSIGN(GPUSurfaceSoftware); + fml::TaskRunnerAffineWeakPtrFactory weak_factory_; + FML_DISALLOW_COPY_AND_ASSIGN(SurfaceSoftware); }; } // namespace flutter -#endif // FLUTTER_SHELL_GPU_GPU_SURFACE_SOFTWARE_H_ +#endif // FLUTTER_SHELL_SURFACE_SURFACE_SOFTWARE_H_ diff --git a/shell/gpu/gpu_surface_vulkan_delegate.cc b/shell/surface/surface_software_delegate.cc similarity index 63% rename from shell/gpu/gpu_surface_vulkan_delegate.cc rename to shell/surface/surface_software_delegate.cc index 3e64ad702279c..2827fa5060e3f 100644 --- a/shell/gpu/gpu_surface_vulkan_delegate.cc +++ b/shell/surface/surface_software_delegate.cc @@ -2,10 +2,10 @@ // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. -#include "flutter/shell/gpu/gpu_surface_vulkan_delegate.h" +#include "flutter/shell/surface/surface_software_delegate.h" namespace flutter { -GPUSurfaceVulkanDelegate::~GPUSurfaceVulkanDelegate() = default; +SurfaceSoftwareDelegate::~SurfaceSoftwareDelegate() = default; } // namespace flutter diff --git a/shell/gpu/gpu_surface_software_delegate.h b/shell/surface/surface_software_delegate.h similarity index 89% rename from shell/gpu/gpu_surface_software_delegate.h rename to shell/surface/surface_software_delegate.h index e46f4ec0f1f13..d0c468e8d6ce2 100644 --- a/shell/gpu/gpu_surface_software_delegate.h +++ b/shell/surface/surface_software_delegate.h @@ -2,8 +2,8 @@ // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. -#ifndef FLUTTER_SHELL_GPU_GPU_SURFACE_SOFTWARE_DELEGATE_H_ -#define FLUTTER_SHELL_GPU_GPU_SURFACE_SOFTWARE_DELEGATE_H_ +#ifndef FLUTTER_SHELL_SURFACE_SURFACE_SOFTWARE_DELEGATE_H_ +#define FLUTTER_SHELL_SURFACE_SURFACE_SOFTWARE_DELEGATE_H_ #include "flutter/flow/embedded_views.h" #include "flutter/fml/macros.h" @@ -24,9 +24,9 @@ namespace flutter { /// @see |IOSSurfaceSoftware|, |AndroidSurfaceSoftware|, /// |EmbedderSurfaceSoftware|. /// -class GPUSurfaceSoftwareDelegate { +class SurfaceSoftwareDelegate { public: - ~GPUSurfaceSoftwareDelegate(); + ~SurfaceSoftwareDelegate(); //---------------------------------------------------------------------------- /// @brief Called when the GPU surface needs a new buffer to render a new @@ -52,4 +52,4 @@ class GPUSurfaceSoftwareDelegate { } // namespace flutter -#endif // FLUTTER_SHELL_GPU_GPU_SURFACE_SOFTWARE_DELEGATE_H_ +#endif // FLUTTER_SHELL_SURFACE_SURFACE_SOFTWARE_DELEGATE_H_ diff --git a/shell/gpu/gpu_surface_vulkan.cc b/shell/surface/surface_vulkan.cc similarity index 85% rename from shell/gpu/gpu_surface_vulkan.cc rename to shell/surface/surface_vulkan.cc index 63f1359722c17..5499a3417aaac 100644 --- a/shell/gpu/gpu_surface_vulkan.cc +++ b/shell/surface/surface_vulkan.cc @@ -2,7 +2,7 @@ // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. -#include "flutter/shell/gpu/gpu_surface_vulkan.h" +#include "flutter/shell/surface/surface_vulkan.h" #include "flutter/fml/logging.h" #include "flutter/fml/trace_event.h" @@ -18,21 +18,21 @@ namespace flutter { -GPUSurfaceVulkan::GPUSurfaceVulkan(GPUSurfaceVulkanDelegate* delegate, - const sk_sp& skia_context, - bool render_to_surface) +SurfaceVulkan::SurfaceVulkan(SurfaceVulkanDelegate* delegate, + const sk_sp& skia_context, + bool render_to_surface) : delegate_(delegate), skia_context_(skia_context), render_to_surface_(render_to_surface), weak_factory_(this) {} -GPUSurfaceVulkan::~GPUSurfaceVulkan() = default; +SurfaceVulkan::~SurfaceVulkan() = default; -bool GPUSurfaceVulkan::IsValid() { +bool SurfaceVulkan::IsValid() { return skia_context_ != nullptr; } -std::unique_ptr GPUSurfaceVulkan::AcquireFrame( +std::unique_ptr SurfaceVulkan::AcquireFrame( const SkISize& frame_size) { if (!IsValid()) { FML_LOG(ERROR) << "Vulkan surface was invalid."; @@ -70,7 +70,7 @@ std::unique_ptr GPUSurfaceVulkan::AcquireFrame( SurfaceFrame::SubmitCallback callback = [image = image, delegate = delegate_]( const SurfaceFrame&, DlCanvas* canvas) -> bool { - TRACE_EVENT0("flutter", "GPUSurfaceVulkan::PresentImage"); + TRACE_EVENT0("flutter", "SurfaceVulkan::PresentImage"); if (canvas == nullptr) { FML_DLOG(ERROR) << "Canvas not available."; return false; @@ -88,7 +88,7 @@ std::unique_ptr GPUSurfaceVulkan::AcquireFrame( std::move(callback), frame_size); } -SkMatrix GPUSurfaceVulkan::GetRootTransformation() const { +SkMatrix SurfaceVulkan::GetRootTransformation() const { // This backend does not support delegating to the underlying platform to // query for root surface transformations. Just return identity. SkMatrix matrix; @@ -96,11 +96,11 @@ SkMatrix GPUSurfaceVulkan::GetRootTransformation() const { return matrix; } -GrDirectContext* GPUSurfaceVulkan::GetContext() { +GrDirectContext* SurfaceVulkan::GetContext() { return skia_context_.get(); } -sk_sp GPUSurfaceVulkan::CreateSurfaceFromVulkanImage( +sk_sp SurfaceVulkan::CreateSurfaceFromVulkanImage( const VkImage image, const VkFormat format, const SkISize& size) { @@ -136,7 +136,7 @@ sk_sp GPUSurfaceVulkan::CreateSurfaceFromVulkanImage( #endif // SK_VULKAN } -SkColorType GPUSurfaceVulkan::ColorTypeFromFormat(const VkFormat format) { +SkColorType SurfaceVulkan::ColorTypeFromFormat(const VkFormat format) { switch (format) { case VK_FORMAT_R8G8B8A8_UNORM: case VK_FORMAT_R8G8B8A8_SRGB: diff --git a/shell/gpu/gpu_surface_vulkan.h b/shell/surface/surface_vulkan.h similarity index 65% rename from shell/gpu/gpu_surface_vulkan.h rename to shell/surface/surface_vulkan.h index 69da9500393d1..f778852dc93c7 100644 --- a/shell/gpu/gpu_surface_vulkan.h +++ b/shell/surface/surface_vulkan.h @@ -2,15 +2,15 @@ // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. -#ifndef FLUTTER_SHELL_GPU_GPU_SURFACE_VULKAN_H_ -#define FLUTTER_SHELL_GPU_GPU_SURFACE_VULKAN_H_ +#ifndef FLUTTER_SHELL_SURFACE_SURFACE_VULKAN_H_ +#define FLUTTER_SHELL_SURFACE_SURFACE_VULKAN_H_ #include #include "flutter/flow/surface.h" #include "flutter/fml/macros.h" #include "flutter/fml/memory/weak_ptr.h" -#include "flutter/shell/gpu/gpu_surface_vulkan_delegate.h" +#include "flutter/shell/surface/surface_vulkan_delegate.h" #include "flutter/vulkan/vulkan_backbuffer.h" #include "flutter/vulkan/vulkan_native_surface.h" #include "flutter/vulkan/vulkan_window.h" @@ -22,19 +22,22 @@ namespace flutter { //------------------------------------------------------------------------------ /// @brief A GPU surface backed by VkImages provided by a -/// GPUSurfaceVulkanDelegate. +/// SurfaceVulkanDelegate. /// -class GPUSurfaceVulkan : public Surface { +/// A user of this approach is the embedder API supporting Vulkan +/// embedders. +/// +class SurfaceVulkan : public Surface { public: //------------------------------------------------------------------------------ - /// @brief Create a GPUSurfaceVulkan while letting it reuse an existing + /// @brief Create a SurfaceVulkan while letting it reuse an existing /// GrDirectContext. /// - GPUSurfaceVulkan(GPUSurfaceVulkanDelegate* delegate, - const sk_sp& context, - bool render_to_surface); + SurfaceVulkan(SurfaceVulkanDelegate* delegate, + const sk_sp& context, + bool render_to_surface); - ~GPUSurfaceVulkan() override; + ~SurfaceVulkan() override; // |Surface| bool IsValid() override; @@ -51,19 +54,19 @@ class GPUSurfaceVulkan : public Surface { static SkColorType ColorTypeFromFormat(const VkFormat format); private: - GPUSurfaceVulkanDelegate* delegate_; + SurfaceVulkanDelegate* delegate_; sk_sp skia_context_; bool render_to_surface_; - fml::WeakPtrFactory weak_factory_; + fml::WeakPtrFactory weak_factory_; sk_sp CreateSurfaceFromVulkanImage(const VkImage image, const VkFormat format, const SkISize& size); - FML_DISALLOW_COPY_AND_ASSIGN(GPUSurfaceVulkan); + FML_DISALLOW_COPY_AND_ASSIGN(SurfaceVulkan); }; } // namespace flutter -#endif // FLUTTER_SHELL_GPU_GPU_SURFACE_VULKAN_H_ +#endif // FLUTTER_SHELL_SURFACE_SURFACE_VULKAN_H_ diff --git a/shell/gpu/gpu_surface_software_delegate.cc b/shell/surface/surface_vulkan_delegate.cc similarity index 61% rename from shell/gpu/gpu_surface_software_delegate.cc rename to shell/surface/surface_vulkan_delegate.cc index 9bc6d8b98fea7..423547c88d3c2 100644 --- a/shell/gpu/gpu_surface_software_delegate.cc +++ b/shell/surface/surface_vulkan_delegate.cc @@ -2,10 +2,10 @@ // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. -#include "flutter/shell/gpu/gpu_surface_software_delegate.h" +#include "flutter/shell/surface/surface_vulkan_delegate.h" namespace flutter { -GPUSurfaceSoftwareDelegate::~GPUSurfaceSoftwareDelegate() = default; +SurfaceVulkanDelegate::~SurfaceVulkanDelegate() = default; } // namespace flutter diff --git a/shell/gpu/gpu_surface_vulkan_delegate.h b/shell/surface/surface_vulkan_delegate.h similarity index 87% rename from shell/gpu/gpu_surface_vulkan_delegate.h rename to shell/surface/surface_vulkan_delegate.h index 2a95f0a613b51..8fa667896d4b8 100644 --- a/shell/gpu/gpu_surface_vulkan_delegate.h +++ b/shell/surface/surface_vulkan_delegate.h @@ -2,8 +2,8 @@ // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. -#ifndef FLUTTER_SHELL_GPU_GPU_SURFACE_VULKAN_DELEGATE_H_ -#define FLUTTER_SHELL_GPU_GPU_SURFACE_VULKAN_DELEGATE_H_ +#ifndef FLUTTER_SHELL_SURFACE_SURFACE_VULKAN_DELEGATE_H_ +#define FLUTTER_SHELL_SURFACE_SURFACE_VULKAN_DELEGATE_H_ #include "flutter/fml/memory/ref_ptr.h" #include "flutter/shell/platform/embedder/embedder.h" @@ -26,9 +26,9 @@ namespace flutter { /// /// @see |EmbedderSurfaceVulkan|. /// -class GPUSurfaceVulkanDelegate { +class SurfaceVulkanDelegate { public: - virtual ~GPUSurfaceVulkanDelegate(); + virtual ~SurfaceVulkanDelegate(); /// @brief Obtain a reference to the Vulkan implementation's proc table. /// @@ -47,4 +47,4 @@ class GPUSurfaceVulkanDelegate { } // namespace flutter -#endif // FLUTTER_SHELL_GPU_GPU_SURFACE_VULKAN_DELEGATE_H_ +#endif // FLUTTER_SHELL_SURFACE_SURFACE_VULKAN_DELEGATE_H_ diff --git a/shell/gpu/gpu_surface_vulkan_impeller.cc b/shell/surface/surface_vulkan_impeller.cc similarity index 87% rename from shell/gpu/gpu_surface_vulkan_impeller.cc rename to shell/surface/surface_vulkan_impeller.cc index 7393a8c731042..d1c0f71a4bed7 100644 --- a/shell/gpu/gpu_surface_vulkan_impeller.cc +++ b/shell/surface/surface_vulkan_impeller.cc @@ -2,7 +2,7 @@ // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. -#include "flutter/shell/gpu/gpu_surface_vulkan_impeller.h" +#include "flutter/shell/surface/surface_vulkan_impeller.h" #include "flutter/fml/make_copyable.h" #include "impeller/display_list/dl_dispatcher.h" @@ -12,7 +12,7 @@ namespace flutter { -GPUSurfaceVulkanImpeller::GPUSurfaceVulkanImpeller( +SurfaceVulkanImpeller::SurfaceVulkanImpeller( std::shared_ptr context) { if (!context || !context->IsValid()) { return; @@ -30,15 +30,15 @@ GPUSurfaceVulkanImpeller::GPUSurfaceVulkanImpeller( } // |Surface| -GPUSurfaceVulkanImpeller::~GPUSurfaceVulkanImpeller() = default; +SurfaceVulkanImpeller::~SurfaceVulkanImpeller() = default; // |Surface| -bool GPUSurfaceVulkanImpeller::IsValid() { +bool SurfaceVulkanImpeller::IsValid() { return is_valid_; } // |Surface| -std::unique_ptr GPUSurfaceVulkanImpeller::AcquireFrame( +std::unique_ptr SurfaceVulkanImpeller::AcquireFrame( const SkISize& size) { if (!IsValid()) { FML_LOG(ERROR) << "Vulkan surface was invalid."; @@ -123,33 +123,33 @@ std::unique_ptr GPUSurfaceVulkanImpeller::AcquireFrame( } // |Surface| -SkMatrix GPUSurfaceVulkanImpeller::GetRootTransformation() const { +SkMatrix SurfaceVulkanImpeller::GetRootTransformation() const { // This backend does not currently support root surface transformations. Just // return identity. return {}; } // |Surface| -GrDirectContext* GPUSurfaceVulkanImpeller::GetContext() { +GrDirectContext* SurfaceVulkanImpeller::GetContext() { // Impeller != Skia. return nullptr; } // |Surface| std::unique_ptr -GPUSurfaceVulkanImpeller::MakeRenderContextCurrent() { +SurfaceVulkanImpeller::MakeRenderContextCurrent() { // This backend has no such concept. return std::make_unique(true); } // |Surface| -bool GPUSurfaceVulkanImpeller::EnableRasterCache() const { +bool SurfaceVulkanImpeller::EnableRasterCache() const { return false; } // |Surface| -std::shared_ptr -GPUSurfaceVulkanImpeller::GetAiksContext() const { +std::shared_ptr SurfaceVulkanImpeller::GetAiksContext() + const { return aiks_context_; } diff --git a/shell/gpu/gpu_surface_vulkan_impeller.h b/shell/surface/surface_vulkan_impeller.h similarity index 71% rename from shell/gpu/gpu_surface_vulkan_impeller.h rename to shell/surface/surface_vulkan_impeller.h index 06f3bf37f4876..e24b26d716fdd 100644 --- a/shell/gpu/gpu_surface_vulkan_impeller.h +++ b/shell/surface/surface_vulkan_impeller.h @@ -2,8 +2,8 @@ // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. -#ifndef FLUTTER_SHELL_GPU_GPU_SURFACE_VULKAN_IMPELLER_H_ -#define FLUTTER_SHELL_GPU_GPU_SURFACE_VULKAN_IMPELLER_H_ +#ifndef FLUTTER_SHELL_SURFACE_SURFACE_VULKAN_IMPELLER_H_ +#define FLUTTER_SHELL_SURFACE_SURFACE_VULKAN_IMPELLER_H_ #include "flutter/common/graphics/gl_context_switch.h" #include "flutter/flow/surface.h" @@ -11,16 +11,16 @@ #include "flutter/fml/memory/weak_ptr.h" #include "flutter/impeller/aiks/aiks_context.h" #include "flutter/impeller/renderer/context.h" -#include "flutter/shell/gpu/gpu_surface_vulkan_delegate.h" +#include "flutter/shell/surface/surface_vulkan_delegate.h" namespace flutter { -class GPUSurfaceVulkanImpeller final : public Surface { +class SurfaceVulkanImpeller final : public Surface { public: - explicit GPUSurfaceVulkanImpeller(std::shared_ptr context); + explicit SurfaceVulkanImpeller(std::shared_ptr context); // |Surface| - ~GPUSurfaceVulkanImpeller() override; + ~SurfaceVulkanImpeller() override; // |Surface| bool IsValid() override; @@ -48,9 +48,9 @@ class GPUSurfaceVulkanImpeller final : public Surface { // |Surface| std::shared_ptr GetAiksContext() const override; - FML_DISALLOW_COPY_AND_ASSIGN(GPUSurfaceVulkanImpeller); + FML_DISALLOW_COPY_AND_ASSIGN(SurfaceVulkanImpeller); }; } // namespace flutter -#endif // FLUTTER_SHELL_GPU_GPU_SURFACE_VULKAN_IMPELLER_H_ +#endif // FLUTTER_SHELL_SURFACE_SURFACE_VULKAN_IMPELLER_H_ diff --git a/shell/testing/BUILD.gn b/shell/testing/BUILD.gn index 28a19c75d1bb9..db95a76d0f9ce 100644 --- a/shell/testing/BUILD.gn +++ b/shell/testing/BUILD.gn @@ -3,13 +3,13 @@ # found in the LICENSE file. import("//flutter/impeller/tools/impeller.gni") -import("//flutter/shell/gpu/gpu.gni") +import("//flutter/shell/surface/surface.gni") if (is_fuchsia) { import("//flutter/tools/fuchsia/gn-sdk/src/gn_configs.gni") } -shell_gpu_configuration("tester_gpu_configuration") { +surface_configuration("tester_surface_configuration") { enable_software = true enable_gl = true enable_vulkan = true @@ -44,7 +44,7 @@ executable("testing") { "//flutter/fml", "//flutter/lib/snapshot", "//flutter/shell/common", - "//flutter/shell/gpu:gpu_surface_software", + "//flutter/shell/surface:software", "//flutter/skia", "//flutter/third_party/abseil-cpp/absl/base:no_destructor", "//flutter/third_party/tonic", @@ -52,7 +52,7 @@ executable("testing") { if (impeller_supports_rendering) { deps += [ - ":tester_gpu_configuration", + ":tester_surface_configuration", "//flutter/impeller", "//flutter/third_party/swiftshader/src/Vulkan:swiftshader_libvulkan_static", ] diff --git a/shell/testing/tester_main.cc b/shell/testing/tester_main.cc index b9a8b19b88840..163d8c0938f3f 100644 --- a/shell/testing/tester_main.cc +++ b/shell/testing/tester_main.cc @@ -23,7 +23,7 @@ #include "flutter/shell/common/shell.h" #include "flutter/shell/common/switches.h" #include "flutter/shell/common/thread_host.h" -#include "flutter/shell/gpu/gpu_surface_software.h" +#include "flutter/shell/surface/surface_software.h" #include "flutter/third_party/abseil-cpp/absl/base/no_destructor.h" #include "third_party/dart/runtime/include/bin/dart_io_api.h" @@ -42,7 +42,7 @@ #include "impeller/renderer/backend/vulkan/surface_context_vk.h" // nogncheck #include "impeller/renderer/context.h" // nogncheck #include "impeller/renderer/vk/compute_shaders_vk.h" // nogncheck -#include "shell/gpu/gpu_surface_vulkan_impeller.h" // nogncheck +#include "shell/surface/surface_vulkan_impeller.h" // nogncheck #if IMPELLER_ENABLE_3D #include "impeller/scene/shaders/vk/scene_shaders_vk.h" // nogncheck #endif // IMPELLER_ENABLE_3D @@ -176,17 +176,16 @@ class TesterExternalViewEmbedder : public ExternalViewEmbedder { DisplayListBuilder builder_; }; -class TesterGPUSurfaceSoftware : public GPUSurfaceSoftware { +class TesterSurfaceSoftware : public SurfaceSoftware { public: - TesterGPUSurfaceSoftware(GPUSurfaceSoftwareDelegate* delegate, - bool render_to_surface) - : GPUSurfaceSoftware(delegate, render_to_surface) {} + TesterSurfaceSoftware(SurfaceSoftwareDelegate* delegate, + bool render_to_surface) + : SurfaceSoftware(delegate, render_to_surface) {} bool EnableRasterCache() const override { return false; } }; -class TesterPlatformView : public PlatformView, - public GPUSurfaceSoftwareDelegate { +class TesterPlatformView : public PlatformView, public SurfaceSoftwareDelegate { public: TesterPlatformView(Delegate& delegate, const TaskRunners& task_runners, @@ -217,19 +216,19 @@ class TesterPlatformView : public PlatformView, #if ALLOW_IMPELLER if (delegate_.OnPlatformViewGetSettings().enable_impeller) { FML_DCHECK(impeller_context_holder_.context); - auto surface = std::make_unique( + auto surface = std::make_unique( impeller_context_holder_.surface_context); FML_DCHECK(surface->IsValid()); return surface; } #endif // ALLOW_IMPELLER - auto surface = std::make_unique( + auto surface = std::make_unique( this, true /* render to surface */); FML_DCHECK(surface->IsValid()); return surface; } - // |GPUSurfaceSoftwareDelegate| + // |SurfaceSoftwareDelegate| sk_sp AcquireBackingStore(const SkISize& size) override { if (sk_surface_ != nullptr && SkISize::Make(sk_surface_->width(), sk_surface_->height()) == size) { @@ -251,7 +250,7 @@ class TesterPlatformView : public PlatformView, return sk_surface_; } - // |GPUSurfaceSoftwareDelegate| + // |SurfaceSoftwareDelegate| bool PresentBackingStore(sk_sp backing_store) override { return true; }