From 6071f149b52f58de92fe9d7ed0d58e925a5ca7b6 Mon Sep 17 00:00:00 2001 From: Justin McCandless Date: Thu, 18 May 2023 09:05:07 -0700 Subject: [PATCH] Revert "Remove obsolete drawShadow bounds workaround" (#127110) Reverts flutter/flutter#127052, which seems to be breaking the build because of a goldens failure. ``` The following TestFailure was thrown running a test: Expected: one widget whose rasterized image matches golden image "shadow.PhysicalModel.enabled.png" Actual: _WidgetTypeFinder: ``` See https://ci.chromium.org/ui/p/flutter/builders/prod/Linux%20web_tests_6/11051/overview --- packages/flutter/lib/src/rendering/proxy_box.dart | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/packages/flutter/lib/src/rendering/proxy_box.dart b/packages/flutter/lib/src/rendering/proxy_box.dart index 8c51850212..bdc906be0e 100644 --- a/packages/flutter/lib/src/rendering/proxy_box.dart +++ b/packages/flutter/lib/src/rendering/proxy_box.dart @@ -2017,6 +2017,7 @@ class RenderPhysicalModel extends _RenderPhysicalModelBase { _updateClip(); final RRect offsetRRect = _clip!.shift(offset); + final Rect offsetBounds = offsetRRect.outerRect; final Path offsetRRectAsPath = Path()..addRRect(offsetRRect); bool paintShadows = true; assert(() { @@ -2037,6 +2038,14 @@ class RenderPhysicalModel extends _RenderPhysicalModelBase { final Canvas canvas = context.canvas; if (elevation != 0.0 && paintShadows) { + // The drawShadow call doesn't add the region of the shadow to the + // picture's bounds, so we draw a hardcoded amount of extra space to + // account for the maximum potential area of the shadow. + // TODO(jsimmons): remove this when Skia does it for us. + canvas.drawRect( + offsetBounds.inflate(20.0), + _transparentPaint, + ); canvas.drawShadow( offsetRRectAsPath, shadowColor,