diff --git a/Userland/Libraries/LibPDF/ColorSpace.cpp b/Userland/Libraries/LibPDF/ColorSpace.cpp index b5a14ede35..74d4a91d5e 100644 --- a/Userland/Libraries/LibPDF/ColorSpace.cpp +++ b/Userland/Libraries/LibPDF/ColorSpace.cpp @@ -499,9 +499,6 @@ ICCBasedColorSpace::ICCBasedColorSpace(NonnullRefPtr profile) PDFErrorOr ICCBasedColorSpace::style(ReadonlySpan arguments) const { - if (!s_srgb_profile) - s_srgb_profile = TRY(Gfx::ICC::sRGB()); - Vector bytes; for (size_t i = 0; i < arguments.size(); ++i) { auto const& arg = arguments[i]; @@ -522,7 +519,7 @@ PDFErrorOr ICCBasedColorSpace::style(ReadonlySpan arguments auto pcs = TRY(m_profile->to_pcs(bytes)); Array output; - TRY(s_srgb_profile->from_pcs(m_profile, pcs, output.span())); + TRY(sRGB()->from_pcs(m_profile, pcs, output.span())); return Color(output[0], output[1], output[2]); } @@ -553,6 +550,13 @@ Vector ICCBasedColorSpace::default_decode() const } } +NonnullRefPtr ICCBasedColorSpace::sRGB() +{ + if (!s_srgb_profile) + s_srgb_profile = MUST(Gfx::ICC::sRGB()); + return *s_srgb_profile; +} + PDFErrorOr> LabColorSpace::create(Document* document, Vector&& parameters) { if (parameters.size() != 1) diff --git a/Userland/Libraries/LibPDF/ColorSpace.h b/Userland/Libraries/LibPDF/ColorSpace.h index 81296e40b3..70beac13a8 100644 --- a/Userland/Libraries/LibPDF/ColorSpace.h +++ b/Userland/Libraries/LibPDF/ColorSpace.h @@ -188,6 +188,8 @@ public: Vector default_decode() const override; ColorSpaceFamily const& family() const override { return ColorSpaceFamily::ICCBased; } + static NonnullRefPtr sRGB(); + private: ICCBasedColorSpace(NonnullRefPtr);