@@ -415,32 +415,34 @@ class ImageFilterEngineLayer extends ContainerLayer
415415 } else {
416416 convertible = _filter as CkManagedSkImageFilterConvertible ;
417417 }
418- final ui.Rect childPaintBounds =
418+ ui.Rect childPaintBounds =
419419 prerollChildren (prerollContext, childMatrix);
420- if (_filter is ui.ColorFilter ) {
421- // If the filter is a ColorFilter, the extended paint bounds will be the
422- // entire screen, which is not what we want.
423- paintBounds = childPaintBounds;
424- } else {
425- convertible.withSkImageFilter ((skFilter) {
426- paintBounds = rectFromSkIRect (
427- skFilter.getOutputBounds (toSkRect (childPaintBounds)),
428- );
429- });
430- }
420+ childPaintBounds = childPaintBounds.translate (_offset.dx, _offset.dy);
421+ if (_filter is ui.ColorFilter ) {
422+ // If the filter is a ColorFilter, the extended paint bounds will be the
423+ // entire screen, which is not what we want.
424+ paintBounds = childPaintBounds;
425+ } else {
426+ convertible.withSkImageFilter ((skFilter) {
427+ paintBounds = rectFromSkIRect (
428+ skFilter.getOutputBounds (toSkRect (childPaintBounds)),
429+ );
430+ });
431+ }
431432 prerollContext.mutatorsStack.pop ();
432433 }
433434
434435 @override
435436 void paint (PaintContext paintContext) {
436437 assert (needsPainting);
438+ final ui.Rect offsetPaintBounds = paintBounds.shift (- _offset);
437439 paintContext.internalNodesCanvas.save ();
438440 paintContext.internalNodesCanvas.translate (_offset.dx, _offset.dy);
439441 paintContext.internalNodesCanvas
440- .clipRect (paintBounds , ui.ClipOp .intersect, false );
442+ .clipRect (offsetPaintBounds , ui.ClipOp .intersect, false );
441443 final CkPaint paint = CkPaint ();
442444 paint.imageFilter = _filter;
443- paintContext.internalNodesCanvas.saveLayer (paintBounds , paint);
445+ paintContext.internalNodesCanvas.saveLayer (offsetPaintBounds , paint);
444446 paintChildren (paintContext);
445447 paintContext.internalNodesCanvas.restore ();
446448 paintContext.internalNodesCanvas.restore ();
0 commit comments