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

Commit eb89d9d

Browse files
authored
Explain why OpacityLayer has an offset field (#9713)
According to the request by Amir and Chris.
1 parent f37b78a commit eb89d9d

File tree

1 file changed

+10
-0
lines changed

1 file changed

+10
-0
lines changed

flow/layers/opacity_layer.h

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,16 @@ namespace flutter {
1515
// |EnsureSingleChild| will assert if there are no children.
1616
class OpacityLayer : public ContainerLayer {
1717
public:
18+
// An offset is provided here because OpacityLayer.addToScene method in the
19+
// Flutter framework can take an optional offset argument.
20+
//
21+
// By default, that offset is always zero, and all the offsets are handled by
22+
// some parent TransformLayers. But we allow the offset to be non-zero for
23+
// backward compatibility. If it's non-zero, the old behavior is to propage
24+
// that offset to all the leaf layers (e.g., PictureLayer). That will make
25+
// the retained rendering inefficient as a small offset change could propagate
26+
// to many leaf layers. Therefore we try to capture that offset here to stop
27+
// the propagation as repainting the OpacityLayer is expensive.
1828
OpacityLayer(int alpha, const SkPoint& offset);
1929
~OpacityLayer() override;
2030

0 commit comments

Comments
 (0)