estimateSourceUnderlayPaintBounds function

Rect2D? estimateSourceUnderlayPaintBounds(
  1. Rect2D sourceBounds,
  2. CanvasSourceUnderlay underlay
)

Returns the paint estimate produced by one underlay from the ORIGINAL source bounds.

Underlays never expand from previously accumulated underlay bounds.

Implementation

Rect2D? estimateSourceUnderlayPaintBounds(
  Rect2D sourceBounds,
  CanvasSourceUnderlay underlay,
) {
  return switch (underlay) {
    ShadowEffect(:final offset, :final blurSigma) =>
      shadowContributesToPaint(underlay)
          ? sourceBounds
                .inflate(shadowBlurExtentInSigmas * blurSigma)
                .translate(offset)
          : null,
  };
}