Commit 07275405 authored by Jason Simmons's avatar Jason Simmons Committed by GitHub

Apply the paint offset to the bounds rectangle for shader masks (#10458)

Fixes https://github.com/flutter/flutter/issues/10424
parent cb959724
......@@ -416,7 +416,7 @@ class PaintingContext {
_stopRecordingIfNeeded();
final ShaderMaskLayer shaderLayer = new ShaderMaskLayer(
shader: shader,
maskRect: maskRect,
maskRect: maskRect.shift(offset),
blendMode: blendMode,
);
_appendLayer(shaderLayer);
......
......@@ -834,8 +834,8 @@ class RenderShaderMask extends RenderProxyBox {
void paint(PaintingContext context, Offset offset) {
if (child != null) {
assert(needsCompositing);
final Rect rect = Offset.zero & size;
context.pushShaderMask(offset, _shaderCallback(rect), rect, _blendMode, super.paint);
final Shader shader = _shaderCallback(offset & size);
context.pushShaderMask(offset, shader, Offset.zero & size, _blendMode, super.paint);
}
}
}
......
......@@ -22,4 +22,28 @@ void main() {
final Widget child = new Container(width: 100.0, height: 100.0);
await tester.pumpWidget(new ShaderMask(child: child, shaderCallback: createShader));
});
testWidgets('Bounds rect includes offset', (WidgetTester tester) async {
Rect shaderBounds;
Shader recordShaderBounds(Rect bounds) {
shaderBounds = bounds;
return createShader(bounds);
}
final Widget widget = new Align(
alignment: FractionalOffset.center,
child: new SizedBox(
width: 400.0,
height: 400.0,
child: new ShaderMask(
shaderCallback: recordShaderBounds,
child: new Container(width: 100.0, height: 100.0)
),
),
);
await tester.pumpWidget(widget);
// The shader bounds rectangle should reflect the position of the centered SizedBox.
expect(shaderBounds, equals(new Rect.fromLTWH(200.0, 100.0, 400.0, 400.0)));
});
}
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