Bug 1320684 - Start metadata decoding when the first data chunk has been received. r=tnikkel
This commit is contained in:
@@ -84,7 +84,8 @@ RasterImage::RasterImage(ImageURL* aURI /* = nullptr */) :
|
|||||||
mTransient(false),
|
mTransient(false),
|
||||||
mSyncLoad(false),
|
mSyncLoad(false),
|
||||||
mDiscardable(false),
|
mDiscardable(false),
|
||||||
mHasSourceData(false),
|
mSomeSourceData(false),
|
||||||
|
mAllSourceData(false),
|
||||||
mHasBeenDecoded(false),
|
mHasBeenDecoded(false),
|
||||||
mPendingAnimation(false),
|
mPendingAnimation(false),
|
||||||
mAnimationFinished(false),
|
mAnimationFinished(false),
|
||||||
@@ -146,14 +147,6 @@ RasterImage::Init(const char* aMimeType,
|
|||||||
SurfaceCache::LockImage(ImageKey(this));
|
SurfaceCache::LockImage(ImageKey(this));
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!mSyncLoad) {
|
|
||||||
// Create an async metadata decoder and verify we succeed in doing so.
|
|
||||||
nsresult rv = DecodeMetadata(DECODE_FLAGS_DEFAULT);
|
|
||||||
if (NS_FAILED(rv)) {
|
|
||||||
return NS_ERROR_FAILURE;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
// Mark us as initialized
|
// Mark us as initialized
|
||||||
mInitialized = true;
|
mInitialized = true;
|
||||||
|
|
||||||
@@ -359,7 +352,7 @@ RasterImage::LookupFrame(const IntSize& aSize,
|
|||||||
// Sync decoding guarantees that we got the frame, but if it's owned by an
|
// Sync decoding guarantees that we got the frame, but if it's owned by an
|
||||||
// async decoder that's currently running, the contents of the frame may not
|
// async decoder that's currently running, the contents of the frame may not
|
||||||
// be available yet. Make sure we get everything.
|
// be available yet. Make sure we get everything.
|
||||||
if (mHasSourceData && (aFlags & FLAG_SYNC_DECODE)) {
|
if (mAllSourceData && (aFlags & FLAG_SYNC_DECODE)) {
|
||||||
result.Surface()->WaitUntilFinished();
|
result.Surface()->WaitUntilFinished();
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -874,7 +867,7 @@ RasterImage::OnImageDataComplete(nsIRequest*, nsISupports*, nsresult aStatus,
|
|||||||
MOZ_ASSERT(NS_IsMainThread());
|
MOZ_ASSERT(NS_IsMainThread());
|
||||||
|
|
||||||
// Record that we have all the data we're going to get now.
|
// Record that we have all the data we're going to get now.
|
||||||
mHasSourceData = true;
|
mAllSourceData = true;
|
||||||
|
|
||||||
// Let decoders know that there won't be any more data coming.
|
// Let decoders know that there won't be any more data coming.
|
||||||
mSourceBuffer->Complete(aStatus);
|
mSourceBuffer->Complete(aStatus);
|
||||||
@@ -946,6 +939,14 @@ RasterImage::OnImageDataAvailable(nsIRequest*,
|
|||||||
uint32_t aCount)
|
uint32_t aCount)
|
||||||
{
|
{
|
||||||
nsresult rv = mSourceBuffer->AppendFromInputStream(aInputStream, aCount);
|
nsresult rv = mSourceBuffer->AppendFromInputStream(aInputStream, aCount);
|
||||||
|
if (NS_SUCCEEDED(rv) && !mSomeSourceData) {
|
||||||
|
mSomeSourceData = true;
|
||||||
|
if (!mSyncLoad) {
|
||||||
|
// Create an async metadata decoder and verify we succeed in doing so.
|
||||||
|
rv = DecodeMetadata(DECODE_FLAGS_DEFAULT);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
if (NS_FAILED(rv)) {
|
if (NS_FAILED(rv)) {
|
||||||
DoError();
|
DoError();
|
||||||
}
|
}
|
||||||
@@ -1029,7 +1030,7 @@ RasterImage::Discard()
|
|||||||
|
|
||||||
bool
|
bool
|
||||||
RasterImage::CanDiscard() {
|
RasterImage::CanDiscard() {
|
||||||
return mHasSourceData && // ...have the source data...
|
return mAllSourceData && // ...have the source data...
|
||||||
!mAnimationState; // Can never discard animated images
|
!mAnimationState; // Can never discard animated images
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -1204,7 +1205,7 @@ RasterImage::Decode(const IntSize& aSize,
|
|||||||
mDecodeCount++;
|
mDecodeCount++;
|
||||||
|
|
||||||
// We're ready to decode; start the decoder.
|
// We're ready to decode; start the decoder.
|
||||||
return LaunchDecodingTask(task, this, aFlags, mHasSourceData);
|
return LaunchDecodingTask(task, this, aFlags, mAllSourceData);
|
||||||
}
|
}
|
||||||
|
|
||||||
NS_IMETHODIMP
|
NS_IMETHODIMP
|
||||||
@@ -1227,7 +1228,7 @@ RasterImage::DecodeMetadata(uint32_t aFlags)
|
|||||||
}
|
}
|
||||||
|
|
||||||
// We're ready to decode; start the decoder.
|
// We're ready to decode; start the decoder.
|
||||||
LaunchDecodingTask(task, this, aFlags, mHasSourceData);
|
LaunchDecodingTask(task, this, aFlags, mAllSourceData);
|
||||||
return NS_OK;
|
return NS_OK;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -323,7 +323,6 @@ private:
|
|||||||
return (mLockCount == 0 || (mAnimationState && mAnimationConsumers == 0));
|
return (mLockCount == 0 || (mAnimationState && mAnimationConsumers == 0));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
//////////////////////////////////////////////////////////////////////////////
|
//////////////////////////////////////////////////////////////////////////////
|
||||||
// Decoding.
|
// Decoding.
|
||||||
//////////////////////////////////////////////////////////////////////////////
|
//////////////////////////////////////////////////////////////////////////////
|
||||||
@@ -423,11 +422,12 @@ private: // data
|
|||||||
NotNull<RefPtr<SourceBuffer>> mSourceBuffer;
|
NotNull<RefPtr<SourceBuffer>> mSourceBuffer;
|
||||||
|
|
||||||
// Boolean flags (clustered together to conserve space):
|
// Boolean flags (clustered together to conserve space):
|
||||||
bool mHasSize:1; // Has SetSize() been called?
|
bool mHasSize:1; // Has SetSize() been called?
|
||||||
bool mTransient:1; // Is the image short-lived?
|
bool mTransient:1; // Is the image short-lived?
|
||||||
bool mSyncLoad:1; // Are we loading synchronously?
|
bool mSyncLoad:1; // Are we loading synchronously?
|
||||||
bool mDiscardable:1; // Is container discardable?
|
bool mDiscardable:1; // Is container discardable?
|
||||||
bool mHasSourceData:1; // Do we have source data?
|
bool mSomeSourceData:1; // Do we have some source data?
|
||||||
|
bool mAllSourceData:1; // Do we have all the source data?
|
||||||
bool mHasBeenDecoded:1; // Decoded at least once?
|
bool mHasBeenDecoded:1; // Decoded at least once?
|
||||||
|
|
||||||
// Whether we're waiting to start animation. If we get a StartAnimation() call
|
// Whether we're waiting to start animation. If we get a StartAnimation() call
|
||||||
|
|||||||
Reference in New Issue
Block a user