[Impeller] detect max cull rect on bounds. (flutter/engine#54013)

Fixes https://github.com/flutter/flutter/issues/151785

if the bounds given to impeller SaveLayer is kMaxCullRect, treat this as unbounded.
This commit is contained in:
Jonah Williams
2024-07-20 10:29:28 -07:00
committed by GitHub
parent 5c954b9cfe
commit 0e9b328fc2
2 changed files with 14 additions and 4 deletions

View File

@@ -35,7 +35,7 @@ SkRect GetCullRect(ISize window_size) {
} // namespace
TEST_P(AiksTest, CollapsedDrawPaintInSubpass) {
DisplayListBuilder builder(GetCullRect(GetWindowSize()));
DisplayListBuilder builder;
DlPaint paint;
paint.setColor(DlColor::kYellow());
@@ -55,7 +55,7 @@ TEST_P(AiksTest, CollapsedDrawPaintInSubpass) {
TEST_P(AiksTest, CollapsedDrawPaintInSubpassBackdropFilter) {
// Bug: https://github.com/flutter/flutter/issues/131576
DisplayListBuilder builder(GetCullRect(GetWindowSize()));
DisplayListBuilder builder;
DlPaint paint;
paint.setColor(DlColor::kYellow());

View File

@@ -612,6 +612,9 @@ void DlDispatcherBase::save(uint32_t total_content_depth) {
GetCanvas().Save(total_content_depth);
}
static constexpr SkRect kMaxCullRect =
SkRect::MakeLTRB(-1E9F, -1E9F, 1E9F, 1E9F);
// |flutter::DlOpReceiver|
void DlDispatcherBase::saveLayer(const SkRect& bounds,
const flutter::SaveLayerOptions& options,
@@ -622,8 +625,15 @@ void DlDispatcherBase::saveLayer(const SkRect& bounds,
auto promise = options.content_is_clipped()
? ContentBoundsPromise::kMayClipContents
: ContentBoundsPromise::kContainsContents;
GetCanvas().SaveLayer(paint, skia_conversions::ToRect(bounds),
ToImageFilter(backdrop), promise, total_content_depth,
std::optional<Rect> impeller_bounds;
if (bounds == kMaxCullRect) {
impeller_bounds = std::nullopt;
} else {
impeller_bounds = skia_conversions::ToRect(bounds);
}
GetCanvas().SaveLayer(paint, impeller_bounds, ToImageFilter(backdrop),
promise, total_content_depth,
options.can_distribute_opacity());
}