зеркало из https://github.com/mozilla/gecko-dev.git
Bug 1258741 - Part 2. Ensure we consistently render partially decoded images. r=tnikkel
This commit is contained in:
Родитель
54d6f7e0c4
Коммит
46250e2a5e
|
@ -190,33 +190,31 @@ Decoder::CompleteDecode()
|
|||
PostError();
|
||||
}
|
||||
|
||||
// If this was a metadata decode and we never got a size, the decode failed.
|
||||
if (IsMetadataDecode() && !HasSize()) {
|
||||
PostError();
|
||||
if (IsMetadataDecode()) {
|
||||
// If this was a metadata decode and we never got a size, the decode failed.
|
||||
if (!HasSize()) {
|
||||
PostError();
|
||||
}
|
||||
return;
|
||||
}
|
||||
|
||||
// If the implementation left us mid-frame, finish that up.
|
||||
if (mInFrame && !HasError()) {
|
||||
// If the implementation left us mid-frame, finish that up. Note that it may
|
||||
// have left us transparent.
|
||||
if (mInFrame) {
|
||||
PostHasTransparency();
|
||||
PostFrameStop();
|
||||
}
|
||||
|
||||
// If PostDecodeDone() has not been called, we need to send teardown
|
||||
// notifications (and report an error to the console later).
|
||||
if (!mDecodeDone && !IsMetadataDecode()) {
|
||||
// If PostDecodeDone() has not been called, we may need to send teardown
|
||||
// notifications if it is unrecoverable.
|
||||
if (!mDecodeDone) {
|
||||
// We should always report an error to the console in this case.
|
||||
mShouldReportError = true;
|
||||
|
||||
// Even if we encountered an error, we're still usable if we have at least
|
||||
// one complete frame.
|
||||
if (GetCompleteFrameCount() > 0) {
|
||||
// We're usable, so do exactly what we should have when the decoder
|
||||
// completed.
|
||||
|
||||
// Not writing to the entire frame may have left us transparent.
|
||||
// We're usable if we have at least one complete frame, so do exactly
|
||||
// what we should have when the decoder completed.
|
||||
PostHasTransparency();
|
||||
|
||||
if (mInFrame) {
|
||||
PostFrameStop();
|
||||
}
|
||||
PostDecodeDone();
|
||||
} else {
|
||||
// We're not usable. Record some final progress indicating the error.
|
||||
|
@ -224,7 +222,7 @@ Decoder::CompleteDecode()
|
|||
}
|
||||
}
|
||||
|
||||
if (mDecodeDone && !IsMetadataDecode()) {
|
||||
if (mDecodeDone) {
|
||||
MOZ_ASSERT(HasError() || mCurrentFrame, "Should have an error or a frame");
|
||||
|
||||
// If this image wasn't animated and isn't a transient image, mark its frame
|
||||
|
@ -510,8 +508,12 @@ Decoder::PostError()
|
|||
{
|
||||
mError = true;
|
||||
|
||||
if (mInFrame && mCurrentFrame) {
|
||||
if (mInFrame) {
|
||||
MOZ_ASSERT(mCurrentFrame);
|
||||
MOZ_ASSERT(mFrameCount > 0);
|
||||
mCurrentFrame->Abort();
|
||||
mInFrame = false;
|
||||
--mFrameCount;
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -1617,13 +1617,13 @@ RasterImage::NotifyDecodeComplete(const DecoderFinalStatus& aStatus,
|
|||
mAnimationState->SetDoneDecoding(true);
|
||||
}
|
||||
|
||||
if (!aStatus.mWasMetadataDecode && aTelemetry.mChunkCount) {
|
||||
Telemetry::Accumulate(Telemetry::IMAGE_DECODE_CHUNKS, aTelemetry.mChunkCount);
|
||||
}
|
||||
// Do some telemetry if this isn't a metadata decode.
|
||||
if (!aStatus.mWasMetadataDecode) {
|
||||
if (aTelemetry.mChunkCount) {
|
||||
Telemetry::Accumulate(Telemetry::IMAGE_DECODE_CHUNKS, aTelemetry.mChunkCount);
|
||||
}
|
||||
|
||||
if (aStatus.mFinished) {
|
||||
// Do some telemetry if this isn't a metadata decode.
|
||||
if (!aStatus.mWasMetadataDecode) {
|
||||
if (aStatus.mFinished) {
|
||||
Telemetry::Accumulate(Telemetry::IMAGE_DECODE_TIME,
|
||||
int32_t(aTelemetry.mDecodeTime.ToMicroseconds()));
|
||||
|
||||
|
@ -1631,26 +1631,30 @@ RasterImage::NotifyDecodeComplete(const DecoderFinalStatus& aStatus,
|
|||
Telemetry::Accumulate(*aTelemetry.mSpeedHistogram, aTelemetry.Speed());
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// Detect errors.
|
||||
if (aStatus.mHadError) {
|
||||
DoError();
|
||||
} else if (aStatus.mWasMetadataDecode && !mHasSize) {
|
||||
DoError();
|
||||
}
|
||||
// Only act on errors if we have no usable frames from the decoder.
|
||||
if (aStatus.mHadError &&
|
||||
(!mAnimationState || mAnimationState->KnownFrameCount() == 0)) {
|
||||
DoError();
|
||||
} else if (aStatus.mWasMetadataDecode && !mHasSize) {
|
||||
DoError();
|
||||
}
|
||||
|
||||
// XXX(aosmond): Can we get this far without mFinished == true?
|
||||
if (aStatus.mFinished && aStatus.mWasMetadataDecode) {
|
||||
// If we were waiting to fire the load event, go ahead and fire it now.
|
||||
if (mLoadProgress && aStatus.mWasMetadataDecode) {
|
||||
if (mLoadProgress) {
|
||||
NotifyForLoadEvent(*mLoadProgress);
|
||||
mLoadProgress = Nothing();
|
||||
NotifyProgress(FLAG_ONLOAD_UNBLOCKED);
|
||||
}
|
||||
}
|
||||
|
||||
// If we were a metadata decode and a full decode was requested, do it.
|
||||
if (aStatus.mFinished && aStatus.mWasMetadataDecode && mWantFullDecode) {
|
||||
mWantFullDecode = false;
|
||||
RequestDecodeForSize(mSize, DECODE_FLAGS_DEFAULT);
|
||||
// If we were a metadata decode and a full decode was requested, do it.
|
||||
if (mWantFullDecode) {
|
||||
mWantFullDecode = false;
|
||||
RequestDecodeForSize(mSize, DECODE_FLAGS_DEFAULT);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
|
Загрузка…
Ссылка в новой задаче