Unverified Commit 95fbd819 authored by Jason Simmons's avatar Jason Simmons Committed by GitHub

Place the transform and its children within the RenderFlow's opacity layer (#15543)

Fixes https://github.com/flutter/flutter/issues/15037
parent 340c6803
...@@ -342,7 +342,7 @@ class RenderFlow extends RenderBox ...@@ -342,7 +342,7 @@ class RenderFlow extends RenderBox
_paintingContext.pushTransform(needsCompositing, _paintingOffset, transform, painter); _paintingContext.pushTransform(needsCompositing, _paintingOffset, transform, painter);
} else { } else {
_paintingContext.pushOpacity(_paintingOffset, _getAlphaFromOpacity(opacity), (PaintingContext context, Offset offset) { _paintingContext.pushOpacity(_paintingOffset, _getAlphaFromOpacity(opacity), (PaintingContext context, Offset offset) {
_paintingContext.pushTransform(needsCompositing, offset, transform, painter); context.pushTransform(needsCompositing, offset, transform, painter);
}); });
} }
} }
......
...@@ -4,6 +4,7 @@ ...@@ -4,6 +4,7 @@
import 'package:flutter_test/flutter_test.dart'; import 'package:flutter_test/flutter_test.dart';
import 'package:flutter/widgets.dart'; import 'package:flutter/widgets.dart';
import 'package:flutter/rendering.dart';
class TestFlowDelegate extends FlowDelegate { class TestFlowDelegate extends FlowDelegate {
TestFlowDelegate({this.startOffset}) : super(repaint: startOffset); TestFlowDelegate({this.startOffset}) : super(repaint: startOffset);
...@@ -28,6 +29,22 @@ class TestFlowDelegate extends FlowDelegate { ...@@ -28,6 +29,22 @@ class TestFlowDelegate extends FlowDelegate {
bool shouldRepaint(TestFlowDelegate oldDelegate) => startOffset == oldDelegate.startOffset; bool shouldRepaint(TestFlowDelegate oldDelegate) => startOffset == oldDelegate.startOffset;
} }
class OpacityFlowDelegate extends FlowDelegate {
OpacityFlowDelegate(this.opacity);
double opacity;
@override
void paintChildren(FlowPaintingContext context) {
for (int i = 0; i < context.childCount; ++i) {
context.paintChild(i, opacity: opacity);
}
}
@override
bool shouldRepaint(OpacityFlowDelegate oldDelegate) => opacity != oldDelegate.opacity;
}
void main() { void main() {
testWidgets('Flow control test', (WidgetTester tester) async { testWidgets('Flow control test', (WidgetTester tester) async {
final AnimationController startOffset = new AnimationController.unbounded( final AnimationController startOffset = new AnimationController.unbounded(
...@@ -82,4 +99,23 @@ void main() { ...@@ -82,4 +99,23 @@ void main() {
await tester.tapAt(const Offset(20.0, 90.0)); await tester.tapAt(const Offset(20.0, 90.0));
expect(log, equals(<int>[0])); expect(log, equals(<int>[0]));
}); });
testWidgets('Flow opacity layer', (WidgetTester tester) async {
const double opacity = 0.2;
await tester.pumpWidget(
new Flow(
delegate: new OpacityFlowDelegate(opacity),
children: <Widget>[
new Container(width: 100.0, height: 100.0),
]
)
);
ContainerLayer layer = RendererBinding.instance.renderView.debugLayer;
while (layer != null && !(layer is OpacityLayer))
layer = layer.firstChild;
expect(layer, const isInstanceOf<OpacityLayer>());
final OpacityLayer opacityLayer = layer;
expect(opacityLayer.alpha, equals(opacity * 255));
expect(layer.firstChild, const isInstanceOf<TransformLayer>());
});
} }
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