diff --git a/Userland/Libraries/LibPDF/ColorSpace.cpp b/Userland/Libraries/LibPDF/ColorSpace.cpp index b4a46f54267..0afb4230cfe 100644 --- a/Userland/Libraries/LibPDF/ColorSpace.cpp +++ b/Userland/Libraries/LibPDF/ColorSpace.cpp @@ -78,7 +78,7 @@ NonnullRefPtr DeviceGrayColorSpace::the() return instance; } -PDFErrorOr DeviceGrayColorSpace::color(Vector const& arguments) const +PDFErrorOr DeviceGrayColorSpace::color(ReadonlySpan arguments) const { VERIFY(arguments.size() == 1); auto gray = static_cast(arguments[0].to_float() * 255.0f); @@ -96,7 +96,7 @@ NonnullRefPtr DeviceRGBColorSpace::the() return instance; } -PDFErrorOr DeviceRGBColorSpace::color(Vector const& arguments) const +PDFErrorOr DeviceRGBColorSpace::color(ReadonlySpan arguments) const { VERIFY(arguments.size() == 3); auto r = static_cast(arguments[0].to_float() * 255.0f); @@ -116,7 +116,7 @@ NonnullRefPtr DeviceCMYKColorSpace::the() return instance; } -PDFErrorOr DeviceCMYKColorSpace::color(Vector const& arguments) const +PDFErrorOr DeviceCMYKColorSpace::color(ReadonlySpan arguments) const { VERIFY(arguments.size() == 4); auto c = arguments[0].to_float(); @@ -274,7 +274,7 @@ constexpr Array convert_to_srgb(Array xyz) return matrix_multiply(conversion_matrix, xyz); } -PDFErrorOr CalRGBColorSpace::color(Vector const& arguments) const +PDFErrorOr CalRGBColorSpace::color(ReadonlySpan arguments) const { VERIFY(arguments.size() == 3); auto a = clamp(arguments[0].to_float(), 0.0f, 1.0f); @@ -338,7 +338,7 @@ ICCBasedColorSpace::ICCBasedColorSpace(NonnullRefPtr profile) { } -PDFErrorOr ICCBasedColorSpace::color(Vector const& arguments) const +PDFErrorOr ICCBasedColorSpace::color(ReadonlySpan arguments) const { if (!s_srgb_profile) s_srgb_profile = TRY(Gfx::ICC::sRGB()); @@ -389,7 +389,7 @@ PDFErrorOr> SeparationColorSpace::create(Doc return color_space; } -PDFErrorOr SeparationColorSpace::color(Vector const&) const +PDFErrorOr SeparationColorSpace::color(ReadonlySpan) const { return Error::rendering_unsupported_error("Separation color spaces not yet implemented"); } diff --git a/Userland/Libraries/LibPDF/ColorSpace.h b/Userland/Libraries/LibPDF/ColorSpace.h index ae4fba0231c..81f6631ec26 100644 --- a/Userland/Libraries/LibPDF/ColorSpace.h +++ b/Userland/Libraries/LibPDF/ColorSpace.h @@ -55,7 +55,7 @@ public: virtual ~ColorSpace() = default; - virtual PDFErrorOr color(Vector const& arguments) const = 0; + virtual PDFErrorOr color(ReadonlySpan arguments) const = 0; virtual int number_of_components() const = 0; virtual Vector default_decode() const = 0; virtual ColorSpaceFamily const& family() const = 0; @@ -67,7 +67,7 @@ public: ~DeviceGrayColorSpace() override = default; - PDFErrorOr color(Vector const& arguments) const override; + PDFErrorOr color(ReadonlySpan arguments) const override; int number_of_components() const override { return 1; } Vector default_decode() const override; ColorSpaceFamily const& family() const override { return ColorSpaceFamily::DeviceGray; } @@ -82,7 +82,7 @@ public: ~DeviceRGBColorSpace() override = default; - PDFErrorOr color(Vector const& arguments) const override; + PDFErrorOr color(ReadonlySpan arguments) const override; int number_of_components() const override { return 3; } Vector default_decode() const override; ColorSpaceFamily const& family() const override { return ColorSpaceFamily::DeviceRGB; } @@ -97,7 +97,7 @@ public: ~DeviceCMYKColorSpace() override = default; - PDFErrorOr color(Vector const& arguments) const override; + PDFErrorOr color(ReadonlySpan arguments) const override; int number_of_components() const override { return 4; } Vector default_decode() const override; ColorSpaceFamily const& family() const override { return ColorSpaceFamily::DeviceCMYK; } @@ -112,7 +112,7 @@ public: ~CalRGBColorSpace() override = default; - PDFErrorOr color(Vector const& arguments) const override; + PDFErrorOr color(ReadonlySpan arguments) const override; int number_of_components() const override { return 3; } Vector default_decode() const override; ColorSpaceFamily const& family() const override { return ColorSpaceFamily::CalRGB; } @@ -132,7 +132,7 @@ public: ~ICCBasedColorSpace() override = default; - PDFErrorOr color(Vector const& arguments) const override; + PDFErrorOr color(ReadonlySpan arguments) const override; int number_of_components() const override; Vector default_decode() const override; ColorSpaceFamily const& family() const override { return ColorSpaceFamily::ICCBased; } @@ -150,7 +150,7 @@ public: ~SeparationColorSpace() override = default; - PDFErrorOr color(Vector const& arguments) const override; + PDFErrorOr color(ReadonlySpan arguments) const override; int number_of_components() const override { TODO(); } Vector default_decode() const override; ColorSpaceFamily const& family() const override { return ColorSpaceFamily::Separation; } diff --git a/Userland/Libraries/LibPDF/Renderer.cpp b/Userland/Libraries/LibPDF/Renderer.cpp index df310f61c2c..896f060d4fa 100644 --- a/Userland/Libraries/LibPDF/Renderer.cpp +++ b/Userland/Libraries/LibPDF/Renderer.cpp @@ -11,7 +11,7 @@ #include #define RENDERER_HANDLER(name) \ - PDFErrorOr Renderer::handle_##name([[maybe_unused]] Vector const& args, [[maybe_unused]] Optional> extra_resources) + PDFErrorOr Renderer::handle_##name([[maybe_unused]] ReadonlySpan args, [[maybe_unused]] Optional> extra_resources) #define RENDERER_TODO(name) \ RENDERER_HANDLER(name) \ @@ -489,7 +489,7 @@ RENDERER_HANDLER(text_set_matrix_and_line_matrix) RENDERER_HANDLER(text_next_line) { - TRY(handle_text_next_line_offset({ 0.0f, -text_state().leading })); + TRY(handle_text_next_line_offset(Array { 0.0f, -text_state().leading })); return {}; } @@ -742,16 +742,16 @@ PDFErrorOr Renderer::set_graphics_state_from_dict(NonnullRefPtrcontains(CommonNames::LW)) - TRY(handle_set_line_width({ dict->get_value(CommonNames::LW) })); + TRY(handle_set_line_width(Array { dict->get_value(CommonNames::LW) })); if (dict->contains(CommonNames::LC)) - TRY(handle_set_line_cap({ dict->get_value(CommonNames::LC) })); + TRY(handle_set_line_cap(Array { dict->get_value(CommonNames::LC) })); if (dict->contains(CommonNames::LJ)) - TRY(handle_set_line_join({ dict->get_value(CommonNames::LJ) })); + TRY(handle_set_line_join(Array { dict->get_value(CommonNames::LJ) })); if (dict->contains(CommonNames::ML)) - TRY(handle_set_miter_limit({ dict->get_value(CommonNames::ML) })); + TRY(handle_set_miter_limit(Array { dict->get_value(CommonNames::ML) })); if (dict->contains(CommonNames::D)) { auto array = MUST(dict->get_array(m_document, CommonNames::D)); @@ -759,7 +759,7 @@ PDFErrorOr Renderer::set_graphics_state_from_dict(NonnullRefPtrcontains(CommonNames::RI)) - TRY(handle_set_color_rendering_intent({ dict->get_value(CommonNames::RI) })); + TRY(handle_set_color_rendering_intent(Array { dict->get_value(CommonNames::RI) })); // FIXME: OP // FIXME: op @@ -774,7 +774,7 @@ PDFErrorOr Renderer::set_graphics_state_from_dict(NonnullRefPtrcontains(CommonNames::FL)) - TRY(handle_set_flatness_tolerance({ dict->get_value(CommonNames::FL) })); + TRY(handle_set_flatness_tolerance(Array { dict->get_value(CommonNames::FL) })); // FIXME: SM // FIXME: SA diff --git a/Userland/Libraries/LibPDF/Renderer.h b/Userland/Libraries/LibPDF/Renderer.h index dd7c8890845..201802af0cf 100644 --- a/Userland/Libraries/LibPDF/Renderer.h +++ b/Userland/Libraries/LibPDF/Renderer.h @@ -114,11 +114,11 @@ private: PDFErrorOr handle_operator(Operator const&, Optional> = {}); #define V(name, snake_name, symbol) \ - PDFErrorOr handle_##snake_name(Vector const& args, Optional> = {}); + PDFErrorOr handle_##snake_name(ReadonlySpan args, Optional> = {}); ENUMERATE_OPERATORS(V) #undef V - PDFErrorOr handle_text_next_line_show_string(Vector const& args, Optional> = {}); - PDFErrorOr handle_text_next_line_show_string_set_spacing(Vector const& args, Optional> = {}); + PDFErrorOr handle_text_next_line_show_string(ReadonlySpan args, Optional> = {}); + PDFErrorOr handle_text_next_line_show_string_set_spacing(ReadonlySpan args, Optional> = {}); void begin_path_paint(); void end_path_paint();