forked from mirrors/gecko-dev
Backed out 2 changesets (bug 1446309) for build bustages at builds/worker/workspace/build/src/image/RasterImage.cpp on a CLOSED TREE
Backed out changeset 45e3f5d8e294 (bug 1446309) Backed out changeset 69a4c2a0aac6 (bug 1446309)
This commit is contained in:
parent
58a3b0b973
commit
0e3ad61a5d
23 changed files with 126 additions and 242 deletions
|
|
@ -365,12 +365,11 @@ ClippedImage::IsImageContainerAvailableAtSize(LayerManager* aManager,
|
|||
return false;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP_(ImgDrawResult)
|
||||
ClippedImage::GetImageContainerAtSize(layers::LayerManager* aManager,
|
||||
const gfx::IntSize& aSize,
|
||||
NS_IMETHODIMP_(already_AddRefed<ImageContainer>)
|
||||
ClippedImage::GetImageContainerAtSize(LayerManager* aManager,
|
||||
const IntSize& aSize,
|
||||
const Maybe<SVGImageContext>& aSVGContext,
|
||||
uint32_t aFlags,
|
||||
layers::ImageContainer** aOutContainer)
|
||||
uint32_t aFlags)
|
||||
{
|
||||
// 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
|
||||
|
|
@ -379,11 +378,11 @@ ClippedImage::GetImageContainerAtSize(layers::LayerManager* aManager,
|
|||
// that method for performance reasons.
|
||||
|
||||
if (!ShouldClip()) {
|
||||
return InnerImage()->GetImageContainerAtSize(aManager, aSize, aSVGContext,
|
||||
aFlags, aOutContainer);
|
||||
return InnerImage()->GetImageContainerAtSize(aManager, aSize,
|
||||
aSVGContext, aFlags);
|
||||
}
|
||||
|
||||
return ImgDrawResult::NOT_SUPPORTED;
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
static bool
|
||||
|
|
|
|||
|
|
@ -51,12 +51,11 @@ public:
|
|||
IsImageContainerAvailableAtSize(layers::LayerManager* aManager,
|
||||
const gfx::IntSize& aSize,
|
||||
uint32_t aFlags) override;
|
||||
NS_IMETHOD_(ImgDrawResult)
|
||||
NS_IMETHOD_(already_AddRefed<layers::ImageContainer>)
|
||||
GetImageContainerAtSize(layers::LayerManager* aManager,
|
||||
const gfx::IntSize& aSize,
|
||||
const Maybe<SVGImageContext>& aSVGContext,
|
||||
uint32_t aFlags,
|
||||
layers::ImageContainer** aOutContainer) override;
|
||||
uint32_t aFlags) override;
|
||||
NS_IMETHOD_(ImgDrawResult) Draw(gfxContext* aContext,
|
||||
const nsIntSize& aSize,
|
||||
const ImageRegion& aRegion,
|
||||
|
|
|
|||
|
|
@ -234,14 +234,13 @@ DynamicImage::IsImageContainerAvailableAtSize(LayerManager* aManager,
|
|||
return false;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP_(ImgDrawResult)
|
||||
DynamicImage::GetImageContainerAtSize(layers::LayerManager* aManager,
|
||||
const gfx::IntSize& aSize,
|
||||
NS_IMETHODIMP_(already_AddRefed<ImageContainer>)
|
||||
DynamicImage::GetImageContainerAtSize(LayerManager* aManager,
|
||||
const IntSize& aSize,
|
||||
const Maybe<SVGImageContext>& aSVGContext,
|
||||
uint32_t aFlags,
|
||||
layers::ImageContainer** aContainer)
|
||||
uint32_t aFlags)
|
||||
{
|
||||
return ImgDrawResult::NOT_SUPPORTED;
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP_(ImgDrawResult)
|
||||
|
|
|
|||
|
|
@ -77,19 +77,18 @@ FrozenImage::IsImageContainerAvailableAtSize(LayerManager* aManager,
|
|||
return false;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP_(ImgDrawResult)
|
||||
NS_IMETHODIMP_(already_AddRefed<ImageContainer>)
|
||||
FrozenImage::GetImageContainerAtSize(layers::LayerManager* aManager,
|
||||
const gfx::IntSize& aSize,
|
||||
const IntSize& aSize,
|
||||
const Maybe<SVGImageContext>& aSVGContext,
|
||||
uint32_t aFlags,
|
||||
layers::ImageContainer** aOutContainer)
|
||||
uint32_t aFlags)
|
||||
{
|
||||
// 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;
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP_(ImgDrawResult)
|
||||
|
|
|
|||
|
|
@ -50,12 +50,11 @@ public:
|
|||
IsImageContainerAvailableAtSize(layers::LayerManager* aManager,
|
||||
const gfx::IntSize& aSize,
|
||||
uint32_t aFlags) override;
|
||||
NS_IMETHOD_(ImgDrawResult)
|
||||
NS_IMETHOD_(already_AddRefed<layers::ImageContainer>)
|
||||
GetImageContainerAtSize(layers::LayerManager* aManager,
|
||||
const gfx::IntSize& aSize,
|
||||
const Maybe<SVGImageContext>& aSVGContext,
|
||||
uint32_t aFlags,
|
||||
layers::ImageContainer** aOutContainer) override;
|
||||
uint32_t aFlags) override;
|
||||
NS_IMETHOD_(ImgDrawResult) Draw(gfxContext* aContext,
|
||||
const nsIntSize& aSize,
|
||||
const ImageRegion& aRegion,
|
||||
|
|
|
|||
|
|
@ -104,12 +104,11 @@ ImageResource::SetCurrentImage(ImageContainer* aContainer,
|
|||
}
|
||||
}
|
||||
|
||||
ImgDrawResult
|
||||
already_AddRefed<ImageContainer>
|
||||
ImageResource::GetImageContainerImpl(LayerManager* aManager,
|
||||
const IntSize& aSize,
|
||||
const Maybe<SVGImageContext>& aSVGContext,
|
||||
uint32_t aFlags,
|
||||
ImageContainer** aOutContainer)
|
||||
uint32_t aFlags)
|
||||
{
|
||||
MOZ_ASSERT(NS_IsMainThread());
|
||||
MOZ_ASSERT(aManager);
|
||||
|
|
@ -120,15 +119,11 @@ ImageResource::GetImageContainerImpl(LayerManager* aManager,
|
|||
== FLAG_NONE,
|
||||
"Unsupported flag passed to GetImageContainer");
|
||||
|
||||
ImgDrawResult drawResult;
|
||||
IntSize size;
|
||||
Tie(drawResult, size) = GetImageContainerSize(aManager, aSize, aFlags);
|
||||
if (drawResult != ImgDrawResult::SUCCESS) {
|
||||
return drawResult;
|
||||
IntSize size = GetImageContainerSize(aManager, aSize, aFlags);
|
||||
if (size.IsEmpty()) {
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
MOZ_ASSERT(!size.IsEmpty());
|
||||
|
||||
if (mAnimationConsumers == 0) {
|
||||
SendOnUnlockedDraw(aFlags);
|
||||
}
|
||||
|
|
@ -160,8 +155,7 @@ ImageResource::GetImageContainerImpl(LayerManager* aManager,
|
|||
case ImgDrawResult::SUCCESS:
|
||||
case ImgDrawResult::BAD_IMAGE:
|
||||
case ImgDrawResult::BAD_ARGS:
|
||||
container.forget(aOutContainer);
|
||||
return entry->mLastDrawResult;
|
||||
return container.forget();
|
||||
case ImgDrawResult::NOT_READY:
|
||||
case ImgDrawResult::INCOMPLETE:
|
||||
case ImgDrawResult::TEMPORARY_ERROR:
|
||||
|
|
@ -171,8 +165,7 @@ ImageResource::GetImageContainerImpl(LayerManager* aManager,
|
|||
// Unused by GetFrameInternal
|
||||
default:
|
||||
MOZ_ASSERT_UNREACHABLE("Unhandled ImgDrawResult type!");
|
||||
container.forget(aOutContainer);
|
||||
return entry->mLastDrawResult;
|
||||
return container.forget();
|
||||
}
|
||||
}
|
||||
|
||||
|
|
@ -180,6 +173,7 @@ ImageResource::GetImageContainerImpl(LayerManager* aManager,
|
|||
NotifyDrawingObservers();
|
||||
#endif
|
||||
|
||||
ImgDrawResult drawResult;
|
||||
IntSize bestSize;
|
||||
RefPtr<SourceSurface> surface;
|
||||
Tie(drawResult, bestSize, surface) =
|
||||
|
|
@ -218,8 +212,7 @@ ImageResource::GetImageContainerImpl(LayerManager* aManager,
|
|||
case ImgDrawResult::SUCCESS:
|
||||
case ImgDrawResult::BAD_IMAGE:
|
||||
case ImgDrawResult::BAD_ARGS:
|
||||
container.forget(aOutContainer);
|
||||
return entry->mLastDrawResult;
|
||||
return container.forget();
|
||||
case ImgDrawResult::NOT_READY:
|
||||
case ImgDrawResult::INCOMPLETE:
|
||||
case ImgDrawResult::TEMPORARY_ERROR:
|
||||
|
|
@ -230,8 +223,7 @@ ImageResource::GetImageContainerImpl(LayerManager* aManager,
|
|||
// Unused by GetFrameInternal
|
||||
default:
|
||||
MOZ_ASSERT_UNREACHABLE("Unhandled DrawResult type!");
|
||||
container.forget(aOutContainer);
|
||||
return entry->mLastDrawResult;
|
||||
return container.forget();
|
||||
}
|
||||
}
|
||||
break;
|
||||
|
|
@ -253,8 +245,7 @@ ImageResource::GetImageContainerImpl(LayerManager* aManager,
|
|||
|
||||
SetCurrentImage(container, surface, true);
|
||||
entry->mLastDrawResult = drawResult;
|
||||
container.forget(aOutContainer);
|
||||
return drawResult;
|
||||
return container.forget();
|
||||
}
|
||||
|
||||
void
|
||||
|
|
|
|||
|
|
@ -353,19 +353,18 @@ protected:
|
|||
* the same as the size of the surface in the image container, but it is the
|
||||
* best effort estimate.
|
||||
*/
|
||||
virtual Tuple<ImgDrawResult, gfx::IntSize>
|
||||
GetImageContainerSize(layers::LayerManager* aManager,
|
||||
virtual gfx::IntSize GetImageContainerSize(layers::LayerManager* aManager,
|
||||
const gfx::IntSize& aSize,
|
||||
uint32_t aFlags)
|
||||
{
|
||||
return MakeTuple(ImgDrawResult::NOT_SUPPORTED, gfx::IntSize(0, 0));
|
||||
return gfx::IntSize(0, 0);
|
||||
}
|
||||
|
||||
ImgDrawResult GetImageContainerImpl(layers::LayerManager* aManager,
|
||||
already_AddRefed<layers::ImageContainer>
|
||||
GetImageContainerImpl(layers::LayerManager* aManager,
|
||||
const gfx::IntSize& aSize,
|
||||
const Maybe<SVGImageContext>& aSVGContext,
|
||||
uint32_t aFlags,
|
||||
layers::ImageContainer** aContainer);
|
||||
uint32_t aFlags);
|
||||
|
||||
void UpdateImageContainer();
|
||||
|
||||
|
|
|
|||
|
|
@ -222,15 +222,14 @@ ImageWrapper::IsImageContainerAvailableAtSize(LayerManager* aManager,
|
|||
return mInnerImage->IsImageContainerAvailableAtSize(aManager, aSize, aFlags);
|
||||
}
|
||||
|
||||
NS_IMETHODIMP_(ImgDrawResult)
|
||||
ImageWrapper::GetImageContainerAtSize(layers::LayerManager* aManager,
|
||||
const gfx::IntSize& aSize,
|
||||
NS_IMETHODIMP_(already_AddRefed<ImageContainer>)
|
||||
ImageWrapper::GetImageContainerAtSize(LayerManager* aManager,
|
||||
const IntSize& aSize,
|
||||
const Maybe<SVGImageContext>& aSVGContext,
|
||||
uint32_t aFlags,
|
||||
layers::ImageContainer** aOutContainer)
|
||||
uint32_t aFlags)
|
||||
{
|
||||
return mInnerImage->GetImageContainerAtSize(aManager, aSize, aSVGContext,
|
||||
aFlags, aOutContainer);
|
||||
return mInnerImage->GetImageContainerAtSize(aManager, aSize,
|
||||
aSVGContext, aFlags);
|
||||
}
|
||||
|
||||
NS_IMETHODIMP_(ImgDrawResult)
|
||||
|
|
|
|||
|
|
@ -45,9 +45,6 @@ namespace image {
|
|||
* permanent condition.
|
||||
*
|
||||
* BAD_ARGS: We failed to draw because bad arguments were passed to draw().
|
||||
*
|
||||
* NOT_SUPPORTED: The requested operation is not supported, but the image is
|
||||
* otherwise valid.
|
||||
*/
|
||||
enum class MOZ_MUST_USE_TYPE ImgDrawResult : uint8_t
|
||||
{
|
||||
|
|
@ -57,8 +54,7 @@ enum class MOZ_MUST_USE_TYPE ImgDrawResult : uint8_t
|
|||
NOT_READY,
|
||||
TEMPORARY_ERROR,
|
||||
BAD_IMAGE,
|
||||
BAD_ARGS,
|
||||
NOT_SUPPORTED
|
||||
BAD_ARGS
|
||||
};
|
||||
|
||||
/**
|
||||
|
|
|
|||
|
|
@ -182,12 +182,11 @@ OrientedImage::IsImageContainerAvailableAtSize(LayerManager* aManager,
|
|||
return false;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP_(ImgDrawResult)
|
||||
OrientedImage::GetImageContainerAtSize(layers::LayerManager* aManager,
|
||||
const gfx::IntSize& aSize,
|
||||
NS_IMETHODIMP_(already_AddRefed<ImageContainer>)
|
||||
OrientedImage::GetImageContainerAtSize(LayerManager* aManager,
|
||||
const IntSize& aSize,
|
||||
const Maybe<SVGImageContext>& aSVGContext,
|
||||
uint32_t aFlags,
|
||||
layers::ImageContainer** aOutContainer)
|
||||
uint32_t aFlags)
|
||||
{
|
||||
// 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
|
||||
|
|
@ -196,11 +195,11 @@ OrientedImage::GetImageContainerAtSize(layers::LayerManager* aManager,
|
|||
// that method for performance reasons.
|
||||
|
||||
if (mOrientation.IsIdentity()) {
|
||||
return InnerImage()->GetImageContainerAtSize(aManager, aSize, aSVGContext,
|
||||
aFlags, aOutContainer);
|
||||
return InnerImage()->GetImageContainerAtSize(aManager, aSize,
|
||||
aSVGContext, aFlags);
|
||||
}
|
||||
|
||||
return ImgDrawResult::NOT_SUPPORTED;
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
struct MatrixBuilder
|
||||
|
|
|
|||
|
|
@ -48,12 +48,11 @@ public:
|
|||
IsImageContainerAvailableAtSize(layers::LayerManager* aManager,
|
||||
const gfx::IntSize& aSize,
|
||||
uint32_t aFlags) override;
|
||||
NS_IMETHOD_(ImgDrawResult)
|
||||
NS_IMETHOD_(already_AddRefed<layers::ImageContainer>)
|
||||
GetImageContainerAtSize(layers::LayerManager* aManager,
|
||||
const gfx::IntSize& aSize,
|
||||
const Maybe<SVGImageContext>& aSVGContext,
|
||||
uint32_t aFlags,
|
||||
layers::ImageContainer** aOutContainer) override;
|
||||
uint32_t aFlags) override;
|
||||
NS_IMETHOD_(ImgDrawResult) Draw(gfxContext* aContext,
|
||||
const nsIntSize& aSize,
|
||||
const ImageRegion& aRegion,
|
||||
|
|
|
|||
|
|
@ -627,34 +627,20 @@ RasterImage::GetFrameInternal(const IntSize& aSize,
|
|||
return MakeTuple(ImgDrawResult::SUCCESS, suggestedSize, std::move(surface));
|
||||
}
|
||||
|
||||
Tuple<ImgDrawResult, IntSize>
|
||||
IntSize
|
||||
RasterImage::GetImageContainerSize(LayerManager* aManager,
|
||||
const IntSize& aSize,
|
||||
uint32_t aFlags)
|
||||
{
|
||||
if (!mHasSize) {
|
||||
return MakeTuple(ImgDrawResult::NOT_READY, IntSize(0, 0));
|
||||
}
|
||||
|
||||
if (aSize.IsEmpty()) {
|
||||
return MakeTuple(ImgDrawResult::BAD_ARGS, IntSize(0, 0));
|
||||
}
|
||||
|
||||
// We check the minimum size because while we support downscaling, we do not
|
||||
// support upscaling. If aSize > mSize, we will never give a larger surface
|
||||
// than mSize. If mSize > aSize, and mSize > maxTextureSize, we still want to
|
||||
// use image containers if aSize <= maxTextureSize.
|
||||
int32_t maxTextureSize = aManager->GetMaxTextureSize();
|
||||
if (min(mSize.width, aSize.width) > maxTextureSize ||
|
||||
min(mSize.height, aSize.height) > maxTextureSize) {
|
||||
return MakeTuple(ImgDrawResult::NOT_SUPPORTED, IntSize(0, 0));
|
||||
if (!IsImageContainerAvailableAtSize(aManager, aSize, aFlags)) {
|
||||
return IntSize(0, 0);
|
||||
}
|
||||
|
||||
if (!CanDownscaleDuringDecode(aSize, aFlags)) {
|
||||
return MakeTuple(ImgDrawResult::SUCCESS, mSize);
|
||||
return mSize;
|
||||
}
|
||||
|
||||
return MakeTuple(ImgDrawResult::SUCCESS, aSize);
|
||||
return aSize;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP_(bool)
|
||||
|
|
@ -666,10 +652,7 @@ RasterImage::IsImageContainerAvailable(LayerManager* aManager, uint32_t aFlags)
|
|||
NS_IMETHODIMP_(already_AddRefed<ImageContainer>)
|
||||
RasterImage::GetImageContainer(LayerManager* aManager, uint32_t aFlags)
|
||||
{
|
||||
RefPtr<ImageContainer> container;
|
||||
GetImageContainerImpl(aManager, mSize, Nothing(), aFlags,
|
||||
getter_AddRefs(container));
|
||||
return container.forget();
|
||||
return GetImageContainerImpl(aManager, mSize, Nothing(), aFlags);
|
||||
}
|
||||
|
||||
NS_IMETHODIMP_(bool)
|
||||
|
|
@ -691,18 +674,16 @@ RasterImage::IsImageContainerAvailableAtSize(LayerManager* aManager,
|
|||
return true;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP_(ImgDrawResult)
|
||||
RasterImage::GetImageContainerAtSize(layers::LayerManager* aManager,
|
||||
const gfx::IntSize& aSize,
|
||||
NS_IMETHODIMP_(already_AddRefed<ImageContainer>)
|
||||
RasterImage::GetImageContainerAtSize(LayerManager* aManager,
|
||||
const IntSize& aSize,
|
||||
const Maybe<SVGImageContext>& aSVGContext,
|
||||
uint32_t aFlags,
|
||||
layers::ImageContainer** aOutContainer)
|
||||
uint32_t aFlags)
|
||||
{
|
||||
// We do not pass in the given SVG context because in theory it could differ
|
||||
// between calls, but actually have no impact on the actual contents of the
|
||||
// image container.
|
||||
return GetImageContainerImpl(aManager, aSize, Nothing(),
|
||||
aFlags, aOutContainer);
|
||||
return GetImageContainerImpl(aManager, aSize, Nothing(), aFlags);
|
||||
}
|
||||
|
||||
size_t
|
||||
|
|
|
|||
|
|
@ -312,8 +312,7 @@ private:
|
|||
uint32_t aWhichFrame,
|
||||
uint32_t aFlags) override;
|
||||
|
||||
Tuple<ImgDrawResult, gfx::IntSize>
|
||||
GetImageContainerSize(layers::LayerManager* aManager,
|
||||
gfx::IntSize GetImageContainerSize(layers::LayerManager* aManager,
|
||||
const gfx::IntSize& aSize,
|
||||
uint32_t aFlags) override;
|
||||
|
||||
|
|
|
|||
|
|
@ -849,31 +849,16 @@ VectorImage::GetFrameInternal(const IntSize& aSize,
|
|||
}
|
||||
|
||||
//******************************************************************************
|
||||
Tuple<ImgDrawResult, IntSize>
|
||||
IntSize
|
||||
VectorImage::GetImageContainerSize(LayerManager* aManager,
|
||||
const IntSize& aSize,
|
||||
uint32_t aFlags)
|
||||
{
|
||||
if (mError) {
|
||||
return MakeTuple(ImgDrawResult::BAD_IMAGE, IntSize(0, 0));
|
||||
if (!IsImageContainerAvailableAtSize(aManager, aSize, aFlags)) {
|
||||
return IntSize(0, 0);
|
||||
}
|
||||
|
||||
if (!mIsFullyLoaded) {
|
||||
return MakeTuple(ImgDrawResult::NOT_READY, IntSize(0, 0));
|
||||
}
|
||||
|
||||
if (mHaveAnimations ||
|
||||
aManager->GetBackendType() != LayersBackend::LAYERS_WR) {
|
||||
return MakeTuple(ImgDrawResult::NOT_SUPPORTED, IntSize(0, 0));
|
||||
}
|
||||
|
||||
// We don't need to check if the size is too big since we only support
|
||||
// WebRender backends.
|
||||
if (aSize.IsEmpty()) {
|
||||
return MakeTuple(ImgDrawResult::BAD_ARGS, IntSize(0, 0));
|
||||
}
|
||||
|
||||
return MakeTuple(ImgDrawResult::SUCCESS, aSize);
|
||||
return aSize;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP_(bool)
|
||||
|
|
@ -908,12 +893,11 @@ VectorImage::IsImageContainerAvailableAtSize(LayerManager* aManager,
|
|||
}
|
||||
|
||||
//******************************************************************************
|
||||
NS_IMETHODIMP_(ImgDrawResult)
|
||||
VectorImage::GetImageContainerAtSize(layers::LayerManager* aManager,
|
||||
const gfx::IntSize& aSize,
|
||||
NS_IMETHODIMP_(already_AddRefed<ImageContainer>)
|
||||
VectorImage::GetImageContainerAtSize(LayerManager* aManager,
|
||||
const IntSize& aSize,
|
||||
const Maybe<SVGImageContext>& aSVGContext,
|
||||
uint32_t aFlags,
|
||||
layers::ImageContainer** aOutContainer)
|
||||
uint32_t aFlags)
|
||||
{
|
||||
Maybe<SVGImageContext> newSVGContext;
|
||||
MaybeRestrictSVGContext(newSVGContext, aSVGContext, aFlags);
|
||||
|
|
@ -926,7 +910,7 @@ VectorImage::GetImageContainerAtSize(layers::LayerManager* aManager,
|
|||
FLAG_FORCE_PRESERVEASPECTRATIO_NONE);
|
||||
return GetImageContainerImpl(aManager, aSize,
|
||||
newSVGContext ? newSVGContext : aSVGContext,
|
||||
flags, aOutContainer);
|
||||
flags);
|
||||
}
|
||||
|
||||
bool
|
||||
|
|
|
|||
|
|
@ -87,8 +87,7 @@ private:
|
|||
uint32_t aWhichFrame,
|
||||
uint32_t aFlags) override;
|
||||
|
||||
Tuple<ImgDrawResult, IntSize>
|
||||
GetImageContainerSize(layers::LayerManager* aManager,
|
||||
IntSize GetImageContainerSize(layers::LayerManager* aManager,
|
||||
const IntSize& aSize,
|
||||
uint32_t aFlags) override;
|
||||
|
||||
|
|
|
|||
|
|
@ -57,7 +57,6 @@ native nsIntRectByVal(nsIntRect);
|
|||
native nsSize(nsSize);
|
||||
[ptr] native nsIFrame(nsIFrame);
|
||||
native TempRefImageContainer(already_AddRefed<mozilla::layers::ImageContainer>);
|
||||
[ptr] native ImageContainer(mozilla::layers::ImageContainer);
|
||||
[ref] native ImageRegion(mozilla::image::ImageRegion);
|
||||
[ptr] native LayerManager(mozilla::layers::LayerManager);
|
||||
native Orientation(mozilla::image::Orientation);
|
||||
|
|
@ -296,6 +295,15 @@ interface imgIContainer : nsISupports
|
|||
[noscript, notxpcom] TempRefImageContainer getImageContainer(in LayerManager aManager,
|
||||
in uint32_t aFlags);
|
||||
|
||||
/**
|
||||
* @return true if getImageContainer() is expected to return a valid
|
||||
* ImageContainer when passed the given @Manager, @Size and @Flags
|
||||
* parameters.
|
||||
*/
|
||||
[noscript, notxpcom] boolean isImageContainerAvailableAtSize(in LayerManager aManager,
|
||||
[const] in nsIntSize aSize,
|
||||
in uint32_t aFlags);
|
||||
|
||||
/**
|
||||
* Attempts to create an ImageContainer (and Image) containing the current
|
||||
* frame at the given size. Match the requested size is best effort; it's
|
||||
|
|
@ -314,23 +322,12 @@ interface imgIContainer : nsISupports
|
|||
* @param aFlags Decoding / drawing flags (in other words, FLAG_* flags).
|
||||
* Currently only FLAG_SYNC_DECODE and FLAG_SYNC_DECODE_IF_FAST
|
||||
* are supported.
|
||||
* @param aContainer Return value for ImageContainer for the current frame.
|
||||
* May be null depending on the draw result.
|
||||
* @return The draw result for the current frame.
|
||||
* @return An ImageContainer for the current frame, or nullptr if one could
|
||||
* not be created.
|
||||
*/
|
||||
[noscript, notxpcom] ImgDrawResult getImageContainerAtSize(in LayerManager aManager,
|
||||
[noscript, notxpcom] TempRefImageContainer getImageContainerAtSize(in LayerManager aManager,
|
||||
[const] in nsIntSize aSize,
|
||||
[const] in MaybeSVGImageContext aSVGContext,
|
||||
in uint32_t aFlags,
|
||||
out ImageContainer aOutContainer);
|
||||
|
||||
/**
|
||||
* @return true if getImageContainer() is expected to return a valid
|
||||
* ImageContainer when passed the given @Manager, @Size and @Flags
|
||||
* parameters.
|
||||
*/
|
||||
[noscript, notxpcom] boolean isImageContainerAvailableAtSize(in LayerManager aManager,
|
||||
[const] in nsIntSize aSize,
|
||||
in uint32_t aFlags);
|
||||
|
||||
/**
|
||||
|
|
|
|||
|
|
@ -70,13 +70,12 @@ TEST_F(ImageContainers, RasterImageContainer)
|
|||
// Upscaling should give the native size.
|
||||
IntSize requestedSize = testCase.mSize;
|
||||
requestedSize.Scale(2, 2);
|
||||
RefPtr<layers::ImageContainer> upscaleContainer;
|
||||
RefPtr<layers::ImageContainer> upscaleContainer =
|
||||
image->GetImageContainerAtSize(layerManager,
|
||||
requestedSize,
|
||||
Nothing(),
|
||||
imgIContainer::FLAG_SYNC_DECODE |
|
||||
imgIContainer::FLAG_HIGH_QUALITY_SCALING,
|
||||
getter_AddRefs(upscaleContainer));
|
||||
imgIContainer::FLAG_HIGH_QUALITY_SCALING);
|
||||
ASSERT_TRUE(upscaleContainer != nullptr);
|
||||
containerSize = upscaleContainer->GetCurrentSize();
|
||||
EXPECT_EQ(testCase.mSize.width, containerSize.width);
|
||||
|
|
@ -86,23 +85,21 @@ TEST_F(ImageContainers, RasterImageContainer)
|
|||
requestedSize = testCase.mSize;
|
||||
requestedSize.width /= 2;
|
||||
requestedSize.height /= 2;
|
||||
RefPtr<layers::ImageContainer> downscaleContainer;
|
||||
RefPtr<layers::ImageContainer> downscaleContainer =
|
||||
image->GetImageContainerAtSize(layerManager,
|
||||
requestedSize,
|
||||
Nothing(),
|
||||
imgIContainer::FLAG_SYNC_DECODE |
|
||||
imgIContainer::FLAG_HIGH_QUALITY_SCALING,
|
||||
getter_AddRefs(downscaleContainer));
|
||||
imgIContainer::FLAG_HIGH_QUALITY_SCALING);
|
||||
containerSize = downscaleContainer->GetCurrentSize();
|
||||
EXPECT_EQ(requestedSize.width, containerSize.width);
|
||||
EXPECT_EQ(requestedSize.height, containerSize.height);
|
||||
|
||||
// Get at native size again. Should give same container.
|
||||
RefPtr<layers::ImageContainer> againContainer;
|
||||
RefPtr<layers::ImageContainer> againContainer =
|
||||
image->GetImageContainerAtSize(layerManager,
|
||||
testCase.mSize,
|
||||
Nothing(),
|
||||
imgIContainer::FLAG_SYNC_DECODE,
|
||||
getter_AddRefs(againContainer));
|
||||
imgIContainer::FLAG_SYNC_DECODE);
|
||||
ASSERT_EQ(nativeContainer.get(), againContainer.get());
|
||||
}
|
||||
|
|
|
|||
|
|
@ -479,10 +479,8 @@ BulletRenderer::CreateWebRenderCommandsForImage(nsDisplayItem* aItem,
|
|||
gfx::IntSize decodeSize =
|
||||
nsLayoutUtils::ComputeImageContainerDrawingParameters(mImage, aItem->Frame(), destRect,
|
||||
aSc, flags, svgContext);
|
||||
|
||||
RefPtr<layers::ImageContainer> container;
|
||||
mImage->GetImageContainerAtSize(aManager, decodeSize, svgContext,
|
||||
flags, getter_AddRefs(container));
|
||||
RefPtr<layers::ImageContainer> container =
|
||||
mImage->GetImageContainerAtSize(aManager, decodeSize, svgContext, flags);
|
||||
if (!container) {
|
||||
return false;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -1811,50 +1811,8 @@ nsDisplayImage::CreateWebRenderCommands(mozilla::wr::DisplayListBuilder& aBuilde
|
|||
IntSize decodeSize =
|
||||
nsLayoutUtils::ComputeImageContainerDrawingParameters(mImage, mFrame, destRect,
|
||||
aSc, flags, svgContext);
|
||||
|
||||
RefPtr<layers::ImageContainer> container;
|
||||
ImgDrawResult drawResult =
|
||||
mImage->GetImageContainerAtSize(aManager, decodeSize, svgContext,
|
||||
flags, getter_AddRefs(container));
|
||||
|
||||
// While we got a container, it may not contain a fully decoded surface. If
|
||||
// that is the case, and we have an image we were previously displaying which
|
||||
// has a fully decoded surface, then we should prefer the previous image.
|
||||
bool updatePrevImage = false;
|
||||
switch (drawResult) {
|
||||
case ImgDrawResult::NOT_READY:
|
||||
case ImgDrawResult::INCOMPLETE:
|
||||
case ImgDrawResult::TEMPORARY_ERROR:
|
||||
if (mPrevImage && mPrevImage != mImage) {
|
||||
RefPtr<ImageContainer> prevContainer;
|
||||
drawResult = mPrevImage->GetImageContainerAtSize(aManager, decodeSize,
|
||||
svgContext, flags,
|
||||
getter_AddRefs(prevContainer));
|
||||
if (prevContainer && drawResult == ImgDrawResult::SUCCESS) {
|
||||
container = std::move(prevContainer);
|
||||
break;
|
||||
}
|
||||
|
||||
// Previous image was unusable; we can forget about it.
|
||||
updatePrevImage = true;
|
||||
}
|
||||
break;
|
||||
default:
|
||||
updatePrevImage = mPrevImage != mImage;
|
||||
break;
|
||||
}
|
||||
|
||||
// The previous image was not used, and is different from the current image.
|
||||
// We should forget about it. We need to update the frame as well because the
|
||||
// display item may get recreated.
|
||||
if (updatePrevImage) {
|
||||
mPrevImage = mImage;
|
||||
if (mFrame->IsImageFrame()) {
|
||||
nsImageFrame* f = static_cast<nsImageFrame*>(mFrame);
|
||||
f->mPrevImage = f->mImage;
|
||||
}
|
||||
}
|
||||
|
||||
RefPtr<ImageContainer> container =
|
||||
mImage->GetImageContainerAtSize(aManager, decodeSize, svgContext, flags);
|
||||
if (!container) {
|
||||
return false;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -3721,10 +3721,8 @@ nsCSSBorderImageRenderer::CreateWebRenderCommands(nsDisplayItem* aItem,
|
|||
gfx::IntSize decodeSize =
|
||||
nsLayoutUtils::ComputeImageContainerDrawingParameters(img, aForFrame, destRect,
|
||||
aSc, flags, svgContext);
|
||||
|
||||
RefPtr<layers::ImageContainer> container;
|
||||
img->GetImageContainerAtSize(aManager, decodeSize, svgContext,
|
||||
flags, getter_AddRefs(container));
|
||||
RefPtr<layers::ImageContainer> container =
|
||||
img->GetImageContainerAtSize(aManager, decodeSize, svgContext, flags);
|
||||
if (!container) {
|
||||
return;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -618,10 +618,8 @@ nsImageRenderer::BuildWebRenderDisplayItems(nsPresContext* aPresContext,
|
|||
gfx::IntSize decodeSize =
|
||||
nsLayoutUtils::ComputeImageContainerDrawingParameters(mImageContainer, mForFrame, destRect,
|
||||
aSc, containerFlags, svgContext);
|
||||
|
||||
RefPtr<layers::ImageContainer> container;
|
||||
mImageContainer->GetImageContainerAtSize(aManager, decodeSize, svgContext,
|
||||
containerFlags, getter_AddRefs(container));
|
||||
RefPtr<layers::ImageContainer> container =
|
||||
mImageContainer->GetImageContainerAtSize(aManager, decodeSize, svgContext, containerFlags);
|
||||
if (!container) {
|
||||
NS_WARNING("Failed to get image container");
|
||||
return ImgDrawResult::NOT_READY;
|
||||
|
|
|
|||
|
|
@ -452,10 +452,8 @@ nsImageBoxFrame::CreateWebRenderCommands(mozilla::wr::DisplayListBuilder& aBuild
|
|||
gfx::IntSize decodeSize =
|
||||
nsLayoutUtils::ComputeImageContainerDrawingParameters(imgCon, aItem->Frame(), fillRect,
|
||||
aSc, containerFlags, svgContext);
|
||||
|
||||
RefPtr<layers::ImageContainer> container;
|
||||
imgCon->GetImageContainerAtSize(aManager, decodeSize, svgContext,
|
||||
containerFlags, getter_AddRefs(container));
|
||||
RefPtr<layers::ImageContainer> container =
|
||||
imgCon->GetImageContainerAtSize(aManager, decodeSize, svgContext, containerFlags);
|
||||
if (!container) {
|
||||
NS_WARNING("Failed to get image container");
|
||||
return Nothing();
|
||||
|
|
|
|||
|
|
@ -789,8 +789,7 @@ nsBaseDragService::DrawDragForImage(nsPresContext* aPresContext,
|
|||
imgIContainer::FRAME_CURRENT,
|
||||
SamplingFilter::GOOD, /* no SVGImageContext */ Nothing(),
|
||||
imgIContainer::FLAG_SYNC_DECODE, 1.0);
|
||||
if (res == ImgDrawResult::BAD_IMAGE || res == ImgDrawResult::BAD_ARGS ||
|
||||
res == ImgDrawResult::NOT_SUPPORTED) {
|
||||
if (res == ImgDrawResult::BAD_IMAGE || res == ImgDrawResult::BAD_ARGS) {
|
||||
return NS_ERROR_FAILURE;
|
||||
}
|
||||
*aSurface = dt->Snapshot();
|
||||
|
|
|
|||
Loading…
Reference in a new issue