Преглед изворни кода

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.)
Nico Weber пре 1 година
родитељ
комит
022fce75a6
2 измењених фајлова са 19 додато и 5 уклоњено
  1. 6 3
      Userland/Libraries/LibPDF/Parser.cpp
  2. 13 2
      Userland/Libraries/LibPDF/Renderer.cpp

+ 6 - 3
Userland/Libraries/LibPDF/Parser.cpp

@@ -591,9 +591,12 @@ PDFErrorOr<Vector<Operator>> 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<Value> inline_image_args;
+                auto map_object = make_object<DictObject>(move(map));
+                inline_image_args.append(make_object<StreamObject>(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)));

+ 13 - 2
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)
 {