Browse Source

LibPDF: Add debug settings for clipping paths and images

Nico Weber 1 year ago
parent
commit
1845a406ea
2 changed files with 10 additions and 3 deletions
  1. 7 3
      Userland/Libraries/LibPDF/Renderer.cpp
  2. 3 0
      Userland/Libraries/LibPDF/Renderer.h

+ 7 - 3
Userland/Libraries/LibPDF/Renderer.cpp

@@ -312,13 +312,15 @@ void Renderer::deactivate_clip()
 
 void Renderer::begin_path_paint()
 {
-    activate_clip();
+    if (m_rendering_preferences.clip_paths)
+        activate_clip();
 }
 
 void Renderer::end_path_paint()
 {
     m_current_path.clear();
-    deactivate_clip();
+    if (m_rendering_preferences.clip_paths)
+        deactivate_clip();
 }
 
 RENDERER_HANDLER(path_stroke)
@@ -1238,7 +1240,9 @@ PDFErrorOr<void> Renderer::show_image(NonnullRefPtr<StreamObject> image)
         Renderer& m_renderer;
     };
 
-    ClipRAII clip_raii(*this);
+    OwnPtr<ClipRAII> clip_raii;
+    if (m_rendering_preferences.clip_images)
+        clip_raii = make<ClipRAII>(*this);
 
     if (!m_rendering_preferences.show_images) {
         show_empty_image(width, height);

+ 3 - 0
Userland/Libraries/LibPDF/Renderer.h

@@ -90,6 +90,9 @@ struct RenderingPreferences {
     bool show_clipping_paths { false };
     bool show_images { true };
 
+    bool clip_paths { true };
+    bool clip_images { true };
+
     unsigned hash() const
     {
         return static_cast<unsigned>(show_clipping_paths) | static_cast<unsigned>(show_images) << 1;