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

Commit a9967ba

Browse files
committed
shift Preroll from MutatorsStack to LayerStateStack
1 parent a760ce7 commit a9967ba

31 files changed

+299
-333
lines changed

display_list/display_list_color.h

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,9 @@ struct DlColor {
1414
constexpr DlColor() : argb(0xFF000000) {}
1515
constexpr DlColor(uint32_t argb) : argb(argb) {}
1616

17+
static constexpr uint8_t toAlpha(SkScalar opacity) { return toC(opacity); }
18+
static constexpr SkScalar toOpacity(uint8_t alpha) { return toF(alpha); }
19+
1720
// clang-format off
1821
static constexpr DlColor kTransparent() {return 0x00000000;};
1922
static constexpr DlColor kBlack() {return 0xFF000000;};

flow/embedded_views.cc

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -109,6 +109,12 @@ void MutatorsStack::Pop() {
109109
vector_.pop_back();
110110
};
111111

112+
void MutatorsStack::PopTo(size_t stack_count) {
113+
while (vector_.size() > stack_count) {
114+
Pop();
115+
}
116+
}
117+
112118
const std::vector<std::shared_ptr<Mutator>>::const_reverse_iterator
113119
MutatorsStack::Top() const {
114120
return vector_.rend();

flow/embedded_views.h

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -160,6 +160,8 @@ class MutatorsStack {
160160
// and destroys it.
161161
void Pop();
162162

163+
void PopTo(size_t stack_count);
164+
163165
// Returns a reverse iterator pointing to the top of the stack, which is the
164166
// mutator that is furtherest from the leaf node.
165167
const std::vector<std::shared_ptr<Mutator>>::const_reverse_iterator Top()
@@ -178,6 +180,7 @@ class MutatorsStack {
178180
const std::vector<std::shared_ptr<Mutator>>::const_iterator End() const;
179181

180182
bool is_empty() const { return vector_.empty(); }
183+
size_t stack_count() const { return vector_.size(); }
181184

182185
bool operator==(const MutatorsStack& other) const {
183186
if (vector_.size() != other.vector_.size()) {

flow/layers/checkerboard_layertree_unittests.cc

Lines changed: 12 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -39,8 +39,8 @@ TEST_F(CheckerBoardLayerTest, ClipRectSaveLayerNotCheckBoard) {
3939
preroll_context()->cull_rect = cull_bounds; // Cull child
4040

4141
layer->Preroll(preroll_context(), initial_matrix);
42-
EXPECT_EQ(preroll_context()->cull_rect, cull_bounds); // Untouched
43-
EXPECT_TRUE(preroll_context()->mutators_stack.is_empty()); // Untouched
42+
EXPECT_EQ(preroll_context()->cull_rect, cull_bounds); // Untouched
43+
EXPECT_TRUE(preroll_context()->state_stack.is_empty()); // Untouched
4444
EXPECT_EQ(mock_layer->paint_bounds(), child_bounds);
4545
EXPECT_EQ(layer->paint_bounds(), child_intersect_bounds);
4646
EXPECT_TRUE(mock_layer->needs_painting(paint_context()));
@@ -89,8 +89,8 @@ TEST_F(CheckerBoardLayerTest, ClipRectSaveLayerCheckBoard) {
8989
preroll_context()->cull_rect = cull_bounds; // Cull child
9090

9191
layer->Preroll(preroll_context(), initial_matrix);
92-
EXPECT_EQ(preroll_context()->cull_rect, cull_bounds); // Untouched
93-
EXPECT_TRUE(preroll_context()->mutators_stack.is_empty()); // Untouched
92+
EXPECT_EQ(preroll_context()->cull_rect, cull_bounds); // Untouched
93+
EXPECT_TRUE(preroll_context()->state_stack.is_empty()); // Untouched
9494
EXPECT_EQ(mock_layer->paint_bounds(), child_bounds);
9595
EXPECT_EQ(layer->paint_bounds(), child_intersect_bounds);
9696
EXPECT_TRUE(mock_layer->needs_painting(paint_context()));
@@ -132,8 +132,8 @@ TEST_F(CheckerBoardLayerTest, ClipPathSaveLayerNotCheckBoard) {
132132
layer->Add(mock_layer);
133133

134134
layer->Preroll(preroll_context(), initial_matrix);
135-
EXPECT_EQ(preroll_context()->cull_rect, kGiantRect); // Untouched
136-
EXPECT_TRUE(preroll_context()->mutators_stack.is_empty()); // Untouched
135+
EXPECT_EQ(preroll_context()->cull_rect, kGiantRect); // Untouched
136+
EXPECT_TRUE(preroll_context()->state_stack.is_empty()); // Untouched
137137
EXPECT_EQ(mock_layer->paint_bounds(), child_bounds);
138138
EXPECT_EQ(layer->paint_bounds(), mock_layer->paint_bounds());
139139
EXPECT_TRUE(mock_layer->needs_painting(paint_context()));
@@ -173,8 +173,8 @@ TEST_F(CheckerBoardLayerTest, ClipPathSaveLayerCheckBoard) {
173173
layer->Add(mock_layer);
174174

175175
layer->Preroll(preroll_context(), initial_matrix);
176-
EXPECT_EQ(preroll_context()->cull_rect, kGiantRect); // Untouched
177-
EXPECT_TRUE(preroll_context()->mutators_stack.is_empty()); // Untouched
176+
EXPECT_EQ(preroll_context()->cull_rect, kGiantRect); // Untouched
177+
EXPECT_TRUE(preroll_context()->state_stack.is_empty()); // Untouched
178178
EXPECT_EQ(mock_layer->paint_bounds(), child_bounds);
179179
EXPECT_EQ(layer->paint_bounds(), mock_layer->paint_bounds());
180180
EXPECT_TRUE(mock_layer->needs_painting(paint_context()));
@@ -214,8 +214,8 @@ TEST_F(CheckerBoardLayerTest, ClipRRectSaveLayerNotCheckBoard) {
214214
layer->Add(mock_layer);
215215

216216
layer->Preroll(preroll_context(), initial_matrix);
217-
EXPECT_EQ(preroll_context()->cull_rect, kGiantRect); // Untouched
218-
EXPECT_TRUE(preroll_context()->mutators_stack.is_empty()); // Untouched
217+
EXPECT_EQ(preroll_context()->cull_rect, kGiantRect); // Untouched
218+
EXPECT_TRUE(preroll_context()->state_stack.is_empty()); // Untouched
219219
EXPECT_EQ(mock_layer->paint_bounds(), child_bounds);
220220
EXPECT_EQ(layer->paint_bounds(), mock_layer->paint_bounds());
221221
EXPECT_TRUE(mock_layer->needs_painting(paint_context()));
@@ -255,8 +255,8 @@ TEST_F(CheckerBoardLayerTest, ClipRRectSaveLayerCheckBoard) {
255255
layer->Add(mock_layer);
256256

257257
layer->Preroll(preroll_context(), initial_matrix);
258-
EXPECT_EQ(preroll_context()->cull_rect, kGiantRect); // Untouched
259-
EXPECT_TRUE(preroll_context()->mutators_stack.is_empty()); // Untouched
258+
EXPECT_EQ(preroll_context()->cull_rect, kGiantRect); // Untouched
259+
EXPECT_TRUE(preroll_context()->state_stack.is_empty()); // Untouched
260260
EXPECT_EQ(mock_layer->paint_bounds(), child_bounds);
261261
EXPECT_EQ(layer->paint_bounds(), mock_layer->paint_bounds());
262262
EXPECT_TRUE(mock_layer->needs_painting(paint_context()));

flow/layers/clip_path_layer.cc

Lines changed: 1 addition & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -23,13 +23,7 @@ const SkRect& ClipPathLayer::clip_shape_bounds() const {
2323
return clip_shape().getBounds();
2424
}
2525

26-
void ClipPathLayer::OnMutatorsStackPushClipShape(
27-
MutatorsStack& mutators_stack) {
28-
mutators_stack.PushClipPath(clip_shape());
29-
}
30-
31-
void ClipPathLayer::OnCanvasClipShape(
32-
LayerStateStack::MutatorContext& mutator) const {
26+
void ClipPathLayer::ApplyClip(LayerStateStack::MutatorContext& mutator) const {
3327
mutator.clipPath(clip_shape(), clip_behavior() != Clip::hardEdge);
3428
}
3529

flow/layers/clip_path_layer.h

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -21,10 +21,7 @@ class ClipPathLayer : public ClipShapeLayer<SkPath> {
2121
protected:
2222
const SkRect& clip_shape_bounds() const override;
2323

24-
void OnMutatorsStackPushClipShape(MutatorsStack& mutators_stack) override;
25-
26-
void OnCanvasClipShape(
27-
LayerStateStack::MutatorContext& mutator) const override;
24+
void ApplyClip(LayerStateStack::MutatorContext& mutator) const override;
2825

2926
private:
3027
FML_DISALLOW_COPY_AND_ASSIGN(ClipPathLayer);

flow/layers/clip_path_layer_unittests.cc

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -30,8 +30,8 @@ TEST_F(ClipPathLayerTest, PaintingEmptyLayerDies) {
3030
auto layer = std::make_shared<ClipPathLayer>(SkPath(), Clip::hardEdge);
3131

3232
layer->Preroll(preroll_context(), SkMatrix());
33-
EXPECT_EQ(preroll_context()->cull_rect, kGiantRect); // Untouched
34-
EXPECT_TRUE(preroll_context()->mutators_stack.is_empty()); // Untouched
33+
EXPECT_EQ(preroll_context()->cull_rect, kGiantRect); // Untouched
34+
EXPECT_TRUE(preroll_context()->state_stack.is_empty()); // Untouched
3535
EXPECT_EQ(layer->paint_bounds(), kEmptyRect);
3636
EXPECT_EQ(layer->child_paint_bounds(), kEmptyRect);
3737
EXPECT_FALSE(layer->needs_painting(paint_context()));
@@ -66,8 +66,8 @@ TEST_F(ClipPathLayerTest, PaintingCulledLayerDies) {
6666
preroll_context()->cull_rect = distant_bounds; // Cull these children
6767

6868
layer->Preroll(preroll_context(), initial_matrix);
69-
EXPECT_EQ(preroll_context()->cull_rect, distant_bounds); // Untouched
70-
EXPECT_TRUE(preroll_context()->mutators_stack.is_empty()); // Untouched
69+
EXPECT_EQ(preroll_context()->cull_rect, distant_bounds); // Untouched
70+
EXPECT_TRUE(preroll_context()->state_stack.is_empty()); // Untouched
7171
EXPECT_EQ(mock_layer->paint_bounds(), child_bounds);
7272
EXPECT_EQ(layer->paint_bounds(), child_bounds);
7373
EXPECT_EQ(layer->child_paint_bounds(), child_bounds);
@@ -105,8 +105,8 @@ TEST_F(ClipPathLayerTest, ChildOutsideBounds) {
105105
preroll_context()->cull_rect = cull_bounds; // Cull child
106106

107107
layer->Preroll(preroll_context(), initial_matrix);
108-
EXPECT_EQ(preroll_context()->cull_rect, cull_bounds); // Untouched
109-
EXPECT_TRUE(preroll_context()->mutators_stack.is_empty()); // Untouched
108+
EXPECT_EQ(preroll_context()->cull_rect, cull_bounds); // Untouched
109+
EXPECT_TRUE(preroll_context()->state_stack.is_empty()); // Untouched
110110
EXPECT_EQ(mock_layer->paint_bounds(), child_bounds);
111111
EXPECT_EQ(layer->paint_bounds(), child_intersect_bounds);
112112
EXPECT_EQ(layer->child_paint_bounds(), child_bounds);
@@ -141,8 +141,8 @@ TEST_F(ClipPathLayerTest, FullyContainedChild) {
141141
layer->Add(mock_layer);
142142

143143
layer->Preroll(preroll_context(), initial_matrix);
144-
EXPECT_EQ(preroll_context()->cull_rect, kGiantRect); // Untouched
145-
EXPECT_TRUE(preroll_context()->mutators_stack.is_empty()); // Untouched
144+
EXPECT_EQ(preroll_context()->cull_rect, kGiantRect); // Untouched
145+
EXPECT_TRUE(preroll_context()->state_stack.is_empty()); // Untouched
146146
EXPECT_EQ(mock_layer->paint_bounds(), child_bounds);
147147
EXPECT_EQ(layer->paint_bounds(), mock_layer->paint_bounds());
148148
EXPECT_EQ(layer->child_paint_bounds(), child_bounds);
@@ -184,8 +184,8 @@ TEST_F(ClipPathLayerTest, PartiallyContainedChild) {
184184
preroll_context()->cull_rect = cull_bounds; // Cull child
185185

186186
layer->Preroll(preroll_context(), initial_matrix);
187-
EXPECT_EQ(preroll_context()->cull_rect, cull_bounds); // Untouched
188-
EXPECT_TRUE(preroll_context()->mutators_stack.is_empty()); // Untouched
187+
EXPECT_EQ(preroll_context()->cull_rect, cull_bounds); // Untouched
188+
EXPECT_TRUE(preroll_context()->state_stack.is_empty()); // Untouched
189189
EXPECT_EQ(mock_layer->paint_bounds(), child_bounds);
190190
EXPECT_EQ(layer->paint_bounds(), child_intersect_bounds);
191191
EXPECT_EQ(layer->child_paint_bounds(), child_bounds);

flow/layers/clip_rect_layer.cc

Lines changed: 1 addition & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -23,13 +23,7 @@ const SkRect& ClipRectLayer::clip_shape_bounds() const {
2323
return clip_shape();
2424
}
2525

26-
void ClipRectLayer::OnMutatorsStackPushClipShape(
27-
MutatorsStack& mutators_stack) {
28-
mutators_stack.PushClipRect(clip_shape());
29-
}
30-
31-
void ClipRectLayer::OnCanvasClipShape(
32-
LayerStateStack::MutatorContext& mutator) const {
26+
void ClipRectLayer::ApplyClip(LayerStateStack::MutatorContext& mutator) const {
3327
mutator.clipRect(clip_shape(), clip_behavior() != Clip::hardEdge);
3428
}
3529

flow/layers/clip_rect_layer.h

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -20,10 +20,7 @@ class ClipRectLayer : public ClipShapeLayer<SkRect> {
2020
protected:
2121
const SkRect& clip_shape_bounds() const override;
2222

23-
void OnMutatorsStackPushClipShape(MutatorsStack& mutators_stack) override;
24-
25-
void OnCanvasClipShape(
26-
LayerStateStack::MutatorContext& mutator) const override;
23+
void ApplyClip(LayerStateStack::MutatorContext& mutator) const override;
2724

2825
private:
2926
FML_DISALLOW_COPY_AND_ASSIGN(ClipRectLayer);

flow/layers/clip_rect_layer_unittests.cc

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -27,8 +27,8 @@ TEST_F(ClipRectLayerTest, PaintingEmptyLayerDies) {
2727
auto layer = std::make_shared<ClipRectLayer>(kEmptyRect, Clip::hardEdge);
2828

2929
layer->Preroll(preroll_context(), SkMatrix());
30-
EXPECT_EQ(preroll_context()->cull_rect, kGiantRect); // Untouched
31-
EXPECT_TRUE(preroll_context()->mutators_stack.is_empty()); // Untouched
30+
EXPECT_EQ(preroll_context()->cull_rect, kGiantRect); // Untouched
31+
EXPECT_TRUE(preroll_context()->state_stack.is_empty()); // Untouched
3232
EXPECT_EQ(layer->paint_bounds(), kEmptyRect);
3333
EXPECT_EQ(layer->child_paint_bounds(), kEmptyRect);
3434
EXPECT_FALSE(layer->needs_painting(paint_context()));
@@ -61,8 +61,8 @@ TEST_F(ClipRectLayerTest, PaintingCulledLayerDies) {
6161
preroll_context()->cull_rect = distant_bounds; // Cull these children
6262

6363
layer->Preroll(preroll_context(), initial_matrix);
64-
EXPECT_EQ(preroll_context()->cull_rect, distant_bounds); // Untouched
65-
EXPECT_TRUE(preroll_context()->mutators_stack.is_empty()); // Untouched
64+
EXPECT_EQ(preroll_context()->cull_rect, distant_bounds); // Untouched
65+
EXPECT_TRUE(preroll_context()->state_stack.is_empty()); // Untouched
6666
EXPECT_EQ(mock_layer->paint_bounds(), child_bounds);
6767
EXPECT_EQ(layer->paint_bounds(), child_bounds);
6868
EXPECT_EQ(layer->child_paint_bounds(), child_bounds);
@@ -100,8 +100,8 @@ TEST_F(ClipRectLayerTest, ChildOutsideBounds) {
100100
preroll_context()->cull_rect = cull_bounds; // Cull child
101101

102102
layer->Preroll(preroll_context(), initial_matrix);
103-
EXPECT_EQ(preroll_context()->cull_rect, cull_bounds); // Untouched
104-
EXPECT_TRUE(preroll_context()->mutators_stack.is_empty()); // Untouched
103+
EXPECT_EQ(preroll_context()->cull_rect, cull_bounds); // Untouched
104+
EXPECT_TRUE(preroll_context()->state_stack.is_empty()); // Untouched
105105
EXPECT_EQ(mock_layer->paint_bounds(), child_bounds);
106106
EXPECT_EQ(layer->paint_bounds(), child_intersect_bounds);
107107
EXPECT_EQ(layer->child_paint_bounds(), child_bounds);
@@ -136,8 +136,8 @@ TEST_F(ClipRectLayerTest, FullyContainedChild) {
136136
layer->Add(mock_layer);
137137

138138
layer->Preroll(preroll_context(), initial_matrix);
139-
EXPECT_EQ(preroll_context()->cull_rect, kGiantRect); // Untouched
140-
EXPECT_TRUE(preroll_context()->mutators_stack.is_empty()); // Untouched
139+
EXPECT_EQ(preroll_context()->cull_rect, kGiantRect); // Untouched
140+
EXPECT_TRUE(preroll_context()->state_stack.is_empty()); // Untouched
141141
EXPECT_EQ(mock_layer->paint_bounds(), child_bounds);
142142
EXPECT_EQ(layer->paint_bounds(), mock_layer->paint_bounds());
143143
EXPECT_EQ(layer->child_paint_bounds(), child_bounds);
@@ -179,8 +179,8 @@ TEST_F(ClipRectLayerTest, PartiallyContainedChild) {
179179
preroll_context()->cull_rect = cull_bounds; // Cull child
180180

181181
layer->Preroll(preroll_context(), initial_matrix);
182-
EXPECT_EQ(preroll_context()->cull_rect, cull_bounds); // Untouched
183-
EXPECT_TRUE(preroll_context()->mutators_stack.is_empty()); // Untouched
182+
EXPECT_EQ(preroll_context()->cull_rect, cull_bounds); // Untouched
183+
EXPECT_TRUE(preroll_context()->state_stack.is_empty()); // Untouched
184184
EXPECT_EQ(mock_layer->paint_bounds(), child_bounds);
185185
EXPECT_EQ(layer->paint_bounds(), child_intersect_bounds);
186186
EXPECT_EQ(layer->child_paint_bounds(), child_bounds);

flow/layers/clip_rrect_layer.cc

Lines changed: 1 addition & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -23,13 +23,7 @@ const SkRect& ClipRRectLayer::clip_shape_bounds() const {
2323
return clip_shape().getBounds();
2424
}
2525

26-
void ClipRRectLayer::OnMutatorsStackPushClipShape(
27-
MutatorsStack& mutators_stack) {
28-
mutators_stack.PushClipRRect(clip_shape());
29-
}
30-
31-
void ClipRRectLayer::OnCanvasClipShape(
32-
LayerStateStack::MutatorContext& mutator) const {
26+
void ClipRRectLayer::ApplyClip(LayerStateStack::MutatorContext& mutator) const {
3327
mutator.clipRRect(clip_shape(), clip_behavior() != Clip::hardEdge);
3428
}
3529

flow/layers/clip_rrect_layer.h

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -20,10 +20,7 @@ class ClipRRectLayer : public ClipShapeLayer<SkRRect> {
2020
protected:
2121
const SkRect& clip_shape_bounds() const override;
2222

23-
void OnMutatorsStackPushClipShape(MutatorsStack& mutators_stack) override;
24-
25-
void OnCanvasClipShape(
26-
LayerStateStack::MutatorContext& mutator) const override;
23+
void ApplyClip(LayerStateStack::MutatorContext& mutator) const override;
2724

2825
private:
2926
FML_DISALLOW_COPY_AND_ASSIGN(ClipRRectLayer);

flow/layers/clip_rrect_layer_unittests.cc

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -29,8 +29,8 @@ TEST_F(ClipRRectLayerTest, PaintingEmptyLayerDies) {
2929
auto layer = std::make_shared<ClipRRectLayer>(layer_rrect, Clip::hardEdge);
3030

3131
layer->Preroll(preroll_context(), SkMatrix());
32-
EXPECT_EQ(preroll_context()->cull_rect, kGiantRect); // Untouched
33-
EXPECT_TRUE(preroll_context()->mutators_stack.is_empty()); // Untouched
32+
EXPECT_EQ(preroll_context()->cull_rect, kGiantRect); // Untouched
33+
EXPECT_TRUE(preroll_context()->state_stack.is_empty()); // Untouched
3434
EXPECT_EQ(layer->paint_bounds(), kEmptyRect);
3535
EXPECT_EQ(layer->child_paint_bounds(), kEmptyRect);
3636
EXPECT_FALSE(layer->needs_painting(paint_context()));
@@ -66,8 +66,8 @@ TEST_F(ClipRRectLayerTest, PaintingCulledLayerDies) {
6666
preroll_context()->cull_rect = distant_bounds; // Cull these children
6767

6868
layer->Preroll(preroll_context(), initial_matrix);
69-
EXPECT_EQ(preroll_context()->cull_rect, distant_bounds); // Untouched
70-
EXPECT_TRUE(preroll_context()->mutators_stack.is_empty()); // Untouched
69+
EXPECT_EQ(preroll_context()->cull_rect, distant_bounds); // Untouched
70+
EXPECT_TRUE(preroll_context()->state_stack.is_empty()); // Untouched
7171
EXPECT_EQ(mock_layer->paint_bounds(), child_bounds);
7272
EXPECT_EQ(layer->paint_bounds(), child_bounds);
7373
EXPECT_EQ(layer->child_paint_bounds(), child_bounds);
@@ -105,8 +105,8 @@ TEST_F(ClipRRectLayerTest, ChildOutsideBounds) {
105105
preroll_context()->cull_rect = cull_bounds; // Cull child
106106

107107
layer->Preroll(preroll_context(), initial_matrix);
108-
EXPECT_EQ(preroll_context()->cull_rect, cull_bounds); // Untouched
109-
EXPECT_TRUE(preroll_context()->mutators_stack.is_empty()); // Untouched
108+
EXPECT_EQ(preroll_context()->cull_rect, cull_bounds); // Untouched
109+
EXPECT_TRUE(preroll_context()->state_stack.is_empty()); // Untouched
110110
EXPECT_EQ(mock_layer->paint_bounds(), child_bounds);
111111
EXPECT_EQ(layer->paint_bounds(), child_intersect_bounds);
112112
EXPECT_EQ(layer->child_paint_bounds(), child_bounds);
@@ -141,8 +141,8 @@ TEST_F(ClipRRectLayerTest, FullyContainedChild) {
141141
layer->Add(mock_layer);
142142

143143
layer->Preroll(preroll_context(), initial_matrix);
144-
EXPECT_EQ(preroll_context()->cull_rect, kGiantRect); // Untouched
145-
EXPECT_TRUE(preroll_context()->mutators_stack.is_empty()); // Untouched
144+
EXPECT_EQ(preroll_context()->cull_rect, kGiantRect); // Untouched
145+
EXPECT_TRUE(preroll_context()->state_stack.is_empty()); // Untouched
146146
EXPECT_EQ(mock_layer->paint_bounds(), child_bounds);
147147
EXPECT_EQ(layer->paint_bounds(), mock_layer->paint_bounds());
148148
EXPECT_EQ(layer->child_paint_bounds(), child_bounds);
@@ -184,8 +184,8 @@ TEST_F(ClipRRectLayerTest, PartiallyContainedChild) {
184184
preroll_context()->cull_rect = cull_bounds; // Cull child
185185

186186
layer->Preroll(preroll_context(), initial_matrix);
187-
EXPECT_EQ(preroll_context()->cull_rect, cull_bounds); // Untouched
188-
EXPECT_TRUE(preroll_context()->mutators_stack.is_empty()); // Untouched
187+
EXPECT_EQ(preroll_context()->cull_rect, cull_bounds); // Untouched
188+
EXPECT_TRUE(preroll_context()->state_stack.is_empty()); // Untouched
189189
EXPECT_EQ(mock_layer->paint_bounds(), child_bounds);
190190
EXPECT_EQ(layer->paint_bounds(), child_intersect_bounds);
191191
EXPECT_EQ(layer->child_paint_bounds(), child_bounds);

flow/layers/clip_shape_layer.h

Lines changed: 5 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -59,7 +59,9 @@ class ClipShapeLayer : public CacheableContainerLayer {
5959

6060
Layer::AutoPrerollSaveLayerState save =
6161
Layer::AutoPrerollSaveLayerState::Create(context, UsesSaveLayer());
62-
OnMutatorsStackPushClipShape(context->mutators_stack);
62+
63+
auto mutator = context->state_stack.save();
64+
ApplyClip(mutator);
6365

6466
SkRect child_paint_bounds = SkRect::MakeEmpty();
6567
PrerollChildren(context, matrix, &child_paint_bounds);
@@ -73,15 +75,14 @@ class ClipShapeLayer : public CacheableContainerLayer {
7375
context->renderable_state_flags = SAVE_LAYER_RENDER_FLAGS;
7476
}
7577

76-
context->mutators_stack.Pop();
7778
context->cull_rect = previous_cull_rect;
7879
}
7980

8081
void Paint(PaintContext& context) const override {
8182
FML_DCHECK(needs_painting(context));
8283

8384
auto mutator = context.state_stack.save();
84-
OnCanvasClipShape(mutator);
85+
ApplyClip(mutator);
8586

8687
if (!UsesSaveLayer()) {
8788
PaintChildren(context);
@@ -110,9 +111,7 @@ class ClipShapeLayer : public CacheableContainerLayer {
110111

111112
protected:
112113
virtual const SkRect& clip_shape_bounds() const = 0;
113-
virtual void OnMutatorsStackPushClipShape(MutatorsStack& mutators_stack) = 0;
114-
virtual void OnCanvasClipShape(
115-
LayerStateStack::MutatorContext& mutator) const = 0;
114+
virtual void ApplyClip(LayerStateStack::MutatorContext& mutator) const = 0;
116115
virtual ~ClipShapeLayer() = default;
117116

118117
const ClipShape& clip_shape() const { return clip_shape_; }

flow/layers/layer.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -53,7 +53,7 @@ struct PrerollContext {
5353
RasterCache* raster_cache;
5454
GrDirectContext* gr_context;
5555
ExternalViewEmbedder* view_embedder;
56-
MutatorsStack& mutators_stack;
56+
LayerStateStack& state_stack;
5757
SkColorSpace* dst_color_space;
5858
SkRect cull_rect;
5959
bool surface_needs_readback;

0 commit comments

Comments
 (0)