Bug 633627 Create shadow bitmap in device space r=joe

This commit is contained in:
Benjamin Stover 2011-08-31 09:03:58 -07:00
Родитель a8065cb251
Коммит 287d94109a
1 изменённых файлов: 35 добавлений и 5 удалений

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

@ -4199,13 +4199,22 @@ nsContextBoxBlur::Init(const nsRect& aRect, nscoord aSpreadRadius,
return nsnull;
}
// We convert our radii and our buffer to device space coordinates. When
// device space is smaller than our content space, we would otherwise be
// oversampling.
gfxIntSize blurRadius = ComputeBlurRadius(aBlurRadius, aAppUnitsPerDevPixel);
PRInt32 spreadRadius = NS_MIN(PRInt32(aSpreadRadius / aAppUnitsPerDevPixel),
PRInt32(MAX_SPREAD_RADIUS));
aDestinationCtx->UserToDevice(blurRadius);
PRInt32 spreadRadiusScalar = NS_MIN(
PRInt32(aSpreadRadius / aAppUnitsPerDevPixel),
PRInt32(MAX_SPREAD_RADIUS));
gfxIntSize spreadRadius(spreadRadiusScalar, spreadRadiusScalar);
aDestinationCtx->UserToDevice(spreadRadius);
mDestinationCtx = aDestinationCtx;
// If not blurring, draw directly onto the destination device
if (blurRadius.width <= 0 && blurRadius.height <= 0 && spreadRadius <= 0 &&
if (blurRadius.width <= 0 && blurRadius.height <= 0 && spreadRadiusScalar <= 0 &&
!(aFlags & FORCE_MASK)) {
mContext = aDestinationCtx;
return mContext;
@ -4214,13 +4223,29 @@ nsContextBoxBlur::Init(const nsRect& aRect, nscoord aSpreadRadius,
// Convert from app units to device pixels
gfxRect rect = nsLayoutUtils::RectToGfxRect(aRect, aAppUnitsPerDevPixel);
gfxRect deviceRect = mDestinationCtx->UserToDevice(rect);
gfxRect dirtyRect =
nsLayoutUtils::RectToGfxRect(aDirtyRect, aAppUnitsPerDevPixel);
dirtyRect.RoundOut();
gfxRect deviceDirtyRect = mDestinationCtx->UserToDevice(dirtyRect);
gfxRect deviceSkipRect;
gfxRect* deviceSkipRectPtr = NULL;
if (aSkipRect) {
deviceSkipRect = mDestinationCtx->UserToDevice(*aSkipRect);
deviceSkipRectPtr = &deviceSkipRect;
}
// Create the temporary surface for blurring
mContext = blur.Init(rect, gfxIntSize(spreadRadius, spreadRadius),
blurRadius, &dirtyRect, aSkipRect);
mContext = blur.Init(deviceRect, spreadRadius, blurRadius,
&deviceDirtyRect, deviceSkipRectPtr);
gfxMatrix matrix = aDestinationCtx->CurrentMatrix();
if (mContext) {
mContext->Scale(matrix.xx, matrix.yy);
}
return mContext;
}
@ -4230,6 +4255,11 @@ nsContextBoxBlur::DoPaint()
if (mContext == mDestinationCtx)
return;
// Since blurred mask is in device coordinates, the scales for painting the
// mask should be identity.
gfxContextMatrixAutoSaveRestore save(mDestinationCtx);
gfxMatrix matrix = mDestinationCtx->CurrentMatrix();
mDestinationCtx->Scale(1 / matrix.xx, 1 / matrix.yy);
blur.Paint(mDestinationCtx);
}