Skip to content

Commit

Permalink
LibPDF: Clip stroke for B / B* operators
Browse files Browse the repository at this point in the history
  • Loading branch information
nico committed Mar 8, 2024
1 parent 2c327a6 commit 3a46acd
Showing 1 changed file with 18 additions and 2 deletions.
20 changes: 18 additions & 2 deletions Userland/Libraries/LibPDF/Renderer.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -388,22 +388,38 @@ RENDERER_HANDLER(path_fill_evenodd)

RENDERER_HANDLER(path_fill_stroke_nonzero)
{
begin_path_paint();
if (state().stroke_style.has<NonnullRefPtr<Gfx::PaintStyle>>()) {
m_anti_aliasing_painter.stroke_path(m_current_path, state().stroke_style.get<NonnullRefPtr<Gfx::PaintStyle>>(), line_width());
} else {
m_anti_aliasing_painter.stroke_path(m_current_path, state().stroke_style.get<Color>(), line_width());
}
return handle_path_fill_nonzero(args);
m_current_path.close_all_subpaths();
if (state().paint_style.has<NonnullRefPtr<Gfx::PaintStyle>>()) {
m_anti_aliasing_painter.fill_path(m_current_path, state().paint_style.get<NonnullRefPtr<Gfx::PaintStyle>>(), 1.0, Gfx::Painter::WindingRule::Nonzero);
} else {
m_anti_aliasing_painter.fill_path(m_current_path, state().paint_style.get<Color>(), Gfx::Painter::WindingRule::Nonzero);
}
end_path_paint();
return {};
}

RENDERER_HANDLER(path_fill_stroke_evenodd)
{
begin_path_paint();
if (state().stroke_style.has<NonnullRefPtr<Gfx::PaintStyle>>()) {
m_anti_aliasing_painter.stroke_path(m_current_path, state().stroke_style.get<NonnullRefPtr<Gfx::PaintStyle>>(), line_width());
} else {
m_anti_aliasing_painter.stroke_path(m_current_path, state().stroke_style.get<Color>(), line_width());
}
return handle_path_fill_evenodd(args);
m_current_path.close_all_subpaths();
if (state().paint_style.has<NonnullRefPtr<Gfx::PaintStyle>>()) {
m_anti_aliasing_painter.fill_path(m_current_path, state().paint_style.get<NonnullRefPtr<Gfx::PaintStyle>>(), 1.0, Gfx::Painter::WindingRule::EvenOdd);
} else {
m_anti_aliasing_painter.fill_path(m_current_path, state().paint_style.get<Color>(), Gfx::Painter::WindingRule::EvenOdd);
}
end_path_paint();
return {};
}

RENDERER_HANDLER(path_close_fill_stroke_nonzero)
Expand Down

0 comments on commit 3a46acd

Please sign in to comment.