Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

DisplayList SaveLayer (and root layer) read-back flags #53104

Merged
merged 6 commits into from
May 30, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 7 additions & 1 deletion display_list/display_list.cc
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,9 @@ DisplayList::DisplayList()
bounds_({0, 0, 0, 0}),
can_apply_group_opacity_(true),
is_ui_thread_safe_(true),
modifies_transparent_black_(false) {}
modifies_transparent_black_(false),
root_has_backdrop_filter_(false),
max_root_blend_mode_(DlBlendMode::kClear) {}

DisplayList::DisplayList(DisplayListStorage&& storage,
size_t byte_count,
Expand All @@ -36,6 +38,8 @@ DisplayList::DisplayList(DisplayListStorage&& storage,
bool can_apply_group_opacity,
bool is_ui_thread_safe,
bool modifies_transparent_black,
DlBlendMode max_root_blend_mode,
bool root_has_backdrop_filter,
sk_sp<const DlRTree> rtree)
: storage_(std::move(storage)),
byte_count_(byte_count),
Expand All @@ -48,6 +52,8 @@ DisplayList::DisplayList(DisplayListStorage&& storage,
can_apply_group_opacity_(can_apply_group_opacity),
is_ui_thread_safe_(is_ui_thread_safe),
modifies_transparent_black_(modifies_transparent_black),
root_has_backdrop_filter_(root_has_backdrop_filter),
max_root_blend_mode_(max_root_blend_mode),
rtree_(std::move(rtree)) {}

DisplayList::~DisplayList() {
Expand Down
31 changes: 31 additions & 0 deletions display_list/display_list.h
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@
#include <memory>
#include <optional>

#include "flutter/display_list/dl_blend_mode.h"
#include "flutter/display_list/dl_sampling_options.h"
#include "flutter/display_list/geometry/dl_rtree.h"
#include "flutter/fml/logging.h"
Expand Down Expand Up @@ -208,6 +209,13 @@ class SaveLayerOptions {
return options;
}

bool contains_backdrop_filter() const { return fHasBackdropFilter; }
SaveLayerOptions with_contains_backdrop_filter() const {
SaveLayerOptions options(this);
options.fHasBackdropFilter = true;
return options;
}

SaveLayerOptions& operator=(const SaveLayerOptions& other) {
flags_ = other.flags_;
return *this;
Expand All @@ -226,6 +234,7 @@ class SaveLayerOptions {
unsigned fCanDistributeOpacity : 1;
unsigned fBoundsFromCaller : 1;
unsigned fContentIsClipped : 1;
unsigned fHasBackdropFilter : 1;
};
uint32_t flags_;
};
Expand Down Expand Up @@ -313,6 +322,24 @@ class DisplayList : public SkRefCnt {

const DisplayListStorage& GetStorage() const { return storage_; }

/// @brief Indicates if there are any saveLayer operations at the root
/// surface level of the DisplayList that use a backdrop filter.
///
/// This condition can be used to determine what kind of surface to create
/// for the root layer into which to render the DisplayList as some GPUs
/// can support surfaces that do or do not support the readback that would
/// be required for the backdrop filter to do its work.
bool root_has_backdrop_filter() const { return root_has_backdrop_filter_; }

/// @brief Indicates the maximum DlBlendMode used on any rendering op
/// in the root surface of the DisplayList.
///
/// This condition can be used to determine what kind of surface to create
/// for the root layer into which to render the DisplayList as some GPUs
/// can support surfaces that do or do not support the readback that would
/// be required for the indicated blend mode to do its work.
DlBlendMode max_root_blend_mode() const { return max_root_blend_mode_; }

private:
DisplayList(DisplayListStorage&& ptr,
size_t byte_count,
Expand All @@ -324,6 +351,8 @@ class DisplayList : public SkRefCnt {
bool can_apply_group_opacity,
bool is_ui_thread_safe,
bool modifies_transparent_black,
DlBlendMode max_root_blend_mode,
bool root_has_backdrop_filter,
sk_sp<const DlRTree> rtree);

static uint32_t next_unique_id();
Expand All @@ -345,6 +374,8 @@ class DisplayList : public SkRefCnt {
const bool can_apply_group_opacity_;
const bool is_ui_thread_safe_;
const bool modifies_transparent_black_;
const bool root_has_backdrop_filter_;
const DlBlendMode max_root_blend_mode_;

const sk_sp<const DlRTree> rtree_;

Expand Down
Loading