38 if (
auto id = obj->
getId()) {
44 g_error(
"Object doesn't have any sort of id.");
63 auto const cache_key = group_ctx.
cache_key();
71 auto const item_id =
_gen.add_transparency_group(group_ctx.
_ctx);
84std::optional<CapyPDF_TransparencyGroupId>
97 bool fill_used =
false, stroke_used =
false;
100 std::optional<double> opacity;
104 cache_key = {std::get<0>(cache_key),
paint_to_cache_key(context_style->
fill, opacity), std::get<2>(cache_key)};
107 std::optional<double> opacity;
114 if (
auto marker = cast<SPMarker>(
item)) {
115 tr = marker->c2p * tr;
124 if (!bbox || bbox->width() == 0 || bbox->height() == 0) {
129 if (
auto anchor = cast<SPAnchor>(
item)) {
135 group_ctx.set_matrix(tr);
139 auto const item_id =
_gen.add_transparency_group(group_ctx._ctx);
153 std::string cache_key =
get_id(mask);
165 group_ctx.transform(transform);
168 if (
auto child_item = cast<SPItem>(&obj)) {
170 group_ctx.paint_group(*item_id, child_item->style);
175 auto const item_id =
_gen.add_transparency_group(group_ctx._ctx);
187 std::vector<SPObject *> objects;
188 if (style->
fill.set && style->
fill.href) {
189 if (
auto gradient = cast<SPGradient>(style->
fill.href->getObject())) {
192 bbox.
unionWith(gradient->getAllItemsBox());
197 if (
auto gradient = cast<SPGradient>(style->
stroke.href->getObject())) {
200 bbox.
unionWith(gradient->getAllItemsBox());
205 if (!objects.empty() && bbox) {
207 bool painted =
false;
208 for (
auto obj : objects) {
209 if (
auto item = cast<SPItem>(obj)) {
211 gradient_mask.set_paint_style(style_map,
item->
style, context_style);
217 return _gen.add_transparency_group(gradient_mask._ctx);
232 std::vector<CapyPDF_AnnotationId>
result;
234 auto bbox = a->visualBounds(a->i2doc_affine() * page_tr,
true,
false,
true);
235 if (!bbox || !a->href || !
page->itemOnPage(a)) {
239 auto annot = capypdf::Annotation();
240 annot.set_rectangle(bbox->left(), bbox->bottom(), bbox->right(), bbox->top());
241 annot.set_flags(CAPY_ANNOTATION_FLAG_HIDDEN);
244 auto obj = a->local_link->getObject();
245 auto dest = capypdf::Destination();
246 if (
auto target_page = cast<SPPage>(obj)) {
247 dest.set_page_fit(target_page->getPageIndex());
248 annot.set_destination(dest);
249 }
else if (
auto item = cast<SPItem>(obj)) {
253 dest.set_page_xyz(target_page->getPageIndex(), {}, item_box->bottom(), {});
254 annot.set_destination(dest);
257 annot.set_uri(std::string(a->href));
261 annot.set_uri(std::string(a->href));
3x3 matrix representing an affine transformation.
void unionWith(CRect const &b)
Enlarge the rectangle to contain the argument.
Axis-aligned rectangle that can be empty.
std::optional< CapyPDF_TransparencyGroupId > item_to_transparency_group(SPItem const *item, SPStyle const *context_style=nullptr, bool is_soft_mask=false)
Render any type of item into a transparency group.
std::set< SPAnchor const * > _anchors
std::map< std::string, CapyPDF_TransparencyGroupId > _mask_cache
StyleMemory _paint_memory
std::map< ItemCacheKey, CapyPDF_TransparencyGroupId > _item_cache
std::optional< CapyPDF_TransparencyGroupId > style_to_transparency_mask(SPStyle const *style, SPStyle const *context_style)
Render gradient transparencies into a transparency mask.
std::vector< CapyPDF_AnnotationId > get_anchors_for_page(SPPage const *page)
Load an anchor link and add it to the page.
std::optional< CapyPDF_TransparencyGroupId > mask_to_transparency_group(SPMask const *mask, Geom::Affine const &transform)
Render a mask out to a transparency group context.
void add_page(PageContext &page)
std::optional< CapyPDF_TransparencyGroupId > add_group(ItemContext &context)
void set_label(uint32_t page, std::string const &label)
capypdf::DrawContext _ctx
ItemCacheKey cache_key() const
static Geom::Affine page_transform(SPPage const *page)
Get the transformation for the given page.
StyleMap get_ifset(SPStyle const *style) const
Return a StyleMap of all the set styles, filtered in the same way as get_changes.
SPPage * getPageFor(SPItem *item, bool contains) const
Return the first page that contains the given item.
virtual char const * attribute(char const *key) const =0
Get the string representation of a node's attribute.
Inkscape::PageManager & getPageManager()
Base class for visual SVG elements.
Geom::Affine i2doc_affine() const
Returns the accumulated transformation of the item and all its ancestors, including root's viewport.
Geom::OptRect visualBounds(Geom::Affine const &transform=Geom::identity(), bool wfilter=true, bool wclip=true, bool wmask=true) const
Get item's visual bounding box in this item's coordinate system.
Geom::OptRect visualBounds(Geom::Affine const &transform) const
SPObject is an abstract base class of all of the document nodes at the SVG document level.
char const * getId() const
Returns the objects current ID string.
SPStyle * style
Represents the style properties, whether from presentation attributes, the style attribute,...
Inkscape::XML::Node * getRepr()
Returns the XML representation of tree.
T< SPAttr::FILL, SPIPaint > fill
fill
T< SPAttr::STROKE, SPIPaint > stroke
stroke
T< SPAttr::FILL_OPACITY, SPIScale24 > fill_opacity
fill-opacity
T< SPAttr::STROKE_OPACITY, SPIScale24 > stroke_opacity
stroke-opacity
Affine identity()
Create an identity matrix.
std::tuple< std::string, std::string, std::string > ItemCacheKey
std::string get_id(SPObject const *obj)
Attempt to get an object's id, even if it's a clone.
bool gradient_has_transparency(SPPaintServer const *paint)
Returns true if the gradient has transparency.
std::string paint_to_cache_key(SPIPaint const &paint, std::optional< double > opacity)
Turn a paint into a string for use in caching keys.
void get_context_use_recursive(SPItem const *item, bool &fill, bool &stroke)
Find out if any of the item, or its decendents use context-fill and context-stroke.
TODO: insert short description here.
SVG <image> implementation.
Some things pertinent to all visible shapes: SPItem, SPItemView, SPItemCtx.
SPRoot: SVG <svg> implementation.
SPStyle - a style object for SPItem objects.