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

Conversation

MacDue
Copy link
Member

@MacDue MacDue commented Jul 7, 2024

Using the path rasterizer here is much slower than simply drawing four lines. This also more accurately shows the (real) clip as the bounding box is truncated to an int before adding it as a clip rect.

Fixes #23056

Using the path rasterizer here is much slower than simply drawing four
lines. This also more accurately shows the (real) clip as the bounding
box is truncated to an int before adding it as a clip rect.

Fixes SerenityOS#23056
@github-actions github-actions bot added the 👀 pr-needs-review PR needs review from a maintainer or community member label Jul 7, 2024
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 :)

@nico nico merged commit e8fe2f4 into SerenityOS:master Jul 12, 2024
12 checks passed
@nico
Copy link
Contributor

nico commented Jul 12, 2024

Thanks!

@github-actions github-actions bot removed the 👀 pr-needs-review PR needs review from a maintainer or community member label Jul 12, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

drawing clipping rects on 0000612.pdf takes an unreasonable amount of time
2 participants