[cairo-commit] 5 commits - src/cairo-botor-scan-converter.c src/cairo-box-inline.h src/cairo-boxes-private.h src/cairo-boxes.c src/cairo-clip-boxes.c src/cairo-line.c src/cairo-polygon-intersect.c src/cairo-polygon-reduce.c src/cairo-qt-surface.cpp

Uli Schlachter psychon at kemper.freedesktop.org
Sat Jul 2 11:43:47 UTC 2016


 src/cairo-botor-scan-converter.c |    2 -
 src/cairo-box-inline.h           |   10 ++++++
 src/cairo-boxes-private.h        |    3 -
 src/cairo-boxes.c                |    5 ---
 src/cairo-clip-boxes.c           |   61 +++++++++++++++++++++++----------------
 src/cairo-line.c                 |    8 ++---
 src/cairo-polygon-intersect.c    |    2 -
 src/cairo-polygon-reduce.c       |    2 -
 src/cairo-qt-surface.cpp         |    2 -
 9 files changed, 56 insertions(+), 39 deletions(-)

New commits:
commit 97d8b2b7de5084cafa282630f5b1147c4ef05cb8
Author: Enrico Weigelt, metux IT consult <enrico.weigelt at gr13.net>
Date:   Thu Jun 30 17:46:39 2016 +0200

    qt: replaced calls to _cairo_clip_init_copy() by _cairo_clip_copy()
    
    _cairo_clip_init_copy() was removed with commit b132fae5e843c329d1414d1a65b2e8d66b99852f,
    but a few calls were still remaining.
    
    Signed-off-by: Enrico Weigelt, metux IT consult <enrico.weigelt at gr13.net>
    Signed-off-by: Uli Schlachter <psychon at znc.in>

diff --git a/src/cairo-qt-surface.cpp b/src/cairo-qt-surface.cpp
index 7ddad77..25c60a8 100644
--- a/src/cairo-qt-surface.cpp
+++ b/src/cairo-qt-surface.cpp
@@ -1216,7 +1216,7 @@ _cairo_qt_fast_fill (cairo_qt_surface_t *qs,
 
 	cairo_clip_t clip, old_clip = qs->clipper.clip;
 
-	_cairo_clip_init_copy (&clip, &qs->clipper.clip);
+	qs->clipper.clip = _cairo_clip_copy (&clip);
 	status = (cairo_int_status_t) _cairo_clip_clip (&clip,
 							path,
 							fill_rule,
commit f212db2fccfa3825d6a4dc55d5077e5fb756d50b
Author: Enrico Weigelt, metux IT consult <enrico.weigelt at gr13.net>
Date:   Thu Jun 30 17:45:45 2016 +0200

    core: fixed code duplication
    
    We have two places where copying from box set to clip is
    implemented in the same way. Just move that to one function.
    
    Signed-off-by: Enrico Weigelt, metux IT consult <enrico.weigelt at gr13.net>
    Signed-off-by: Uli Schlachter <psychon at znc.in>

diff --git a/src/cairo-clip-boxes.c b/src/cairo-clip-boxes.c
index 6e4b50d..1d33cc8 100644
--- a/src/cairo-clip-boxes.c
+++ b/src/cairo-clip-boxes.c
@@ -264,6 +264,35 @@ _cairo_clip_intersect_box (cairo_clip_t *clip,
     return _cairo_clip_intersect_rectangle_box (clip, &r, box);
 }
 
+/**
+ * copy a box set to an clip
+ *
+ * @param	box	the box set to copy from
+ * @param	clip	the clip to copy to (return buffer)
+ * @result		zero if the allocation failed - the clip will be set to all-clipped
+ *			otherwise non-zero
+ */
+static cairo_bool_t
+_cairo_boxes_copy_to_clip (const cairo_boxes_t *boxes, cairo_clip_t *clip)
+{
+    /* XXX cow-boxes? */
+    if (boxes->num_boxes == 1) {
+	clip->boxes = &clip->embedded_box;
+	clip->boxes[0] = boxes->chunks.base[0];
+	clip->num_boxes = 1;
+	return TRUE;
+    }
+
+    clip->boxes = _cairo_boxes_to_array (boxes, &clip->num_boxes);
+    if (unlikely (clip->boxes == NULL))
+    {
+	_cairo_clip_set_all_clipped (clip);
+	return FALSE;
+    }
+
+    return TRUE;
+}
+
 cairo_clip_t *
 _cairo_clip_intersect_boxes (cairo_clip_t *clip,
 			     const cairo_boxes_t *boxes)
@@ -301,13 +330,10 @@ _cairo_clip_intersect_boxes (cairo_clip_t *clip,
     if (boxes->num_boxes == 0) {
 	clip = _cairo_clip_set_all_clipped (clip);
 	goto out;
-    } else if (boxes->num_boxes == 1) {
-	clip->boxes = &clip->embedded_box;
-	clip->boxes[0] = boxes->chunks.base[0];
-	clip->num_boxes = 1;
-    } else {
-	clip->boxes = _cairo_boxes_to_array (boxes, &clip->num_boxes);
     }
+
+    _cairo_boxes_copy_to_clip (boxes, clip);
+
     _cairo_boxes_extents (boxes, &limits);
 
     _cairo_box_round_to_rectangle (&limits, &extents);
@@ -574,16 +600,8 @@ _cairo_clip_from_boxes (const cairo_boxes_t *boxes)
     if (clip == NULL)
 	return _cairo_clip_set_all_clipped (clip);
 
-    /* XXX cow-boxes? */
-    if(boxes->num_boxes == 1) {
-	clip->boxes = &clip->embedded_box;
-	clip->boxes[0] = boxes->chunks.base[0];
-	clip->num_boxes = 1;
-    } else {
-	clip->boxes = _cairo_boxes_to_array (boxes, &clip->num_boxes);
-	if (clip->boxes == NULL)
-	    return _cairo_clip_set_all_clipped (clip);
-    }
+    if (unlikely (! _cairo_boxes_copy_to_clip (boxes, clip)))
+	return clip;
 
     _cairo_boxes_extents (boxes, &extents);
     _cairo_box_round_to_rectangle (&extents, &clip->extents);
commit 5bb43c92b3b35e9df8bdb8b14997e98c4a05d917
Author: Enrico Weigelt, metux IT consult <enrico.weigelt at gr13.net>
Date:   Thu Jun 30 17:45:44 2016 +0200

    core: dropped actually unused parameter of _cairo_boxes_to_array()
    
    When parameter force_allocation is false *and* the box set has
    exactly one chunk, this chunk is returned directly - w/o copying it.
    
    That mode is never used, and it's highly problematic as it's unclear
    whether we have to free the returnd object or it's still owned
    by somebody else.
    
    Just dropping the useless parameter / corner case to make the function
    simpler and more robust.
    
    Signed-off-by: Enrico Weigelt, metux IT consult <enrico.weigelt at gr13.net>
    Signed-off-by: Uli Schlachter <psychon at znc.in>

diff --git a/src/cairo-boxes-private.h b/src/cairo-boxes-private.h
index d1f9dfc..fd622ae 100644
--- a/src/cairo-boxes-private.h
+++ b/src/cairo-boxes-private.h
@@ -92,8 +92,7 @@ _cairo_boxes_extents (const cairo_boxes_t *boxes,
 
 cairo_private cairo_box_t *
 _cairo_boxes_to_array (const cairo_boxes_t *boxes,
-		       int *num_boxes,
-		       cairo_bool_t force_allocation);
+		       int *num_boxes);
 
 cairo_private cairo_status_t
 _cairo_boxes_intersect (const cairo_boxes_t *a,
diff --git a/src/cairo-boxes.c b/src/cairo-boxes.c
index db002ef..6ddf81a 100644
--- a/src/cairo-boxes.c
+++ b/src/cairo-boxes.c
@@ -345,16 +345,13 @@ _cairo_boxes_clear (cairo_boxes_t *boxes)
  * */
 cairo_box_t *
 _cairo_boxes_to_array (const cairo_boxes_t *boxes,
-		       int *num_boxes,
-		       cairo_bool_t force_allocation)
+		       int *num_boxes)
 {
     const struct _cairo_boxes_chunk *chunk;
     cairo_box_t *box;
     int i, j;
 
     *num_boxes = boxes->num_boxes;
-    if (boxes->chunks.next == NULL && ! force_allocation)
-	    return boxes->chunks.base;
 
     box = _cairo_malloc_ab (boxes->num_boxes, sizeof (cairo_box_t));
     if (box == NULL) {
diff --git a/src/cairo-clip-boxes.c b/src/cairo-clip-boxes.c
index f9ccfcb..6e4b50d 100644
--- a/src/cairo-clip-boxes.c
+++ b/src/cairo-clip-boxes.c
@@ -306,7 +306,7 @@ _cairo_clip_intersect_boxes (cairo_clip_t *clip,
 	clip->boxes[0] = boxes->chunks.base[0];
 	clip->num_boxes = 1;
     } else {
-	clip->boxes = _cairo_boxes_to_array (boxes, &clip->num_boxes, TRUE);
+	clip->boxes = _cairo_boxes_to_array (boxes, &clip->num_boxes);
     }
     _cairo_boxes_extents (boxes, &limits);
 
@@ -580,7 +580,7 @@ _cairo_clip_from_boxes (const cairo_boxes_t *boxes)
 	clip->boxes[0] = boxes->chunks.base[0];
 	clip->num_boxes = 1;
     } else {
-	clip->boxes = _cairo_boxes_to_array (boxes, &clip->num_boxes, TRUE);
+	clip->boxes = _cairo_boxes_to_array (boxes, &clip->num_boxes);
 	if (clip->boxes == NULL)
 	    return _cairo_clip_set_all_clipped (clip);
     }
commit b23c2291d8fdebd417697d5b70f31226632e3a1e
Author: Enrico Weigelt, metux IT consult <enrico.weigelt at gr13.net>
Date:   Thu Jun 30 17:45:43 2016 +0200

    core: helper inline for rect->box conversion
    
    Signed-off-by: Enrico Weigelt, metux IT consult <enrico.weigelt at gr13.net>
    Signed-off-by: Uli Schlachter <psychon at znc.in>

diff --git a/src/cairo-box-inline.h b/src/cairo-box-inline.h
index d6b9941..59e5a0d 100644
--- a/src/cairo-box-inline.h
+++ b/src/cairo-box-inline.h
@@ -57,6 +57,16 @@ _cairo_box_from_integers (cairo_box_t *box, int x, int y, int w, int h)
     box->p2.y = _cairo_fixed_from_int (y + h);
 }
 
+static inline void
+_cairo_box_from_rectangle_int (cairo_box_t *box,
+			       const cairo_rectangle_int_t *rect)
+{
+    box->p1.x = _cairo_fixed_from_int (rect->x);
+    box->p1.y = _cairo_fixed_from_int (rect->y);
+    box->p2.x = _cairo_fixed_from_int (rect->x + rect->width);
+    box->p2.y = _cairo_fixed_from_int (rect->y + rect->height);
+}
+
 /* assumes box->p1 is top-left, p2 bottom-right */
 static inline void
 _cairo_box_add_point (cairo_box_t *box,
diff --git a/src/cairo-clip-boxes.c b/src/cairo-clip-boxes.c
index 7bcbeb1..f9ccfcb 100644
--- a/src/cairo-clip-boxes.c
+++ b/src/cairo-clip-boxes.c
@@ -119,11 +119,7 @@ _cairo_clip_contains_rectangle (const cairo_clip_t *clip,
 {
     cairo_box_t box;
 
-    box.p1.x = _cairo_fixed_from_int (rect->x);
-    box.p1.y = _cairo_fixed_from_int (rect->y);
-    box.p2.x = _cairo_fixed_from_int (rect->x + rect->width);
-    box.p2.y = _cairo_fixed_from_int (rect->y + rect->height);
-
+    _cairo_box_from_rectangle_int (&box, rect);
     return _cairo_clip_contains_rectangle_box (clip, rect, &box);
 }
 
@@ -347,10 +343,7 @@ _cairo_clip_intersect_rectangle (cairo_clip_t       *clip,
     if (r->width == 0 || r->height == 0)
 	return _cairo_clip_set_all_clipped (clip);
 
-    box.p1.x = _cairo_fixed_from_int (r->x);
-    box.p1.y = _cairo_fixed_from_int (r->y);
-    box.p2.x = _cairo_fixed_from_int (r->x + r->width);
-    box.p2.y = _cairo_fixed_from_int (r->y + r->height);
+    _cairo_box_from_rectangle_int (&box, r);
 
     return _cairo_clip_intersect_rectangle_box (clip, r, &box);
 }
commit ae403448af410984852aeff76278dc96e7141b9e
Author: Enrico Weigelt, metux IT consult <enrico.weigelt at gr13.net>
Date:   Thu Jun 30 17:45:42 2016 +0200

    core: fix compiler warnings
    
    The code correct, but the compiler can't check that and thinks
    there're uninitialized variables.
    
    Perhaps we could rewrite it in a better way, so the compiler
    can do better (even arch specific) optimizations.
    
    Signed-off-by: Enrico Weigelt, metux IT consult <enrico.weigelt at gr13.net>
    Signed-off-by: Uli Schlachter <psychon at znc.in>

diff --git a/src/cairo-botor-scan-converter.c b/src/cairo-botor-scan-converter.c
index e23aefe..64883a6 100644
--- a/src/cairo-botor-scan-converter.c
+++ b/src/cairo-botor-scan-converter.c
@@ -456,7 +456,7 @@ edges_compare_x_for_y (const cairo_edge_t *a,
        HAVE_BX      = 0x2,
        HAVE_BOTH    = HAVE_AX | HAVE_BX
     } have_ax_bx = HAVE_BOTH;
-    int32_t ax, bx;
+    int32_t ax = 0, bx = 0;
 
     /* XXX given we have x and dx? */
 
diff --git a/src/cairo-line.c b/src/cairo-line.c
index cb13927..dc00a9c 100644
--- a/src/cairo-line.c
+++ b/src/cairo-line.c
@@ -110,9 +110,9 @@ lines_compare_x_for_y_general (const cairo_line_t *a,
      * should prevent that before the tessellation algorithm
      * begins.
      */
-    int32_t dx;
-    int32_t adx, ady;
-    int32_t bdx, bdy;
+    int32_t dx = 0;
+    int32_t adx = 0, ady = 0;
+    int32_t bdx = 0, bdy = 0;
     enum {
        HAVE_NONE    = 0x0,
        HAVE_DX      = 0x1,
@@ -218,7 +218,7 @@ lines_compare_x_for_y (const cairo_line_t *a,
        HAVE_BX      = 0x2,
        HAVE_BOTH    = HAVE_AX | HAVE_BX
     } have_ax_bx = HAVE_BOTH;
-    int32_t ax, bx;
+    int32_t ax = 0, bx = 0;
 
     if (y == a->p1.y)
 	ax = a->p1.x;
diff --git a/src/cairo-polygon-intersect.c b/src/cairo-polygon-intersect.c
index 8cb8fb1..9c1777f 100644
--- a/src/cairo-polygon-intersect.c
+++ b/src/cairo-polygon-intersect.c
@@ -447,7 +447,7 @@ edges_compare_x_for_y (const cairo_bo_edge_t *a,
        HAVE_BX      = 0x2,
        HAVE_BOTH    = HAVE_AX | HAVE_BX
     } have_ax_bx = HAVE_BOTH;
-    int32_t ax, bx;
+    int32_t ax = 0, bx = 0;
 
     if (y == a->edge.line.p1.y)
 	ax = a->edge.line.p1.x;
diff --git a/src/cairo-polygon-reduce.c b/src/cairo-polygon-reduce.c
index ea457fe..da6c9ab 100644
--- a/src/cairo-polygon-reduce.c
+++ b/src/cairo-polygon-reduce.c
@@ -445,7 +445,7 @@ edges_compare_x_for_y (const cairo_bo_edge_t *a,
        HAVE_BX      = 0x2,
        HAVE_BOTH    = HAVE_AX | HAVE_BX
     } have_ax_bx = HAVE_BOTH;
-    int32_t ax, bx;
+    int32_t ax = 0, bx = 0;
 
     if (y == a->edge.line.p1.y)
 	ax = a->edge.line.p1.x;


More information about the cairo-commit mailing list