Code

fix clipping with unfilled paths
authorbuliabyak <buliabyak@users.sourceforge.net>
Sun, 19 Mar 2006 23:00:15 +0000 (23:00 +0000)
committerbuliabyak <buliabyak@users.sourceforge.net>
Sun, 19 Mar 2006 23:00:15 +0000 (23:00 +0000)
src/display/nr-arena-item.cpp
src/display/nr-arena-shape.cpp

index e816460b90e494cf88e6a27db732e01f096c36c9..3bdd88724d2f9693714ce2d0fc582c3ac4d38848 100644 (file)
@@ -675,7 +675,7 @@ nr_arena_item_invoke_clip (NRArenaItem *item, NRRectL *area, NRPixBlock *pb)
        nr_return_val_if_fail ((pb->area.y1 - pb->area.y0) >= (area->y1 - area->y0), NR_ARENA_ITEM_STATE_INVALID);
 
 #ifdef NR_ARENA_ITEM_VERBOSE
-       printf ("Invoke render %p: %d %d - %d %d\n", item, area->x0, area->y0, area->x1, area->y1);
+       printf ("Invoke render %p: %d %d - %d %d, item bbox %d %d - %d %d\n", item, area->x0, area->y0, area->x1, area->y1, (&item->bbox)->x0, (&item->bbox)->y0, (&item->bbox)->x1, (&item->bbox)->y1);
 #endif
 
        if (item->visible && nr_rect_l_test_intersect (area, &item->bbox)) {
index 4fd381ad4fabe0850baedaafbd180cdfb4dcae2f..367555f6bc5d37fe5c5bdd0bcb680d0224408499 100644 (file)
@@ -185,7 +185,7 @@ nr_arena_shape_set_child_position (NRArenaItem *item, NRArenaItem *child, NRAren
 }
 
 void nr_arena_shape_update_stroke(NRArenaShape *shape,NRGC* gc);
-void nr_arena_shape_update_fill(NRArenaShape *shape,NRGC *gc);
+void nr_arena_shape_update_fill(NRArenaShape *shape, NRGC *gc, bool force_shape = false);
 void nr_arena_shape_add_bboxes(NRArenaShape* shape,NRRect &bbox);
 
 static guint
@@ -377,11 +377,12 @@ int matrix_is_isometry(NR::Matrix p) {
     return 0;
 }
 
+/** force_shape is used for clipping paths, when we need the shape for clipping even if it's not filled */
 void
-nr_arena_shape_update_fill(NRArenaShape *shape,NRGC *gc)
+nr_arena_shape_update_fill(NRArenaShape *shape, NRGC *gc, bool force_shape)
 {
     shape->delayed_shp = false;
-    if ((shape->_fill.paint.type() != NRArenaShape::Paint::NONE) &&
+    if ((shape->_fill.paint.type() != NRArenaShape::Paint::NONE || force_shape) &&
         ((shape->curve->end > 2) || (shape->curve->bpath[1].code == NR_CURVETO)) ) {
            if (TRUE || !shape->fill_shp) {
                NR::Matrix  cached_to_new;
@@ -424,6 +425,7 @@ nr_arena_shape_update_fill(NRArenaShape *shape,NRGC *gc)
 
                    if ( shape->fill_shp == NULL )
                        shape->fill_shp=new Shape;
+
                    shape->fill_shp->Reset(shape->cached_fill->numberOfPoints(),
                                           shape->cached_fill->numberOfEdges());
                    for (int i = 0; i < shape->cached_fill->numberOfPoints(); i++)
@@ -742,15 +744,14 @@ static guint
 nr_arena_shape_clip (NRArenaItem *item, NRRectL *area, NRPixBlock *pb)
 {
     NRArenaShape *shape = NR_ARENA_SHAPE (item);
-
     if (!shape->curve) return item->state;
 
     if ( shape->delayed_shp ) {
        if ( nr_rect_l_test_intersect (area, &item->bbox) ) {
            NRGC   tempGC(NULL);
            tempGC.transform=shape->ctm;
-           nr_arena_shape_update_stroke(shape,&tempGC);
-           nr_arena_shape_update_fill(shape,&tempGC);
+           //nr_arena_shape_update_stroke(shape,&tempGC); // we don't need stroke for clipping
+           nr_arena_shape_update_fill(shape, &tempGC, true);
            /*      NRRect bbox;
                    bbox.x0 = bbox.y0 = bbox.x1 = bbox.y1 = 0.0;
                    nr_arena_shape_add_bboxes(shape,bbox);