mirror of
https://github.com/fergalmoran/ladybird.git
synced 2025-12-22 09:19:03 +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:
committed by
Sam Atkins
parent
f6ce06d56b
commit
f3ff9c26bc
@@ -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");
|
||||
|
||||
Reference in New Issue
Block a user