-
Notifications
You must be signed in to change notification settings - Fork 6k
Move renderer config to EmbedderTestContext #56699
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -8,7 +8,6 @@ | |
| #include "flutter/runtime/dart_vm.h" | ||
| #include "flutter/shell/platform/embedder/embedder.h" | ||
| #include "tests/embedder_test_context.h" | ||
| #include "third_party/skia/include/core/SkBitmap.h" | ||
| #include "third_party/skia/include/core/SkImage.h" | ||
|
|
||
| namespace flutter::testing { | ||
|
|
@@ -27,28 +26,6 @@ EmbedderConfigBuilder::EmbedderConfigBuilder( | |
|
|
||
| custom_task_runners_.struct_size = sizeof(FlutterCustomTaskRunners); | ||
|
|
||
| InitializeGLRendererConfig(); | ||
| InitializeMetalRendererConfig(); | ||
| InitializeVulkanRendererConfig(); | ||
|
Member
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. The initialise methods above (and the similar software renderer config initialisation below) moved to ctors of |
||
|
|
||
| software_renderer_config_.struct_size = sizeof(FlutterSoftwareRendererConfig); | ||
| software_renderer_config_.surface_present_callback = | ||
| [](void* context, const void* allocation, size_t row_bytes, | ||
| size_t height) { | ||
| auto image_info = | ||
| SkImageInfo::MakeN32Premul(SkISize::Make(row_bytes / 4, height)); | ||
| SkBitmap bitmap; | ||
| if (!bitmap.installPixels(image_info, const_cast<void*>(allocation), | ||
| row_bytes)) { | ||
| FML_LOG(ERROR) << "Could not copy pixels for the software " | ||
| "composition from the engine."; | ||
| return false; | ||
| } | ||
| bitmap.setImmutable(); | ||
| return reinterpret_cast<EmbedderTestContextSoftware*>(context)->Present( | ||
| SkImages::RasterFromBitmap(bitmap)); | ||
| }; | ||
|
|
||
| // The first argument is always the executable name. Don't make tests have to | ||
| // do this manually. | ||
| AddCommandLineArgument("embedder_unittest"); | ||
|
|
@@ -79,30 +56,6 @@ FlutterProjectArgs& EmbedderConfigBuilder::GetProjectArgs() { | |
| return project_args_; | ||
| } | ||
|
|
||
| void EmbedderConfigBuilder::SetSoftwareRendererConfig(SkISize surface_size) { | ||
| renderer_config_.type = FlutterRendererType::kSoftware; | ||
| renderer_config_.software = software_renderer_config_; | ||
| context_.SetupSurface(surface_size); | ||
| } | ||
|
|
||
| void EmbedderConfigBuilder::SetRendererConfig(EmbedderTestContextType type, | ||
| SkISize surface_size) { | ||
| switch (type) { | ||
| case EmbedderTestContextType::kOpenGLContext: | ||
| SetOpenGLRendererConfig(surface_size); | ||
| break; | ||
| case EmbedderTestContextType::kMetalContext: | ||
| SetMetalRendererConfig(surface_size); | ||
| break; | ||
| case EmbedderTestContextType::kVulkanContext: | ||
| SetVulkanRendererConfig(surface_size); | ||
| break; | ||
| case EmbedderTestContextType::kSoftwareContext: | ||
| SetSoftwareRendererConfig(surface_size); | ||
| break; | ||
| } | ||
| } | ||
|
Member
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. No need for for the |
||
|
|
||
| void EmbedderConfigBuilder::SetAssetsPath() { | ||
| project_args_.assets_path = context_.GetAssetsPath().c_str(); | ||
| } | ||
|
|
@@ -217,10 +170,6 @@ void EmbedderConfigBuilder::SetupVsyncCallback() { | |
| }; | ||
| } | ||
|
|
||
| FlutterRendererConfig& EmbedderConfigBuilder::GetRendererConfig() { | ||
| return renderer_config_; | ||
| } | ||
|
Member
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Unloved and unused now. |
||
|
|
||
| void EmbedderConfigBuilder::SetRenderTaskRunner( | ||
| const FlutterTaskRunnerDescription* runner) { | ||
| if (runner == nullptr) { | ||
|
|
@@ -336,11 +285,12 @@ UniqueEngine EmbedderConfigBuilder::SetupEngine(bool run) const { | |
| project_args.dart_entrypoint_argc = 0; | ||
| } | ||
|
|
||
| auto result = | ||
| run ? FlutterEngineRun(FLUTTER_ENGINE_VERSION, &renderer_config_, | ||
| &project_args, &context_, &engine) | ||
| : FlutterEngineInitialize(FLUTTER_ENGINE_VERSION, &renderer_config_, | ||
| &project_args, &context_, &engine); | ||
| auto result = run ? FlutterEngineRun(FLUTTER_ENGINE_VERSION, | ||
| &context_.GetRendererConfig(), | ||
| &project_args, &context_, &engine) | ||
| : FlutterEngineInitialize( | ||
| FLUTTER_ENGINE_VERSION, &context_.GetRendererConfig(), | ||
| &project_args, &context_, &engine); | ||
|
|
||
| if (result != kSuccess) { | ||
| return {}; | ||
|
|
@@ -349,52 +299,4 @@ UniqueEngine EmbedderConfigBuilder::SetupEngine(bool run) const { | |
| return UniqueEngine{engine}; | ||
| } | ||
|
|
||
| #ifndef SHELL_ENABLE_GL | ||
|
Member
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Everything below here are just methods on the appropriate |
||
| // OpenGL fallback implementations. | ||
| // See: flutter/shell/platform/embedder/tests/embedder_config_builder_gl.cc. | ||
|
|
||
| void EmbedderConfigBuilder::InitializeGLRendererConfig() { | ||
| // no-op. | ||
| } | ||
|
|
||
| void EmbedderConfigBuilder::SetOpenGLFBOCallBack() { | ||
| FML_LOG(FATAL) << "OpenGL is not enabled in this build."; | ||
| } | ||
|
|
||
| void EmbedderConfigBuilder::SetOpenGLPresentCallBack() { | ||
| FML_LOG(FATAL) << "OpenGL is not enabled in this build."; | ||
| } | ||
|
|
||
| void EmbedderConfigBuilder::SetOpenGLRendererConfig(SkISize surface_size) { | ||
| FML_LOG(FATAL) << "OpenGL is not enabled in this build."; | ||
| } | ||
| #endif | ||
| #ifndef SHELL_ENABLE_METAL | ||
| // Metal fallback implementations. | ||
| // See: flutter/shell/platform/embedder/tests/embedder_config_builder_metal.mm. | ||
|
|
||
| void EmbedderConfigBuilder::InitializeMetalRendererConfig() { | ||
| // no-op. | ||
| } | ||
|
|
||
| void EmbedderConfigBuilder::SetMetalRendererConfig(SkISize surface_size) { | ||
| FML_LOG(FATAL) << "Metal is not enabled in this build."; | ||
| } | ||
| #endif | ||
| #ifndef SHELL_ENABLE_VULKAN | ||
| // Vulkan fallback implementations. | ||
| // See: flutter/shell/platform/embedder/tests/embedder_config_builder_vulkan.cc. | ||
|
|
||
| void EmbedderConfigBuilder::InitializeVulkanRendererConfig() { | ||
| // no-op. | ||
| } | ||
|
|
||
| void EmbedderConfigBuilder::SetVulkanRendererConfig( | ||
| SkISize surface_size, | ||
| std::optional<FlutterVulkanInstanceProcAddressCallback> | ||
| instance_proc_address_callback) { | ||
| FML_LOG(FATAL) << "Vulkan is not enabled in this build."; | ||
| } | ||
| #endif | ||
|
|
||
| } // namespace flutter::testing | ||
This file was deleted.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Here and below
(1, 1)was the default parameter value... but we only ever defaulted it for the software renderer, now we're consistent across the board and make people announce what they want so readers don't need to check the method declaration.