mirror of
https://github.com/RGBCube/serenity
synced 2025-07-25 21:37:35 +00:00
LibPDF: Improve path clipping support
The existing path clipping support was broken, as it performed the clipping operation as soon as the path clipping commands (W/W*) were received. The correct behavior is to keep a clipping path in the graphic state, *intersect* that with the current path upon receiving W/W*, and apply the clipping when performing painting operations. On top of that, the intersection happening at W/W* time does not affect the painting operation happening on the current on-build path, but takes effect only after the current path is cleared; therefore a current and a next clipping path need to be kept track of. Path clipping is not yet supported on the Painter class, nor is path intersection. We thus continue using the same simplified bounding box approach to calculate clipping paths. Since now we are dealing with more rectangles-as-path code, I've made helper functions to build a rectangle path and reuse it as needed.
This commit is contained in:
parent
c92f450ff0
commit
a1e36e8f78
2 changed files with 65 additions and 17 deletions
|
@ -64,8 +64,14 @@ struct TextState {
|
|||
bool knockout { true };
|
||||
};
|
||||
|
||||
struct ClippingPaths {
|
||||
Gfx::Path current;
|
||||
Gfx::Path next;
|
||||
};
|
||||
|
||||
struct GraphicsState {
|
||||
Gfx::AffineTransform ctm;
|
||||
ClippingPaths clipping_paths;
|
||||
RefPtr<ColorSpace> stroke_color_space { DeviceGrayColorSpace::the() };
|
||||
RefPtr<ColorSpace> paint_color_space { DeviceGrayColorSpace::the() };
|
||||
Gfx::Color stroke_color { Gfx::Color::NamedColor::Black };
|
||||
|
@ -95,6 +101,8 @@ private:
|
|||
PDFErrorOr<void> handle_text_next_line_show_string(Vector<Value> const& args);
|
||||
PDFErrorOr<void> handle_text_next_line_show_string_set_spacing(Vector<Value> const& args);
|
||||
|
||||
void begin_path_paint();
|
||||
void end_path_paint();
|
||||
PDFErrorOr<void> set_graphics_state_from_dict(NonnullRefPtr<DictObject>);
|
||||
void show_text(String const&);
|
||||
PDFErrorOr<NonnullRefPtr<ColorSpace>> get_color_space(Value const&);
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue