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] Ensure that overlay surfaces are constructed with wide gamut settings. #48190
Merged
Merged
Changes from all commits
Commits
Show all changes
16 commits
Select commit
Hold shift + click to select a range
4ce1db5
[Impeller] dont blit onto wide gamut surface.
55272b4
add excluded file.
5beac1e
overlay views should have same pixel format as original view.
4d2a209
++
98c7c7e
++
f63e4d5
Update FlutterPlatformViews.mm
8010349
Update FlutterPlatformViews.mm
075e579
Update FlutterOverlayView.mm
a9a7a9c
++
6dd77e6
no temp
17b4c29
release
97a732e
Merge branch 'main' into fix_wide_gamut_blit
98b553f
++
0e9c87d
Merge branch 'fix_wide_gamut_blit' of github.com:jonahwilliams/engine…
d98696a
review.
6d89959
remove extra ivar
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
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,77 @@ | ||
| // Copyright 2013 The Flutter Authors. All rights reserved. | ||
| // Use of this source code is governed by a BSD-style license that can be | ||
| // found in the LICENSE file. | ||
|
|
||
| #include "gtest/gtest.h" | ||
| #include "impeller/base/validation.h" | ||
| #include "impeller/core/formats.h" | ||
| #include "impeller/core/texture_descriptor.h" | ||
| #include "impeller/playground/playground_test.h" | ||
| #include "impeller/renderer/command_buffer.h" | ||
|
|
||
| namespace impeller { | ||
| namespace testing { | ||
|
|
||
| using BlitPassTest = PlaygroundTest; | ||
| INSTANTIATE_PLAYGROUND_SUITE(BlitPassTest); | ||
|
|
||
| TEST_P(BlitPassTest, BlitAcrossDifferentPixelFormatsFails) { | ||
| ScopedValidationDisable scope; // avoid noise in output. | ||
| auto context = GetContext(); | ||
| auto cmd_buffer = context->CreateCommandBuffer(); | ||
| auto blit_pass = cmd_buffer->CreateBlitPass(); | ||
|
|
||
| TextureDescriptor src_desc; | ||
| src_desc.format = PixelFormat::kA8UNormInt; | ||
| src_desc.size = {100, 100}; | ||
| auto src = context->GetResourceAllocator()->CreateTexture(src_desc); | ||
|
|
||
| TextureDescriptor dst_format; | ||
| dst_format.format = PixelFormat::kR8G8B8A8UNormInt; | ||
| dst_format.size = {100, 100}; | ||
| auto dst = context->GetResourceAllocator()->CreateTexture(dst_format); | ||
|
|
||
| EXPECT_FALSE(blit_pass->AddCopy(src, dst)); | ||
gaaclarke marked this conversation as resolved.
Show resolved
Hide resolved
|
||
| } | ||
|
|
||
| TEST_P(BlitPassTest, BlitAcrossDifferentSampleCountsFails) { | ||
| ScopedValidationDisable scope; // avoid noise in output. | ||
| auto context = GetContext(); | ||
| auto cmd_buffer = context->CreateCommandBuffer(); | ||
| auto blit_pass = cmd_buffer->CreateBlitPass(); | ||
|
|
||
| TextureDescriptor src_desc; | ||
| src_desc.format = PixelFormat::kR8G8B8A8UNormInt; | ||
| src_desc.sample_count = SampleCount::kCount4; | ||
| src_desc.size = {100, 100}; | ||
| auto src = context->GetResourceAllocator()->CreateTexture(src_desc); | ||
|
|
||
| TextureDescriptor dst_format; | ||
| dst_format.format = PixelFormat::kR8G8B8A8UNormInt; | ||
| dst_format.size = {100, 100}; | ||
| auto dst = context->GetResourceAllocator()->CreateTexture(dst_format); | ||
|
|
||
| EXPECT_FALSE(blit_pass->AddCopy(src, dst)); | ||
| } | ||
|
|
||
| TEST_P(BlitPassTest, BlitPassesForMatchingFormats) { | ||
| ScopedValidationDisable scope; // avoid noise in output. | ||
| auto context = GetContext(); | ||
| auto cmd_buffer = context->CreateCommandBuffer(); | ||
| auto blit_pass = cmd_buffer->CreateBlitPass(); | ||
|
|
||
| TextureDescriptor src_desc; | ||
| src_desc.format = PixelFormat::kR8G8B8A8UNormInt; | ||
| src_desc.size = {100, 100}; | ||
| auto src = context->GetResourceAllocator()->CreateTexture(src_desc); | ||
|
|
||
| TextureDescriptor dst_format; | ||
| dst_format.format = PixelFormat::kR8G8B8A8UNormInt; | ||
| dst_format.size = {100, 100}; | ||
| auto dst = context->GetResourceAllocator()->CreateTexture(dst_format); | ||
|
|
||
| EXPECT_TRUE(blit_pass->AddCopy(src, dst)); | ||
| } | ||
|
|
||
| } // namespace testing | ||
| } // namespace impeller | ||
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 |
|---|---|---|
|
|
@@ -2,6 +2,7 @@ | |
| // Use of this source code is governed by a BSD-style license that can be | ||
| // found in the LICENSE file. | ||
|
|
||
| #include <Metal/Metal.h> | ||
| #import <UIKit/UIGestureRecognizerSubclass.h> | ||
|
|
||
| #include <list> | ||
|
|
@@ -14,6 +15,7 @@ | |
| #import "flutter/shell/platform/darwin/common/framework/Headers/FlutterChannels.h" | ||
| #import "flutter/shell/platform/darwin/ios/framework/Source/FlutterOverlayView.h" | ||
| #import "flutter/shell/platform/darwin/ios/framework/Source/FlutterPlatformViews_Internal.h" | ||
| #import "flutter/shell/platform/darwin/ios/framework/Source/FlutterView.h" | ||
| #import "flutter/shell/platform/darwin/ios/framework/Source/FlutterViewController_Internal.h" | ||
| #import "flutter/shell/platform/darwin/ios/ios_surface.h" | ||
|
|
||
|
|
@@ -85,13 +87,15 @@ static bool ClipRRectContainsPlatformViewBoundingRect(const SkRRect& clip_rrect, | |
|
|
||
| std::shared_ptr<FlutterPlatformViewLayer> FlutterPlatformViewLayerPool::GetLayer( | ||
| GrDirectContext* gr_context, | ||
| const std::shared_ptr<IOSContext>& ios_context) { | ||
| const std::shared_ptr<IOSContext>& ios_context, | ||
| MTLPixelFormat pixel_format) { | ||
| if (available_layer_index_ >= layers_.size()) { | ||
| std::shared_ptr<FlutterPlatformViewLayer> layer; | ||
| fml::scoped_nsobject<UIView> overlay_view; | ||
| fml::scoped_nsobject<UIView> overlay_view_wrapper; | ||
|
|
||
| if (!gr_context) { | ||
| bool impeller_enabled = !!ios_context->GetImpellerContext(); | ||
gaaclarke marked this conversation as resolved.
Show resolved
Hide resolved
|
||
| if (!gr_context && !impeller_enabled) { | ||
|
Contributor
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. It seems like the intention of this code was to run when the software backend was enabled, but it was running with Impeller enabled. I don't even know who to FYI, maybe @dnfield @chinmaygarde ? |
||
| overlay_view.reset([[FlutterOverlayView alloc] init]); | ||
| overlay_view_wrapper.reset([[FlutterOverlayView alloc] init]); | ||
|
|
||
|
|
@@ -104,8 +108,10 @@ static bool ClipRRectContainsPlatformViewBoundingRect(const SkRRect& clip_rrect, | |
| std::move(surface)); | ||
| } else { | ||
| CGFloat screenScale = [UIScreen mainScreen].scale; | ||
| overlay_view.reset([[FlutterOverlayView alloc] initWithContentsScale:screenScale]); | ||
| overlay_view_wrapper.reset([[FlutterOverlayView alloc] initWithContentsScale:screenScale]); | ||
| overlay_view.reset([[FlutterOverlayView alloc] initWithContentsScale:screenScale | ||
| pixelFormat:pixel_format]); | ||
| overlay_view_wrapper.reset([[FlutterOverlayView alloc] initWithContentsScale:screenScale | ||
| pixelFormat:pixel_format]); | ||
|
|
||
| auto ca_layer = fml::scoped_nsobject<CALayer>{[[overlay_view.get() layer] retain]}; | ||
| std::unique_ptr<IOSSurface> ios_surface = IOSSurface::Create(ios_context, ca_layer); | ||
|
|
@@ -735,13 +741,15 @@ static bool ClipRRectContainsPlatformViewBoundingRect(const SkRRect& clip_rrect, | |
| // on the overlay layer. | ||
| background_canvas->ClipRect(joined_rect, DlCanvas::ClipOp::kDifference); | ||
| // Get a new host layer. | ||
| std::shared_ptr<FlutterPlatformViewLayer> layer = GetLayer(gr_context, // | ||
| ios_context, // | ||
| slice, // | ||
| joined_rect, // | ||
| current_platform_view_id, // | ||
| overlay_id // | ||
| ); | ||
| std::shared_ptr<FlutterPlatformViewLayer> layer = | ||
| GetLayer(gr_context, // | ||
| ios_context, // | ||
| slice, // | ||
| joined_rect, // | ||
| current_platform_view_id, // | ||
| overlay_id, // | ||
| ((FlutterView*)flutter_view_.get()).pixelFormat // | ||
| ); | ||
| did_submit &= layer->did_submit_last_frame; | ||
| platform_view_layers[current_platform_view_id].push_back(layer); | ||
| overlay_id++; | ||
|
|
@@ -811,9 +819,11 @@ static bool ClipRRectContainsPlatformViewBoundingRect(const SkRRect& clip_rrect, | |
| EmbedderViewSlice* slice, | ||
| SkRect rect, | ||
| int64_t view_id, | ||
| int64_t overlay_id) { | ||
| int64_t overlay_id, | ||
| MTLPixelFormat pixel_format) { | ||
| FML_DCHECK(flutter_view_); | ||
| std::shared_ptr<FlutterPlatformViewLayer> layer = layer_pool_->GetLayer(gr_context, ios_context); | ||
| std::shared_ptr<FlutterPlatformViewLayer> layer = | ||
| layer_pool_->GetLayer(gr_context, ios_context, pixel_format); | ||
|
|
||
| UIView* overlay_view_wrapper = layer->overlay_view_wrapper.get(); | ||
| auto screenScale = [UIScreen mainScreen].scale; | ||
|
|
||
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
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.
Uh oh!
There was an error while loading. Please reload this page.