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

Commit 3039cd3

Browse files
committed
Add a display list op to clear to transformation stack.
This allows for the implementation of the DisplayListCanvasRecoder::didSetM44. Instead of another operation that clears the transformation stack along with setting a new transformation on it. A single no-payload operation that clears the stack is added. Existing ops to push to the stack are then reused.
1 parent 46c2cca commit 3039cd3

12 files changed

+46
-9
lines changed

DEPS

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -110,7 +110,7 @@ deps = {
110110
'src': 'https://github.com/flutter/buildroot.git' + '@' + '8cbf38af7d48cc298ae86e614533b4b2d0dc6758',
111111

112112
'src/flutter/impeller':
113-
Var('github_git') + '/flutter/impeller' + '@' + 'c1572a3335c4a533dacc28b86cbebdf08b5a57ed',
113+
Var('github_git') + '/flutter/impeller' + '@' + 'b662deba147396d68e549e41d5d2d6b1cb0b0119',
114114

115115
# Fuchsia compatibility
116116
#

display_list/display_list.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -103,6 +103,7 @@ namespace flutter {
103103
V(Skew) \
104104
V(Transform2DAffine) \
105105
V(TransformFullPerspective) \
106+
V(TransformReset) \
106107
\
107108
V(ClipIntersectRect) \
108109
V(ClipIntersectRRect) \

display_list/display_list_builder.cc

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -427,8 +427,10 @@ void DisplayListBuilder::transformFullPerspective(
427427
mwx, mwy, mwz, mwt);
428428
}
429429
}
430-
431430
// clang-format on
431+
void DisplayListBuilder::transformReset() {
432+
Push<TransformResetOp>(0, 0);
433+
}
432434

433435
void DisplayListBuilder::clipRect(const SkRect& rect,
434436
SkClipOp clip_op,

display_list/display_list_builder.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -176,8 +176,8 @@ class DisplayListBuilder final : public virtual Dispatcher,
176176
SkScalar myx, SkScalar myy, SkScalar myz, SkScalar myt,
177177
SkScalar mzx, SkScalar mzy, SkScalar mzz, SkScalar mzt,
178178
SkScalar mwx, SkScalar mwy, SkScalar mwz, SkScalar mwt) override;
179-
180179
// clang-format on
180+
void transformReset() override;
181181

182182
void clipRect(const SkRect& rect, SkClipOp clip_op, bool is_aa) override;
183183
void clipRRect(const SkRRect& rrect, SkClipOp clip_op, bool is_aa) override;

display_list/display_list_canvas_dispatcher.cc

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -100,6 +100,9 @@ void DisplayListCanvasDispatcher::transformFullPerspective(
100100
mwx, mwy, mwz, mwt));
101101
}
102102
// clang-format on
103+
void DisplayListCanvasDispatcher::transformReset() {
104+
canvas_->resetMatrix();
105+
}
103106

104107
void DisplayListCanvasDispatcher::clipRect(const SkRect& rect,
105108
SkClipOp clip_op,

display_list/display_list_canvas_dispatcher.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -46,6 +46,7 @@ class DisplayListCanvasDispatcher : public virtual Dispatcher,
4646
SkScalar mzx, SkScalar mzy, SkScalar mzz, SkScalar mzt,
4747
SkScalar mwx, SkScalar mwy, SkScalar mwz, SkScalar mwt) override;
4848
// clang-format on
49+
void transformReset() override;
4950

5051
void clipRect(const SkRect& rect, SkClipOp clip_op, bool is_aa) override;
5152
void clipRRect(const SkRRect& rrect, SkClipOp clip_op, bool is_aa) override;

display_list/display_list_canvas_recorder.cc

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,10 @@ void DisplayListCanvasRecorder::didConcat44(const SkM44& m44) {
2828
m44.rc(3, 0), m44.rc(3, 1), m44.rc(3, 2), m44.rc(3, 3));
2929
}
3030
// clang-format on
31+
void DisplayListCanvasRecorder::didSetM44(const SkM44& matrix) {
32+
builder_->transformReset();
33+
didConcat44(matrix);
34+
}
3135
void DisplayListCanvasRecorder::didTranslate(SkScalar tx, SkScalar ty) {
3236
builder_->translate(tx, ty);
3337
}
@@ -230,11 +234,6 @@ void DisplayListCanvasRecorder::onDrawShadowRec(const SkPath& path,
230234
<< __FUNCTION__;
231235
}
232236

233-
void DisplayListCanvasRecorder::didSetM44(const SkM44&) {
234-
FML_DLOG(ERROR) << "Unimplemented DisplayListCanvasRecorder::"
235-
<< __FUNCTION__;
236-
}
237-
238237
void DisplayListCanvasRecorder::onDrawBehind(const SkPaint&) {
239238
FML_DLOG(ERROR) << "Unimplemented DisplayListCanvasRecorder::"
240239
<< __FUNCTION__;

display_list/display_list_dispatcher.h

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -168,9 +168,11 @@ class Dispatcher {
168168
SkScalar myx, SkScalar myy, SkScalar myz, SkScalar myt,
169169
SkScalar mzx, SkScalar mzy, SkScalar mzz, SkScalar mzt,
170170
SkScalar mwx, SkScalar mwy, SkScalar mwz, SkScalar mwt) = 0;
171-
172171
// clang-format on
173172

173+
// Clears the transformation stack.
174+
virtual void transformReset() = 0;
175+
174176
virtual void clipRect(const SkRect& rect, SkClipOp clip_op, bool is_aa) = 0;
175177
virtual void clipRRect(const SkRRect& rrect,
176178
SkClipOp clip_op,

display_list/display_list_ops.h

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -382,6 +382,15 @@ struct TransformFullPerspectiveOp final : DLOp {
382382
}
383383
};
384384

385+
// 4 byte header with no payload.
386+
struct TransformResetOp final : DLOp {
387+
static const auto kType = DisplayListOpType::kTransformReset;
388+
389+
TransformResetOp() = default;
390+
391+
void dispatch(Dispatcher& dispatcher) const { dispatcher.transformReset(); }
392+
};
393+
385394
// 4 byte header + 4 byte common payload packs into minimum 8 bytes
386395
// SkRect is 16 more bytes, which packs efficiently into 24 bytes total
387396
// SkRRect is 52 more bytes, which rounds up to 56 bytes (4 bytes unused)

display_list/display_list_unittests.cc

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1370,6 +1370,18 @@ TEST(DisplayList, DisplayListFullPerspectiveTransformHandling) {
13701370
}
13711371
}
13721372

1373+
TEST(DisplayList, DisplayListTransformResetHandling) {
1374+
DisplayListBuilder builder;
1375+
builder.scale(20.0, 20.0);
1376+
builder.transformReset();
1377+
auto list = builder.Build();
1378+
ASSERT_NE(list, nullptr);
1379+
sk_sp<SkSurface> surface = SkSurface::MakeRasterN32Premul(10, 10);
1380+
SkCanvas* canvas = surface->getCanvas();
1381+
list->RenderTo(canvas);
1382+
ASSERT_TRUE(canvas->getTotalMatrix().isIdentity());
1383+
}
1384+
13731385
TEST(DisplayList, SingleOpsMightSupportGroupOpacityWithOrWithoutBlendMode) {
13741386
auto run_tests = [](std::string name,
13751387
void build(DisplayListBuilder & builder),

0 commit comments

Comments
 (0)