Inkscape
Vector Graphics Editor
Loading...
Searching...
No Matches
Inkscape::Extension::Internal::PdfBuilder::DrawContext Class Reference

#include <build-drawing.h>

Inheritance diagram for Inkscape::Extension::Internal::PdfBuilder::DrawContext:
Inkscape::Extension::Internal::PdfBuilder::GroupContext Inkscape::Extension::Internal::PdfBuilder::PageContext Inkscape::Extension::Internal::PdfBuilder::PatternContext Inkscape::Extension::Internal::PdfBuilder::ItemContext

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.
 
Documentget_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
 

Detailed Description

Definition at line 30 of file build-drawing.h.

Constructor & Destructor Documentation

◆ DrawContext()

Inkscape::Extension::Internal::PdfBuilder::DrawContext::DrawContext ( Document doc,
capypdf::DrawContext  ctx,
bool  soft_mask 
)
inline

Definition at line 33 of file build-drawing.h.

◆ ~DrawContext()

Inkscape::Extension::Internal::PdfBuilder::DrawContext::~DrawContext ( )
default

Member Function Documentation

◆ clip_text_layout()

void Inkscape::Extension::Internal::PdfBuilder::DrawContext::clip_text_layout ( Text::Layout const &  layout)

◆ end_ocg()

void Inkscape::Extension::Internal::PdfBuilder::DrawContext::end_ocg ( )

Definition at line 320 of file build-drawing.cpp.

References _ctx.

Referenced by paint_item().

◆ get_document()

Document & Inkscape::Extension::Internal::PdfBuilder::DrawContext::get_document ( )
inline

Definition at line 64 of file build-drawing.h.

References _doc.

◆ get_softmask()

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().

◆ paint_group()

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_item()

◆ paint_item_clone()

void Inkscape::Extension::Internal::PdfBuilder::DrawContext::paint_item_clone ( SPUse const *  use,
SPStyle const *  context_style 
)

◆ paint_item_group()

◆ paint_item_to_raster()

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.

  • item - The SPItem to convert to a bitmap
  • tr - Item transformation to apply
  • resolution - The DPI resolution to use.
  • antialias - Optionally turn off antialiasing.

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().

◆ paint_raster()

◆ paint_shape()

◆ paint_text_layout()

◆ set_clip_path()

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().

◆ 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().

◆ set_matrix()

void Inkscape::Extension::Internal::PdfBuilder::DrawContext::set_matrix ( Geom::Affine const &  affine)
protected

Set the transformation matrix for this context Group.

Definition at line 39 of file build-drawing.cpp.

References _ctx.

◆ set_paint_style()

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.

  • map - The style map indicating changes in the PDF remndering stack
  • style - The style to apply to the stream

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().

◆ set_shape()

bool Inkscape::Extension::Internal::PdfBuilder::DrawContext::set_shape ( SPShape const *  shape)

◆ set_shape_path()

void Inkscape::Extension::Internal::PdfBuilder::DrawContext::set_shape_path ( Geom::Path const &  path)
private

◆ 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().

◆ set_shape_rectangle()

bool Inkscape::Extension::Internal::PdfBuilder::DrawContext::set_shape_rectangle ( Geom::Rect const &  rect)
private

◆ start_ocg()

void Inkscape::Extension::Internal::PdfBuilder::DrawContext::start_ocg ( CapyPDF_OptionalContentGroupId  ocgid)

Definition at line 315 of file build-drawing.cpp.

References _ctx.

Referenced by paint_item().

◆ transform()

void Inkscape::Extension::Internal::PdfBuilder::DrawContext::transform ( Geom::Affine const &  affine)
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().

Friends And Related Symbol Documentation

◆ Document

friend class Document
friend

Definition at line 68 of file build-drawing.h.

Member Data Documentation

◆ _ctx

◆ _doc

◆ _soft_mask

bool Inkscape::Extension::Internal::PdfBuilder::DrawContext::_soft_mask = false
private

The documentation for this class was generated from the following files: