Skip to content
This repository was archived by the owner on Feb 25, 2025. It is now read-only.
Merged
31 changes: 7 additions & 24 deletions display_list/display_list.cc
Original file line number Diff line number Diff line change
Expand Up @@ -5,9 +5,9 @@
#include <type_traits>

#include "flutter/display_list/display_list.h"
#include "flutter/display_list/display_list_builder.h"
#include "flutter/display_list/display_list_canvas_dispatcher.h"
#include "flutter/display_list/display_list_ops.h"
#include "flutter/display_list/display_list_utils.h"
#include "flutter/fml/trace_event.h"

namespace flutter {
Expand All @@ -31,16 +31,19 @@ DisplayList::DisplayList(uint8_t* ptr,
unsigned int op_count,
size_t nested_byte_count,
unsigned int nested_op_count,
const SkRect& bounds,
const SkRect& cull_rect,
bool can_apply_group_opacity)
bool can_apply_group_opacity,
sk_sp<const DlRTree> rtree)
: storage_(ptr),
byte_count_(byte_count),
op_count_(op_count),
nested_byte_count_(nested_byte_count),
nested_op_count_(nested_op_count),
bounds_({0, 0, -1, -1}),
bounds_(bounds),
bounds_cull_(cull_rect),
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I believe that bounds_cull was only ever used as a max bounds for the accumulators so the field is likely obsolete now.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Done.

can_apply_group_opacity_(can_apply_group_opacity) {
can_apply_group_opacity_(can_apply_group_opacity),
rtree_(std::move(rtree)) {
static std::atomic<uint32_t> next_id{1};
do {
unique_id_ = next_id.fetch_add(+1, std::memory_order_relaxed);
Expand All @@ -52,26 +55,6 @@ DisplayList::~DisplayList() {
DisposeOps(ptr, ptr + byte_count_);
}

void DisplayList::ComputeBounds() {
RectBoundsAccumulator accumulator;
DisplayListBoundsCalculator calculator(accumulator, &bounds_cull_);
Dispatch(calculator);
if (calculator.is_unbounded()) {
FML_LOG(INFO) << "returning partial bounds for unbounded DisplayList";
}
bounds_ = accumulator.bounds();
}

void DisplayList::ComputeRTree() {
RTreeBoundsAccumulator accumulator;
DisplayListBoundsCalculator calculator(accumulator, &bounds_cull_);
Dispatch(calculator);
if (calculator.is_unbounded()) {
FML_LOG(INFO) << "returning partial rtree for unbounded DisplayList";
}
rtree_ = accumulator.rtree();
}

void DisplayList::Dispatch(Dispatcher& dispatcher,
uint8_t* ptr,
uint8_t* end) const {
Expand Down
25 changes: 6 additions & 19 deletions display_list/display_list.h
Original file line number Diff line number Diff line change
Expand Up @@ -248,21 +248,9 @@ class DisplayList : public SkRefCnt {

uint32_t unique_id() const { return unique_id_; }

const SkRect& bounds() {
if (bounds_.width() < 0.0) {
// ComputeBounds() will leave the variable with a
// non-negative width and height
ComputeBounds();
}
return bounds_;
}
const SkRect& bounds() { return bounds_; }

sk_sp<const DlRTree> rtree() {
if (!rtree_) {
ComputeRTree();
}
return rtree_;
}
sk_sp<const DlRTree> rtree() { return rtree_; }

bool Equals(const DisplayList* other) const;
bool Equals(const DisplayList& other) const { return Equals(&other); }
Expand All @@ -280,8 +268,10 @@ class DisplayList : public SkRefCnt {
unsigned int op_count,
size_t nested_byte_count,
unsigned int nested_op_count,
const SkRect& bounds,
const SkRect& cull_rect,
bool can_apply_group_opacity);
bool can_apply_group_opacity,
sk_sp<const DlRTree> rtree);

struct SkFreeDeleter {
void operator()(uint8_t* p) { sk_free(p); }
Expand All @@ -295,15 +285,12 @@ class DisplayList : public SkRefCnt {

uint32_t unique_id_;
SkRect bounds_;
sk_sp<const DlRTree> rtree_;

// Only used for drawPaint() and drawColor()
SkRect bounds_cull_;

bool can_apply_group_opacity_;
sk_sp<const DlRTree> rtree_;

void ComputeBounds();
void ComputeRTree();
void Dispatch(Dispatcher& ctx, uint8_t* ptr, uint8_t* end) const;

friend class DisplayListBuilder;
Expand Down
Loading