Skip to content

Commit e1e6a41

Browse files
authored
Improve DisplayList bounds calculations (flutter#28656)
1 parent 969f68d commit e1e6a41

File tree

8 files changed

+1546
-461
lines changed

8 files changed

+1546
-461
lines changed

flow/display_list.cc

Lines changed: 23 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -797,33 +797,33 @@ struct DrawTextBlobOp final : DLOp {
797797
};
798798

799799
// 4 byte header + 28 byte payload packs evenly into 32 bytes
800-
#define DEFINE_DRAW_SHADOW_OP(name, occludes) \
801-
struct Draw##name##Op final : DLOp { \
802-
static const auto kType = DisplayListOpType::kDraw##name; \
803-
\
804-
Draw##name##Op(const SkPath& path, \
805-
SkColor color, \
806-
SkScalar elevation, \
807-
SkScalar dpr) \
808-
: color(color), elevation(elevation), dpr(dpr), path(path) {} \
809-
\
810-
const SkColor color; \
811-
const SkScalar elevation; \
812-
const SkScalar dpr; \
813-
const SkPath path; \
814-
\
815-
void dispatch(Dispatcher& dispatcher) const { \
816-
dispatcher.drawShadow(path, color, elevation, occludes, dpr); \
817-
} \
800+
#define DEFINE_DRAW_SHADOW_OP(name, nonoccluding) \
801+
struct Draw##name##Op final : DLOp { \
802+
static const auto kType = DisplayListOpType::kDraw##name; \
803+
\
804+
Draw##name##Op(const SkPath& path, \
805+
SkColor color, \
806+
SkScalar elevation, \
807+
SkScalar dpr) \
808+
: color(color), elevation(elevation), dpr(dpr), path(path) {} \
809+
\
810+
const SkColor color; \
811+
const SkScalar elevation; \
812+
const SkScalar dpr; \
813+
const SkPath path; \
814+
\
815+
void dispatch(Dispatcher& dispatcher) const { \
816+
dispatcher.drawShadow(path, color, elevation, nonoccluding, dpr); \
817+
} \
818818
};
819819
DEFINE_DRAW_SHADOW_OP(Shadow, false)
820-
DEFINE_DRAW_SHADOW_OP(ShadowOccludes, true)
820+
DEFINE_DRAW_SHADOW_OP(NonOccludingShadow, true)
821821
#undef DEFINE_DRAW_SHADOW_OP
822822

823823
#pragma pack(pop, DLOp_Alignment)
824824

825825
void DisplayList::ComputeBounds() {
826-
DisplayListBoundsCalculator calculator(bounds_cull_);
826+
DisplayListBoundsCalculator calculator(&bounds_cull_);
827827
Dispatch(calculator);
828828
bounds_ = calculator.getBounds();
829829
}
@@ -1365,10 +1365,10 @@ void DisplayListBuilder::drawTextBlob(const sk_sp<SkTextBlob> blob,
13651365
void DisplayListBuilder::drawShadow(const SkPath& path,
13661366
const SkColor color,
13671367
const SkScalar elevation,
1368-
bool occludes,
1368+
bool transparentOccluder,
13691369
SkScalar dpr) {
1370-
occludes //
1371-
? Push<DrawShadowOccludesOp>(0, 1, path, color, elevation, dpr)
1370+
transparentOccluder //
1371+
? Push<DrawNonOccludingShadowOp>(0, 1, path, color, elevation, dpr)
13721372
: Push<DrawShadowOp>(0, 1, path, color, elevation, dpr);
13731373
}
13741374

flow/display_list.h

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -148,7 +148,7 @@ namespace flutter {
148148
V(DrawTextBlob) \
149149
\
150150
V(DrawShadow) \
151-
V(DrawShadowOccludes)
151+
V(DrawNonOccludingShadow)
152152

153153
#define DL_OP_TO_ENUM_VALUE(name) k##name,
154154
enum class DisplayListOpType { FOR_EACH_DISPLAY_LIST_OP(DL_OP_TO_ENUM_VALUE) };
@@ -245,8 +245,8 @@ class Dispatcher {
245245
virtual void setMaskBlurFilter(SkBlurStyle style, SkScalar sigma) = 0;
246246

247247
virtual void save() = 0;
248-
virtual void restore() = 0;
249248
virtual void saveLayer(const SkRect* bounds, bool restoreWithPaint) = 0;
249+
virtual void restore() = 0;
250250

251251
virtual void translate(SkScalar tx, SkScalar ty) = 0;
252252
virtual void scale(SkScalar sx, SkScalar sy) = 0;
@@ -325,7 +325,7 @@ class Dispatcher {
325325
virtual void drawShadow(const SkPath& path,
326326
const SkColor color,
327327
const SkScalar elevation,
328-
bool occludes,
328+
bool transparentOccluder,
329329
SkScalar dpr) = 0;
330330
};
331331

@@ -358,8 +358,8 @@ class DisplayListBuilder final : public virtual Dispatcher, public SkRefCnt {
358358
void setMaskBlurFilter(SkBlurStyle style, SkScalar sigma) override;
359359

360360
void save() override;
361-
void restore() override;
362361
void saveLayer(const SkRect* bounds, bool restoreWithPaint) override;
362+
void restore() override;
363363

364364
void translate(SkScalar tx, SkScalar ty) override;
365365
void scale(SkScalar sx, SkScalar sy) override;
@@ -440,7 +440,7 @@ class DisplayListBuilder final : public virtual Dispatcher, public SkRefCnt {
440440
void drawShadow(const SkPath& path,
441441
const SkColor color,
442442
const SkScalar elevation,
443-
bool occludes,
443+
bool transparentOccluder,
444444
SkScalar dpr) override;
445445

446446
sk_sp<DisplayList> Build();

flow/display_list_canvas.cc

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -176,10 +176,10 @@ void DisplayListCanvasDispatcher::drawTextBlob(const sk_sp<SkTextBlob> blob,
176176
void DisplayListCanvasDispatcher::drawShadow(const SkPath& path,
177177
const SkColor color,
178178
const SkScalar elevation,
179-
bool occludes,
179+
bool transparentOccluder,
180180
SkScalar dpr) {
181181
flutter::PhysicalShapeLayer::DrawShadow(canvas_, path, color, elevation,
182-
occludes, dpr);
182+
transparentOccluder, dpr);
183183
}
184184

185185
DisplayListCanvasRecorder::DisplayListCanvasRecorder(const SkRect& bounds)

flow/display_list_canvas.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -110,7 +110,7 @@ class DisplayListCanvasDispatcher : public virtual Dispatcher,
110110
void drawShadow(const SkPath& path,
111111
const SkColor color,
112112
const SkScalar elevation,
113-
bool occludes,
113+
bool transparentOccluder,
114114
SkScalar dpr) override;
115115

116116
private:

0 commit comments

Comments
 (0)