зеркало из https://github.com/mozilla/gecko-dev.git
Bug 633627 Create shadow bitmap in device space r=joe
This commit is contained in:
Родитель
a8065cb251
Коммит
287d94109a
|
@ -4199,13 +4199,22 @@ nsContextBoxBlur::Init(const nsRect& aRect, nscoord aSpreadRadius,
|
||||||
return nsnull;
|
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);
|
gfxIntSize blurRadius = ComputeBlurRadius(aBlurRadius, aAppUnitsPerDevPixel);
|
||||||
PRInt32 spreadRadius = NS_MIN(PRInt32(aSpreadRadius / aAppUnitsPerDevPixel),
|
aDestinationCtx->UserToDevice(blurRadius);
|
||||||
PRInt32(MAX_SPREAD_RADIUS));
|
|
||||||
|
PRInt32 spreadRadiusScalar = NS_MIN(
|
||||||
|
PRInt32(aSpreadRadius / aAppUnitsPerDevPixel),
|
||||||
|
PRInt32(MAX_SPREAD_RADIUS));
|
||||||
|
gfxIntSize spreadRadius(spreadRadiusScalar, spreadRadiusScalar);
|
||||||
|
aDestinationCtx->UserToDevice(spreadRadius);
|
||||||
|
|
||||||
mDestinationCtx = aDestinationCtx;
|
mDestinationCtx = aDestinationCtx;
|
||||||
|
|
||||||
// If not blurring, draw directly onto the destination device
|
// 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)) {
|
!(aFlags & FORCE_MASK)) {
|
||||||
mContext = aDestinationCtx;
|
mContext = aDestinationCtx;
|
||||||
return mContext;
|
return mContext;
|
||||||
|
@ -4214,13 +4223,29 @@ nsContextBoxBlur::Init(const nsRect& aRect, nscoord aSpreadRadius,
|
||||||
// Convert from app units to device pixels
|
// Convert from app units to device pixels
|
||||||
gfxRect rect = nsLayoutUtils::RectToGfxRect(aRect, aAppUnitsPerDevPixel);
|
gfxRect rect = nsLayoutUtils::RectToGfxRect(aRect, aAppUnitsPerDevPixel);
|
||||||
|
|
||||||
|
gfxRect deviceRect = mDestinationCtx->UserToDevice(rect);
|
||||||
|
|
||||||
gfxRect dirtyRect =
|
gfxRect dirtyRect =
|
||||||
nsLayoutUtils::RectToGfxRect(aDirtyRect, aAppUnitsPerDevPixel);
|
nsLayoutUtils::RectToGfxRect(aDirtyRect, aAppUnitsPerDevPixel);
|
||||||
dirtyRect.RoundOut();
|
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
|
// Create the temporary surface for blurring
|
||||||
mContext = blur.Init(rect, gfxIntSize(spreadRadius, spreadRadius),
|
mContext = blur.Init(deviceRect, spreadRadius, blurRadius,
|
||||||
blurRadius, &dirtyRect, aSkipRect);
|
&deviceDirtyRect, deviceSkipRectPtr);
|
||||||
|
|
||||||
|
gfxMatrix matrix = aDestinationCtx->CurrentMatrix();
|
||||||
|
if (mContext) {
|
||||||
|
mContext->Scale(matrix.xx, matrix.yy);
|
||||||
|
}
|
||||||
return mContext;
|
return mContext;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -4230,6 +4255,11 @@ nsContextBoxBlur::DoPaint()
|
||||||
if (mContext == mDestinationCtx)
|
if (mContext == mDestinationCtx)
|
||||||
return;
|
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);
|
blur.Paint(mDestinationCtx);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Загрузка…
Ссылка в новой задаче