[cairo] [PATCH 56/71] drm: replace use of _cairo_clip_to_boxes()

Enrico Weigelt, metux IT consult enrico.weigelt at gr13.net
Mon Apr 17 16:57:35 UTC 2017


_cairo_clip_to_boxes() doesnt exist anymore, but we also dont need to copy box lists at all.

Signed-off-by: Enrico Weigelt, metux IT consult <enrico.weigelt at gr13.net>
---
 src/drm/cairo-drm-i915-surface.c | 42 +++++++------------------------------
 src/drm/cairo-drm-i965-glyphs.c  | 10 ++++-----
 src/drm/cairo-drm-i965-surface.c | 45 ++++++----------------------------------
 3 files changed, 17 insertions(+), 80 deletions(-)

diff --git a/src/drm/cairo-drm-i915-surface.c b/src/drm/cairo-drm-i915-surface.c
index cebcb43a4..5d343d426 100644
--- a/src/drm/cairo-drm-i915-surface.c
+++ b/src/drm/cairo-drm-i915-surface.c
@@ -101,6 +101,7 @@
 
 #include "cairo-boxes-private.h"
 #include "cairo-cache-private.h"
+#include "cairo-clip-inline.h"
 #include "cairo-composite-rectangles-private.h"
 #include "cairo-default-context-private.h"
 #include "cairo-error-private.h"
@@ -1875,9 +1876,7 @@ i915_surface_fill_with_alpha (void			*abstract_dst,
     i915_surface_t *dst = _cairo_abstract_surface_cast_i915 (abstract_dst);
     cairo_composite_rectangles_t extents;
     composite_polygon_info_t info;
-    cairo_box_t boxes_stack[32], *clip_boxes = boxes_stack;
     cairo_clip_t *local_clip = NULL;
-    int num_boxes = ARRAY_LENGTH (boxes_stack);
     cairo_int_status_t status;
 
     status = _cairo_composite_rectangles_init_for_fill (&extents,
@@ -1906,20 +1905,13 @@ i915_surface_fill_with_alpha (void			*abstract_dst,
     if (clip != NULL)
 	clip = local_clip = _cairo_clip_copy (clip);
 
-    status = _cairo_clip_to_boxes (&clip, &extents, &clip_boxes, &num_boxes);
-    if (unlikely (status)) {
-	_cairo_clip_destroy (local_clip);
-
-	return status;
-    }
-
     assert (! _cairo_path_fixed_fill_is_empty (path));
 
     if (_cairo_path_fixed_fill_is_rectilinear (path)) {
 	cairo_boxes_t boxes;
 
 	_cairo_boxes_init (&boxes);
-	_cairo_boxes_limit (&boxes, clip_boxes, num_boxes);
+	_cairo_boxes_limit (&boxes, extents.clip->boxes, extents.clip->num_boxes);
 	status = (cairo_int_status_t)_cairo_path_fixed_fill_rectilinear_to_boxes (path,
 							      fill_rule,
 							      antialias,
@@ -1937,7 +1929,7 @@ i915_surface_fill_with_alpha (void			*abstract_dst,
 	    goto CLEANUP_BOXES;
     }
 
-    _cairo_polygon_init (&info.polygon, clip_boxes, num_boxes);
+    _cairo_polygon_init (&info.polygon, extents.clip->boxes, extents.clip->num_boxes);
 
     status = _cairo_path_fixed_fill_to_polygon (path, tolerance, &info.polygon);
     if (unlikely (status))
@@ -1968,9 +1960,6 @@ CLEANUP_POLYGON:
     _cairo_polygon_fini (&info.polygon);
 
 CLEANUP_BOXES:
-    if (clip_boxes != boxes_stack)
-	free (clip_boxes);
-
     _cairo_clip_destroy (local_clip);
 
     return status;
@@ -1988,9 +1977,6 @@ i915_surface_paint_with_alpha (void			*abstract_dst,
     cairo_composite_rectangles_t extents;
     cairo_clip_t *local_clip = NULL;
     cairo_clip_path_t *clip_path;
-    cairo_boxes_t boxes;
-    int num_boxes = ARRAY_LENGTH (boxes.boxes_embedded);
-    cairo_box_t *clip_boxes = boxes.boxes_embedded;
     cairo_status_t status;
 
     status = _cairo_composite_rectangles_init_for_paint (&extents,
@@ -2007,13 +1993,6 @@ i915_surface_paint_with_alpha (void			*abstract_dst,
     if (clip != NULL)
 	clip = local_clip = _cairo_clip_copy (clip);
 
-    status = _cairo_clip_to_boxes (&clip, &extents, &clip_boxes, &num_boxes);
-    if (unlikely (status)) {
-	_cairo_clip_destroy (local_clip);
-
-	return status;
-    }
-
     /* If the clip cannot be reduced to a set of boxes, we will need to
      * use a clipmask. Paint is special as it is the only operation that
      * does not implicitly use a mask, so we may be able to reduce this
@@ -2032,13 +2011,12 @@ i915_surface_paint_with_alpha (void			*abstract_dst,
     }
     else
     {
-	_cairo_boxes_init_for_array (&boxes, clip_boxes, num_boxes);
+	cairo_boxes_t boxes;
+	_cairo_boxes_init_for_array (&boxes, extents.clip->boxes, extents.clip->num_boxes);
 	status = _clip_and_composite_boxes (dst, op, source,
 					    &boxes, antialias,
 					    &extents, clip, opacity);
     }
-    if (clip_boxes != boxes.boxes_embedded)
-	free (clip_boxes);
 
     _cairo_clip_destroy (local_clip);
 
@@ -2212,8 +2190,6 @@ i915_surface_stroke (void			*abstract_dst,
     i915_surface_t *dst = abstract_dst;
     cairo_composite_rectangles_t extents;
     composite_polygon_info_t info;
-    cairo_box_t boxes_stack[32], *clip_boxes = boxes_stack;
-    int num_boxes = ARRAY_LENGTH (boxes_stack);
     cairo_clip_t *local_clip = NULL;
     cairo_int_status_t status;
 
@@ -2234,7 +2210,6 @@ i915_surface_stroke (void			*abstract_dst,
     if (clip != NULL)
 	clip = local_clip = _cairo_clip_copy (clip);
 
-    status = _cairo_clip_to_boxes (&clip, &extents, &clip_boxes, &num_boxes);
     if (unlikely (status)) {
 	_cairo_clip_destroy (local_clip);
 
@@ -2245,7 +2220,7 @@ i915_surface_stroke (void			*abstract_dst,
 	cairo_boxes_t boxes;
 
 	_cairo_boxes_init (&boxes);
-	_cairo_boxes_limit (&boxes, clip_boxes, num_boxes);
+	_cairo_boxes_limit (&boxes, extents.clip->boxes, extents.clip->num_boxes);
 	status = (cairo_int_status_t)_cairo_path_fixed_stroke_rectilinear_to_boxes (path,
 								stroke_style,
 								ctm,
@@ -2263,7 +2238,7 @@ i915_surface_stroke (void			*abstract_dst,
 	    goto CLEANUP_BOXES;
     }
 
-    _cairo_polygon_init (&info.polygon, clip_boxes, num_boxes);
+    _cairo_polygon_init (&info.polygon, extents.clip->boxes, extents.clip->num_boxes);
 
     status = _cairo_path_fixed_stroke_to_polygon (path,
 						  stroke_style,
@@ -2298,9 +2273,6 @@ CLEANUP_POLYGON:
     _cairo_polygon_fini (&info.polygon);
 
 CLEANUP_BOXES:
-    if (clip_boxes != boxes_stack)
-	free (clip_boxes);
-
     _cairo_clip_destroy (local_clip);
 
     return status;
diff --git a/src/drm/cairo-drm-i965-glyphs.c b/src/drm/cairo-drm-i965-glyphs.c
index 2ff338acb..f3ff1761c 100644
--- a/src/drm/cairo-drm-i965-glyphs.c
+++ b/src/drm/cairo-drm-i965-glyphs.c
@@ -165,13 +165,12 @@ i965_surface_mask_internal (i965_surface_t *dst,
     shader.mask.base.stride = mask->intel.drm.stride;
 
     if (clip != NULL) {
-	status = _cairo_clip_get_region (clip, &clip_region);
-	assert (status == CAIRO_STATUS_SUCCESS || status == CAIRO_INT_STATUS_UNSUPPORTED);
+	clip_region = _cairo_clip_get_region (clip);
 
 	if (clip_region != NULL && cairo_region_num_rectangles (clip_region) == 1)
 	    clip_region = NULL;
 
-	if (status == CAIRO_INT_STATUS_UNSUPPORTED)
+	if (clip_region == NULL)
 	    i965_shader_set_clip (&shader, clip);
     }
 
@@ -318,10 +317,9 @@ i965_surface_glyphs (void			*abstract_surface,
 	    return status;
 
 	if (clip != NULL) {
-	    status = _cairo_clip_get_region (clip, &clip_region);
-	    assert (status == CAIRO_STATUS_SUCCESS || status == CAIRO_INT_STATUS_UNSUPPORTED);
+	    clip_region = _cairo_clip_get_region (clip);
 
-	    if (status == CAIRO_INT_STATUS_UNSUPPORTED)
+	    if (clip_region == NULL)
 		i965_shader_set_clip (&glyphs.shader, clip);
 	}
     }
diff --git a/src/drm/cairo-drm-i965-surface.c b/src/drm/cairo-drm-i965-surface.c
index 5b9e136f0..5a84b37d2 100644
--- a/src/drm/cairo-drm-i965-surface.c
+++ b/src/drm/cairo-drm-i965-surface.c
@@ -988,7 +988,6 @@ _composite_boxes (i965_surface_t *dst,
 		  const cairo_clip_t *clip,
 		  const cairo_composite_rectangles_t *extents)
 {
-    cairo_region_t *clip_region = NULL;
     const struct _cairo_boxes_chunk *chunk;
     cairo_int_status_t status;
     i965_shader_t shader;
@@ -1011,7 +1010,7 @@ _composite_boxes (i965_surface_t *dst,
 	return status;
 
     if (clip != NULL) {
-	clip_region = _cairo_clip_get_region (clip);
+	cairo_region_t *clip_region = _cairo_clip_get_region (clip);
 	if (clip_region == NULL)
 	    i965_shader_set_clip (&shader, clip);
     }
@@ -1089,9 +1088,7 @@ i965_surface_paint (void			*abstract_dst,
     i965_surface_t *dst = cairo_abstract_surface_cast_i965(abstract_dst);
     cairo_composite_rectangles_t extents;
     cairo_boxes_t boxes;
-    cairo_box_t *clip_boxes = boxes.boxes_embedded;
     cairo_clip_t *local_clip = NULL;
-    int num_boxes = ARRAY_LENGTH (boxes.boxes_embedded);
     cairo_status_t status;
 
     /* XXX unsupported operators? use pixel shader blending, eventually */
@@ -1109,18 +1106,10 @@ i965_surface_paint (void			*abstract_dst,
     if (clip != NULL)
 	clip = local_clip = _cairo_clip_copy (clip);
 
-    status = _cairo_clip_to_boxes (&clip, &extents, &clip_boxes, &num_boxes);
-    if (unlikely (status)) {
-	_cairo_clip_destroy (local_clip);
-	return status;
-    }
-
-    _cairo_boxes_init_for_array (&boxes, clip_boxes, num_boxes);
+    _cairo_boxes_init_for_array (&boxes, extents.clip->boxes, extents.clip->num_boxes);
     status = _clip_and_composite_boxes (dst, op, source,
 					&boxes, CAIRO_ANTIALIAS_DEFAULT,
 					&extents, clip);
-    if (clip_boxes != boxes.boxes_embedded)
-	free (clip_boxes);
 
     _cairo_clip_destroy (local_clip);
 
@@ -1265,8 +1254,6 @@ i965_surface_stroke (void			*abstract_dst,
     i965_surface_t *dst = abstract_dst;
     cairo_composite_rectangles_t extents;
     composite_polygon_info_t info;
-    cairo_box_t boxes_stack[32], *clip_boxes = boxes_stack;
-    int num_boxes = ARRAY_LENGTH (boxes_stack);
     cairo_clip_t *local_clip = NULL;
     cairo_int_status_t status;
 
@@ -1284,17 +1271,11 @@ i965_surface_stroke (void			*abstract_dst,
     if (clip != NULL)
 	clip = local_clip = _cairo_clip_copy (clip);
 
-    status = _cairo_clip_to_boxes (&clip, &extents, &clip_boxes, &num_boxes);
-    if (unlikely (status)) {
-	_cairo_clip_destroy (local_clip);
-	return status;
-    }
-
     if (_cairo_path_fixed_stroke_is_rectilinear (path)) {
 	cairo_boxes_t boxes;
 
 	_cairo_boxes_init (&boxes);
-	_cairo_boxes_limit (&boxes, clip_boxes, num_boxes);
+	_cairo_boxes_limit (&boxes, extents.clip->boxes, extents.clip->num_boxes);
 	status = _cairo_path_fixed_stroke_rectilinear_to_boxes (path,
 								stroke_style,
 								ctm,
@@ -1312,7 +1293,7 @@ i965_surface_stroke (void			*abstract_dst,
 	    goto CLEANUP_BOXES;
     }
 
-    _cairo_polygon_init (&info.polygon, clip_boxes, num_boxes);
+    _cairo_polygon_init (&info.polygon, extents.clip->boxes, extents.clip->num_boxes);
 
     status = _cairo_path_fixed_stroke_to_polygon (path,
 						  stroke_style,
@@ -1345,9 +1326,6 @@ CLEANUP_POLYGON:
     _cairo_polygon_fini (&info.polygon);
 
 CLEANUP_BOXES:
-    if (clip_boxes != boxes_stack)
-	free (clip_boxes);
-
     _cairo_clip_destroy (local_clip);
 
     return status;
@@ -1366,9 +1344,7 @@ i965_surface_fill (void			*abstract_dst,
     i965_surface_t *dst = cairo_abstract_surface_cast_i965(abstract_dst);
     cairo_composite_rectangles_t extents;
     composite_polygon_info_t info;
-    cairo_box_t boxes_stack[32], *clip_boxes = boxes_stack;
     cairo_clip_t *local_clip = NULL;
-    int num_boxes = ARRAY_LENGTH (boxes_stack);
     cairo_int_status_t status;
 
     status = _cairo_composite_rectangles_init_for_fill (&extents,
@@ -1386,19 +1362,13 @@ i965_surface_fill (void			*abstract_dst,
     if (clip != NULL)
 	clip = local_clip = _cairo_clip_copy (clip);
 
-    status = _cairo_clip_to_boxes (&clip, &extents, &clip_boxes, &num_boxes);
-    if (unlikely (status)) {
-	_cairo_clip_destroy (local_clip);
-	return status;
-    }
-
     assert (! _cairo_path_fixed_fill_is_empty (path));
 
     if (_cairo_path_fixed_fill_is_rectilinear (path)) {
 	cairo_boxes_t boxes;
 
 	_cairo_boxes_init (&boxes);
-	_cairo_boxes_limit (&boxes, clip_boxes, num_boxes);
+	_cairo_boxes_limit (&boxes, extents.clip->boxes, extents.clip->num_boxes);
 	status = _cairo_path_fixed_fill_rectilinear_to_boxes (path,
 							      fill_rule,
 							      antialias,
@@ -1415,7 +1385,7 @@ i965_surface_fill (void			*abstract_dst,
 	    goto CLEANUP_BOXES;
     }
 
-    _cairo_polygon_init (&info.polygon, clip_boxes, num_boxes);
+    _cairo_polygon_init (&info.polygon, extents.clip->boxes, extents.clip->num_boxes);
 
     status = _cairo_path_fixed_fill_to_polygon (path, tolerance, &info.polygon);
     if (unlikely (status))
@@ -1444,9 +1414,6 @@ CLEANUP_POLYGON:
     _cairo_polygon_fini (&info.polygon);
 
 CLEANUP_BOXES:
-    if (clip_boxes != boxes_stack)
-	free (clip_boxes);
-
     _cairo_clip_destroy (local_clip);
 
     return status;
-- 
2.11.0.rc0.7.gbe5a750



More information about the cairo mailing list