Skip to content

Commit

Permalink
[DisplayList] track unbounded state on save layers and DisplayLists (f…
Browse files Browse the repository at this point in the history
…lutter#54032)

New flags on SaveLayerOptions will report if a saveLayer result is unbounded because a rendering operation within its contents did not have a definable bounds and there was no clip installed at the time (consider DrawPaint for example). A similar flag is found on DisplayList objects which reports if their top level had an unbounded operation.
  • Loading branch information
flar authored Jul 23, 2024
1 parent b910443 commit bf5df94
Show file tree
Hide file tree
Showing 7 changed files with 601 additions and 60 deletions.
1 change: 1 addition & 0 deletions display_list/BUILD.gn
Original file line number Diff line number Diff line change
Expand Up @@ -130,6 +130,7 @@ if (enable_unittests) {
":display_list",
":display_list_fixtures",
"//flutter/display_list/testing:display_list_testing",
"//flutter/impeller/typographer/backends/skia:typographer_skia_backend",
"//flutter/testing",
"//flutter/testing:skia",
]
Expand Down
3 changes: 3 additions & 0 deletions display_list/display_list.cc
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@ DisplayList::DisplayList()
is_ui_thread_safe_(true),
modifies_transparent_black_(false),
root_has_backdrop_filter_(false),
root_is_unbounded_(false),
max_root_blend_mode_(DlBlendMode::kClear) {}

DisplayList::DisplayList(DisplayListStorage&& storage,
Expand All @@ -40,6 +41,7 @@ DisplayList::DisplayList(DisplayListStorage&& storage,
bool modifies_transparent_black,
DlBlendMode max_root_blend_mode,
bool root_has_backdrop_filter,
bool root_is_unbounded,
sk_sp<const DlRTree> rtree)
: storage_(std::move(storage)),
byte_count_(byte_count),
Expand All @@ -53,6 +55,7 @@ DisplayList::DisplayList(DisplayListStorage&& storage,
is_ui_thread_safe_(is_ui_thread_safe),
modifies_transparent_black_(modifies_transparent_black),
root_has_backdrop_filter_(root_has_backdrop_filter),
root_is_unbounded_(root_is_unbounded),
max_root_blend_mode_(max_root_blend_mode),
rtree_(std::move(rtree)) {}

Expand Down
22 changes: 22 additions & 0 deletions display_list/display_list.h
Original file line number Diff line number Diff line change
Expand Up @@ -216,6 +216,13 @@ class SaveLayerOptions {
return options;
}

bool content_is_unbounded() const { return fContentIsUnbounded; }
SaveLayerOptions with_content_is_unbounded() const {
SaveLayerOptions options(this);
options.fContentIsUnbounded = true;
return options;
}

SaveLayerOptions& operator=(const SaveLayerOptions& other) {
flags_ = other.flags_;
return *this;
Expand All @@ -235,6 +242,7 @@ class SaveLayerOptions {
unsigned fBoundsFromCaller : 1;
unsigned fContentIsClipped : 1;
unsigned fHasBackdropFilter : 1;
unsigned fContentIsUnbounded : 1;
};
uint32_t flags_;
};
Expand Down Expand Up @@ -331,6 +339,18 @@ class DisplayList : public SkRefCnt {
/// be required for the backdrop filter to do its work.
bool root_has_backdrop_filter() const { return root_has_backdrop_filter_; }

/// @brief Indicates if a rendering operation at the root level of the
/// DisplayList had an unbounded result, not otherwise limited by
/// a clip operation.
///
/// This condition can occur in a number of situations. The most common
/// situation is when there is a drawPaint or drawColor rendering
/// operation which fills out the entire drawable surface unless it is
/// bounded by a clip. Other situations include an operation rendered
/// through an ImageFilter that cannot compute the resulting bounds or
/// when an unclipped backdrop filter is applied by a save layer.
bool root_is_unbounded() const { return root_is_unbounded_; }

/// @brief Indicates the maximum DlBlendMode used on any rendering op
/// in the root surface of the DisplayList.
///
Expand All @@ -353,6 +373,7 @@ class DisplayList : public SkRefCnt {
bool modifies_transparent_black,
DlBlendMode max_root_blend_mode,
bool root_has_backdrop_filter,
bool root_is_unbounded,
sk_sp<const DlRTree> rtree);

static uint32_t next_unique_id();
Expand All @@ -375,6 +396,7 @@ class DisplayList : public SkRefCnt {
const bool is_ui_thread_safe_;
const bool modifies_transparent_black_;
const bool root_has_backdrop_filter_;
const bool root_is_unbounded_;
const DlBlendMode max_root_blend_mode_;

const sk_sp<const DlRTree> rtree_;
Expand Down
Loading

0 comments on commit bf5df94

Please sign in to comment.