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

Commit 24413fb

Browse files
committed
fix initial matrix/clip when reapplying for new canvas/builder
1 parent 001228b commit 24413fb

File tree

2 files changed

+17
-9
lines changed

2 files changed

+17
-9
lines changed

flow/layers/layer_state_stack.cc

Lines changed: 15 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -21,9 +21,9 @@ static inline bool has_perspective(const SkM44& matrix) {
2121

2222
LayerStateStack::LayerStateStack(const SkRect* cull_rect) {
2323
if (cull_rect) {
24-
cull_rect_ = *cull_rect;
24+
initial_cull_rect_ = cull_rect_ = *cull_rect;
2525
} else {
26-
cull_rect_ = kGiantRect;
26+
initial_cull_rect_ = cull_rect_ = kGiantRect;
2727
}
2828
}
2929

@@ -72,35 +72,35 @@ void LayerStateStack::set_delegate(MutatorsStack* stack) {
7272
void LayerStateStack::set_initial_cull_rect(const SkRect& cull_rect) {
7373
FML_CHECK(is_empty()) << "set_initial_cull_rect() must be called before any "
7474
"state is pushed onto the state stack";
75-
cull_rect_ = cull_rect;
75+
initial_cull_rect_ = cull_rect_ = cull_rect;
7676
}
7777

7878
void LayerStateStack::set_initial_transform(const SkMatrix& matrix) {
7979
FML_CHECK(is_empty()) << "set_initial_transform() must be called before any "
8080
"state is pushed onto the state stack";
81-
matrix_ = SkM44(matrix);
81+
initial_matrix_ = matrix_ = SkM44(matrix);
8282
}
8383

8484
void LayerStateStack::set_initial_transform(const SkM44& matrix) {
8585
FML_CHECK(is_empty()) << "set_initial_transform() must be called before any "
8686
"state is pushed onto the state stack";
87-
matrix_ = matrix;
87+
initial_matrix_ = matrix_ = matrix;
8888
}
8989

9090
void LayerStateStack::set_initial_state(const SkRect& cull_rect,
9191
const SkMatrix& matrix) {
9292
FML_CHECK(is_empty()) << "set_initial_state() must be called before any "
9393
"state is pushed onto the state stack";
94-
cull_rect_ = cull_rect;
95-
matrix_ = SkM44(matrix);
94+
initial_cull_rect_ = cull_rect_ = cull_rect;
95+
initial_matrix_ = matrix_ = SkM44(matrix);
9696
}
9797

9898
void LayerStateStack::set_initial_state(const SkRect& cull_rect,
9999
const SkM44& matrix) {
100100
FML_CHECK(is_empty()) << "set_initial_state() must be called before any "
101101
"state is pushed onto the state stack";
102-
cull_rect_ = cull_rect;
103-
matrix_ = matrix;
102+
initial_cull_rect_ = cull_rect_ = cull_rect;
103+
initial_matrix_ = matrix_ = matrix;
104104
}
105105

106106
void LayerStateStack::reapply_all() {
@@ -110,11 +110,17 @@ void LayerStateStack::reapply_all() {
110110
// the stack. When we are finished, though, the local attributes
111111
// contents should match the current outstanding_ values;
112112
RenderingAttributes attributes = outstanding_;
113+
SkM44 matrix = matrix_;
114+
SkRect cull_rect = cull_rect_;
113115
outstanding_ = {};
116+
matrix_ = initial_matrix_;
117+
cull_rect_ = initial_cull_rect_;
114118
for (auto& state : state_stack_) {
115119
state->reapply(this);
116120
}
117121
FML_DCHECK(attributes == outstanding_);
122+
FML_DCHECK(matrix == matrix_);
123+
FML_DCHECK(cull_rect == cull_rect_);
118124
}
119125

120126
AutoRestore::AutoRestore(LayerStateStack* stack)

flow/layers/layer_state_stack.h

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -494,7 +494,9 @@ class LayerStateStack {
494494
std::vector<std::unique_ptr<StateEntry>> state_stack_;
495495
friend class MutatorContext;
496496

497+
SkM44 initial_matrix_;
497498
SkM44 matrix_;
499+
SkRect initial_cull_rect_;
498500
SkRect cull_rect_;
499501

500502
SkCanvas* canvas_ = nullptr;

0 commit comments

Comments
 (0)