X-Git-Url: https://git.tokkee.org/?a=blobdiff_plain;f=src%2Fextension%2Finternal%2Fpdfinput%2Fsvg-builder.h;h=9298884a1898fddfddfb91d317be1269f345dabe;hb=c53f16f52840e8c0f2be9c1cc3af633c0ba1552e;hp=a329e3020111d67f42ba6f92419aea3ef0b17736;hpb=68664e00e2372534b4df2fdc5f54f836bafece18;p=inkscape.git diff --git a/src/extension/internal/pdfinput/svg-builder.h b/src/extension/internal/pdfinput/svg-builder.h index a329e3020..9298884a1 100644 --- a/src/extension/internal/pdfinput/svg-builder.h +++ b/src/extension/internal/pdfinput/svg-builder.h @@ -32,11 +32,14 @@ namespace Inkscape { #include "CharTypes.h" class GooString; class Function; -class SampledFunction; struct GfxState; +class GfxColor; +class GfxColorSpace; +class GfxRGB; +class GfxPath; class GfxPattern; -class GfxShadingPattern; class GfxTilingPattern; +class GfxShading; class GfxFont; class GfxImageColorMap; class Stream; @@ -51,6 +54,19 @@ namespace Inkscape { namespace Extension { namespace Internal { +struct SvgTransparencyGroup; + +/** + * \struct SvgGraphicsState + * Holds information about the current softmask and group depth. + * Could be later used to store other graphics state parameters so that we could + * emit only the differences in style settings from the parent state. + */ +struct SvgGraphicsState { + Inkscape::XML::Node *softmask; // Points to current softmask node + int group_depth; // Depth of nesting groups at this level +}; + /** * \struct SvgGlyph * Holds information about glyphs added by PdfParser which haven't been added @@ -86,6 +102,7 @@ public: // Property setting void setDocumentSize(double width, double height); // Document size in px void setAsLayer(char *layer_name=NULL); + void setGroupOpacity(double opacity); // Handling the node stack Inkscape::XML::Node *pushGroup(); @@ -94,10 +111,32 @@ public: // Path adding void addPath(GfxState *state, bool fill, bool stroke, bool even_odd=false); + void addShadedFill(GfxShading *shading, double *matrix, GfxPath *path, bool even_odd=false); // Image handling void addImage(GfxState *state, Stream *str, int width, int height, GfxImageColorMap *color_map, int *mask_colors); + void addImageMask(GfxState *state, Stream *str, int width, int height, + bool invert); + void addMaskedImage(GfxState *state, Stream *str, int width, int height, + GfxImageColorMap *color_map, + Stream *mask_str, int mask_width, int mask_height, + bool invert_mask); + void addSoftMaskedImage(GfxState *state, Stream *str, int width, int height, + GfxImageColorMap *color_map, + Stream *mask_str, int mask_width, int mask_height, + GfxImageColorMap *mask_color_map); + + // Transparency group and soft mask handling + void pushTransparencyGroup(GfxState *state, double *bbox, + GfxColorSpace *blending_color_space, + bool isolated, bool knockout, + bool for_softmask); + void popTransparencyGroup(GfxState *state); + void paintTransparencyGroup(GfxState *state, double *bbox); + void setSoftMask(GfxState *state, double *bbox, bool alpha, + Function *transfer_func, GfxColor *backdrop_color); + void clearSoftMask(GfxState *state); // Text handling void beginString(GfxState *state, GooString *s); @@ -131,20 +170,22 @@ public: bool getTransform(double *transform); private: - SvgBuilder(); + void _init(); // Pattern creation gchar *_createPattern(GfxPattern *pattern, GfxState *state, bool is_stroke=false); - gchar *_createGradient(GfxShadingPattern *shading_pattern); - bool _addStopsToGradient(Inkscape::XML::Node *gradient, Function *func, double opacity); - bool _addSamplesToGradient(Inkscape::XML::Node *gradient, SampledFunction *func, - double offset0, double offset1, double opacity); + gchar *_createGradient(GfxShading *shading, double *matrix, bool for_shading=false); + void _addStopToGradient(Inkscape::XML::Node *gradient, double offset, + GfxRGB *color, double opacity); + bool _addGradientStops(Inkscape::XML::Node *gradient, GfxShading *shading, + Function *func); gchar *_createTilingPattern(GfxTilingPattern *tiling_pattern, GfxState *state, bool is_stroke=false); // Image/mask creation Inkscape::XML::Node *_createImage(Stream *str, int width, int height, GfxImageColorMap *color_map, int *mask_colors, bool alpha_only=false, bool invert_alpha=false); + Inkscape::XML::Node *_createMask(double width, double height); // Style setting SPCSSAttr *_setStyle(GfxState *state, bool fill, bool stroke, bool even_odd=false); void _setStrokeStyle(SPCSSAttr *css, GfxState *state); @@ -152,7 +193,13 @@ private: void _flushText(); // Write buffered text into doc + // Handling of node stack + Inkscape::XML::Node *pushNode(const char* name); + Inkscape::XML::Node *popNode(); + std::vector _node_stack; std::vector _group_depth; // Depth of nesting groups + SvgTransparencyGroup *_transp_group_stack; // Transparency group stack + std::vector _state_stack; SPCSSAttr *_font_style; // Current font style GfxFont *_current_font; @@ -166,6 +213,7 @@ private: bool _invalidated_style; GfxState *_current_state; + bool _is_top_level; // Whether this SvgBuilder is the top-level one SPDocument *_doc; gchar *_docname; // Basename of the URI from which this document is created XRef *_xref; // Cross-reference table from the PDF doc we're converting from