mirror of
https://github.com/mozilla/gecko-dev.git
synced 2025-02-27 21:00:50 +00:00
Bug 1211264. Fallback to render dest rect with outer box shadows on non-int transforms. r=mstange
This commit is contained in:
parent
17d87da8ac
commit
1dcb06648d
@ -449,18 +449,15 @@ CacheBlur(DrawTarget& aDT,
|
||||
|
||||
// Blurs a small surface and creates the mask.
|
||||
static already_AddRefed<SourceSurface>
|
||||
CreateBlurMask(const IntSize& aRectSize,
|
||||
CreateBlurMask(const IntSize& aMinSize,
|
||||
RectCornerRadii* aCornerRadii,
|
||||
IntSize aBlurRadius,
|
||||
IntMargin& aExtendDestBy,
|
||||
IntMargin& aSliceBorder,
|
||||
DrawTarget& aDestDrawTarget)
|
||||
{
|
||||
IntMargin slice;
|
||||
gfxAlphaBoxBlur blur;
|
||||
IntSize minSize =
|
||||
ComputeMinSizeForShadowShape(aCornerRadii, aBlurRadius, slice, aRectSize);
|
||||
IntRect minRect(IntPoint(), minSize);
|
||||
IntRect minRect(IntPoint(), aMinSize);
|
||||
|
||||
gfxContext* blurCtx = blur.Init(ThebesRect(Rect(minRect)), IntSize(),
|
||||
aBlurRadius, nullptr, nullptr);
|
||||
@ -488,7 +485,7 @@ CreateBlurMask(const IntSize& aRectSize,
|
||||
|
||||
IntRect expandedMinRect(topLeft, result->GetSize());
|
||||
aExtendDestBy = expandedMinRect - minRect;
|
||||
aSliceBorder = slice + aExtendDestBy;
|
||||
aSliceBorder += aExtendDestBy;
|
||||
|
||||
MOZ_ASSERT(aSliceBorder.LeftRight() <= expandedMinRect.width);
|
||||
MOZ_ASSERT(aSliceBorder.TopBottom() <= expandedMinRect.height);
|
||||
@ -513,14 +510,15 @@ CreateBoxShadow(SourceSurface* aBlurMask, const Color& aShadowColor)
|
||||
return boxShadowDT->Snapshot();
|
||||
}
|
||||
|
||||
static SourceSurface*
|
||||
static already_AddRefed<SourceSurface>
|
||||
GetBlur(DrawTarget& aDT,
|
||||
const IntSize& aRectSize,
|
||||
const IntSize& aBlurRadius,
|
||||
RectCornerRadii* aCornerRadii,
|
||||
const Color& aShadowColor,
|
||||
IntMargin& aExtendDestBy,
|
||||
IntMargin& aSlice)
|
||||
IntMargin& aSlice,
|
||||
gfxContext* aDestinationCtx)
|
||||
{
|
||||
if (!gBlurCache) {
|
||||
gBlurCache = new BlurCache();
|
||||
@ -529,18 +527,28 @@ GetBlur(DrawTarget& aDT,
|
||||
IntSize minSize =
|
||||
ComputeMinSizeForShadowShape(aCornerRadii, aBlurRadius, aSlice, aRectSize);
|
||||
|
||||
// We can get seams using the min size rect when drawing to the destination rect
|
||||
// if we have a non-pixel aligned destination transformation. In those cases,
|
||||
// fallback to just rendering the destination rect.
|
||||
Matrix destMatrix = ToMatrix(aDestinationCtx->CurrentMatrix());
|
||||
bool useDestRect = !destMatrix.IsRectilinear() || destMatrix.HasNonIntegerTranslation();
|
||||
if (useDestRect) {
|
||||
minSize = aRectSize;
|
||||
}
|
||||
|
||||
BlurCacheData* cached = gBlurCache->Lookup(minSize, aBlurRadius,
|
||||
aCornerRadii, aShadowColor,
|
||||
aDT.GetBackendType());
|
||||
if (cached) {
|
||||
if (cached && !useDestRect) {
|
||||
// See CreateBlurMask() for these values
|
||||
aExtendDestBy = cached->mExtendDest;
|
||||
aSlice = aSlice + aExtendDestBy;
|
||||
return cached->mBlur;
|
||||
RefPtr<SourceSurface> blur = cached->mBlur;
|
||||
return blur.forget();
|
||||
}
|
||||
|
||||
RefPtr<SourceSurface> blurMask =
|
||||
CreateBlurMask(aRectSize, aCornerRadii, aBlurRadius, aExtendDestBy, aSlice, aDT);
|
||||
CreateBlurMask(minSize, aCornerRadii, aBlurRadius, aExtendDestBy, aSlice, aDT);
|
||||
|
||||
if (!blurMask) {
|
||||
return nullptr;
|
||||
@ -551,8 +559,13 @@ GetBlur(DrawTarget& aDT,
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
CacheBlur(aDT, minSize, aBlurRadius, aCornerRadii, aShadowColor, aExtendDestBy, boxShadow);
|
||||
return boxShadow;
|
||||
if (useDestRect) {
|
||||
// Since we're just going to paint the actual rect to the destination
|
||||
aSlice.SizeTo(0, 0, 0, 0);
|
||||
} else {
|
||||
CacheBlur(aDT, minSize, aBlurRadius, aCornerRadii, aShadowColor, aExtendDestBy, boxShadow);
|
||||
}
|
||||
return boxShadow.forget();
|
||||
}
|
||||
|
||||
void
|
||||
@ -698,7 +711,8 @@ gfxAlphaBoxBlur::BlurRectangle(gfxContext* aDestinationCtx,
|
||||
RefPtr<SourceSurface> boxShadow = GetBlur(destDrawTarget,
|
||||
rect.Size(), blurRadius,
|
||||
aCornerRadii, aShadowColor,
|
||||
extendDestBy, slice);
|
||||
extendDestBy, slice,
|
||||
aDestinationCtx);
|
||||
if (!boxShadow) {
|
||||
return;
|
||||
}
|
||||
|
15
layout/reftests/box-shadow/boxshadow-rotated-ref.html
Normal file
15
layout/reftests/box-shadow/boxshadow-rotated-ref.html
Normal file
@ -0,0 +1,15 @@
|
||||
<html>
|
||||
<head>
|
||||
<style>
|
||||
div.second {
|
||||
margin: 35px auto 95px auto;
|
||||
box-shadow: 0px 0px 15px 0px #808080;
|
||||
width: 100;
|
||||
height: 116.36px;
|
||||
}
|
||||
</style>
|
||||
</head>
|
||||
<body>
|
||||
<div class="second"></div>
|
||||
</body>
|
||||
</html>
|
16
layout/reftests/box-shadow/boxshadow-rotated.html
Normal file
16
layout/reftests/box-shadow/boxshadow-rotated.html
Normal file
@ -0,0 +1,16 @@
|
||||
<html>
|
||||
<head>
|
||||
<style>
|
||||
div.first {
|
||||
margin: 35px auto 95px auto;
|
||||
box-shadow: 0px 0px 15px 0px #808080;
|
||||
transform: rotate(-180deg);
|
||||
width: 100;
|
||||
height: 116.36px;
|
||||
}
|
||||
</style>
|
||||
</head>
|
||||
<body>
|
||||
<div class="first"></div>
|
||||
</body>
|
||||
</html>
|
@ -25,6 +25,7 @@ random-if(d2d) == boxshadow-threecorners.html boxshadow-threecorners-ref.html
|
||||
fuzzy-if(OSX==1010,1,24) == boxshadow-large-border-radius.html boxshadow-large-border-radius-ref.html # Bug 1209649
|
||||
== boxshadow-border-radius-int.html boxshadow-border-radius-int-ref.html
|
||||
== boxshadow-inset-neg-spread.html about:blank
|
||||
fuzzy(26,3610) == boxshadow-rotated.html boxshadow-rotated-ref.html # Bug 1211264
|
||||
|
||||
== overflow-not-scrollable-1.html overflow-not-scrollable-1-ref.html
|
||||
== overflow-not-scrollable-1.html overflow-not-scrollable-1-ref2.html
|
||||
|
Loading…
x
Reference in New Issue
Block a user