From 1d1e7abba791af0fd83e627195fe8d13e80907cc Mon Sep 17 00:00:00 2001 From: Lucas CHOLLET Date: Sun, 12 Nov 2023 18:19:19 -0500 Subject: [PATCH] LibGfx/TIFF: Put the `TIFFLoadingContext` class in a TIFF namespace --- .../Libraries/LibGfx/ImageFormats/TIFFLoader.cpp | 14 +++++++++----- .../Libraries/LibGfx/ImageFormats/TIFFLoader.h | 4 +++- 2 files changed, 12 insertions(+), 6 deletions(-) diff --git a/Userland/Libraries/LibGfx/ImageFormats/TIFFLoader.cpp b/Userland/Libraries/LibGfx/ImageFormats/TIFFLoader.cpp index f3271d6b70..c77c41ffbf 100644 --- a/Userland/Libraries/LibGfx/ImageFormats/TIFFLoader.cpp +++ b/Userland/Libraries/LibGfx/ImageFormats/TIFFLoader.cpp @@ -12,6 +12,8 @@ namespace Gfx { +namespace TIFF { + class TIFFLoadingContext { public: enum class State { @@ -630,9 +632,11 @@ private: Metadata m_metadata {}; }; +} + TIFFImageDecoderPlugin::TIFFImageDecoderPlugin(NonnullOwnPtr stream) { - m_context = make(move(stream)); + m_context = make(move(stream)); } bool TIFFImageDecoderPlugin::sniff(ReadonlyBytes bytes) @@ -662,10 +666,10 @@ ErrorOr TIFFImageDecoderPlugin::frame(size_t index, Option if (index > 0) return Error::from_string_literal("TIFFImageDecoderPlugin: Invalid frame index"); - if (m_context->state() == TIFFLoadingContext::State::Error) + if (m_context->state() == TIFF::TIFFLoadingContext::State::Error) return Error::from_string_literal("TIFFImageDecoderPlugin: Decoding failed"); - if (m_context->state() < TIFFLoadingContext::State::FrameDecoded) + if (m_context->state() < TIFF::TIFFLoadingContext::State::FrameDecoded) TRY(m_context->decode_frame()); return ImageFrameDescriptor { m_context->bitmap(), 0 }; @@ -673,8 +677,8 @@ ErrorOr TIFFImageDecoderPlugin::frame(size_t index, Option } template -struct AK::Formatter> : Formatter { - ErrorOr format(FormatBuilder& builder, Gfx::TIFFLoadingContext::Rational value) +struct AK::Formatter> : Formatter { + ErrorOr format(FormatBuilder& builder, Gfx::TIFF::TIFFLoadingContext::Rational value) { return Formatter::format(builder, "{} ({}/{})"sv, static_cast(value.numerator) / value.denominator, value.numerator, value.denominator); } diff --git a/Userland/Libraries/LibGfx/ImageFormats/TIFFLoader.h b/Userland/Libraries/LibGfx/ImageFormats/TIFFLoader.h index 809cc50a03..72cc0ce2ae 100644 --- a/Userland/Libraries/LibGfx/ImageFormats/TIFFLoader.h +++ b/Userland/Libraries/LibGfx/ImageFormats/TIFFLoader.h @@ -13,7 +13,9 @@ namespace Gfx { // https://www.itu.int/itudoc/itu-t/com16/tiff-fx/docs/tiff6.pdf +namespace TIFF { class TIFFLoadingContext; +} class TIFFImageDecoderPlugin : public ImageDecoderPlugin { public: @@ -29,7 +31,7 @@ public: private: TIFFImageDecoderPlugin(NonnullOwnPtr); - OwnPtr m_context; + OwnPtr m_context; }; }