diff --git a/Userland/Libraries/LibPDF/Renderer.cpp b/Userland/Libraries/LibPDF/Renderer.cpp index 04cd6f9a70..59ccd4a92e 100644 --- a/Userland/Libraries/LibPDF/Renderer.cpp +++ b/Userland/Libraries/LibPDF/Renderer.cpp @@ -290,11 +290,7 @@ RENDERER_HANDLER(path_append_rect) return {}; } -/// -// Path painting operations -/// - -void Renderer::begin_path_paint() +void Renderer::activate_clip() { auto bounding_box = state().clipping_paths.current.bounding_box(); m_painter.clear_clip_rect(); @@ -304,11 +300,25 @@ void Renderer::begin_path_paint() m_painter.add_clip_rect(bounding_box.to_type()); } +void Renderer::deactivate_clip() +{ + m_painter.clear_clip_rect(); + state().clipping_paths.current = state().clipping_paths.next; +} + +/// +// Path painting operations +/// + +void Renderer::begin_path_paint() +{ + activate_clip(); +} + void Renderer::end_path_paint() { m_current_path.clear(); - m_painter.clear_clip_rect(); - state().clipping_paths.current = state().clipping_paths.next; + deactivate_clip(); } RENDERER_HANDLER(path_stroke) diff --git a/Userland/Libraries/LibPDF/Renderer.h b/Userland/Libraries/LibPDF/Renderer.h index 177679dd4e..32a3467d29 100644 --- a/Userland/Libraries/LibPDF/Renderer.h +++ b/Userland/Libraries/LibPDF/Renderer.h @@ -127,6 +127,9 @@ private: PDFErrorOr handle_text_next_line_show_string(ReadonlySpan args, Optional> = {}); PDFErrorOr handle_text_next_line_show_string_set_spacing(ReadonlySpan args, Optional> = {}); + void activate_clip(); + void deactivate_clip(); + void begin_path_paint(); void end_path_paint(); PDFErrorOr set_graphics_state_from_dict(NonnullRefPtr);