Skip to content
This repository was archived by the owner on Feb 25, 2025. It is now read-only.
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
34 changes: 7 additions & 27 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 @@ -23,24 +23,24 @@ DisplayList::DisplayList()
nested_op_count_(0),
unique_id_(0),
bounds_({0, 0, 0, 0}),
bounds_cull_({0, 0, 0, 0}),
can_apply_group_opacity_(true) {}

DisplayList::DisplayList(uint8_t* ptr,
size_t byte_count,
unsigned int op_count,
size_t nested_byte_count,
unsigned int nested_op_count,
const SkRect& cull_rect,
bool can_apply_group_opacity)
const SkRect& bounds,
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_cull_(cull_rect),
can_apply_group_opacity_(can_apply_group_opacity) {
bounds_(bounds),
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 +52,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
28 changes: 6 additions & 22 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,9 @@ class DisplayList : public SkRefCnt {
unsigned int op_count,
size_t nested_byte_count,
unsigned int nested_op_count,
const SkRect& cull_rect,
bool can_apply_group_opacity);
const SkRect& bounds,
bool can_apply_group_opacity,
sk_sp<const DlRTree> rtree);

struct SkFreeDeleter {
void operator()(uint8_t* p) { sk_free(p); }
Expand All @@ -295,15 +284,10 @@ 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