mirror of
https://github.com/mozilla/gecko-dev.git
synced 2024-11-28 23:31:56 +00:00
Bug 1711061 - Part 2. Add imgIContainer::GetImageProvider skeleton. r=tnikkel
In later parts in this series, GetImageProvider will replace GetImageContainerAtSize. This will be a more specialized and lower overhead means to get a wr::ImageKey for a particular surface. Differential Revision: https://phabricator.services.mozilla.com/D126596
This commit is contained in:
parent
3a20c5a464
commit
d4b2d17796
@ -318,6 +318,27 @@ ClippedImage::GetImageContainerAtSize(WindowRenderer* aRenderer,
|
||||
return ImgDrawResult::NOT_SUPPORTED;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP_(ImgDrawResult)
|
||||
ClippedImage::GetImageProvider(WindowRenderer* aRenderer,
|
||||
const gfx::IntSize& aSize,
|
||||
const Maybe<SVGImageContext>& aSVGContext,
|
||||
const Maybe<ImageIntRegion>& aRegion,
|
||||
uint32_t aFlags,
|
||||
WebRenderImageProvider** aProvider) {
|
||||
// XXX(seth): We currently don't have a way of clipping the result of
|
||||
// GetImageContainer. We work around this by always returning null, but if it
|
||||
// ever turns out that ClippedImage is widely used on codepaths that can
|
||||
// actually benefit from GetImageContainer, it would be a good idea to fix
|
||||
// that method for performance reasons.
|
||||
|
||||
if (!ShouldClip()) {
|
||||
return InnerImage()->GetImageProvider(aRenderer, aSize, aSVGContext,
|
||||
aRegion, aFlags, aProvider);
|
||||
}
|
||||
|
||||
return ImgDrawResult::NOT_SUPPORTED;
|
||||
}
|
||||
|
||||
static bool MustCreateSurface(gfxContext* aContext, const nsIntSize& aSize,
|
||||
const ImageRegion& aRegion,
|
||||
const uint32_t aFlags) {
|
||||
|
@ -51,6 +51,11 @@ class ClippedImage : public ImageWrapper {
|
||||
const Maybe<ImageIntRegion>& aRegion, uint32_t aFlags,
|
||||
layers::ImageContainer** aOutContainer) override;
|
||||
NS_IMETHOD_(ImgDrawResult)
|
||||
GetImageProvider(WindowRenderer* aRenderer, const gfx::IntSize& aSize,
|
||||
const Maybe<SVGImageContext>& aSVGContext,
|
||||
const Maybe<ImageIntRegion>& aRegion, uint32_t aFlags,
|
||||
WebRenderImageProvider** aProvider) override;
|
||||
NS_IMETHOD_(ImgDrawResult)
|
||||
Draw(gfxContext* aContext, const nsIntSize& aSize, const ImageRegion& aRegion,
|
||||
uint32_t aWhichFrame, gfx::SamplingFilter aSamplingFilter,
|
||||
const Maybe<SVGImageContext>& aSVGContext, uint32_t aFlags,
|
||||
|
@ -179,6 +179,16 @@ DynamicImage::GetImageContainerAtSize(WindowRenderer* aRenderer,
|
||||
return ImgDrawResult::NOT_SUPPORTED;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP_(ImgDrawResult)
|
||||
DynamicImage::GetImageProvider(WindowRenderer* aRenderer,
|
||||
const gfx::IntSize& aSize,
|
||||
const Maybe<SVGImageContext>& aSVGContext,
|
||||
const Maybe<ImageIntRegion>& aRegion,
|
||||
uint32_t aFlags,
|
||||
WebRenderImageProvider** aProvider) {
|
||||
return ImgDrawResult::NOT_SUPPORTED;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP_(ImgDrawResult)
|
||||
DynamicImage::Draw(gfxContext* aContext, const nsIntSize& aSize,
|
||||
const ImageRegion& aRegion, uint32_t aWhichFrame,
|
||||
|
@ -79,6 +79,26 @@ FrozenImage::GetImageContainerAtSize(WindowRenderer* aRenderer,
|
||||
return ImgDrawResult::NOT_SUPPORTED;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP_(ImgDrawResult)
|
||||
FrozenImage::GetImageProvider(WindowRenderer* aRenderer,
|
||||
const gfx::IntSize& aSize,
|
||||
const Maybe<SVGImageContext>& aSVGContext,
|
||||
const Maybe<ImageIntRegion>& aRegion,
|
||||
uint32_t aFlags,
|
||||
WebRenderImageProvider** aProvider) {
|
||||
if (IsNonAnimated()) {
|
||||
return InnerImage()->GetImageProvider(aRenderer, aSize, aSVGContext,
|
||||
aRegion, aFlags, aProvider);
|
||||
}
|
||||
|
||||
// XXX(seth): GetImageContainer does not currently support anything but the
|
||||
// current frame. We work around this by always returning null, but if it ever
|
||||
// turns out that FrozenImage is widely used on codepaths that can actually
|
||||
// benefit from GetImageContainer, it would be a good idea to fix that method
|
||||
// for performance reasons.
|
||||
return ImgDrawResult::NOT_SUPPORTED;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP_(ImgDrawResult)
|
||||
FrozenImage::Draw(gfxContext* aContext, const nsIntSize& aSize,
|
||||
const ImageRegion& aRegion,
|
||||
|
@ -50,6 +50,11 @@ class FrozenImage : public ImageWrapper {
|
||||
const Maybe<ImageIntRegion>& aRegion, uint32_t aFlags,
|
||||
layers::ImageContainer** aOutContainer) override;
|
||||
NS_IMETHOD_(ImgDrawResult)
|
||||
GetImageProvider(WindowRenderer* aRenderer, const gfx::IntSize& aSize,
|
||||
const Maybe<SVGImageContext>& aSVGContext,
|
||||
const Maybe<ImageIntRegion>& aRegion, uint32_t aFlags,
|
||||
WebRenderImageProvider** aProvider) override;
|
||||
NS_IMETHOD_(ImgDrawResult)
|
||||
Draw(gfxContext* aContext, const nsIntSize& aSize, const ImageRegion& aRegion,
|
||||
uint32_t aWhichFrame, gfx::SamplingFilter aSamplingFilter,
|
||||
const Maybe<SVGImageContext>& aSVGContext, uint32_t aFlags,
|
||||
|
@ -181,6 +181,17 @@ ImageWrapper::GetImageContainerAtSize(WindowRenderer* aRenderer,
|
||||
aRegion, aFlags, aOutContainer);
|
||||
}
|
||||
|
||||
NS_IMETHODIMP_(ImgDrawResult)
|
||||
ImageWrapper::GetImageProvider(WindowRenderer* aRenderer,
|
||||
const gfx::IntSize& aSize,
|
||||
const Maybe<SVGImageContext>& aSVGContext,
|
||||
const Maybe<ImageIntRegion>& aRegion,
|
||||
uint32_t aFlags,
|
||||
WebRenderImageProvider** aProvider) {
|
||||
return mInnerImage->GetImageProvider(aRenderer, aSize, aSVGContext, aRegion,
|
||||
aFlags, aProvider);
|
||||
}
|
||||
|
||||
NS_IMETHODIMP_(ImgDrawResult)
|
||||
ImageWrapper::Draw(gfxContext* aContext, const nsIntSize& aSize,
|
||||
const ImageRegion& aRegion, uint32_t aWhichFrame,
|
||||
|
@ -175,6 +175,27 @@ OrientedImage::GetImageContainerAtSize(
|
||||
return ImgDrawResult::NOT_SUPPORTED;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP_(ImgDrawResult)
|
||||
OrientedImage::GetImageProvider(WindowRenderer* aRenderer,
|
||||
const gfx::IntSize& aSize,
|
||||
const Maybe<SVGImageContext>& aSVGContext,
|
||||
const Maybe<ImageIntRegion>& aRegion,
|
||||
uint32_t aFlags,
|
||||
WebRenderImageProvider** aProvider) {
|
||||
// XXX(seth): We currently don't have a way of orienting the result of
|
||||
// GetImageContainer. We work around this by always returning null, but if it
|
||||
// ever turns out that OrientedImage is widely used on codepaths that can
|
||||
// actually benefit from GetImageContainer, it would be a good idea to fix
|
||||
// that method for performance reasons.
|
||||
|
||||
if (mOrientation.IsIdentity()) {
|
||||
return InnerImage()->GetImageProvider(aRenderer, aSize, aSVGContext,
|
||||
aRegion, aFlags, aProvider);
|
||||
}
|
||||
|
||||
return ImgDrawResult::NOT_SUPPORTED;
|
||||
}
|
||||
|
||||
struct MatrixBuilder {
|
||||
explicit MatrixBuilder(bool aInvert) : mInvert(aInvert) {}
|
||||
|
||||
|
@ -46,6 +46,11 @@ class OrientedImage : public ImageWrapper {
|
||||
const Maybe<ImageIntRegion>& aRegion, uint32_t aFlags,
|
||||
layers::ImageContainer** aOutContainer) override;
|
||||
NS_IMETHOD_(ImgDrawResult)
|
||||
GetImageProvider(WindowRenderer* aRenderer, const gfx::IntSize& aSize,
|
||||
const Maybe<SVGImageContext>& aSVGContext,
|
||||
const Maybe<ImageIntRegion>& aRegion, uint32_t aFlags,
|
||||
WebRenderImageProvider** aProvider) override;
|
||||
NS_IMETHOD_(ImgDrawResult)
|
||||
Draw(gfxContext* aContext, const nsIntSize& aSize, const ImageRegion& aRegion,
|
||||
uint32_t aWhichFrame, gfx::SamplingFilter aSamplingFilter,
|
||||
const Maybe<SVGImageContext>& aSVGContext, uint32_t aFlags,
|
||||
|
@ -653,6 +653,16 @@ RasterImage::GetImageContainerAtSize(WindowRenderer* aRenderer,
|
||||
aOutContainer);
|
||||
}
|
||||
|
||||
NS_IMETHODIMP_(ImgDrawResult)
|
||||
RasterImage::GetImageProvider(WindowRenderer* aRenderer,
|
||||
const gfx::IntSize& aSize,
|
||||
const Maybe<SVGImageContext>& aSVGContext,
|
||||
const Maybe<ImageIntRegion>& aRegion,
|
||||
uint32_t aFlags,
|
||||
WebRenderImageProvider** aProvider) {
|
||||
return ImgDrawResult::NOT_SUPPORTED;
|
||||
}
|
||||
|
||||
size_t RasterImage::SizeOfSourceWithComputedFallback(
|
||||
SizeOfState& aState) const {
|
||||
return mSourceBuffer->SizeOfIncludingThisWithComputedFallback(
|
||||
|
@ -852,6 +852,17 @@ VectorImage::GetImageContainerAtSize(WindowRenderer* aRenderer,
|
||||
return rv;
|
||||
}
|
||||
|
||||
//******************************************************************************
|
||||
NS_IMETHODIMP_(ImgDrawResult)
|
||||
VectorImage::GetImageProvider(WindowRenderer* aRenderer,
|
||||
const gfx::IntSize& aSize,
|
||||
const Maybe<SVGImageContext>& aSVGContext,
|
||||
const Maybe<ImageIntRegion>& aRegion,
|
||||
uint32_t aFlags,
|
||||
WebRenderImageProvider** aProvider) {
|
||||
return ImgDrawResult::NOT_SUPPORTED;
|
||||
}
|
||||
|
||||
bool VectorImage::MaybeRestrictSVGContext(
|
||||
Maybe<SVGImageContext>& aNewSVGContext,
|
||||
const Maybe<SVGImageContext>& aSVGContext, uint32_t aFlags) {
|
||||
|
@ -48,6 +48,7 @@ namespace image {
|
||||
|
||||
class ImageRegion;
|
||||
class ImageIntRegion;
|
||||
class WebRenderImageProvider;
|
||||
struct Orientation;
|
||||
struct Resolution;
|
||||
|
||||
@ -70,6 +71,7 @@ native nsSize(nsSize);
|
||||
[ptr] native nsIFrame(nsIFrame);
|
||||
native TempRefImageContainer(already_AddRefed<mozilla::layers::ImageContainer>);
|
||||
[ptr] native ImageContainer(mozilla::layers::ImageContainer);
|
||||
[ptr] native WebRenderImageProvider(mozilla::image::WebRenderImageProvider);
|
||||
[ref] native ImageRegion(mozilla::image::ImageRegion);
|
||||
[ptr] native WindowRenderer(mozilla::WindowRenderer);
|
||||
native Orientation(mozilla::image::Orientation);
|
||||
@ -352,6 +354,33 @@ interface imgIContainer : nsISupports
|
||||
in uint32_t aFlags,
|
||||
out ImageContainer aOutContainer);
|
||||
|
||||
/**
|
||||
* Attempts to find a WebRenderImageProvider containing the current frame at
|
||||
* the given size. Match the requested size is best effort; it's not
|
||||
* guaranteed that the surface you get will be a perfect match. (Some reasons
|
||||
* you may get a surface of a different size include: if you requested
|
||||
* upscaling, or if downscale-during-decode is disabled.)
|
||||
*
|
||||
* @param aRenderer The WindowRenderer which will be used to render the
|
||||
* ImageContainer.
|
||||
* @param aSVGContext If specified, SVG-related rendering context, such as
|
||||
* overridden attributes on the image document's root <svg>
|
||||
* node, and the size of the viewport that the full image
|
||||
* would occupy. Ignored for raster images.
|
||||
* @param aFlags Decoding / drawing flags (in other words, FLAG_* flags).
|
||||
* Currently only FLAG_SYNC_DECODE and FLAG_SYNC_DECODE_IF_FAST
|
||||
* are supported.
|
||||
* @param aProvider Return value for WebRenderImageProvider for the current
|
||||
* frame. May be null depending on the draw result.
|
||||
* @return The draw result for the current frame.
|
||||
*/
|
||||
[noscript, notxpcom] ImgDrawResult getImageProvider(in WindowRenderer aRenderer,
|
||||
[const] in nsIntSize aSize,
|
||||
[const] in MaybeSVGImageContext aSVGContext,
|
||||
[const] in MaybeImageIntRegion aRegion,
|
||||
in uint32_t aFlags,
|
||||
out WebRenderImageProvider aProvider);
|
||||
|
||||
/**
|
||||
* Draw the requested frame of this image onto the context specified.
|
||||
*
|
||||
|
Loading…
Reference in New Issue
Block a user