зеркало из https://github.com/mozilla/gecko-dev.git
Bug 1360112 - Correct background image position when enabling webrender background image. r=mattwoodrow
This commit is contained in:
Родитель
59b75a786f
Коммит
f29e1a70ba
|
@ -6733,6 +6733,16 @@ nsLayoutUtils::ComputeSizeForDrawingWithFallback(imgIContainer* aImage,
|
||||||
return imageSize;
|
return imageSize;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/* static */ nsPoint
|
||||||
|
nsLayoutUtils::GetBackgroundFirstTilePos(const nsPoint& aDest,
|
||||||
|
const nsPoint& aFill,
|
||||||
|
const nsSize& aRepeatSize)
|
||||||
|
{
|
||||||
|
return nsPoint(NSToIntFloor(float(aFill.x - aDest.x) / aRepeatSize.width) * aRepeatSize.width,
|
||||||
|
NSToIntFloor(float(aFill.y - aDest.y) / aRepeatSize.height) * aRepeatSize.height) +
|
||||||
|
aDest;
|
||||||
|
}
|
||||||
|
|
||||||
/* static */ DrawResult
|
/* static */ DrawResult
|
||||||
nsLayoutUtils::DrawBackgroundImage(gfxContext& aContext,
|
nsLayoutUtils::DrawBackgroundImage(gfxContext& aContext,
|
||||||
nsIFrame* aForFrame,
|
nsIFrame* aForFrame,
|
||||||
|
@ -6763,9 +6773,7 @@ nsLayoutUtils::DrawBackgroundImage(gfxContext& aContext,
|
||||||
aOpacity);
|
aOpacity);
|
||||||
}
|
}
|
||||||
|
|
||||||
nsPoint firstTilePos = aDest.TopLeft() +
|
nsPoint firstTilePos = GetBackgroundFirstTilePos(aDest.TopLeft(), aFill.TopLeft(), aRepeatSize);
|
||||||
nsPoint(NSToIntFloor(float(aFill.x - aDest.x) / aRepeatSize.width) * aRepeatSize.width,
|
|
||||||
NSToIntFloor(float(aFill.y - aDest.y) / aRepeatSize.height) * aRepeatSize.height);
|
|
||||||
for (int32_t i = firstTilePos.x; i < aFill.XMost(); i += aRepeatSize.width) {
|
for (int32_t i = firstTilePos.x; i < aFill.XMost(); i += aRepeatSize.width) {
|
||||||
for (int32_t j = firstTilePos.y; j < aFill.YMost(); j += aRepeatSize.height) {
|
for (int32_t j = firstTilePos.y; j < aFill.YMost(); j += aRepeatSize.height) {
|
||||||
nsRect dest(i, j, aDest.width, aDest.height);
|
nsRect dest(i, j, aDest.width, aDest.height);
|
||||||
|
|
|
@ -1605,6 +1605,10 @@ public:
|
||||||
nsStyleContext* aStyleContext = nullptr,
|
nsStyleContext* aStyleContext = nullptr,
|
||||||
DrawStringFlags aFlags = DrawStringFlags::eDefault);
|
DrawStringFlags aFlags = DrawStringFlags::eDefault);
|
||||||
|
|
||||||
|
static nsPoint GetBackgroundFirstTilePos(const nsPoint& aDest,
|
||||||
|
const nsPoint& aFill,
|
||||||
|
const nsSize& aRepeatSize);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Supports only LTR or RTL. Bidi (mixed direction) is not supported.
|
* Supports only LTR or RTL. Bidi (mixed direction) is not supported.
|
||||||
*/
|
*/
|
||||||
|
|
|
@ -625,11 +625,17 @@ nsImageRenderer::BuildWebRenderDisplayItems(nsPresContext* aPresContext,
|
||||||
aDest, appUnitsPerDevPixel);
|
aDest, appUnitsPerDevPixel);
|
||||||
LayerRect dest = aLayer->RelativeToParent(destRect);
|
LayerRect dest = aLayer->RelativeToParent(destRect);
|
||||||
|
|
||||||
|
nsPoint firstTilePos = nsLayoutUtils::GetBackgroundFirstTilePos(aDest.TopLeft(),
|
||||||
|
aFill.TopLeft(),
|
||||||
|
aRepeatSize);
|
||||||
LayoutDeviceRect fillRect = LayoutDeviceRect::FromAppUnits(
|
LayoutDeviceRect fillRect = LayoutDeviceRect::FromAppUnits(
|
||||||
aFill, appUnitsPerDevPixel);
|
nsRect(firstTilePos.x, firstTilePos.y,
|
||||||
|
aFill.XMost() - firstTilePos.x, aFill.YMost() - firstTilePos.y),
|
||||||
|
appUnitsPerDevPixel);
|
||||||
LayerRect fill = aLayer->RelativeToParent(fillRect);
|
LayerRect fill = aLayer->RelativeToParent(fillRect);
|
||||||
|
LayerRect clip = aLayer->RelativeToParent(
|
||||||
|
LayoutDeviceRect::FromAppUnits(aFill,appUnitsPerDevPixel));
|
||||||
|
|
||||||
LayerRect clip = fill;
|
|
||||||
Size gapSize((aRepeatSize.width - aDest.width) / appUnitsPerDevPixel,
|
Size gapSize((aRepeatSize.width - aDest.width) / appUnitsPerDevPixel,
|
||||||
(aRepeatSize.height - aDest.height) / appUnitsPerDevPixel);
|
(aRepeatSize.height - aDest.height) / appUnitsPerDevPixel);
|
||||||
aBuilder.PushImage(wr::ToWrRect(fill), aBuilder.BuildClipRegion(wr::ToWrRect(clip)),
|
aBuilder.PushImage(wr::ToWrRect(fill), aBuilder.BuildClipRegion(wr::ToWrRect(clip)),
|
||||||
|
|
Загрузка…
Ссылка в новой задаче