From 376b1a2309d89265ab5a9eabc44b78c9b76133ae Mon Sep 17 00:00:00 2001 From: Nico Weber Date: Wed, 20 Mar 2024 19:00:07 -0400 Subject: [PATCH] LibGfx/JBIG2: Have just one CombinationOperator enum class We already had two, and we would need another one for text segments. No behavior change. --- .../LibGfx/ImageFormats/JBIG2Loader.cpp | 21 +++++++------------ 1 file changed, 8 insertions(+), 13 deletions(-) diff --git a/Userland/Libraries/LibGfx/ImageFormats/JBIG2Loader.cpp b/Userland/Libraries/LibGfx/ImageFormats/JBIG2Loader.cpp index c6e5e614d29..180c5a9abae 100644 --- a/Userland/Libraries/LibGfx/ImageFormats/JBIG2Loader.cpp +++ b/Userland/Libraries/LibGfx/ImageFormats/JBIG2Loader.cpp @@ -440,11 +440,15 @@ enum class CombinationOperator { And = 1, Xor = 2, XNor = 3, + Replace = 4, }; struct Page { IntSize size; + + // This is never CombinationOperator::Replace for Pages. CombinationOperator default_combination_operator { CombinationOperator::Or }; + OwnPtr bits; }; @@ -656,15 +660,6 @@ struct [[gnu::packed]] RegionSegmentInformationField { BigEndian y_location; u8 flags; - // FIXME: Or have just ::CombinationOperator represent both page and segment operators? - enum class CombinationOperator { - Or = 0, - And = 1, - Xor = 2, - XNor = 3, - Replace = 4, - }; - CombinationOperator external_combination_operator() const { VERIFY((flags & 0x7) <= 4); @@ -690,7 +685,7 @@ static ErrorOr decode_region_segment_information_ return Error::from_string_literal("JBIG2ImageDecoderPlugin: Invalid region segment information field operator"); // NOTE 3 – If the colour extension flag (COLEXTFLAG) is equal to 1, the external combination operator must be REPLACE. - if (result.is_color_bitmap() && result.external_combination_operator() != RegionSegmentInformationField::CombinationOperator::Replace) + if (result.is_color_bitmap() && result.external_combination_operator() != CombinationOperator::Replace) return Error::from_string_literal("JBIG2ImageDecoderPlugin: Invalid colored region segment information field operator"); return result; @@ -996,9 +991,9 @@ static ErrorOr decode_immediate_generic_region(JBIG2LoadingContext& contex || information_field.y_location + information_field.height > (u32)context.page.size.height()) { return Error::from_string_literal("JBIG2ImageDecoderPlugin: Region bounds outsize of page bounds"); } - if (information_field.external_combination_operator() != RegionSegmentInformationField::CombinationOperator::Or - && information_field.external_combination_operator() != RegionSegmentInformationField::CombinationOperator::Xor - && information_field.external_combination_operator() != RegionSegmentInformationField::CombinationOperator::Replace) + if (information_field.external_combination_operator() != CombinationOperator::Or + && information_field.external_combination_operator() != CombinationOperator::Xor + && information_field.external_combination_operator() != CombinationOperator::Replace) return Error::from_string_literal("JBIG2ImageDecoderPlugin: Cannot handle external combination operator other than OR, XOR, and REPLACE yet"); for (size_t y = 0; y < information_field.height; ++y) {