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

Commit 155eb4b

Browse files
committed
More aggressive out-of-lining.
1 parent 3e712c1 commit 155eb4b

File tree

5 files changed

+38
-31
lines changed

5 files changed

+38
-31
lines changed

flow/layers/container_layer.cc

Lines changed: 17 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,22 @@ void ContainerLayer::Add(std::shared_ptr<Layer> layer) {
2020
}
2121
}
2222

23-
void ContainerLayer::UpdateChildReadback(Layer* layer) {
23+
void ContainerLayer::ClearChildren() {
24+
layers_.clear();
25+
if (child_needs_screen_readback_) {
26+
child_needs_screen_readback_ = false;
27+
UpdateTreeReadsSurface();
28+
}
29+
}
30+
31+
void ContainerLayer::set_renders_to_save_layer(bool protects) {
32+
if (renders_to_save_layer_ != protects) {
33+
renders_to_save_layer_ = protects;
34+
UpdateTreeReadsSurface();
35+
}
36+
}
37+
38+
void ContainerLayer::UpdateChildReadback(const Layer* layer) {
2439
if (child_needs_screen_readback_ == layer->tree_reads_surface()) {
2540
return;
2641
}
@@ -39,7 +54,7 @@ void ContainerLayer::UpdateChildReadback(Layer* layer) {
3954
UpdateTreeReadsSurface();
4055
}
4156

42-
bool ContainerLayer::ComputeTreeReadsSurface() {
57+
bool ContainerLayer::ComputeTreeReadsSurface() const {
4358
return layer_reads_surface() ||
4459
(!renders_to_save_layer_ && child_needs_screen_readback_);
4560
}

flow/layers/container_layer.h

Lines changed: 4 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -27,15 +27,15 @@ class ContainerLayer : public Layer {
2727

2828
// Called when the layer, which must be a child of this container,
2929
// changes its tree_reads_surface() result.
30-
void UpdateChildReadback(Layer* layer);
30+
void UpdateChildReadback(const Layer* layer);
3131

3232
protected:
3333
void PrerollChildren(PrerollContext* context,
3434
const SkMatrix& child_matrix,
3535
SkRect* child_paint_bounds);
3636
void PaintChildren(PaintContext& context) const;
3737

38-
virtual bool ComputeTreeReadsSurface() override;
38+
virtual bool ComputeTreeReadsSurface() const override;
3939

4040
#if defined(OS_FUCHSIA)
4141
void UpdateSceneChildren(SceneUpdateContext& context);
@@ -48,21 +48,10 @@ class ContainerLayer : public Layer {
4848
// children perform non-associative rendering. Those children
4949
// will now be performing those operations on the SaveLayer
5050
// rather than the layer that this container renders onto.
51-
void set_renders_to_save_layer(bool protects) {
52-
if (renders_to_save_layer_ != protects) {
53-
renders_to_save_layer_ = protects;
54-
UpdateTreeReadsSurface();
55-
}
56-
}
51+
void set_renders_to_save_layer(bool protects);
5752

5853
// For OpacityLayer to restructure to have a single child.
59-
void ClearChildren() {
60-
layers_.clear();
61-
if (child_needs_screen_readback_) {
62-
child_needs_screen_readback_ = false;
63-
UpdateTreeReadsSurface();
64-
}
65-
}
54+
void ClearChildren();
6655

6756
private:
6857
std::vector<std::shared_ptr<Layer>> layers_;

flow/layers/layer.cc

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,14 @@ uint64_t Layer::NextUniqueID() {
2929
return id;
3030
}
3131

32-
bool Layer::ComputeTreeReadsSurface() {
32+
void Layer::set_layer_reads_surface(bool reads) {
33+
if (layer_reads_surface_ != reads) {
34+
layer_reads_surface_ = reads;
35+
UpdateTreeReadsSurface();
36+
}
37+
}
38+
39+
bool Layer::ComputeTreeReadsSurface() const {
3340
return layer_reads_surface_;
3441
}
3542

flow/layers/layer.h

Lines changed: 8 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -155,30 +155,26 @@ class Layer {
155155
// see Layer::set_layer_reads_surface()
156156
// see ContainerLayer::set_renders_to_save_layer()
157157
// see ContainerLayer::UpdateChildReadback()
158-
bool tree_reads_surface() { return tree_reads_surface_; }
158+
bool tree_reads_surface() const { return tree_reads_surface_; }
159159

160160
uint64_t unique_id() const { return unique_id_; }
161161

162162
protected:
163163
// Compute a new value for tree_reads_surface_ from all of the various
164164
// properties of this layer.
165-
virtual bool ComputeTreeReadsSurface();
165+
// Used by UpdateTreeReadsSurface()
166+
virtual bool ComputeTreeReadsSurface() const;
166167

167168
// Update the tree_reads_surface_ value and propagate changes to
168169
// ancestors if needed.
170+
// Uses ComputeTreeReadsSurface()
169171
void UpdateTreeReadsSurface();
170172

171173
// True iff the layer itself (not a child or other descendant) performs
172-
// an operation which must read back from the surface on which it is
173-
// rendered.
174-
bool layer_reads_surface() { return layer_reads_surface_; }
175-
176-
void set_layer_reads_surface(bool reads) {
177-
if (layer_reads_surface_ != reads) {
178-
layer_reads_surface_ = reads;
179-
UpdateTreeReadsSurface();
180-
}
181-
}
174+
// an operation which reads from the surface on which it is rendered.
175+
bool layer_reads_surface() const { return layer_reads_surface_; }
176+
177+
void set_layer_reads_surface(bool reads);
182178

183179
private:
184180
ContainerLayer* parent_;

flow/layers/layer_tree.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -43,7 +43,7 @@ class LayerTree {
4343
root_layer_ = std::move(root_layer);
4444
}
4545

46-
bool root_needs_screen_readback() {
46+
bool root_needs_screen_readback() const {
4747
return root_layer_ && root_layer_->tree_reads_surface();
4848
}
4949

0 commit comments

Comments
 (0)