From 022fce75a6352041df1d75dd2629cdebb05bac81 Mon Sep 17 00:00:00 2001 From: Nico Weber Date: Mon, 18 Dec 2023 16:36:29 -0500 Subject: [PATCH] LibPDF: Get inline image data from parser to renderer We create a inline_image_end operator that has all the relevant data in a synthetic StreamObject. inline_image_end is still a RENDERER_TODO(), so no real behavior change. (Previously we'd call only inline_image_begin, so string the todo message is about is now a bit different. But no interesting behavior change.) --- Userland/Libraries/LibPDF/Parser.cpp | 9 ++++++--- Userland/Libraries/LibPDF/Renderer.cpp | 15 +++++++++++++-- 2 files changed, 19 insertions(+), 5 deletions(-) diff --git a/Userland/Libraries/LibPDF/Parser.cpp b/Userland/Libraries/LibPDF/Parser.cpp index 6c79431392..7ba360e866 100644 --- a/Userland/Libraries/LibPDF/Parser.cpp +++ b/Userland/Libraries/LibPDF/Parser.cpp @@ -591,9 +591,12 @@ PDFErrorOr> Parser::parse_operators() m_reader.consume_whitespace(); auto stream_bytes = m_reader.bytes().slice(stream_start, stream_end - stream_start); - // FIXME: Do more with inline images than just skipping them. - (void)map; - (void)stream_bytes; + + Vector inline_image_args; + auto map_object = make_object(move(map)); + inline_image_args.append(make_object(move(map_object), MUST(ByteBuffer::copy(stream_bytes)))); + operators.append(Operator(OperatorType::InlineImageEnd, move(inline_image_args))); + continue; } operators.append(Operator(operator_type, move(operator_args))); diff --git a/Userland/Libraries/LibPDF/Renderer.cpp b/Userland/Libraries/LibPDF/Renderer.cpp index f45667ad8e..74af884b39 100644 --- a/Userland/Libraries/LibPDF/Renderer.cpp +++ b/Userland/Libraries/LibPDF/Renderer.cpp @@ -688,8 +688,19 @@ RENDERER_HANDLER(set_painting_color_and_space_to_cmyk) } RENDERER_TODO(shade) -RENDERER_TODO(inline_image_begin) -RENDERER_TODO(inline_image_begin_data) + +RENDERER_HANDLER(inline_image_begin) +{ + // The parser only calls the inline_image_end handler for inline images. + VERIFY_NOT_REACHED(); +} + +RENDERER_HANDLER(inline_image_begin_data) +{ + // The parser only calls the inline_image_end handler for inline images. + VERIFY_NOT_REACHED(); +} + RENDERER_TODO(inline_image_end) RENDERER_HANDLER(paint_xobject) {