Inkscape
Vector Graphics Editor
|
#include <build-drawing.h>
Public Member Functions | |
DrawContext (Document &doc, capypdf::DrawContext ctx, bool soft_mask) | |
~DrawContext ()=default | |
void | paint_item (SPItem const *item, Geom::Affine const &tr=Geom::identity(), SPStyle const *context_style=nullptr) |
Paint the given object into the given context, making groups if needed. | |
void | paint_item_group (SPGroup const *group, SPStyle const *context_style) |
void | paint_item_clone (SPUse const *use, SPStyle const *context_style) |
Paint the given clone object, finding or generating a transparency group from it. | |
void | paint_group (CapyPDF_TransparencyGroupId child_id, SPStyle const *style=nullptr, Geom::Affine const &tr=Geom::identity(), std::optional< CapyPDF_TransparencyGroupId > soft_mask={}) |
Paint a child group at the requested location. | |
void | paint_shape (SPShape const *shape, SPStyle const *context_style) |
Paint a single shape path. | |
void | paint_raster (SPImage const *image) |
Draw the raster data stored in URI into the PDF context. | |
void | paint_item_to_raster (SPItem const *item, Geom::Affine const &tr, double resolution, bool antialias) |
Draw an item as a bitmap and return. | |
void | paint_text_layout (Text::Layout const &layout, SPStyle const *context_style) |
Paint the given layout into the PDF document Drawing content. | |
void | clip_text_layout (Text::Layout const &layout) |
Use the text object as a clipping mask in the PDF. | |
void | start_ocg (CapyPDF_OptionalContentGroupId ocgid) |
void | end_ocg () |
bool | set_shape (SPShape const *shape) |
bool | set_shape_pathvector (Geom::PathVector const &pathv) |
void | set_clip_path (std::optional< Geom::PathVector > clip, SPStyle *style=nullptr) |
Apply the clip path to the existing context. | |
void | set_clip_rectangle (Geom::OptRect const &rect) |
Apply the clipping rectangle with a NONZERO fill rule. | |
void | set_paint_style (StyleMap const &map, SPStyle const *style, SPStyle const *context_style) |
Set the style for drawing shapes from the SVG style, this is all the styles that relate to how vector paths are drawn with stroke, fill and other shape properties. | |
Document & | get_document () |
std::optional< double > | get_softmask (double opacity) const |
Protected Member Functions | |
void | set_matrix (Geom::Affine const &affine) |
Set the transformation matrix for this context Group. | |
void | transform (Geom::Affine const &affine) |
Add a transform to the current context stream. | |
Protected Attributes | |
capypdf::DrawContext | _ctx |
Document & | _doc |
Private Member Functions | |
void | set_shape_path (Geom::Path const &path) |
bool | set_shape_rectangle (Geom::Rect const &rect) |
Private Attributes | |
bool | _soft_mask = false |
Friends | |
class | Document |
Definition at line 30 of file build-drawing.h.
|
inline |
Definition at line 33 of file build-drawing.h.
|
default |
void Inkscape::Extension::Internal::PdfBuilder::DrawContext::clip_text_layout | ( | Text::Layout const & | layout | ) |
Use the text object as a clipping mask in the PDF.
Definition at line 220 of file build-text.cpp.
References _ctx, _doc, _soft_mask, Inkscape::Extension::Internal::err(), Inkscape::Text::Layout::getActualLength(), Inkscape::Text::Layout::input_stream(), and Inkscape::Text::Layout::spans().
Referenced by paint_item().
void Inkscape::Extension::Internal::PdfBuilder::DrawContext::end_ocg | ( | ) |
|
inline |
Definition at line 64 of file build-drawing.h.
References _doc.
std::optional< double > Inkscape::Extension::Internal::PdfBuilder::DrawContext::get_softmask | ( | double | opacity | ) | const |
Definition at line 415 of file build-styles.cpp.
References _soft_mask.
Referenced by set_paint_style().
void Inkscape::Extension::Internal::PdfBuilder::DrawContext::paint_group | ( | CapyPDF_TransparencyGroupId | child_id, |
SPStyle const * | style = nullptr , |
||
Geom::Affine const & | tr = Geom::identity() , |
||
std::optional< CapyPDF_TransparencyGroupId > | soft_mask = {} |
||
) |
Paint a child group at the requested location.
Definition at line 208 of file build-drawing.cpp.
References _ctx, _doc, Inkscape::Extension::Internal::PdfBuilder::Document::get_group_graphics_state(), Geom::identity(), and transform().
Referenced by Inkscape::Extension::Internal::PdfBuilder::PageContext::paint_drawing(), paint_item_clone(), paint_item_group(), and paint_shape().
void Inkscape::Extension::Internal::PdfBuilder::DrawContext::paint_item | ( | SPItem const * | item, |
Geom::Affine const & | tr = Geom::identity() , |
||
SPStyle const * | context_style = nullptr |
||
) |
Paint the given object into the given context, making groups if needed.
Definition at line 79 of file build-drawing.cpp.
References _ctx, _doc, Inkscape::Extension::Internal::PdfBuilder::Document::_gen, _soft_mask, clip_text_layout(), end_ocg(), Inkscape::Extension::Internal::PdfBuilder::Document::get_filter_resolution(), Inkscape::Extension::Internal::PdfBuilder::get_id(), Inkscape::Extension::Internal::StyleMemory::get_ifset(), Inkscape::Extension::Internal::PdfBuilder::Document::get_shape_graphics_state(), Inkscape::Extension::Internal::PdfBuilder::Document::get_text_enabled(), SPItem::getClipPathVector(), SPItem::getClipTextObject(), Geom::identity(), image, SPItem::isFiltered(), item, label, paint_item_clone(), paint_item_group(), paint_item_to_raster(), Inkscape::Extension::Internal::PdfBuilder::Document::paint_memory(), paint_raster(), paint_shape(), paint_text_layout(), Inkscape::Extension::Internal::StyleMemory::remember(), set_clip_path(), set_paint_style(), start_ocg(), SPObject::style, and transform().
Referenced by Inkscape::Extension::Internal::PdfBuilder::ItemContext::paint(), and paint_item_group().
void Inkscape::Extension::Internal::PdfBuilder::DrawContext::paint_item_clone | ( | SPUse const * | use, |
SPStyle const * | context_style | ||
) |
Paint the given clone object, finding or generating a transparency group from it.
Definition at line 189 of file build-drawing.cpp.
References _doc, SPObject::children, SVGLength::computed, Inkscape::Extension::Internal::PdfBuilder::get_id(), Inkscape::Extension::Internal::PdfBuilder::Document::item_to_transparency_group(), paint_group(), SPObject::style, SPDimensions::x, and SPDimensions::y.
Referenced by paint_item().
void Inkscape::Extension::Internal::PdfBuilder::DrawContext::paint_item_group | ( | SPGroup const * | group, |
SPStyle const * | context_style | ||
) |
Definition at line 156 of file build-drawing.cpp.
References _doc, SPObject::children, SPObject::DEPENDENT, SPItem::getMaskRef(), SPMaskReference::getObject(), Geom::identity(), Inkscape::Extension::Internal::PdfBuilder::Document::item_to_transparency_group(), Inkscape::Extension::Internal::PdfBuilder::Document::mask_to_transparency_group(), paint_group(), paint_item(), ref, and Inkscape::Extension::Internal::PdfBuilder::style_needs_group().
Referenced by paint_item().
void Inkscape::Extension::Internal::PdfBuilder::DrawContext::paint_item_to_raster | ( | SPItem const * | item, |
Geom::Affine const & | tr, | ||
double | resolution, | ||
bool | antialias | ||
) |
Draw an item as a bitmap and return.
Definition at line 164 of file build-images.cpp.
References _ctx, _doc, builder, data, SPObject::document, Inkscape::Extension::Internal::PdfBuilder::Document::generator(), Inkscape::Pixbuf::getSurfaceRaw(), Inkscape::Good, height, SPItem::i2doc_affine(), Geom::identity(), image, item, items, Inkscape::None, props, sp_generate_internal_bitmap(), stride, surface, transform(), unpremul_alpha(), SPItem::visualBounds(), and width.
Referenced by paint_item().
void Inkscape::Extension::Internal::PdfBuilder::DrawContext::paint_raster | ( | SPImage const * | image | ) |
Draw the raster data stored in URI into the PDF context.
Definition at line 54 of file build-images.cpp.
References _ctx, _doc, Inkscape::Extension::Internal::PdfBuilder::Document::_gen, SPDocument::createNewDoc(), SPDocument::createNewDocFromMem(), extract_uri_data(), SPItem::GEOMETRIC_BBOX, Inkscape::Extension::Internal::PdfBuilder::get_interpolation(), Inkscape::getHrefAttribute(), Geom::identity(), image, Inkscape::Extension::Internal::PdfBuilder::Document::item_to_transparency_group(), NONE, props, RASTER, set_clip_rectangle(), SVG, and transform().
Referenced by paint_item().
void Inkscape::Extension::Internal::PdfBuilder::DrawContext::paint_shape | ( | SPShape const * | shape, |
SPStyle const * | context_style | ||
) |
Paint a single shape path.
shape | - The shape we want to paint |
Definition at line 234 of file build-drawing.cpp.
References _ctx, _doc, _soft_mask, SPStyle::fill_rule, SPShape::get_markers(), Inkscape::Extension::Internal::PdfBuilder::get_paint_layers(), Inkscape::Extension::Internal::PdfBuilder::Document::item_to_transparency_group(), Inkscape::Extension::Internal::PdfBuilder::PAINT_FILL, Inkscape::Extension::Internal::PdfBuilder::PAINT_FILLSTROKE, paint_group(), Inkscape::Extension::Internal::PdfBuilder::PAINT_MARKERS, Inkscape::Extension::Internal::PdfBuilder::PAINT_STROKE, set_shape(), SP_WIND_RULE_EVENODD, and SPObject::style.
Referenced by paint_item().
void Inkscape::Extension::Internal::PdfBuilder::DrawContext::paint_text_layout | ( | Text::Layout const & | layout, |
SPStyle const * | context_style | ||
) |
Paint the given layout into the PDF document Drawing content.
Definition at line 256 of file build-text.cpp.
References _ctx, _doc, _soft_mask, Inkscape::Extension::Internal::err(), Inkscape::Extension::Internal::StyleMemory::get_changes_and_remember(), Inkscape::Extension::Internal::PdfBuilder::get_paint_layers(), Inkscape::Text::Layout::getActualLength(), Inkscape::Text::Layout::input_stream(), Inkscape::Extension::Internal::PdfBuilder::PAINT_FILL, Inkscape::Extension::Internal::PdfBuilder::PAINT_FILLSTROKE, Inkscape::Extension::Internal::PdfBuilder::PAINT_MARKERS, Inkscape::Extension::Internal::PdfBuilder::Document::paint_memory(), Inkscape::Extension::Internal::PdfBuilder::PAINT_STROKE, and Inkscape::Text::Layout::spans().
Referenced by paint_item().
void Inkscape::Extension::Internal::PdfBuilder::DrawContext::set_clip_path | ( | std::optional< Geom::PathVector > | clip, |
SPStyle * | style = nullptr |
||
) |
Apply the clip path to the existing context.
Definition at line 291 of file build-drawing.cpp.
References _ctx, clip(), SPStyle::clip_rule, set_shape_pathvector(), and SP_WIND_RULE_EVENODD.
Referenced by paint_item(), and set_clip_rectangle().
void Inkscape::Extension::Internal::PdfBuilder::DrawContext::set_clip_rectangle | ( | Geom::OptRect const & | rect | ) |
Apply the clipping rectangle with a NONZERO fill rule.
Definition at line 308 of file build-drawing.cpp.
References set_clip_path().
Referenced by paint_raster().
|
protected |
Set the transformation matrix for this context Group.
Definition at line 39 of file build-drawing.cpp.
References _ctx.
void Inkscape::Extension::Internal::PdfBuilder::DrawContext::set_paint_style | ( | StyleMap const & | map, |
SPStyle const * | style, | ||
SPStyle const * | context_style | ||
) |
Set the style for drawing shapes from the SVG style, this is all the styles that relate to how vector paths are drawn with stroke, fill and other shape properties.
But NOT item styles such as opacity, blending mode etc.
Definition at line 431 of file build-styles.cpp.
References _ctx, _doc, FILL, SPStyle::fill, SPStyle::fill_opacity, Inkscape::Extension::Internal::PdfBuilder::get_linecap(), Inkscape::Extension::Internal::PdfBuilder::get_linejoin(), Inkscape::Extension::Internal::PdfBuilder::Document::get_paint(), get_softmask(), map, STROKE, SPStyle::stroke, STROKE_DASHARRAY, SPStyle::stroke_dasharray, SPStyle::stroke_dashoffset, STROKE_LINECAP, SPStyle::stroke_linecap, STROKE_LINEJOIN, SPStyle::stroke_linejoin, STROKE_MITERLIMIT, SPStyle::stroke_miterlimit, SPStyle::stroke_opacity, STROKE_WIDTH, and SPStyle::stroke_width.
Referenced by paint_item().
bool Inkscape::Extension::Internal::PdfBuilder::DrawContext::set_shape | ( | SPShape const * | shape | ) |
Definition at line 23 of file build-paths.cpp.
References SPShape::curve(), Geom::GenericRect< Coord >::from_xywh(), set_shape_pathvector(), and set_shape_rectangle().
Referenced by paint_shape().
|
private |
Definition at line 67 of file build-paths.cpp.
References _ctx, Geom::cubicbezierpath_from_sbasis(), order, and set_shape_path().
Referenced by set_shape_path(), and set_shape_pathvector().
bool Inkscape::Extension::Internal::PdfBuilder::DrawContext::set_shape_pathvector | ( | Geom::PathVector const & | pathv | ) |
Definition at line 40 of file build-paths.cpp.
References _ctx, Geom::PathVector::empty(), and set_shape_path().
Referenced by set_clip_path(), and set_shape().
|
private |
Definition at line 34 of file build-paths.cpp.
References _ctx, Geom::GenericRect< C >::height(), Geom::GenericRect< C >::left(), Geom::GenericRect< C >::top(), and Geom::GenericRect< C >::width().
Referenced by set_shape().
void Inkscape::Extension::Internal::PdfBuilder::DrawContext::start_ocg | ( | CapyPDF_OptionalContentGroupId | ocgid | ) |
|
protected |
Add a transform to the current context stream.
Definition at line 47 of file build-drawing.cpp.
References _ctx, and Geom::identity().
Referenced by paint_group(), paint_item(), paint_item_to_raster(), and paint_raster().
|
friend |
Definition at line 68 of file build-drawing.h.
|
protected |
Definition at line 73 of file build-drawing.h.
Referenced by Inkscape::Extension::Internal::PdfBuilder::PageContext::add_anchors_for_page(), Inkscape::Extension::Internal::PdfBuilder::Document::add_group(), Inkscape::Extension::Internal::PdfBuilder::PageContext::annotate(), clip_text_layout(), end_ocg(), Inkscape::Extension::Internal::PdfBuilder::PageContext::finalize(), Inkscape::Extension::Internal::PdfBuilder::GroupContext::GroupContext(), paint_group(), paint_item(), paint_item_to_raster(), paint_raster(), paint_shape(), paint_text_layout(), set_clip_path(), set_matrix(), set_paint_style(), set_shape_path(), set_shape_pathvector(), set_shape_rectangle(), start_ocg(), and transform().
|
protected |
Definition at line 74 of file build-drawing.h.
Referenced by Inkscape::Extension::Internal::PdfBuilder::PageContext::add_anchors_for_page(), clip_text_layout(), get_document(), paint_group(), paint_item(), paint_item_clone(), paint_item_group(), paint_item_to_raster(), paint_raster(), paint_shape(), paint_text_layout(), and set_paint_style().
|
private |
Definition at line 80 of file build-drawing.h.
Referenced by clip_text_layout(), get_softmask(), paint_item(), paint_shape(), and paint_text_layout().