Bug 1360246 - Stop calling RelativeToParent on rects for which we only use the size, since that doesn't change with RelativeToParent. r?nical
Also clean up another untyped Size calculation to use
LayoutDeviceSize::FromAppUnits.
MozReview-Commit-ID: DvEIhZpBTEi
--- a/layout/painting/nsCSSRenderingGradients.cpp
+++ b/layout/painting/nsCSSRenderingGradients.cpp
@@ -1062,17 +1062,18 @@ nsCSSGradientRenderer::BuildWebRenderDis
LayoutDeviceRect gradientBounds = LayoutDeviceRect(firstTileBounds.TopLeft(),
LayoutDeviceSize(tileToClip.x, tileToClip.y));
// Calculate the tile spacing, which is the repeat size minus the tile size
LayoutDeviceSize tileSpacing = tileRepeat - firstTileBounds.Size();
// Make the rects relative to the parent stacking context
LayerRect layerClipBounds = aLayer->RelativeToParent(clipBounds);
- LayerRect layerFirstTileBounds = aLayer->RelativeToParent(firstTileBounds);
+ LayerSize layerFirstTileSize = ViewAs<LayerPixel>(firstTileBounds.Size(),
+ PixelCastJustification::WebRenderHasUnitResolution);
LayerRect layerGradientBounds = aLayer->RelativeToParent(gradientBounds);
// srcTransform is used for scaling the gradient to match aSrc
LayoutDeviceRect srcTransform = LayoutDeviceRect(mPresContext->CSSPixelsToAppUnits(aSrc.x),
mPresContext->CSSPixelsToAppUnits(aSrc.y),
aDest.width / ((float)mPresContext->CSSPixelsToAppUnits(aSrc.width)),
aDest.height / ((float)mPresContext->CSSPixelsToAppUnits(aSrc.height)));
@@ -1085,27 +1086,27 @@ nsCSSGradientRenderer::BuildWebRenderDis
aBuilder.PushLinearGradient(
mozilla::wr::ToWrRect(layerGradientBounds),
aBuilder.BuildClipRegion(mozilla::wr::ToWrRect(layerClipBounds)),
mozilla::wr::ToWrPoint(lineStart),
mozilla::wr::ToWrPoint(lineEnd),
stops,
extendMode,
- mozilla::wr::ToWrSize(layerFirstTileBounds.Size()),
+ mozilla::wr::ToWrSize(layerFirstTileSize),
mozilla::wr::ToWrSize(tileSpacing));
} else {
gradientRadius.width *= srcTransform.width;
gradientRadius.height *= srcTransform.height;
aBuilder.PushRadialGradient(
mozilla::wr::ToWrRect(layerGradientBounds),
aBuilder.BuildClipRegion(mozilla::wr::ToWrRect(layerClipBounds)),
mozilla::wr::ToWrPoint(lineStart),
mozilla::wr::ToWrSize(gradientRadius),
stops,
extendMode,
- mozilla::wr::ToWrSize(layerFirstTileBounds.Size()),
+ mozilla::wr::ToWrSize(layerFirstTileSize),
mozilla::wr::ToWrSize(tileSpacing));
}
}
} // namespace mozilla
--- a/layout/painting/nsImageRenderer.cpp
+++ b/layout/painting/nsImageRenderer.cpp
@@ -619,33 +619,32 @@ nsImageRenderer::BuildWebRenderDisplayIt
Maybe<wr::ImageKey> key = aLayer->SendImageContainer(container, aParentCommands);
if (key.isNothing()) {
return DrawResult::BAD_IMAGE;
}
const int32_t appUnitsPerDevPixel = mForFrame->PresContext()->AppUnitsPerDevPixel();
LayoutDeviceRect destRect = LayoutDeviceRect::FromAppUnits(
aDest, appUnitsPerDevPixel);
- LayerRect dest = aLayer->RelativeToParent(destRect);
nsPoint firstTilePos = nsLayoutUtils::GetBackgroundFirstTilePos(aDest.TopLeft(),
aFill.TopLeft(),
aRepeatSize);
LayoutDeviceRect fillRect = LayoutDeviceRect::FromAppUnits(
nsRect(firstTilePos.x, firstTilePos.y,
aFill.XMost() - firstTilePos.x, aFill.YMost() - firstTilePos.y),
appUnitsPerDevPixel);
LayerRect fill = aLayer->RelativeToParent(fillRect);
LayerRect clip = aLayer->RelativeToParent(
LayoutDeviceRect::FromAppUnits(aFill,appUnitsPerDevPixel));
- Size gapSize((aRepeatSize.width - aDest.width) / appUnitsPerDevPixel,
- (aRepeatSize.height - aDest.height) / appUnitsPerDevPixel);
+ LayoutDeviceSize gapSize = LayoutDeviceSize::FromAppUnits(
+ aRepeatSize - aDest.Size(), appUnitsPerDevPixel);
aBuilder.PushImage(wr::ToWrRect(fill), aBuilder.BuildClipRegion(wr::ToWrRect(clip)),
- wr::ToWrSize(dest.Size()), wr::ToWrSize(gapSize),
+ wr::ToWrSize(destRect.Size()), wr::ToWrSize(gapSize),
wr::ImageRendering::Auto, key.value());
break;
}
default:
break;
}
return DrawResult::SUCCESS;