static bool GetInsetBoxShadowRects(const Margin& aBlurMargin, const Margin& aInnerMargin, const Rect& aShadowClipRect, const Rect& aDestinationRect, Rect& aOutWhitespaceRect, Rect& aOutOuterRect) { // We always copy (2 * blur radius) + corner radius worth of data to the destination rect // This covers the blend of the path + the actual blur // Need +1 so that we copy the edges correctly as we'll copy // over the min box shadow corners then the +1 for the edges between // Note, the (x,y) coordinates are from the blur margin // since the frame outside the whitespace rect is 1 blur radius extra space. Rect insideWhiteSpace(aBlurMargin.left, aBlurMargin.top, aInnerMargin.LeftRight() + 1, aInnerMargin.TopBottom() + 1); // If the inner white space rect is larger than the shadow clip rect // our approach does not work as we'll just copy one corner // and cover the destination. In those cases, fallback to the destination rect bool useDestRect = (aShadowClipRect.width <= aInnerMargin.LeftRight()) || (aShadowClipRect.height <= aInnerMargin.TopBottom()); if (useDestRect) { aOutWhitespaceRect = aShadowClipRect; aOutOuterRect = aDestinationRect; } else { aOutWhitespaceRect = insideWhiteSpace; aOutOuterRect = aOutWhitespaceRect; aOutOuterRect.Inflate(aBlurMargin); } return useDestRect; }
static void ComputeRectsForInsetBoxShadow(gfxIntSize aBlurRadius, gfxIntSize aSpreadRadius, const Rect& aDestRect, const Rect& aShadowClipRect, Rect& aOutOuterRect, Rect& aOutInnerRect, Margin& aOutPathMargins) { gfxIntSize marginSize = aBlurRadius + aSpreadRadius; // The sizes we're given for aBlurRadius/aSpreadRadius are radius'. // We actually want to paint the whole blur, so we need the diameter. // We render both the outer / inner blur portions of a blur, // Then we clip out the outer portion later. aOutPathMargins.SizeTo(marginSize.height, marginSize.width, marginSize.height, marginSize.width); aOutPathMargins += aOutPathMargins; aOutOuterRect.x = 0; aOutInnerRect.x = marginSize.width; aOutOuterRect.y = 0; aOutInnerRect.y = marginSize.height; // + 1 for the middle edges so we can sample them aOutInnerRect.width = aOutPathMargins.LeftRight() + 1; aOutInnerRect.height = aOutPathMargins.TopBottom() + 1; // The outer path rect needs to be 1 blur radius past the inner edges aOutOuterRect.width = aOutInnerRect.XMost() + marginSize.width; aOutOuterRect.height = aOutInnerRect.YMost() + marginSize.height; if ((aOutOuterRect.width >= aDestRect.width) || (aOutOuterRect.height >= aDestRect.height) || (aOutInnerRect.width >= aShadowClipRect.width) || (aOutInnerRect.height >= aShadowClipRect.height)) { aOutOuterRect.width = aDestRect.width; aOutOuterRect.height = aDestRect.height; aOutInnerRect.width = aShadowClipRect.width; aOutInnerRect.height = aShadowClipRect.height; aOutPathMargins.SizeTo(0, 0, 0, 0); } }