Code

outline mode: render into the passed cairo_t
authorbuliabyak <buliabyak@users.sourceforge.net>
Fri, 2 Mar 2007 06:56:10 +0000 (06:56 +0000)
committerbuliabyak <buliabyak@users.sourceforge.net>
Fri, 2 Mar 2007 06:56:10 +0000 (06:56 +0000)
src/display/nr-arena-glyphs.cpp
src/display/nr-arena-shape.cpp

index b061e9acda50860fff1bac82ff34b228249cda16..b4bf81c8dab50b00c29549a491d0691815b93a08 100644 (file)
@@ -430,7 +430,7 @@ nr_arena_glyphs_group_update(NRArenaItem *item, NRRectL *area, NRGC *gc, guint s
 
 
 static unsigned int
-nr_arena_glyphs_group_render(cairo_t *ctt, NRArenaItem *item, NRRectL *area, NRPixBlock *pb, unsigned int flags)
+nr_arena_glyphs_group_render(cairo_t *ct, NRArenaItem *item, NRRectL *area, NRPixBlock *pb, unsigned int flags)
 {
     NRArenaItem *child;
 
@@ -442,8 +442,6 @@ nr_arena_glyphs_group_render(cairo_t *ctt, NRArenaItem *item, NRRectL *area, NRP
 
     if (item->arena->rendermode == RENDERMODE_OUTLINE) {
 
-        cairo_t *ct = nr_create_cairo_context (area, pb);
-
         if (!ct) 
             return item->state;
 
@@ -458,22 +456,16 @@ nr_arena_glyphs_group_render(cairo_t *ctt, NRArenaItem *item, NRRectL *area, NRP
 
             cairo_new_path(ct);
             NR::Matrix g_t(g->g_transform);
-            feed_curve_to_cairo (ct, bpath, g_t * group->ctm, NR::Point(area->x0, area->y0));
+            feed_curve_to_cairo (ct, bpath, g_t * group->ctm, NR::Point(pb->area.x0, pb->area.y0));
             cairo_fill(ct);
+            pb->empty = FALSE;
         }
 
-        cairo_surface_t *cst = cairo_get_target(ct);
-        cairo_destroy (ct);
-        cairo_surface_finish (cst);
-        cairo_surface_destroy (cst);
-
-        pb->empty = FALSE;
         return ret;
     }
 
 
 
-
     /* Fill */
     if (style->fill.type != SP_PAINT_TYPE_NONE || item->arena->rendermode == RENDERMODE_OUTLINE) {
         NRPixBlock m;
index 7b8a2c281c83c155b2c66a4a369926f05998c846..bd6ca1df8c18e270447fbaeb614721b0f6f766f4 100644 (file)
@@ -728,12 +728,10 @@ nr_arena_shape_add_bboxes(NRArenaShape* shape, NRRect &bbox)
 
 // cairo outline rendering:
 static unsigned int
-cairo_arena_shape_render_outline(NRArenaItem *item, NRRectL *area, NRPixBlock *pb)
+cairo_arena_shape_render_outline(cairo_t *ct, NRArenaItem *item, NR::Point shift)
 {
     NRArenaShape *shape = NR_ARENA_SHAPE(item);
 
-    cairo_t *ct = nr_create_cairo_context (area, pb);
-
     if (!ct) 
         return item->state;
 
@@ -744,17 +742,10 @@ cairo_arena_shape_render_outline(NRArenaItem *item, NRRectL *area, NRPixBlock *p
     cairo_set_tolerance(ct, 1.25); // low quality, but good enough for outline mode
     cairo_new_path(ct);
 
-    feed_curve_to_cairo (ct, SP_CURVE_BPATH(shape->curve), NR::Matrix(shape->ctm), NR::Point(area->x0, area->y0));
+    feed_curve_to_cairo (ct, SP_CURVE_BPATH(shape->curve), NR::Matrix(shape->ctm), shift);
 
     cairo_stroke(ct);
 
-    cairo_surface_t *cst = cairo_get_target(ct);
-    cairo_destroy (ct);
-    cairo_surface_finish (cst);
-    cairo_surface_destroy (cst);
-
-    pb->empty = FALSE;
-
     return item->state;
 }
 
@@ -850,7 +841,7 @@ cairo_arena_shape_render_stroke(NRArenaItem *item, NRRectL *area, NRPixBlock *pb
  * Renders the item.  Markers are just composed into the parent buffer.
  */
 static unsigned int
-nr_arena_shape_render(cairo_t *ctt, NRArenaItem *item, NRRectL *area, NRPixBlock *pb, unsigned int flags)
+nr_arena_shape_render(cairo_t *ct, NRArenaItem *item, NRRectL *area, NRPixBlock *pb, unsigned int flags)
 {
     NRArenaShape *shape = NR_ARENA_SHAPE(item);
 
@@ -860,7 +851,8 @@ nr_arena_shape_render(cairo_t *ctt, NRArenaItem *item, NRRectL *area, NRPixBlock
     bool outline = (NR_ARENA_ITEM(shape)->arena->rendermode == RENDERMODE_OUTLINE);
 
     if (outline) { 
-        return cairo_arena_shape_render_outline (item, area, pb);
+        pb->empty = FALSE;
+        return cairo_arena_shape_render_outline (ct, item, NR::Point(pb->area.x0, pb->area.y0));
     }
 
     if ( shape->delayed_shp ) {
@@ -980,7 +972,7 @@ nr_arena_shape_render(cairo_t *ctt, NRArenaItem *item, NRRectL *area, NRPixBlock
     /* Just compose children into parent buffer */
     for (NRArenaItem *child = shape->markers; child != NULL; child = child->next) {
         unsigned int ret;
-        ret = nr_arena_item_invoke_render(ctt, child, area, pb, flags);
+        ret = nr_arena_item_invoke_render(ct, child, area, pb, flags);
         if (ret & NR_ARENA_ITEM_STATE_INVALID) return ret;
     }