Bug 1187386 (Part 5) - Merge Decoder::SetSizeOnImage() into ImageMetadata::SetOnImage(). r=tn

This commit is contained in:
Seth Fowler 2015-07-31 07:29:12 -07:00
parent 1b0b4a7c6a
commit ace4842b4f
4 changed files with 18 additions and 27 deletions

View File

@ -274,12 +274,9 @@ Decoder::Finish()
}
}
// Set image metadata before calling DecodingComplete, because
// DecodingComplete calls Optimize().
mImageMetadata.SetOnImage(mImage);
if (HasSize()) {
SetSizeOnImage();
nsresult rv = mImageMetadata.SetOnImage(mImage);
if (NS_FAILED(rv)) {
PostResizeError();
}
if (mDecodeDone && !IsMetadataDecode()) {
@ -409,20 +406,6 @@ Decoder::AllocateFrameInternal(uint32_t aFrameNum,
return ref;
}
void
Decoder::SetSizeOnImage()
{
MOZ_ASSERT(mImageMetadata.HasSize(), "Should have size");
MOZ_ASSERT(mImageMetadata.HasOrientation(), "Should have orientation");
nsresult rv = mImage->SetSize(mImageMetadata.GetWidth(),
mImageMetadata.GetHeight(),
mImageMetadata.GetOrientation());
if (NS_FAILED(rv)) {
PostResizeError();
}
}
/*
* Hook stubs. Override these as necessary in decoder implementations.
*/

View File

@ -253,7 +253,6 @@ public:
uint32_t GetDecodeFlags() const { return DecodeFlags(mFlags); }
bool HasSize() const { return mImageMetadata.HasSize(); }
void SetSizeOnImage();
nsIntSize GetSize() const
{

View File

@ -14,9 +14,11 @@
namespace mozilla {
namespace image {
void
ImageMetadata::SetOnImage(RasterImage* image)
nsresult
ImageMetadata::SetOnImage(RasterImage* aImage)
{
nsresult rv = NS_OK;
if (mHotspotX != -1 && mHotspotY != -1) {
nsCOMPtr<nsISupportsPRUint32> intwrapx =
do_CreateInstance(NS_SUPPORTS_PRUINT32_CONTRACTID);
@ -24,11 +26,18 @@ ImageMetadata::SetOnImage(RasterImage* image)
do_CreateInstance(NS_SUPPORTS_PRUINT32_CONTRACTID);
intwrapx->SetData(mHotspotX);
intwrapy->SetData(mHotspotY);
image->Set("hotspotX", intwrapx);
image->Set("hotspotY", intwrapy);
aImage->Set("hotspotX", intwrapx);
aImage->Set("hotspotY", intwrapy);
}
image->SetLoopCount(mLoopCount);
aImage->SetLoopCount(mLoopCount);
if (HasSize()) {
MOZ_ASSERT(HasOrientation(), "Should have orientation");
rv = aImage->SetSize(GetWidth(), GetHeight(), GetOrientation());
}
return rv;
}
} // namespace image

View File

@ -28,7 +28,7 @@ public:
{ }
// Set the metadata this object represents on an image.
void SetOnImage(RasterImage* image);
nsresult SetOnImage(RasterImage* aImage);
void SetHotspot(uint16_t hotspotx, uint16_t hotspoty)
{