Unverified Commit 9ecba20f authored by Ren You's avatar Ren You Committed by GitHub

Revert "Always push layer for RenderAnimatedOpacityMixin (#83145)" (#84187)

This reverts commit 048baa75.
parent 5c54e70f
......@@ -993,7 +993,7 @@ mixin RenderAnimatedOpacityMixin<T extends RenderObject> on RenderObjectWithChil
_alpha = ui.Color.getAlphaFromOpacity(opacity.value);
if (oldAlpha != _alpha) {
final bool? didNeedCompositing = _currentlyNeedsCompositing;
_currentlyNeedsCompositing = _alpha! > 0;
_currentlyNeedsCompositing = _alpha! > 0 && _alpha! < 255;
if (child != null && didNeedCompositing != _currentlyNeedsCompositing)
markNeedsCompositingBitsUpdate();
markNeedsPaint();
......@@ -1010,6 +1010,12 @@ mixin RenderAnimatedOpacityMixin<T extends RenderObject> on RenderObjectWithChil
layer = null;
return;
}
if (_alpha == 255) {
// No need to keep the layer. We'll create a new one if necessary.
layer = null;
context.paintChild(child!, offset);
return;
}
assert(needsCompositing);
layer = context.pushOpacity(offset, _alpha!, super.paint, oldLayer: layer as OpacityLayer?);
}
......
......@@ -306,7 +306,7 @@ void main() {
expect(renderAnimatedOpacity.needsCompositing, false);
});
test('RenderAnimatedOpacity does composite if it is opaque', () {
test('RenderAnimatedOpacity does not composite if it is opaque', () {
final Animation<double> opacityAnimation = AnimationController(
vsync: FakeTickerProvider(),
)..value = 1.0;
......@@ -318,7 +318,7 @@ void main() {
);
layout(renderAnimatedOpacity, phase: EnginePhase.composite);
expect(renderAnimatedOpacity.needsCompositing, true);
expect(renderAnimatedOpacity.needsCompositing, false);
});
test('RenderAnimatedOpacity reuses its layer', () {
......
......@@ -102,7 +102,7 @@ void main() {
expect(renderSliverAnimatedOpacity.needsCompositing, false);
});
test('RenderSliverAnimatedOpacity does composite if it is opaque', () {
test('RenderSliverAnimatedOpacity does not composite if it is opaque', () {
final Animation<double> opacityAnimation = AnimationController(
vsync: FakeTickerProvider(),
)..value = 1.0;
......@@ -124,7 +124,7 @@ void main() {
);
layout(root, phase: EnginePhase.composite);
expect(renderSliverAnimatedOpacity.needsCompositing, true);
expect(renderSliverAnimatedOpacity.needsCompositing, false);
});
test('RenderSliverAnimatedOpacity reuses its layer', () {
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment