Skip to content

Commit

Permalink
[DisplayList] Compute saveLayer bounds in DLBuilder when not provided
Browse files Browse the repository at this point in the history
  • Loading branch information
flar committed Mar 14, 2024
1 parent 639dd44 commit f2ee790
Show file tree
Hide file tree
Showing 33 changed files with 1,010 additions and 192 deletions.
5 changes: 3 additions & 2 deletions display_list/benchmarking/dl_complexity_gl.cc
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@ unsigned int DisplayListGLComplexityCalculator::GLHelper::BatchedComplexity() {
}

void DisplayListGLComplexityCalculator::GLHelper::saveLayer(
const SkRect* bounds,
const SkRect& bounds,
const SaveLayerOptions options,
const DlImageFilter* backdrop) {
if (IsComplex()) {
Expand Down Expand Up @@ -615,7 +615,8 @@ void DisplayListGLComplexityCalculator::GLHelper::drawDisplayList(
}
GLHelper helper(Ceiling() - CurrentComplexityScore());
if (opacity < SK_Scalar1 && !display_list->can_apply_group_opacity()) {
helper.saveLayer(nullptr, SaveLayerOptions::kWithAttributes, nullptr);
auto bounds = display_list->bounds();
helper.saveLayer(bounds, SaveLayerOptions::kWithAttributes, nullptr);
}
display_list->Dispatch(helper);
AccumulateComplexity(helper.ComplexityScore());
Expand Down
2 changes: 1 addition & 1 deletion display_list/benchmarking/dl_complexity_gl.h
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ class DisplayListGLComplexityCalculator
explicit GLHelper(unsigned int ceiling)
: ComplexityCalculatorHelper(ceiling) {}

void saveLayer(const SkRect* bounds,
void saveLayer(const SkRect& bounds,
const SaveLayerOptions options,
const DlImageFilter* backdrop) override;

Expand Down
5 changes: 3 additions & 2 deletions display_list/benchmarking/dl_complexity_metal.cc
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,7 @@ DisplayListMetalComplexityCalculator::MetalHelper::BatchedComplexity() {
}

void DisplayListMetalComplexityCalculator::MetalHelper::saveLayer(
const SkRect* bounds,
const SkRect& bounds,
const SaveLayerOptions options,
const DlImageFilter* backdrop) {
if (IsComplex()) {
Expand Down Expand Up @@ -559,7 +559,8 @@ void DisplayListMetalComplexityCalculator::MetalHelper::drawDisplayList(
}
MetalHelper helper(Ceiling() - CurrentComplexityScore());
if (opacity < SK_Scalar1 && !display_list->can_apply_group_opacity()) {
helper.saveLayer(nullptr, SaveLayerOptions::kWithAttributes, nullptr);
auto bounds = display_list->bounds();
helper.saveLayer(bounds, SaveLayerOptions::kWithAttributes, nullptr);
}
display_list->Dispatch(helper);
AccumulateComplexity(helper.ComplexityScore());
Expand Down
2 changes: 1 addition & 1 deletion display_list/benchmarking/dl_complexity_metal.h
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ class DisplayListMetalComplexityCalculator
explicit MetalHelper(unsigned int ceiling)
: ComplexityCalculatorHelper(ceiling) {}

void saveLayer(const SkRect* bounds,
void saveLayer(const SkRect& bounds,
const SaveLayerOptions options,
const DlImageFilter* backdrop) override;

Expand Down
32 changes: 30 additions & 2 deletions display_list/display_list.h
Original file line number Diff line number Diff line change
Expand Up @@ -88,9 +88,7 @@ namespace flutter {
\
V(Save) \
V(SaveLayer) \
V(SaveLayerBounds) \
V(SaveLayerBackdrop) \
V(SaveLayerBackdropBounds) \
V(Restore) \
\
V(Translate) \
Expand Down Expand Up @@ -165,6 +163,7 @@ class SaveLayerOptions {
SaveLayerOptions without_optimizations() const {
SaveLayerOptions options;
options.fRendersWithAttributes = fRendersWithAttributes;
options.fBoundsFromCaller = fBoundsFromCaller;
return options;
}

Expand All @@ -182,6 +181,33 @@ class SaveLayerOptions {
return options;
}

// Returns true iff the bounds for the saveLayer operation were provided
// by the caller, otherwise the bounds will have been computed by the
// DisplayListBuilder and provided for reference.
bool bounds_from_caller() const { return fBoundsFromCaller; }
SaveLayerOptions with_bounds_from_caller() const {
SaveLayerOptions options(this);
options.fBoundsFromCaller = true;
return options;
}
SaveLayerOptions without_bounds_from_caller() const {
SaveLayerOptions options(this);
options.fBoundsFromCaller = false;
return options;
}
bool bounds_were_calculated() const { return !fBoundsFromCaller; }

// Returns true iff the bounds for the saveLayer do not fully cover the
// contained rendering operations. This will only occur if the original
// caller supplied bounds and those bounds were not a strict superset
// of the content bounds computed by the DisplayListBuilder.
bool content_is_clipped() const { return fContentIsClipped; }
SaveLayerOptions with_content_is_clipped() const {
SaveLayerOptions options(this);
options.fContentIsClipped = true;
return options;
}

SaveLayerOptions& operator=(const SaveLayerOptions& other) {
flags_ = other.flags_;
return *this;
Expand All @@ -198,6 +224,8 @@ class SaveLayerOptions {
struct {
unsigned fRendersWithAttributes : 1;
unsigned fCanDistributeOpacity : 1;
unsigned fBoundsFromCaller : 1;
unsigned fContentIsClipped : 1;
};
uint32_t flags_;
};
Expand Down
Loading

0 comments on commit f2ee790

Please sign in to comment.