Skip to content
This repository was archived by the owner on Feb 25, 2025. It is now read-only.

Commit 217c86b

Browse files
committed
fix bounds in unit test and minor opt in Dispatch
1 parent b80ab66 commit 217c86b

File tree

2 files changed

+9
-15
lines changed

2 files changed

+9
-15
lines changed

display_list/display_list.cc

Lines changed: 8 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -70,10 +70,8 @@ class NopCuller : public Culler {
7070
NopCuller NopCuller::instance = NopCuller();
7171
class VectorCuller : public Culler {
7272
public:
73-
VectorCuller(sk_sp<const DlRTree> rtree, const std::vector<int>& rect_indices)
74-
: rtree_(std::move(rtree)),
75-
cur_(rect_indices.begin()),
76-
end_(rect_indices.end()) {}
73+
VectorCuller(const DlRTree* rtree, const std::vector<int>& rect_indices)
74+
: rtree_(rtree), cur_(rect_indices.begin()), end_(rect_indices.end()) {}
7775

7876
bool init(DispatchContext& context) override {
7977
if (cur_ < end_) {
@@ -100,7 +98,7 @@ class VectorCuller : public Culler {
10098
}
10199

102100
private:
103-
const sk_sp<const DlRTree> rtree_;
101+
const DlRTree* rtree_;
104102
std::vector<int>::const_iterator cur_;
105103
std::vector<int>::const_iterator end_;
106104
};
@@ -117,16 +115,17 @@ void DisplayList::Dispatch(Dispatcher& ctx, const SkRect& cull_rect) {
117115
Dispatch(ctx);
118116
return;
119117
}
120-
FML_DCHECK(rtree() != nullptr);
121-
if (rtree() == nullptr) {
118+
const DlRTree* rtree = this->rtree().get();
119+
FML_DCHECK(rtree != nullptr);
120+
if (rtree == nullptr) {
122121
FML_LOG(ERROR) << "dispatched with culling rect on DL with no rtree";
123122
Dispatch(ctx);
124123
return;
125124
}
126125
uint8_t* ptr = storage_.get();
127126
std::vector<int> rect_indices;
128-
rtree()->search(cull_rect, &rect_indices);
129-
VectorCuller culler(rtree(), rect_indices);
127+
rtree->search(cull_rect, &rect_indices);
128+
VectorCuller culler(rtree, rect_indices);
130129
Dispatch(ctx, ptr, ptr + byte_count_, culler);
131130
}
132131

display_list/display_list_unittests.cc

Lines changed: 1 addition & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1231,13 +1231,8 @@ TEST(DisplayList, FlutterSvgIssue661BoundsWereEmpty) {
12311231
// line has to be revised too often as the DL implementation is
12321232
// improved and maintained, then we can eliminate this test and
12331233
// just rely on the "rounded out" bounds test that follows.
1234-
FML_LOG(ERROR) << "dl bounds: " << std::setprecision(15)
1235-
<< display_list->bounds().fLeft << ", "
1236-
<< display_list->bounds().fTop << ", "
1237-
<< display_list->bounds().fRight << ", "
1238-
<< display_list->bounds().fBottom;
12391234
EXPECT_EQ(display_list->bounds(),
1240-
SkRect::MakeLTRB(0, 0.00189208984375, 99.9839630127, 100));
1235+
SkRect::MakeLTRB(0, 0.00190162658691406, 99.9839553833008, 100));
12411236
// This is the more practical result. The bounds are "almost" 0,0,100x100
12421237
EXPECT_EQ(display_list->bounds().roundOut(), SkIRect::MakeWH(100, 100));
12431238
EXPECT_EQ(display_list->op_count(), 19u);

0 commit comments

Comments
 (0)