mirror of
https://gitlab.winehq.org/wine/wine-gecko.git
synced 2024-09-13 09:24:08 -07:00
Bug 716140 - Set the size of images via ImageMetadata objects. r=seth
* * * imported patch jpeg-size-decode-more-writing --HG-- extra : rebase_source : 34f28c95b7164c35678f9e61faa3a8497da25893
This commit is contained in:
parent
39b180a45f
commit
5b5ff16d15
@ -213,6 +213,11 @@ nsICODecoder::WriteInternal(const char* aBuffer, uint32_t aCount)
|
||||
{
|
||||
NS_ABORT_IF_FALSE(!HasError(), "Shouldn't call WriteInternal after error!");
|
||||
|
||||
if (IsSizeDecode() && HasSize()) {
|
||||
// More data came in since we found the size. We have nothing to do here.
|
||||
return;
|
||||
}
|
||||
|
||||
if (!aCount) // aCount=0 means EOF
|
||||
return;
|
||||
|
||||
@ -329,6 +334,12 @@ nsICODecoder::WriteInternal(const char* aBuffer, uint32_t aCount)
|
||||
if (!WriteToContainedDecoder(aBuffer, aCount)) {
|
||||
return;
|
||||
}
|
||||
|
||||
if (mContainedDecoder->HasSize()) {
|
||||
PostSize(mContainedDecoder->GetImageMetadata().GetWidth(),
|
||||
mContainedDecoder->GetImageMetadata().GetHeight());
|
||||
}
|
||||
|
||||
mPos += aCount;
|
||||
aBuffer += aCount;
|
||||
aCount = 0;
|
||||
@ -423,6 +434,9 @@ nsICODecoder::WriteInternal(const char* aBuffer, uint32_t aCount)
|
||||
return;
|
||||
}
|
||||
|
||||
PostSize(mContainedDecoder->GetImageMetadata().GetWidth(),
|
||||
mContainedDecoder->GetImageMetadata().GetHeight());
|
||||
|
||||
// We have the size. If we're doing a size decode, we got what
|
||||
// we came for.
|
||||
if (IsSizeDecode())
|
||||
|
@ -194,6 +194,11 @@ nsJPEGDecoder::WriteInternal(const char *aBuffer, uint32_t aCount)
|
||||
|
||||
NS_ABORT_IF_FALSE(!HasError(), "Shouldn't call WriteInternal after error!");
|
||||
|
||||
if (IsSizeDecode() && HasSize()) {
|
||||
// More data came in since we found the size. We have nothing to do here.
|
||||
return;
|
||||
}
|
||||
|
||||
/* Return here if there is a fatal error within libjpeg. */
|
||||
nsresult error_code;
|
||||
// This cast to nsresult makes sense because setjmp() returns whatever we
|
||||
|
@ -237,15 +237,12 @@ Decoder::FlushInvalidations()
|
||||
// Bug 703231
|
||||
// Because of high quality down sampling on mac we show scan lines while decoding.
|
||||
// Bypass this problem by redrawing the border.
|
||||
int32_t width;
|
||||
int32_t height;
|
||||
if (mImageMetadata.HasSize()) {
|
||||
nsIntRect mImageBound(0, 0, mImageMetadata.GetWidth(), mImageMetadata.GetHeight());
|
||||
|
||||
mImage.GetWidth(&width);
|
||||
mImage.GetHeight(&height);
|
||||
nsIntRect mImageBound(0, 0, width, height);
|
||||
|
||||
mInvalidRect.Inflate(1);
|
||||
mInvalidRect = mInvalidRect.Intersect(mImageBound);
|
||||
mInvalidRect.Inflate(1);
|
||||
mInvalidRect = mInvalidRect.Intersect(mImageBound);
|
||||
}
|
||||
#endif
|
||||
mObserver->FrameChanged(&mInvalidRect);
|
||||
}
|
||||
@ -254,6 +251,12 @@ Decoder::FlushInvalidations()
|
||||
mInvalidRect.SetEmpty();
|
||||
}
|
||||
|
||||
void
|
||||
Decoder::SetSizeOnImage()
|
||||
{
|
||||
mImage.SetSize(mImageMetadata.GetWidth(), mImageMetadata.GetHeight());
|
||||
}
|
||||
|
||||
/*
|
||||
* Hook stubs. Override these as necessary in decoder implementations.
|
||||
*/
|
||||
@ -274,7 +277,7 @@ Decoder::PostSize(int32_t aWidth, int32_t aHeight)
|
||||
NS_ABORT_IF_FALSE(aHeight >= 0, "Height can't be negative!");
|
||||
|
||||
// Tell the image
|
||||
mImage.SetSize(aWidth, aHeight);
|
||||
mImageMetadata.SetSize(aWidth, aHeight);
|
||||
|
||||
// Notify the observer
|
||||
if (mObserver)
|
||||
|
@ -131,6 +131,9 @@ public:
|
||||
void SetDecodeFlags(uint32_t aFlags) { mDecodeFlags = aFlags; }
|
||||
uint32_t GetDecodeFlags() { return mDecodeFlags; }
|
||||
|
||||
bool HasSize() const { return mImageMetadata.HasSize(); }
|
||||
void SetSizeOnImage();
|
||||
|
||||
// Use HistogramCount as an invalid Histogram ID
|
||||
virtual Telemetry::ID SpeedHistogram() { return Telemetry::HistogramCount; }
|
||||
|
||||
|
@ -5,6 +5,8 @@
|
||||
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */
|
||||
|
||||
#include "mozilla/StandardInteger.h"
|
||||
#include "mozilla/Util.h"
|
||||
#include "nsSize.h"
|
||||
|
||||
namespace mozilla {
|
||||
namespace image {
|
||||
@ -40,6 +42,16 @@ public:
|
||||
mIsNonPremultiplied = nonPremult;
|
||||
}
|
||||
|
||||
void SetSize(int32_t width, int32_t height)
|
||||
{
|
||||
mSize.construct(nsIntSize(width, height));
|
||||
}
|
||||
|
||||
bool HasSize() const { return !mSize.empty(); }
|
||||
|
||||
int32_t GetWidth() const { return mSize.ref().width; }
|
||||
int32_t GetHeight() const { return mSize.ref().height; }
|
||||
|
||||
private:
|
||||
// The hotspot found on cursors, or -1 if none was found.
|
||||
int32_t mHotspotX;
|
||||
@ -48,6 +60,8 @@ private:
|
||||
// The loop count for animated images, or -1 for infinite loop.
|
||||
int32_t mLoopCount;
|
||||
|
||||
Maybe<nsIntSize> mSize;
|
||||
|
||||
bool mIsNonPremultiplied;
|
||||
};
|
||||
|
||||
|
@ -3216,7 +3216,6 @@ RasterImage::DecodeSomeData(uint32_t aMaxBytes)
|
||||
if (mBytesDecoded == mSourceData.Length())
|
||||
return NS_OK;
|
||||
|
||||
|
||||
// write the proper amount of data
|
||||
uint32_t bytesToDecode = std::min(aMaxBytes,
|
||||
mSourceData.Length() - mBytesDecoded);
|
||||
@ -3362,6 +3361,10 @@ RasterImage::FinishedSomeDecoding(eShutdownIntent aIntent /* = eShutdownIntent_D
|
||||
Telemetry::Accumulate(Telemetry::IMAGE_DECODE_CHUNKS, request->mChunkCount);
|
||||
}
|
||||
|
||||
if (!image->mHasSize && image->mDecoder->HasSize()) {
|
||||
image->mDecoder->SetSizeOnImage();
|
||||
}
|
||||
|
||||
// If the decode finished, or we're specifically being told to shut down,
|
||||
// tell the image and shut down the decoder.
|
||||
if (image->mDecoder->GetDecodeDone() || image->IsDecodeFinished() ||
|
||||
|
Loading…
Reference in New Issue
Block a user