Bug 1285867 (Part 3e) - Use TerminalState to exit the Decode() loop. r=edwin

This commit is contained in:
Seth Fowler 2016-07-11 23:19:58 -07:00
Родитель 87c5e4a570
Коммит 0d49568090
4 изменённых файлов: 19 добавлений и 27 удалений

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

@ -164,10 +164,6 @@ Decoder::Decode(NotNull<IResumable*> aOnResume)
// Pass the data along to the implementation.
terminalState = DoDecode(*mIterator);
if (terminalState == Some(TerminalState::FAILURE)) {
PostDataError();
}
break;
}
@ -175,7 +171,12 @@ Decoder::Decode(NotNull<IResumable*> aOnResume)
MOZ_ASSERT_UNREACHABLE("Unknown SourceBufferIterator state");
terminalState = Some(TerminalState::FAILURE);
}
} while (!GetDecodeDone() && !HasError());
} while (!GetDecodeDone() && !terminalState);
// If decoding failed, record that fact.
if (terminalState == Some(TerminalState::FAILURE)) {
PostDataError();
}
CompleteDecode();
return HasError() ? NS_ERROR_FAILURE : NS_OK;

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

@ -262,12 +262,19 @@ nsBMPDecoder::FinishInternal()
nsIntRect r(0, 0, mH.mWidth, AbsoluteHeight());
PostInvalidation(r);
if (mDoesHaveTransparency) {
MOZ_ASSERT(mMayHaveTransparency);
PostFrameStop(Opacity::SOME_TRANSPARENCY);
} else {
PostFrameStop(Opacity::FULLY_OPAQUE);
}
MOZ_ASSERT_IF(mDoesHaveTransparency, mMayHaveTransparency);
// We have transparency if we either detected some in the image itself
// (i.e., |mDoesHaveTransparency| is true) or we're in an ICO, which could
// mean we have an AND mask that provides transparency (i.e., |mIsWithinICO|
// is true).
// XXX(seth): We can tell when we create the decoder if the AND mask is
// present, so we could be more precise about this.
const Opacity opacity = mDoesHaveTransparency || mIsWithinICO
? Opacity::SOME_TRANSPARENCY
: Opacity::FULLY_OPAQUE;
PostFrameStop(opacity);
PostDecodeDone();
}

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

@ -142,13 +142,6 @@ public:
/// bitmap has been fully decoded.)
bool HasTransparency() const { return mDoesHaveTransparency; }
/// Force transparency from outside. (Used by the ICO decoder.)
void SetHasTransparency()
{
mMayHaveTransparency = true;
mDoesHaveTransparency = true;
}
Maybe<TerminalState> DoDecode(SourceBufferIterator& aIterator) override;
nsresult BeforeFinishInternal() override;
nsresult FinishInternal() override;

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

@ -573,15 +573,6 @@ nsICODecoder::FinishMask()
}
}
// If the mask contained any transparent pixels, record that fact.
if (mHasMaskAlpha) {
PostHasTransparency();
RefPtr<nsBMPDecoder> bmpDecoder =
static_cast<nsBMPDecoder*>(mContainedDecoder.get());
bmpDecoder->SetHasTransparency();
}
return Transition::To(ICOState::FINISHED_RESOURCE, 0);
}