diff --git a/image/decoders/nsICODecoder.cpp b/image/decoders/nsICODecoder.cpp index 7322b42ba756..102a9ffb70c3 100644 --- a/image/decoders/nsICODecoder.cpp +++ b/image/decoders/nsICODecoder.cpp @@ -638,12 +638,12 @@ nsICODecoder::NeedsNewFrame() const } nsresult -nsICODecoder::AllocateFrame(const nsIntSize& aTargetSize /* = nsIntSize() */) +nsICODecoder::AllocateFrame() { nsresult rv; if (mContainedDecoder) { - rv = mContainedDecoder->AllocateFrame(aTargetSize); + rv = mContainedDecoder->AllocateFrame(); mCurrentFrame = mContainedDecoder->GetCurrentFrameRef(); mProgress |= mContainedDecoder->TakeProgress(); mInvalidRect.Union(mContainedDecoder->TakeInvalidRect()); @@ -652,7 +652,7 @@ nsICODecoder::AllocateFrame(const nsIntSize& aTargetSize /* = nsIntSize() */) // Grab a strong ref that we'll later hand over to the contained decoder. This // lets us avoid creating a RawAccessFrameRef off-main-thread. - rv = Decoder::AllocateFrame(aTargetSize); + rv = Decoder::AllocateFrame(); mRefForContainedDecoder = GetCurrentFrameRef(); return rv; } diff --git a/image/decoders/nsICODecoder.h b/image/decoders/nsICODecoder.h index 6cc92d2b27af..556aea4a63db 100644 --- a/image/decoders/nsICODecoder.h +++ b/image/decoders/nsICODecoder.h @@ -40,8 +40,7 @@ public: virtual void WriteInternal(const char* aBuffer, uint32_t aCount) MOZ_OVERRIDE; virtual void FinishInternal() MOZ_OVERRIDE; - virtual nsresult AllocateFrame(const nsIntSize& aTargetSize - /* = nsIntSize() */) MOZ_OVERRIDE; + virtual nsresult AllocateFrame() MOZ_OVERRIDE; protected: virtual bool NeedsNewFrame() const MOZ_OVERRIDE; diff --git a/image/src/Decoder.cpp b/image/src/Decoder.cpp index 9cb85fe667bd..3541e84abe53 100644 --- a/image/src/Decoder.cpp +++ b/image/src/Decoder.cpp @@ -328,18 +328,11 @@ Decoder::FinishSharedDecoder() } nsresult -Decoder::AllocateFrame(const nsIntSize& aTargetSize /* = nsIntSize() */) +Decoder::AllocateFrame() { MOZ_ASSERT(mNeedsNewFrame); - nsIntSize targetSize = aTargetSize; - if (targetSize == nsIntSize()) { - MOZ_ASSERT(HasSize()); - targetSize = mImageMetadata.GetSize(); - } - mCurrentFrame = EnsureFrame(mNewFrameData.mFrameNum, - targetSize, mNewFrameData.mFrameRect, mDecodeFlags, mNewFrameData.mFormat, @@ -373,7 +366,6 @@ Decoder::AllocateFrame(const nsIntSize& aTargetSize /* = nsIntSize() */) RawAccessFrameRef Decoder::EnsureFrame(uint32_t aFrameNum, - const nsIntSize& aTargetSize, const nsIntRect& aFrameRect, uint32_t aDecodeFlags, SurfaceFormat aFormat, @@ -391,8 +383,8 @@ Decoder::EnsureFrame(uint32_t aFrameNum, // Adding a frame that doesn't already exist. This is the normal case. if (aFrameNum == mFrameCount) { - return InternalAddFrame(aFrameNum, aTargetSize, aFrameRect, aDecodeFlags, - aFormat, aPaletteDepth, aPreviousFrame); + return InternalAddFrame(aFrameNum, aFrameRect, aDecodeFlags, aFormat, + aPaletteDepth, aPreviousFrame); } // We're replacing a frame. It must be the first frame; there's no reason to @@ -423,7 +415,7 @@ Decoder::EnsureFrame(uint32_t aFrameNum, bool nonPremult = aDecodeFlags & imgIContainer::FLAG_DECODE_NO_PREMULTIPLY_ALPHA; if (NS_FAILED(aPreviousFrame->ReinitForDecoder(oldSize, aFrameRect, aFormat, - aPaletteDepth, nonPremult))) { + aPaletteDepth, nonPremult))) { NS_WARNING("imgFrame::ReinitForDecoder should succeed"); mFrameCount = 0; aPreviousFrame->Abort(); @@ -435,7 +427,6 @@ Decoder::EnsureFrame(uint32_t aFrameNum, RawAccessFrameRef Decoder::InternalAddFrame(uint32_t aFrameNum, - const nsIntSize& aTargetSize, const nsIntRect& aFrameRect, uint32_t aDecodeFlags, SurfaceFormat aFormat, @@ -447,13 +438,15 @@ Decoder::InternalAddFrame(uint32_t aFrameNum, return RawAccessFrameRef(); } - if (aTargetSize.width <= 0 || aTargetSize.height <= 0 || + MOZ_ASSERT(mImageMetadata.HasSize()); + nsIntSize imageSize(mImageMetadata.GetWidth(), mImageMetadata.GetHeight()); + if (imageSize.width <= 0 || imageSize.height <= 0 || aFrameRect.width <= 0 || aFrameRect.height <= 0) { NS_WARNING("Trying to add frame with zero or negative size"); return RawAccessFrameRef(); } - if (!SurfaceCache::CanHold(aTargetSize.ToIntSize())) { + if (!SurfaceCache::CanHold(imageSize.ToIntSize())) { NS_WARNING("Trying to add frame that's too large for the SurfaceCache"); return RawAccessFrameRef(); } @@ -461,7 +454,7 @@ Decoder::InternalAddFrame(uint32_t aFrameNum, nsRefPtr frame = new imgFrame(); bool nonPremult = aDecodeFlags & imgIContainer::FLAG_DECODE_NO_PREMULTIPLY_ALPHA; - if (NS_FAILED(frame->InitForDecoder(aTargetSize, aFrameRect, aFormat, + if (NS_FAILED(frame->InitForDecoder(imageSize, aFrameRect, aFormat, aPaletteDepth, nonPremult))) { NS_WARNING("imgFrame::Init should succeed"); return RawAccessFrameRef(); @@ -475,7 +468,7 @@ Decoder::InternalAddFrame(uint32_t aFrameNum, InsertOutcome outcome = SurfaceCache::Insert(frame, ImageKey(mImage.get()), - RasterSurfaceKey(aTargetSize.ToIntSize(), + RasterSurfaceKey(imageSize.ToIntSize(), aDecodeFlags, aFrameNum), Lifetime::Persistent); @@ -611,7 +604,7 @@ Decoder::PostFrameStop(Opacity aFrameOpacity /* = Opacity::TRANSPARENT */, } void -Decoder::PostInvalidation(const nsIntRect& aRect) +Decoder::PostInvalidation(nsIntRect& aRect) { // We should be mid-frame NS_ABORT_IF_FALSE(mInFrame, "Can't invalidate when not mid-frame!"); diff --git a/image/src/Decoder.h b/image/src/Decoder.h index 166410ee8562..29494ce0eb7d 100644 --- a/image/src/Decoder.h +++ b/image/src/Decoder.h @@ -277,7 +277,7 @@ public: // Try to allocate a frame as described in mNewFrameData and return the // status code from that attempt. Clears mNewFrameData. - virtual nsresult AllocateFrame(const nsIntSize& aTargetSize = nsIntSize()); + virtual nsresult AllocateFrame(); already_AddRefed GetCurrentFrame() { @@ -352,7 +352,7 @@ protected: // Called by the decoders when they have a region to invalidate. We may not // actually pass these invalidations on right away. - void PostInvalidation(const nsIntRect& aRect); + void PostInvalidation(nsIntRect& aRect); // Called by the decoders when they have successfully decoded the image. This // may occur as the result of the decoder getting to the appropriate point in @@ -379,14 +379,9 @@ protected: * It is not possible to create sparse frame arrays; you can only append * frames to the current frame array, or if there is only one frame in the * array, replace that frame. - * @aTargetSize specifies the target size we're decoding to. If we're not - * downscaling during decode, this will always be the same as the image's - * intrinsic size. - * * If a non-paletted frame is desired, pass 0 for aPaletteDepth. */ RawAccessFrameRef EnsureFrame(uint32_t aFrameNum, - const nsIntSize& aTargetSize, const nsIntRect& aFrameRect, uint32_t aDecodeFlags, gfx::SurfaceFormat aFormat, @@ -394,7 +389,6 @@ protected: imgFrame* aPreviousFrame); RawAccessFrameRef InternalAddFrame(uint32_t aFrameNum, - const nsIntSize& aTargetSize, const nsIntRect& aFrameRect, uint32_t aDecodeFlags, gfx::SurfaceFormat aFormat, diff --git a/image/src/ImageMetadata.h b/image/src/ImageMetadata.h index 9ad46711d103..d2546592c764 100644 --- a/image/src/ImageMetadata.h +++ b/image/src/ImageMetadata.h @@ -51,7 +51,6 @@ public: bool HasSize() const { return mSize.isSome(); } bool HasOrientation() const { return mOrientation.isSome(); } - nsIntSize GetSize() const { return *mSize; } int32_t GetWidth() const { return mSize->width; } int32_t GetHeight() const { return mSize->height; } Orientation GetOrientation() const { return *mOrientation; } diff --git a/image/src/RasterImage.cpp b/image/src/RasterImage.cpp index 6be096690c33..456c83686e4b 100644 --- a/image/src/RasterImage.cpp +++ b/image/src/RasterImage.cpp @@ -1334,12 +1334,10 @@ RasterImage::CreateDecoder(const Maybe& aSize, uint32_t aFlags) // We already have the size; tell the decoder so it can preallocate a // frame. By default, we create an ARGB frame with no offset. If decoders // need a different type, they need to ask for it themselves. - // XXX(seth): Note that we call SetSize() and NeedNewFrame() with the - // image's intrinsic size, but AllocateFrame with our target size. decoder->SetSize(mSize, mOrientation); decoder->NeedNewFrame(0, 0, 0, aSize->width, aSize->height, SurfaceFormat::B8G8R8A8); - decoder->AllocateFrame(*aSize); + decoder->AllocateFrame(); } decoder->SetIterator(mSourceBuffer->Iterator());