Bug 940845 - Part 5: Propogate the blur standard deviation up instead of the blur radius. r=roc

This commit is contained in:
Matt Woodrow 2013-11-26 12:09:04 +13:00
Родитель cf7881aa40
Коммит e464096b18
3 изменённых файлов: 25 добавлений и 11 удалений

Просмотреть файл

@ -117,14 +117,16 @@ gfxIntSize gfxAlphaBoxBlur::CalculateBlurRadius(const gfxPoint& aStd)
gfxAlphaBoxBlur::BlurRectangle(gfxContext *aDestinationCtx,
const gfxRect& aRect,
gfxCornerSizes* aCornerRadii,
const gfxIntSize& aBlurRadius,
const gfxPoint& aBlurStdDev,
const gfxRGBA& aShadowColor,
const gfxRect& aDirtyRect,
const gfxRect& aSkipRect)
{
gfxIntSize blurRadius = CalculateBlurRadius(aBlurStdDev);
// Create the temporary surface for blurring
gfxAlphaBoxBlur blur;
gfxContext *dest = blur.Init(aRect, gfxIntSize(), aBlurRadius, &aDirtyRect, &aSkipRect);
gfxContext *dest = blur.Init(aRect, gfxIntSize(), blurRadius, &aDirtyRect, &aSkipRect);
if (!dest) {
return;

Просмотреть файл

@ -105,7 +105,7 @@ public:
static void BlurRectangle(gfxContext *aDestinationCtx,
const gfxRect& aRect,
gfxCornerSizes* aCornerRadii,
const gfxIntSize& aBlurRadius,
const gfxPoint& aBlurStdDev,
const gfxRGBA& aShadowColor,
const gfxRect& aDirtyRect,
const gfxRect& aSkipRect);

Просмотреть файл

@ -4680,17 +4680,29 @@ nsImageRenderer::GetContainer(LayerManager* aManager)
#define MAX_BLUR_RADIUS 300
#define MAX_SPREAD_RADIUS 50
static inline gfxIntSize
ComputeBlurRadius(nscoord aBlurRadius, int32_t aAppUnitsPerDevPixel, gfxFloat aScaleX = 1.0, gfxFloat aScaleY = 1.0)
static inline gfxPoint ComputeBlurStdDev(nscoord aBlurRadius,
int32_t aAppUnitsPerDevPixel,
gfxFloat aScaleX,
gfxFloat aScaleY)
{
// http://dev.w3.org/csswg/css3-background/#box-shadow says that the
// standard deviation of the blur should be half the given blur value.
gfxFloat blurStdDev = gfxFloat(aBlurRadius) / gfxFloat(aAppUnitsPerDevPixel);
gfxPoint scaledBlurStdDev = gfxPoint(std::min((blurStdDev * aScaleX),
gfxFloat(MAX_BLUR_RADIUS)) / 2.0,
std::min((blurStdDev * aScaleY),
gfxFloat(MAX_BLUR_RADIUS)) / 2.0);
return gfxPoint(std::min((blurStdDev * aScaleX),
gfxFloat(MAX_BLUR_RADIUS)) / 2.0,
std::min((blurStdDev * aScaleY),
gfxFloat(MAX_BLUR_RADIUS)) / 2.0);
}
static inline gfxIntSize
ComputeBlurRadius(nscoord aBlurRadius,
int32_t aAppUnitsPerDevPixel,
gfxFloat aScaleX = 1.0,
gfxFloat aScaleY = 1.0)
{
gfxPoint scaledBlurStdDev = ComputeBlurStdDev(aBlurRadius, aAppUnitsPerDevPixel,
aScaleX, aScaleY);
return
gfxAlphaBoxBlur::CalculateBlurRadius(scaledBlurStdDev);
}
@ -4852,7 +4864,7 @@ nsContextBoxBlur::BlurRectangle(gfxContext* aDestinationCtx,
aDestinationCtx->IdentityMatrix();
}
gfxIntSize blurRadius = ComputeBlurRadius(aBlurRadius, aAppUnitsPerDevPixel, scaleX, scaleY);
gfxPoint blurStdDev = ComputeBlurStdDev(aBlurRadius, aAppUnitsPerDevPixel, scaleX, scaleY);
gfxRect dirtyRect =
nsLayoutUtils::RectToGfxRect(aDirtyRect, aAppUnitsPerDevPixel);
@ -4869,7 +4881,7 @@ nsContextBoxBlur::BlurRectangle(gfxContext* aDestinationCtx,
gfxAlphaBoxBlur::BlurRectangle(aDestinationCtx,
shadowGfxRect,
aCornerRadii,
blurRadius,
blurStdDev,
aShadowColor,
dirtyRect,
skipRect);