Bug 1761002 - Restore the clip rect in webrenderized images. r=mstange

In bug 1758942 there was a bit of clipping logic for webrenderized svg images that was removed because we didn't know what it was useful for.

I still don't quite know, other than that it caused layout/reftests/svg/image/image-preserveAspectRatio-01-raster.svg and layout/reftests/svg/image/image-preserveAspectRatio-02-raster.svg to start failing when the gfx.webrender.svg-images pref is enabled, so let's revert it.

Depends on D141847

Differential Revision: https://phabricator.services.mozilla.com/D141848
This commit is contained in:
Nicolas Silva 2022-03-23 20:28:55 +00:00
Родитель b0457b9551
Коммит 6019443efe
1 изменённых файлов: 11 добавлений и 2 удалений

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

@ -497,7 +497,16 @@ bool SVGImageFrame::CreateWebRenderCommands(
appUnitsPerCSSPixel);
appRect += toReferenceFrame;
auto destRect = LayoutDeviceRect::FromAppUnits(appRect, appUnitsPerDevPx);
auto clipRect = destRect;
if (StyleDisplay()->IsScrollableOverflow()) {
// Apply potential non-trivial clip
auto cssClip = SVGUtils::GetClipRectForFrame(this, 0, 0, width, height);
auto appClip =
nsLayoutUtils::RoundGfxRectToAppRect(cssClip, appUnitsPerCSSPixel);
appClip += toReferenceFrame;
clipRect = LayoutDeviceRect::FromAppUnits(appClip, appUnitsPerDevPx);
// Apply preserveAspectRatio
if (mImageContainer->GetType() == imgIContainer::TYPE_RASTER) {
int32_t nativeWidth, nativeHeight;
@ -611,7 +620,7 @@ bool SVGImageFrame::CreateWebRenderCommands(
Maybe<ImageIntRegion> region;
IntSize decodeSize = nsLayoutUtils::ComputeImageContainerDrawingParameters(
mImageContainer, this, destRect, destRect, aSc, flags, svgContext,
mImageContainer, this, destRect, clipRect, aSc, flags, svgContext,
region);
RefPtr<image::WebRenderImageProvider> provider;
@ -644,7 +653,7 @@ bool SVGImageFrame::CreateWebRenderCommands(
if (provider) {
aManager->CommandBuilder().PushImageProvider(aItem, provider, drawResult,
aBuilder, aResources,
destRect, destRect);
destRect, clipRect);
}
nsDisplayItemGenericImageGeometry::UpdateDrawResult(aItem, drawResult);