Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

LibPDF: Use draw_rect() to show debug clipping rects #24677

Merged
merged 1 commit into from
Jul 12, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 3 additions & 3 deletions Userland/Libraries/LibPDF/Renderer.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -305,12 +305,12 @@ RENDERER_HANDLER(path_append_rect)

void Renderer::activate_clip()
{
auto bounding_box = state().clipping_paths.current.bounding_box();
auto bounding_box = state().clipping_paths.current.bounding_box().to_type<int>();
m_painter.clear_clip_rect();
if (m_rendering_preferences.show_clipping_paths) {
m_painter.stroke_path(rect_path(bounding_box), Color::Black, 1);
m_painter.draw_rect(bounding_box, Color::Black);
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Eventually we'll want to clip against the full path and then probably draw it here, I'm guessing. But this is a clear improvement for now, thanks!

This also more accurately shows the (real) clip as the bounding box is truncated to an int before adding it as a clip rect.

IIRC the real clip rect is a bit off. I haven't looked at PDF things for too long, but my pdf notes have:

- pdf_reference_1-7.pdf p1010 has `pp g` clip very slightly off
  - ITU-T_T_88__08_2018.pdf p124 has image cut off at bottom
  - clip 1 px too high or something
  - 0000372.pdf p22 also has clip off
- 0000354.pdf p7: horizontal line gets clipped away
  - pdf chars have one pixel left over -- maybe clipping path off by one
  - 0000277.pdf p5 gradient bottom too
- "clip images" only works if "clip paths" is checked as well somehow

So maybe what this here drew was right, and the clip was (is) wrong.

Anyways, this matching the actual clip better is an improvement :)

}
m_painter.add_clip_rect(bounding_box.to_type<int>());
m_painter.add_clip_rect(bounding_box);
}

void Renderer::deactivate_clip()
Expand Down
Loading