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

--HG--
extra : rebase_source : 5da2023b266e44970fd0fff7442ad8eea4939379
This commit is contained in:
Seth Fowler 2015-07-31 07:29:12 -07:00
Родитель 3fdb290471
Коммит 973fa019ef
4 изменённых файлов: 18 добавлений и 27 удалений

Просмотреть файл

@ -274,12 +274,9 @@ Decoder::Finish()
} }
} }
// Set image metadata before calling DecodingComplete, because nsresult rv = mImageMetadata.SetOnImage(mImage);
// DecodingComplete calls Optimize(). if (NS_FAILED(rv)) {
mImageMetadata.SetOnImage(mImage); PostResizeError();
if (HasSize()) {
SetSizeOnImage();
} }
if (mDecodeDone && !IsMetadataDecode()) { if (mDecodeDone && !IsMetadataDecode()) {
@ -409,20 +406,6 @@ Decoder::AllocateFrameInternal(uint32_t aFrameNum,
return ref; 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. * Hook stubs. Override these as necessary in decoder implementations.
*/ */

Просмотреть файл

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

Просмотреть файл

@ -14,9 +14,11 @@
namespace mozilla { namespace mozilla {
namespace image { namespace image {
void nsresult
ImageMetadata::SetOnImage(RasterImage* image) ImageMetadata::SetOnImage(RasterImage* aImage)
{ {
nsresult rv = NS_OK;
if (mHotspotX != -1 && mHotspotY != -1) { if (mHotspotX != -1 && mHotspotY != -1) {
nsCOMPtr<nsISupportsPRUint32> intwrapx = nsCOMPtr<nsISupportsPRUint32> intwrapx =
do_CreateInstance(NS_SUPPORTS_PRUINT32_CONTRACTID); do_CreateInstance(NS_SUPPORTS_PRUINT32_CONTRACTID);
@ -24,11 +26,18 @@ ImageMetadata::SetOnImage(RasterImage* image)
do_CreateInstance(NS_SUPPORTS_PRUINT32_CONTRACTID); do_CreateInstance(NS_SUPPORTS_PRUINT32_CONTRACTID);
intwrapx->SetData(mHotspotX); intwrapx->SetData(mHotspotX);
intwrapy->SetData(mHotspotY); intwrapy->SetData(mHotspotY);
image->Set("hotspotX", intwrapx); aImage->Set("hotspotX", intwrapx);
image->Set("hotspotY", intwrapy); 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 } // namespace image

Просмотреть файл

@ -28,7 +28,7 @@ public:
{ } { }
// Set the metadata this object represents on an image. // 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) void SetHotspot(uint16_t hotspotx, uint16_t hotspoty)
{ {