[cairo] [PATCH 33/36] drm: replace use of _cairo_clip_to_boxes()
Enrico Weigelt, metux IT consult
enrico.weigelt at gr13.net
Sat Dec 12 10:52:01 PST 2015
_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 | 37 +++++++--------------------------
src/drm/cairo-drm-i965-glyphs.c | 10 ++++-----
src/drm/cairo-drm-i965-surface.c | 45 ++++++----------------------------------
3 files changed, 18 insertions(+), 74 deletions(-)
diff --git a/src/drm/cairo-drm-i915-surface.c b/src/drm/cairo-drm-i915-surface.c
index 9d07bcb..3f62e9e 100644
--- a/src/drm/cairo-drm-i915-surface.c
+++ b/src/drm/cairo-drm-i915-surface.c
@@ -102,6 +102,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"
@@ -1877,9 +1878,7 @@ i915_surface_fill_with_alpha (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;
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,
@@ -1908,7 +1907,6 @@ 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);
@@ -1921,7 +1919,7 @@ i915_surface_fill_with_alpha (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);
cairo_status_t stat = _cairo_path_fixed_fill_rectilinear_to_boxes (path,
fill_rule,
CAIRO_ANTIALIAS_DEFAULT,
@@ -1939,7 +1937,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))
@@ -1970,9 +1968,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;
@@ -1989,9 +1984,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,
@@ -2008,13 +2000,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
@@ -2033,13 +2018,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, CAIRO_ANTIALIAS_DEFAULT,
&extents, clip, opacity);
}
- if (clip_boxes != boxes.boxes_embedded)
- free (clip_boxes);
_cairo_clip_destroy (local_clip);
@@ -2213,8 +2197,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;
@@ -2235,7 +2217,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);
@@ -2246,12 +2227,13 @@ 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);
cairo_status_t stat = _cairo_path_fixed_stroke_rectilinear_to_boxes (path,
stroke_style,
ctm,
CAIRO_ANTIALIAS_DEFAULT,
&boxes);
+
if (likely (stat == CAIRO_STATUS_SUCCESS)) {
status = _clip_and_composite_boxes (dst, op, source,
&boxes, antialias,
@@ -2264,7 +2246,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,
@@ -2299,9 +2281,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 fd54cd4..5b4e1fa 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 7a01b9d..9d465a1 100644
--- a/src/drm/cairo-drm-i965-surface.c
+++ b/src/drm/cairo-drm-i965-surface.c
@@ -989,7 +989,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;
@@ -1012,7 +1011,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);
}
@@ -1090,9 +1089,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 */
@@ -1110,18 +1107,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);
@@ -1266,8 +1255,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;
@@ -1285,17 +1272,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,
@@ -1313,7 +1294,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,
@@ -1346,9 +1327,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;
@@ -1367,9 +1345,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,
@@ -1387,19 +1363,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,
@@ -1416,7 +1386,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))
@@ -1445,9 +1415,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.6.4.442.g545299f
More information about the cairo
mailing list