mirror of
https://github.com/RGBCube/serenity
synced 2025-07-25 19:27:44 +00:00
LibGfx/PortableFormat: Simplify the State enum
This enum used to store very precise state about the decoding process, let's simplify that by only including two steps: HeaderDecoder and BitmapDecoded.
This commit is contained in:
parent
f6ce06d56b
commit
f3ff9c26bc
5 changed files with 12 additions and 26 deletions
|
@ -30,12 +30,8 @@ struct PortableImageMapLoadingContext {
|
|||
enum class State {
|
||||
NotDecoded = 0,
|
||||
Error,
|
||||
MagicNumber,
|
||||
Width,
|
||||
Height,
|
||||
Maxval,
|
||||
Bitmap,
|
||||
Decoded
|
||||
HeaderDecoded,
|
||||
BitmapDecoded,
|
||||
};
|
||||
|
||||
Type type { Type::Unknown };
|
||||
|
@ -89,7 +85,7 @@ IntSize PortableImageDecoderPlugin<TContext>::size()
|
|||
if (m_context->state == TContext::State::Error)
|
||||
return {};
|
||||
|
||||
if (m_context->state < TContext::State::Decoded) {
|
||||
if (m_context->state < TContext::State::BitmapDecoded) {
|
||||
if (decode(*m_context).is_error()) {
|
||||
m_context->state = TContext::State::Error;
|
||||
// FIXME: We should propagate errors
|
||||
|
@ -156,7 +152,7 @@ ErrorOr<ImageFrameDescriptor> PortableImageDecoderPlugin<TContext>::frame(size_t
|
|||
if (m_context->state == TContext::State::Error)
|
||||
return Error::from_string_literal("PortableImageDecoderPlugin: Decoding failed");
|
||||
|
||||
if (m_context->state < TContext::State::Decoded) {
|
||||
if (m_context->state < TContext::State::BitmapDecoded) {
|
||||
if (decode(*m_context).is_error()) {
|
||||
m_context->state = TContext::State::Error;
|
||||
return Error::from_string_literal("PortableImageDecoderPlugin: Decoding failed");
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue