Code

Added code to initialize DBus (if enabled.)
[inkscape.git] / src / extension / internal / cairo-render-context.h
index ff7ebec7fdcbd15ecdaf86e54d8bd5a81dd7aad6..930668e03b348b1749c08f1d302ee7f4b17dae22 100644 (file)
@@ -9,7 +9,7 @@
  *        Miklos Erdelyi <erdelyim@gmail.com>
  *
  * Copyright (C) 2006 Miklos Erdelyi
- * 
+ *
  * Licensed under GNU GPL
  */
 
@@ -21,8 +21,7 @@
 #include <set>
 #include <string>
 
-#include "libnr/nr-path.h"
-#include <libnr/nr-matrix-ops.h>
+#include <2geom/forward.h>
 
 #include "style.h"
 
@@ -49,15 +48,17 @@ struct CairoGlyphInfo {
 
 struct CairoRenderState {
     unsigned int merge_opacity : 1;     // whether fill/stroke opacity can be mul'd with item opacity
-    unsigned int need_layer : 1;
+    unsigned int need_layer : 1;        // whether object is masked, clipped, and/or has a non-zero opacity
     unsigned int has_overflow : 1;
     unsigned int parent_has_userspace : 1;  // whether the parent's ctm should be applied
     float opacity;
+    bool has_filtereffect;
+    Geom::Matrix item_transform;     // this item's item->transform, for correct clipping
 
     SPClipPath *clip_path;
     SPMask* mask;
 
-    NRMatrix transform;     // the CTM
+    Geom::Matrix transform;     // the CTM
 };
 
 class CairoRenderContext {
@@ -74,22 +75,33 @@ public:
         RENDER_MODE_NORMAL,
         RENDER_MODE_CLIP
     };
-    
+
     typedef enum CairoClipMode {
         CLIP_MODE_PATH,
         CLIP_MODE_MASK
     };
-    
+
     bool setImageTarget(cairo_format_t format);
     bool setPdfTarget(gchar const *utf8_fn);
     bool setPsTarget(gchar const *utf8_fn);
+    /** Set the cairo_surface_t from an external source */
+    bool setSurfaceTarget(cairo_surface_t *surface, bool is_vector, cairo_matrix_t *ctm=NULL);
+
+    void setPSLevel(unsigned int level);
+    void setEPS(bool eps);
+    unsigned int getPSLevel(void);
+    void setPDFLevel(unsigned int level);
+    void setTextToPath(bool texttopath);
+    bool getTextToPath(void);
+    void setFilterToBitmap(bool filtertobitmap);
+    bool getFilterToBitmap(void);
+    void setBitmapResolution(int resolution);
+    int getBitmapResolution(void);
 
     /** Creates the cairo_surface_t for the context with the
     given width, height and with the currently set target
     surface type. */
     bool setupSurface(double width, double height);
-    /** Set the cairo_surface_t from an external source */
-    bool setSurface(cairo_surface_t *surface);
 
     cairo_surface_t *getSurface(void);
 
@@ -101,10 +113,10 @@ public:
     CairoRenderMode getRenderMode(void) const;
     void setClipMode(CairoClipMode mode);
     CairoClipMode getClipMode(void) const;
-    
-    void addBpath(NArtBpath const *bp);
-    void setBpath(NArtBpath const *bp);
-    
+
+    void addPathVector(Geom::PathVector const &pv);
+    void setPathVector(Geom::PathVector const &pv);
+
     void pushLayer(void);
     void popLayer(void);
 
@@ -115,20 +127,20 @@ public:
     CairoRenderState *getParentState(void) const;
     void setStateForStyle(SPStyle const *style);
 
-    void transform(NRMatrix const *transform);
-    void setTransform(NRMatrix const *transform);
-    void getTransform(NRMatrix *copy) const;
-    void getParentTransform(NRMatrix *copy) const;
+    void transform(Geom::Matrix const *transform);
+    void setTransform(Geom::Matrix const *transform);
+    void getTransform(Geom::Matrix *copy) const;
+    void getParentTransform(Geom::Matrix *copy) const;
 
     /* Clipping methods */
-    void addClipPath(NArtBpath const *bp, SPIEnum const *fill_rule);
+    void addClipPath(Geom::PathVector const &pv, SPIEnum const *fill_rule);
     void addClippingRect(double x, double y, double width, double height);
 
     /* Rendering methods */
-    bool renderPath(NRBPath const *bpath, SPStyle const *style, NRRect const *pbox);
+    bool renderPathVector(Geom::PathVector const & pathv, SPStyle const *style, NRRect const *pbox);
     bool renderImage(unsigned char *px, unsigned int w, unsigned int h, unsigned int rs,
-                     NRMatrix const *image_transform, SPStyle const *style);
-    bool renderGlyphtext(PangoFont *font, NRMatrix const *font_matrix,
+                     Geom::Matrix const *image_transform, SPStyle const *style);
+    bool renderGlyphtext(PangoFont *font, Geom::Matrix const *font_matrix,
                          std::vector<CairoGlyphInfo> const &glyphtext, SPStyle const *style);
 
     /* More general rendering methods will have to be added (like fill, stroke) */
@@ -136,28 +148,34 @@ public:
 protected:
     CairoRenderContext(CairoRenderer *renderer);
     virtual ~CairoRenderContext(void);
-    
+
     float _width;
     float _height;
     unsigned short _dpi;
-    
+    unsigned int _pdf_level;
+    unsigned int _ps_level;
+    bool _eps;
+    bool _is_texttopath;
+    bool _is_filtertobitmap;
+    int _bitmapresolution;
+
     FILE *_stream;
-    
+
     unsigned int _is_valid : 1;
     unsigned int _vector_based_target : 1;
 
-    cairo_t *_cr;
+    cairo_t *_cr; // Cairo context
     cairo_surface_t *_surface;
     cairo_surface_type_t _target;
     cairo_format_t _target_format;
     PangoLayout *_layout;
-    
+
     unsigned int _clip_rule : 8;
     unsigned int _clip_winding_failed : 1;
-    
+
     GSList *_state_stack;
     CairoRenderState *_state;    // the current state
-    
+
     CairoRenderer *_renderer;
 
     CairoRenderMode _render_mode;
@@ -166,16 +184,16 @@ protected:
     cairo_pattern_t *_createPatternForPaintServer(SPPaintServer const *const paintserver,
                                                   NRRect const *pbox, float alpha);
     cairo_pattern_t *_createPatternPainter(SPPaintServer const *const paintserver, NRRect const *pbox);
-   
+
     unsigned int _showGlyphs(cairo_t *cr, PangoFont *font, std::vector<CairoGlyphInfo> const &glyphtext, bool is_stroke);
 
-    bool _finishSurfaceSetup(cairo_surface_t *surface);
+    bool _finishSurfaceSetup(cairo_surface_t *surface, cairo_matrix_t *ctm = NULL);
     void _setFillStyle(SPStyle const *style, NRRect const *pbox);
     void _setStrokeStyle(SPStyle const *style, NRRect const *pbox);
-    
-    void _initCairoMatrix(cairo_matrix_t *matrix, NRMatrix const *transform);
+
+    void _initCairoMatrix(cairo_matrix_t *matrix, Geom::Matrix const *transform);
     void _concatTransform(cairo_t *cr, double xx, double yx, double xy, double yy, double x0, double y0);
-    void _concatTransform(cairo_t *cr, NRMatrix const *transform);
+    void _concatTransform(cairo_t *cr, Geom::Matrix const *transform);
 
     CairoRenderState *_createState(void);
 };