mirror of
https://github.com/mozilla/gecko-dev.git
synced 2024-12-04 11:26:09 +00:00
Bug 1488555 - Use ImageRendering property to provide proper filtering support for AsyncImage. r=nical
Introduce an ImageRendering argument for CreateImageKey which is then used at the CreateAsyncImageWebRenderCommands call to provide the proper filtering instead of using always Auto filtering. Update all calls to CreateImageKey to use the new interface.
This commit is contained in:
parent
10681a9714
commit
be01b218cc
@ -1503,6 +1503,7 @@ WebRenderCommandBuilder::CreateImageKey(nsDisplayItem* aItem,
|
||||
ImageContainer* aContainer,
|
||||
mozilla::wr::DisplayListBuilder& aBuilder,
|
||||
mozilla::wr::IpcResourceUpdateQueue& aResources,
|
||||
mozilla::wr::ImageRendering aRendering,
|
||||
const StackingContextHelper& aSc,
|
||||
gfx::IntSize& aSize,
|
||||
const Maybe<LayoutDeviceRect>& aAsyncImageBounds)
|
||||
@ -1530,7 +1531,7 @@ WebRenderCommandBuilder::CreateImageKey(nsDisplayItem* aItem,
|
||||
scBounds,
|
||||
transform,
|
||||
scaleToSize,
|
||||
wr::ImageRendering::Auto,
|
||||
aRendering,
|
||||
wr::MixBlendMode::Normal,
|
||||
!aItem->BackfaceIsHidden());
|
||||
return Nothing();
|
||||
@ -1554,10 +1555,11 @@ WebRenderCommandBuilder::PushImage(nsDisplayItem* aItem,
|
||||
const StackingContextHelper& aSc,
|
||||
const LayoutDeviceRect& aRect)
|
||||
{
|
||||
mozilla::wr::ImageRendering rendering = wr::ToImageRendering(
|
||||
nsLayoutUtils::GetSamplingFilterForFrame(aItem->Frame()));
|
||||
gfx::IntSize size;
|
||||
Maybe<wr::ImageKey> key = CreateImageKey(aItem, aContainer,
|
||||
aBuilder, aResources,
|
||||
aSc, size, Some(aRect));
|
||||
Maybe<wr::ImageKey> key = CreateImageKey(
|
||||
aItem, aContainer, aBuilder, aResources, rendering, aSc, size, Some(aRect));
|
||||
if (aContainer->IsAsync()) {
|
||||
// Async ImageContainer does not create ImageKey, instead it uses Pipeline.
|
||||
MOZ_ASSERT(key.isNothing());
|
||||
@ -1568,8 +1570,7 @@ WebRenderCommandBuilder::PushImage(nsDisplayItem* aItem,
|
||||
}
|
||||
|
||||
auto r = wr::ToRoundedLayoutRect(aRect);
|
||||
gfx::SamplingFilter sampleFilter = nsLayoutUtils::GetSamplingFilterForFrame(aItem->Frame());
|
||||
aBuilder.PushImage(r, r, !aItem->BackfaceIsHidden(), wr::ToImageRendering(sampleFilter), key.value());
|
||||
aBuilder.PushImage(r, r, !aItem->BackfaceIsHidden(), rendering, key.value());
|
||||
|
||||
return true;
|
||||
}
|
||||
|
@ -65,6 +65,7 @@ public:
|
||||
ImageContainer* aContainer,
|
||||
mozilla::wr::DisplayListBuilder& aBuilder,
|
||||
mozilla::wr::IpcResourceUpdateQueue& aResources,
|
||||
mozilla::wr::ImageRendering aRendering,
|
||||
const StackingContextHelper& aSc,
|
||||
gfx::IntSize& aSize,
|
||||
const Maybe<LayoutDeviceRect>& aAsyncImageBounds);
|
||||
|
@ -485,9 +485,11 @@ BulletRenderer::CreateWebRenderCommandsForImage(nsDisplayItem* aItem,
|
||||
return false;
|
||||
}
|
||||
|
||||
mozilla::wr::ImageRendering rendering = wr::ToImageRendering(
|
||||
nsLayoutUtils::GetSamplingFilterForFrame(aItem->Frame()));
|
||||
gfx::IntSize size;
|
||||
Maybe<wr::ImageKey> key = aManager->CommandBuilder().CreateImageKey(aItem, container, aBuilder, aResources,
|
||||
aSc, size, Nothing());
|
||||
Maybe<wr::ImageKey> key = aManager->CommandBuilder().CreateImageKey(
|
||||
aItem, container, aBuilder, aResources, rendering, aSc, size, Nothing());
|
||||
if (key.isNothing()) {
|
||||
return true; // Nothing to do
|
||||
}
|
||||
|
@ -3859,9 +3859,18 @@ nsCSSBorderImageRenderer::CreateWebRenderCommands(
|
||||
return;
|
||||
}
|
||||
|
||||
mozilla::wr::ImageRendering rendering = wr::ToImageRendering(
|
||||
nsLayoutUtils::GetSamplingFilterForFrame(aItem->Frame()));
|
||||
gfx::IntSize size;
|
||||
Maybe<wr::ImageKey> key = aManager->CommandBuilder().CreateImageKey(
|
||||
aItem, container, aBuilder, aResources, aSc, size, Nothing());
|
||||
Maybe<wr::ImageKey> key =
|
||||
aManager->CommandBuilder().CreateImageKey(aItem,
|
||||
container,
|
||||
aBuilder,
|
||||
aResources,
|
||||
rendering,
|
||||
aSc,
|
||||
size,
|
||||
Nothing());
|
||||
if (key.isNothing()) {
|
||||
return;
|
||||
}
|
||||
|
@ -649,9 +649,18 @@ nsImageRenderer::BuildWebRenderDisplayItems(
|
||||
return ImgDrawResult::NOT_READY;
|
||||
}
|
||||
|
||||
mozilla::wr::ImageRendering rendering = wr::ToImageRendering(
|
||||
nsLayoutUtils::GetSamplingFilterForFrame(aItem->Frame()));
|
||||
gfx::IntSize size;
|
||||
Maybe<wr::ImageKey> key = aManager->CommandBuilder().CreateImageKey(
|
||||
aItem, container, aBuilder, aResources, aSc, size, Nothing());
|
||||
Maybe<wr::ImageKey> key =
|
||||
aManager->CommandBuilder().CreateImageKey(aItem,
|
||||
container,
|
||||
aBuilder,
|
||||
aResources,
|
||||
rendering,
|
||||
aSc,
|
||||
size,
|
||||
Nothing());
|
||||
|
||||
if (key.isNothing()) {
|
||||
return ImgDrawResult::NOT_READY;
|
||||
@ -672,14 +681,12 @@ nsImageRenderer::BuildWebRenderDisplayItems(
|
||||
LayoutDeviceSize gapSize = LayoutDeviceSize::FromAppUnits(
|
||||
aRepeatSize - aDest.Size(), appUnitsPerDevPixel);
|
||||
|
||||
SamplingFilter samplingFilter =
|
||||
nsLayoutUtils::GetSamplingFilterForFrame(mForFrame);
|
||||
aBuilder.PushImage(fill,
|
||||
clip,
|
||||
!aItem->BackfaceIsHidden(),
|
||||
wr::ToLayoutSize(destRect.Size()),
|
||||
wr::ToLayoutSize(gapSize),
|
||||
wr::ToImageRendering(samplingFilter),
|
||||
rendering,
|
||||
key.value());
|
||||
break;
|
||||
}
|
||||
|
@ -459,20 +459,24 @@ nsImageBoxFrame::CreateWebRenderCommands(mozilla::wr::DisplayListBuilder& aBuild
|
||||
return Nothing();
|
||||
}
|
||||
|
||||
mozilla::wr::ImageRendering rendering = wr::ToImageRendering(
|
||||
nsLayoutUtils::GetSamplingFilterForFrame(aItem->Frame()));
|
||||
gfx::IntSize size;
|
||||
Maybe<wr::ImageKey> key = aManager->CommandBuilder().CreateImageKey(aItem, container,
|
||||
aBuilder, aResources,
|
||||
aSc, size, Nothing());
|
||||
Maybe<wr::ImageKey> key = aManager->CommandBuilder().CreateImageKey(
|
||||
aItem, container, aBuilder, aResources, rendering, aSc, size, Nothing());
|
||||
if (key.isNothing()) {
|
||||
return Some(ImgDrawResult::NOT_READY);
|
||||
}
|
||||
wr::LayoutRect fill = wr::ToRoundedLayoutRect(fillRect);
|
||||
|
||||
LayoutDeviceSize gapSize(0, 0);
|
||||
SamplingFilter sampleFilter = nsLayoutUtils::GetSamplingFilterForFrame(aItem->Frame());
|
||||
aBuilder.PushImage(fill, fill, !BackfaceIsHidden(),
|
||||
wr::ToLayoutSize(fillRect.Size()), wr::ToLayoutSize(gapSize),
|
||||
wr::ToImageRendering(sampleFilter), key.value());
|
||||
aBuilder.PushImage(fill,
|
||||
fill,
|
||||
!BackfaceIsHidden(),
|
||||
wr::ToLayoutSize(fillRect.Size()),
|
||||
wr::ToLayoutSize(gapSize),
|
||||
rendering,
|
||||
key.value());
|
||||
|
||||
return Some(ImgDrawResult::SUCCESS);
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user