Skip to content

Commit 79db200

Browse files
ColdPaleLightloic-sharma
authored andcommitted
Collapse bounds calculations into DisplayListBuilder (flutter#34365)
* Collapse bounds calculations into DisplayListBuilder * Tweak code * Remove bounds cull * Remove obsolete comment
1 parent ba6fa56 commit 79db200

13 files changed

+635
-1146
lines changed

display_list/display_list.cc

Lines changed: 7 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -5,9 +5,9 @@
55
#include <type_traits>
66

77
#include "flutter/display_list/display_list.h"
8+
#include "flutter/display_list/display_list_builder.h"
89
#include "flutter/display_list/display_list_canvas_dispatcher.h"
910
#include "flutter/display_list/display_list_ops.h"
10-
#include "flutter/display_list/display_list_utils.h"
1111
#include "flutter/fml/trace_event.h"
1212

1313
namespace flutter {
@@ -23,24 +23,24 @@ DisplayList::DisplayList()
2323
nested_op_count_(0),
2424
unique_id_(0),
2525
bounds_({0, 0, 0, 0}),
26-
bounds_cull_({0, 0, 0, 0}),
2726
can_apply_group_opacity_(true) {}
2827

2928
DisplayList::DisplayList(uint8_t* ptr,
3029
size_t byte_count,
3130
unsigned int op_count,
3231
size_t nested_byte_count,
3332
unsigned int nested_op_count,
34-
const SkRect& cull_rect,
35-
bool can_apply_group_opacity)
33+
const SkRect& bounds,
34+
bool can_apply_group_opacity,
35+
sk_sp<const DlRTree> rtree)
3636
: storage_(ptr),
3737
byte_count_(byte_count),
3838
op_count_(op_count),
3939
nested_byte_count_(nested_byte_count),
4040
nested_op_count_(nested_op_count),
41-
bounds_({0, 0, -1, -1}),
42-
bounds_cull_(cull_rect),
43-
can_apply_group_opacity_(can_apply_group_opacity) {
41+
bounds_(bounds),
42+
can_apply_group_opacity_(can_apply_group_opacity),
43+
rtree_(std::move(rtree)) {
4444
static std::atomic<uint32_t> next_id{1};
4545
do {
4646
unique_id_ = next_id.fetch_add(+1, std::memory_order_relaxed);
@@ -52,26 +52,6 @@ DisplayList::~DisplayList() {
5252
DisposeOps(ptr, ptr + byte_count_);
5353
}
5454

55-
void DisplayList::ComputeBounds() {
56-
RectBoundsAccumulator accumulator;
57-
DisplayListBoundsCalculator calculator(accumulator, &bounds_cull_);
58-
Dispatch(calculator);
59-
if (calculator.is_unbounded()) {
60-
FML_LOG(INFO) << "returning partial bounds for unbounded DisplayList";
61-
}
62-
bounds_ = accumulator.bounds();
63-
}
64-
65-
void DisplayList::ComputeRTree() {
66-
RTreeBoundsAccumulator accumulator;
67-
DisplayListBoundsCalculator calculator(accumulator, &bounds_cull_);
68-
Dispatch(calculator);
69-
if (calculator.is_unbounded()) {
70-
FML_LOG(INFO) << "returning partial rtree for unbounded DisplayList";
71-
}
72-
rtree_ = accumulator.rtree();
73-
}
74-
7555
void DisplayList::Dispatch(Dispatcher& dispatcher,
7656
uint8_t* ptr,
7757
uint8_t* end) const {

display_list/display_list.h

Lines changed: 6 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -248,21 +248,9 @@ class DisplayList : public SkRefCnt {
248248

249249
uint32_t unique_id() const { return unique_id_; }
250250

251-
const SkRect& bounds() {
252-
if (bounds_.width() < 0.0) {
253-
// ComputeBounds() will leave the variable with a
254-
// non-negative width and height
255-
ComputeBounds();
256-
}
257-
return bounds_;
258-
}
251+
const SkRect& bounds() { return bounds_; }
259252

260-
sk_sp<const DlRTree> rtree() {
261-
if (!rtree_) {
262-
ComputeRTree();
263-
}
264-
return rtree_;
265-
}
253+
sk_sp<const DlRTree> rtree() { return rtree_; }
266254

267255
bool Equals(const DisplayList* other) const;
268256
bool Equals(const DisplayList& other) const { return Equals(&other); }
@@ -280,8 +268,9 @@ class DisplayList : public SkRefCnt {
280268
unsigned int op_count,
281269
size_t nested_byte_count,
282270
unsigned int nested_op_count,
283-
const SkRect& cull_rect,
284-
bool can_apply_group_opacity);
271+
const SkRect& bounds,
272+
bool can_apply_group_opacity,
273+
sk_sp<const DlRTree> rtree);
285274

286275
struct SkFreeDeleter {
287276
void operator()(uint8_t* p) { sk_free(p); }
@@ -295,15 +284,10 @@ class DisplayList : public SkRefCnt {
295284

296285
uint32_t unique_id_;
297286
SkRect bounds_;
298-
sk_sp<const DlRTree> rtree_;
299-
300-
// Only used for drawPaint() and drawColor()
301-
SkRect bounds_cull_;
302287

303288
bool can_apply_group_opacity_;
289+
sk_sp<const DlRTree> rtree_;
304290

305-
void ComputeBounds();
306-
void ComputeRTree();
307291
void Dispatch(Dispatcher& ctx, uint8_t* ptr, uint8_t* end) const;
308292

309293
friend class DisplayListBuilder;

0 commit comments

Comments
 (0)