This repository was archived by the owner on Feb 25, 2025. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 6k
[Impeller] Add support to embedder for Impeller on GL (via Angle on Windows). #43388
Merged
Merged
Changes from all commits
Commits
Show all changes
32 commits
Select commit
Hold shift + click to select a range
a21ab76
[Impeller] support Impeller via GL/Angle on Windows.
24fca1c
++
b3d8c6c
+
f6cc626
++
e7c5f34
++
a52ea8e
fix order.
cbe8472
++
fbd4bae
formatting
2e9efed
Merge branch 'main' of github.com:flutter/engine into windows
58f9309
Merge branch 'main' of github.com:flutter/engine into windows
26bc607
fix window resize
f260393
configure windows engine based on impeller usage.
e35a5bf
++
a08c222
try this for testing.
8ce0237
++
efa76a9
++
578a965
++
b77fed1
Update flutter_windows_engine.cc
ecbf4f6
++
7527b3c
++
ba686e2
Merge branch 'windows' of github.com:jonahwilliams/engine into windows
e90dca3
dnfield review
8f907a6
comment fix
2cf3013
Add dep
4e1670e
Add missing deps
cc357c3
fix #if macro
f4a52fb
++
17025c6
++
264b474
++
6ae81d6
++
9dc60c2
++
705cf7a
++
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -64,9 +64,20 @@ extern const intptr_t kPlatformStrongDillSize; | |
| #include "rapidjson/rapidjson.h" | ||
| #include "rapidjson/writer.h" | ||
|
|
||
| // Note: the IMPELLER_SUPPORTS_RENDERING may be defined even when the | ||
| // embedder/BUILD.gn variable impeller_supports_rendering is disabled. | ||
| #ifdef SHELL_ENABLE_GL | ||
| #include "flutter/shell/platform/embedder/embedder_external_texture_gl.h" | ||
| #endif | ||
| #ifdef IMPELLER_SUPPORTS_RENDERING | ||
| #include "flutter/shell/platform/embedder/embedder_render_target_impeller.h" // nogncheck | ||
| #include "flutter/shell/platform/embedder/embedder_surface_gl_impeller.h" // nogncheck | ||
| #include "impeller/core/texture.h" // nogncheck | ||
| #include "impeller/renderer/backend/gles/context_gles.h" // nogncheck | ||
| #include "impeller/renderer/backend/gles/texture_gles.h" // nogncheck | ||
| #include "impeller/renderer/context.h" // nogncheck | ||
| #include "impeller/renderer/render_target.h" // nogncheck | ||
|
Comment on lines
+72
to
+78
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. Why are these nognchecked? 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. Pushing up a change to remove these to see what complains |
||
| #endif // IMPELLER_SUPPORTS_RENDERING | ||
| #endif // SHELL_ENABLE_GL | ||
|
|
||
| #ifdef SHELL_ENABLE_METAL | ||
| #include "flutter/shell/platform/embedder/embedder_surface_metal.h" | ||
|
|
@@ -265,7 +276,8 @@ InferOpenGLPlatformViewCreationCallback( | |
| const flutter::PlatformViewEmbedder::PlatformDispatchTable& | ||
| platform_dispatch_table, | ||
| std::unique_ptr<flutter::EmbedderExternalViewEmbedder> | ||
| external_view_embedder) { | ||
| external_view_embedder, | ||
| bool enable_impeller) { | ||
| #ifdef SHELL_ENABLE_GL | ||
| if (config->type != kOpenGL) { | ||
| return nullptr; | ||
|
|
@@ -441,15 +453,30 @@ InferOpenGLPlatformViewCreationCallback( | |
|
|
||
| return fml::MakeCopyable( | ||
| [gl_dispatch_table, fbo_reset_after_present, platform_dispatch_table, | ||
| enable_impeller, | ||
| external_view_embedder = | ||
| std::move(external_view_embedder)](flutter::Shell& shell) mutable { | ||
| std::shared_ptr<flutter::EmbedderExternalViewEmbedder> view_embedder = | ||
| std::move(external_view_embedder); | ||
| if (enable_impeller) { | ||
| return std::make_unique<flutter::PlatformViewEmbedder>( | ||
| shell, // delegate | ||
| shell.GetTaskRunners(), // task runners | ||
| std::make_unique<flutter::EmbedderSurfaceGLImpeller>( | ||
| gl_dispatch_table, fbo_reset_after_present, | ||
| view_embedder), // embedder_surface | ||
| platform_dispatch_table, // embedder platform dispatch table | ||
| view_embedder // external view embedder | ||
| ); | ||
| } | ||
| return std::make_unique<flutter::PlatformViewEmbedder>( | ||
| shell, // delegate | ||
| shell.GetTaskRunners(), // task runners | ||
| gl_dispatch_table, // embedder GL dispatch table | ||
| fbo_reset_after_present, // fbo reset after present | ||
| shell, // delegate | ||
| shell.GetTaskRunners(), // task runners | ||
| std::make_unique<flutter::EmbedderSurfaceGL>( | ||
| gl_dispatch_table, fbo_reset_after_present, | ||
| view_embedder), // embedder_surface | ||
| platform_dispatch_table, // embedder platform dispatch table | ||
| std::move(external_view_embedder) // external view embedder | ||
| view_embedder // external view embedder | ||
| ); | ||
| }); | ||
| #else | ||
|
|
@@ -686,7 +713,7 @@ InferPlatformViewCreationCallback( | |
| case kOpenGL: | ||
| return InferOpenGLPlatformViewCreationCallback( | ||
| config, user_data, platform_dispatch_table, | ||
| std::move(external_view_embedder)); | ||
| std::move(external_view_embedder), enable_impeller); | ||
| case kSoftware: | ||
| return InferSoftwarePlatformViewCreationCallback( | ||
| config, user_data, platform_dispatch_table, | ||
|
|
@@ -924,6 +951,66 @@ static sk_sp<SkSurface> MakeSkSurfaceFromBackingStore( | |
| #endif | ||
| } | ||
|
|
||
| static std::unique_ptr<flutter::EmbedderRenderTarget> | ||
| MakeRenderTargetFromBackingStoreImpeller( | ||
| FlutterBackingStore backing_store, | ||
| const fml::closure& on_release, | ||
| const std::shared_ptr<impeller::AiksContext>& aiks_context, | ||
| const FlutterBackingStoreConfig& config, | ||
| const FlutterOpenGLFramebuffer* framebuffer) { | ||
| #if defined(SHELL_ENABLE_GL) && defined(IMPELLER_SUPPORTS_RENDERING) | ||
|
|
||
| const auto& gl_context = | ||
| impeller::ContextGLES::Cast(*aiks_context->GetContext()); | ||
| const auto size = impeller::ISize(config.size.width, config.size.height); | ||
|
|
||
| impeller::TextureDescriptor color0_tex; | ||
| color0_tex.type = impeller::TextureType::kTexture2D; | ||
| color0_tex.format = impeller::PixelFormat::kR8G8B8A8UNormInt; | ||
| color0_tex.size = size; | ||
| color0_tex.usage = static_cast<impeller::TextureUsageMask>( | ||
| impeller::TextureUsage::kRenderTarget); | ||
| color0_tex.sample_count = impeller::SampleCount::kCount1; | ||
| color0_tex.storage_mode = impeller::StorageMode::kDevicePrivate; | ||
|
|
||
| impeller::ColorAttachment color0; | ||
| color0.texture = std::make_shared<impeller::TextureGLES>( | ||
| gl_context.GetReactor(), color0_tex, | ||
| impeller::TextureGLES::IsWrapped::kWrapped); | ||
| color0.clear_color = impeller::Color::DarkSlateGray(); | ||
| color0.load_action = impeller::LoadAction::kClear; | ||
| color0.store_action = impeller::StoreAction::kStore; | ||
|
|
||
| impeller::TextureDescriptor stencil0_tex; | ||
| stencil0_tex.type = impeller::TextureType::kTexture2D; | ||
| stencil0_tex.format = impeller::PixelFormat::kR8G8B8A8UNormInt; | ||
| stencil0_tex.size = size; | ||
| stencil0_tex.usage = static_cast<impeller::TextureUsageMask>( | ||
| impeller::TextureUsage::kRenderTarget); | ||
| stencil0_tex.sample_count = impeller::SampleCount::kCount1; | ||
|
|
||
| impeller::StencilAttachment stencil0; | ||
| stencil0.clear_stencil = 0; | ||
| stencil0.texture = std::make_shared<impeller::TextureGLES>( | ||
| gl_context.GetReactor(), stencil0_tex, | ||
| impeller::TextureGLES::IsWrapped::kWrapped); | ||
| stencil0.load_action = impeller::LoadAction::kClear; | ||
| stencil0.store_action = impeller::StoreAction::kDontCare; | ||
|
|
||
| impeller::RenderTarget render_target_desc; | ||
|
|
||
| render_target_desc.SetColorAttachment(color0, framebuffer->target); | ||
| render_target_desc.SetStencilAttachment(stencil0); | ||
|
|
||
| return std::make_unique<flutter::EmbedderRenderTargetImpeller>( | ||
| backing_store, aiks_context, | ||
| std::make_unique<impeller::RenderTarget>(std::move(render_target_desc)), | ||
| on_release); | ||
| #else | ||
| return nullptr; | ||
| #endif | ||
| } | ||
|
|
||
| static std::unique_ptr<flutter::EmbedderRenderTarget> | ||
| MakeRenderTargetFromBackingStoreImpeller( | ||
| FlutterBackingStore backing_store, | ||
|
|
@@ -1113,12 +1200,19 @@ CreateEmbedderRenderTarget( | |
| break; | ||
| } | ||
| case kFlutterOpenGLTargetTypeFramebuffer: { | ||
| auto skia_surface = MakeSkSurfaceFromBackingStore( | ||
| context, config, &backing_store.open_gl.framebuffer); | ||
| render_target = MakeRenderTargetFromSkSurface( | ||
| backing_store, std::move(skia_surface), | ||
| collect_callback.Release()); | ||
| break; | ||
| if (enable_impeller) { | ||
| render_target = MakeRenderTargetFromBackingStoreImpeller( | ||
| backing_store, collect_callback.Release(), aiks_context, config, | ||
| &backing_store.open_gl.framebuffer); | ||
| break; | ||
| } else { | ||
| auto skia_surface = MakeSkSurfaceFromBackingStore( | ||
| context, config, &backing_store.open_gl.framebuffer); | ||
| render_target = MakeRenderTargetFromSkSurface( | ||
| backing_store, std::move(skia_surface), | ||
| collect_callback.Release()); | ||
| break; | ||
| } | ||
| } | ||
| } | ||
| break; | ||
|
|
||
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
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.
Adding this is enough to get window resizing working.