[cairo] [PATCH 40/43] drm: fixed _cairo_clip_*() calls
Enrico Weigelt, metux IT consult
enrico.weigelt at gr13.net
Tue Dec 15 11:50:20 PST 2015
With commit b132fae5e843c329d1414d1a65b2e8d66b99852f, the memory
handling of clip objects has changed - they're now managed in an
object pool. Therefore consumers need to be updated.
Signed-off-by: Enrico Weigelt, metux IT consult <enrico.weigelt at gr13.net>
---
src/drm/cairo-drm-i915-glyphs.c | 19 +++-----
src/drm/cairo-drm-i915-spans.c | 3 +-
src/drm/cairo-drm-i915-surface.c | 64 +++++++++------------------
src/drm/cairo-drm-i965-glyphs.c | 17 +++----
src/drm/cairo-drm-i965-surface.c | 95 ++++++++++++----------------------------
5 files changed, 59 insertions(+), 139 deletions(-)
diff --git a/src/drm/cairo-drm-i915-glyphs.c b/src/drm/cairo-drm-i915-glyphs.c
index 6c9a77a..74d0413 100644
--- a/src/drm/cairo-drm-i915-glyphs.c
+++ b/src/drm/cairo-drm-i915-glyphs.c
@@ -303,8 +303,7 @@ i915_surface_glyphs (void *abstract_surface,
i915_device_t *device;
i915_shader_t shader;
cairo_composite_rectangles_t extents;
- cairo_clip_t local_clip;
- cairo_bool_t have_clip = FALSE;
+ cairo_clip_t *local_clip = NULL;
cairo_bool_t overlap;
cairo_region_t *clip_region = NULL;
intel_bo_t *last_bo = NULL;
@@ -327,21 +326,14 @@ i915_surface_glyphs (void *abstract_surface,
if (_cairo_clip_contains_rectangle (clip, &extents.mask))
clip = NULL;
- if (clip != NULL && extents.is_bounded) {
- clip = _cairo_clip_init_copy (&local_clip, clip);
- status = _cairo_clip_rectangle (clip, &extents.bounded);
- if (unlikely (status))
- return status;
-
- have_clip = TRUE;
- }
+ if (clip != NULL && extents.is_bounded)
+ clip = local_clip = _cairo_clip_copy_intersect_rectangle (clip, &extents.bounded);
if (clip != NULL) {
clip_region = _cairo_clip_get_region (clip);
if (unlikely (clip_region == NULL))
{
- if (have_clip)
- _cairo_clip_fini (&local_clip);
+ _cairo_clip_destroy (local_clip);
return CAIRO_INT_STATUS_NOTHING_TO_DO;
}
}
@@ -578,8 +570,7 @@ i915_surface_glyphs (void *abstract_surface,
cairo_surface_destroy (&mask->intel.drm.base);
}
- if (have_clip)
- _cairo_clip_fini (&local_clip);
+ _cairo_clip_destroy (local_clip);
return status;
}
diff --git a/src/drm/cairo-drm-i915-spans.c b/src/drm/cairo-drm-i915-spans.c
index 1f979e8..8753f8a 100644
--- a/src/drm/cairo-drm-i915-spans.c
+++ b/src/drm/cairo-drm-i915-spans.c
@@ -615,13 +615,12 @@ i915_spans_init (i915_spans_t *spans,
cairo_region_t *clip_region = NULL;
clip_region = _cairo_clip_get_region (clip);
- assert (status == CAIRO_STATUS_SUCCESS || status == CAIRO_INT_STATUS_UNSUPPORTED);
if (clip_region != NULL && cairo_region_num_rectangles (clip_region) == 1)
clip_region = NULL;
spans->clip_region = clip_region;
- spans->need_clip_surface = status == CAIRO_INT_STATUS_UNSUPPORTED;
+ spans->need_clip_surface = (clip_region == NULL);
}
spans->head.next = NULL;
diff --git a/src/drm/cairo-drm-i915-surface.c b/src/drm/cairo-drm-i915-surface.c
index c09eeed..9d07bcb 100644
--- a/src/drm/cairo-drm-i915-surface.c
+++ b/src/drm/cairo-drm-i915-surface.c
@@ -112,6 +112,7 @@
#include "cairo-surface-offset-private.h"
#include "cairo-image-surface-private.h"
#include "cairo-box-inline.h"
+#include "cairo-clip-inline.h"
#include <sys/ioctl.h>
#include <sys/mman.h>
@@ -1877,8 +1878,7 @@ i915_surface_fill_with_alpha (void *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;
- cairo_bool_t have_clip = FALSE;
+ cairo_clip_t *local_clip = NULL;
int num_boxes = ARRAY_LENGTH (boxes_stack);
cairo_int_status_t status;
@@ -1905,15 +1905,12 @@ i915_surface_fill_with_alpha (void *abstract_dst,
}
}
- if (clip != NULL) {
- clip = _cairo_clip_init_copy (&local_clip, clip);
- have_clip = TRUE;
- }
+ if (clip != NULL)
+ clip = local_clip = _cairo_clip_copy (clip);
status = _cairo_clip_to_boxes (&clip, &extents, &clip_boxes, &num_boxes);
if (unlikely (status)) {
- if (have_clip)
- _cairo_clip_fini (&local_clip);
+ _cairo_clip_destroy (local_clip);
return status;
}
@@ -1976,8 +1973,7 @@ CLEANUP_BOXES:
if (clip_boxes != boxes_stack)
free (clip_boxes);
- if (have_clip)
- _cairo_clip_fini (&local_clip);
+ _cairo_clip_destroy (local_clip);
return status;
}
@@ -1991,8 +1987,7 @@ i915_surface_paint_with_alpha (void *abstract_dst,
{
i915_surface_t *dst = abstract_dst;
cairo_composite_rectangles_t extents;
- cairo_clip_t local_clip;
- cairo_bool_t have_clip = FALSE;
+ cairo_clip_t *local_clip = NULL;
cairo_clip_path_t *clip_path;
cairo_boxes_t boxes;
int num_boxes = ARRAY_LENGTH (boxes.boxes_embedded);
@@ -2010,15 +2005,12 @@ i915_surface_paint_with_alpha (void *abstract_dst,
if (_cairo_clip_contains_extents (clip, &extents))
clip = NULL;
- if (clip != NULL) {
- clip = _cairo_clip_init_copy (&local_clip, clip);
- have_clip = TRUE;
- }
+ if (clip != NULL)
+ clip = local_clip = _cairo_clip_copy (clip);
status = _cairo_clip_to_boxes (&clip, &extents, &clip_boxes, &num_boxes);
if (unlikely (status)) {
- if (have_clip)
- _cairo_clip_fini (&local_clip);
+ _cairo_clip_destroy (local_clip);
return status;
}
@@ -2049,8 +2041,7 @@ i915_surface_paint_with_alpha (void *abstract_dst,
if (clip_boxes != boxes.boxes_embedded)
free (clip_boxes);
- if (have_clip)
- _cairo_clip_fini (&local_clip);
+ _cairo_clip_destroy (local_clip);
return status;
}
@@ -2084,10 +2075,9 @@ i915_surface_mask (void *abstract_dst,
i915_device_t *device;
cairo_composite_rectangles_t extents;
i915_shader_t shader;
- cairo_clip_t local_clip;
+ cairo_clip_t *local_clip = NULL;
cairo_region_t *clip_region = NULL;
cairo_bool_t need_clip_surface = FALSE;
- cairo_bool_t have_clip = FALSE;
cairo_int_status_t status;
if (mask->type == CAIRO_PATTERN_TYPE_SOLID) {
@@ -2107,16 +2097,8 @@ i915_surface_mask (void *abstract_dst,
if (_cairo_clip_contains_extents (clip, &extents))
clip = NULL;
- if (clip != NULL && extents.is_bounded) {
- clip = _cairo_clip_init_copy (&local_clip, clip);
- status = _cairo_clip_rectangle (clip, &extents.bounded);
- if (unlikely (status)) {
- _cairo_clip_fini (&local_clip);
- return status;
- }
-
- have_clip = TRUE;
- }
+ if (clip != NULL && extents.is_bounded)
+ clip = local_clip = _cairo_clip_copy_intersect_rectangle (clip, &extents.bounded);
i915_shader_init (&shader, dst, op, 1.);
@@ -2211,8 +2193,7 @@ i915_surface_mask (void *abstract_dst,
cairo_device_release (&device->intel.base.base);
err_shader:
i915_shader_fini (&shader);
- if (have_clip)
- _cairo_clip_fini (&local_clip);
+ _cairo_clip_destroy (local_clip);
return status;
}
@@ -2234,8 +2215,7 @@ i915_surface_stroke (void *abstract_dst,
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;
- cairo_bool_t have_clip = FALSE;
+ cairo_clip_t *local_clip = NULL;
cairo_int_status_t status;
status = _cairo_composite_rectangles_init_for_stroke (&extents,
@@ -2252,15 +2232,12 @@ i915_surface_stroke (void *abstract_dst,
if (_cairo_clip_contains_extents (clip, &extents))
clip = NULL;
- if (clip != NULL) {
- clip = _cairo_clip_init_copy (&local_clip, clip);
- have_clip = TRUE;
- }
+ if (clip != NULL)
+ clip = local_clip = _cairo_clip_copy (clip);
status = _cairo_clip_to_boxes (&clip, &extents, &clip_boxes, &num_boxes);
if (unlikely (status)) {
- if (have_clip)
- _cairo_clip_fini (&local_clip);
+ _cairo_clip_destroy (local_clip);
return status;
}
@@ -2325,8 +2302,7 @@ CLEANUP_BOXES:
if (clip_boxes != boxes_stack)
free (clip_boxes);
- if (have_clip)
- _cairo_clip_fini (&local_clip);
+ _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 80cc3be..fd54cd4 100644
--- a/src/drm/cairo-drm-i965-glyphs.c
+++ b/src/drm/cairo-drm-i965-glyphs.c
@@ -39,6 +39,7 @@
#include "cairo-drm-i965-private.h"
#include "cairo-error-private.h"
#include "cairo-rtree-private.h"
+#include "cairo-clip-inline.h"
typedef struct _i965_glyphs i965_glyphs_t;
@@ -245,8 +246,7 @@ i965_surface_glyphs (void *abstract_surface,
i965_device_t *device;
i965_glyphs_t glyphs;
cairo_composite_rectangles_t extents;
- cairo_clip_t local_clip;
- cairo_bool_t have_clip = FALSE;
+ cairo_clip_t *local_clip;
cairo_bool_t overlap;
cairo_region_t *clip_region = NULL;
intel_bo_t *last_bo = NULL;
@@ -268,14 +268,8 @@ i965_surface_glyphs (void *abstract_surface,
if (clip != NULL && _cairo_clip_contains_rectangle (clip, &extents.mask))
clip = NULL;
- if (clip != NULL && extents.is_bounded) {
- clip = _cairo_clip_init_copy (&local_clip, clip);
- status = _cairo_clip_rectangle (clip, &extents.bounded);
- if (unlikely (status))
- return status;
-
- have_clip = TRUE;
- }
+ if (clip != NULL && extents.is_bounded)
+ clip = local_clip = _cairo_clip_copy_intersect_rectangle (clip, &extents.bounded);
if (overlap || ! extents.is_bounded) {
cairo_format_t format;
@@ -518,8 +512,7 @@ i965_surface_glyphs (void *abstract_surface,
cairo_surface_destroy (&mask->intel.drm.base);
}
- if (have_clip)
- _cairo_clip_fini (&local_clip);
+ _cairo_clip_destroy (local_clip);
return status;
}
diff --git a/src/drm/cairo-drm-i965-surface.c b/src/drm/cairo-drm-i965-surface.c
index 92e20ae..3d754e9 100644
--- a/src/drm/cairo-drm-i965-surface.c
+++ b/src/drm/cairo-drm-i965-surface.c
@@ -60,6 +60,7 @@
#include "cairo-error-private.h"
#include "cairo-region-private.h"
#include "cairo-surface-offset-private.h"
+#include "cairo-clip-inline.h"
#include <sys/ioctl.h>
#include <errno.h>
@@ -766,13 +767,8 @@ i965_fixup_unbounded (i965_surface_t *dst,
i965_shader_init (&shader, dst, CAIRO_OPERATOR_CLEAR);
if (clip != NULL) {
- cairo_region_t *clip_region = NULL;
-
- status = _cairo_clip_get_region (clip, &clip_region);
- assert (status == CAIRO_STATUS_SUCCESS || CAIRO_INT_STATUS_UNSUPPORTED);
- assert (clip_region == NULL);
-
- if (status == CAIRO_INT_STATUS_UNSUPPORTED)
+ cairo_region_t *clip_region = _cairo_clip_get_region (clip);
+ if (clip_region == NULL)
i965_shader_set_clip (&shader, clip);
} else {
if (extents->bounded.width == extents->unbounded.width &&
@@ -889,9 +885,8 @@ i965_fixup_unbounded_boxes (i965_surface_t *dst,
i965_shader_init (&shader, dst, CAIRO_OPERATOR_CLEAR);
if (clip != NULL) {
- status = _cairo_clip_get_region (clip, &clip_region);
- assert (status == CAIRO_STATUS_SUCCESS || CAIRO_INT_STATUS_UNSUPPORTED);
- if (status == CAIRO_INT_STATUS_UNSUPPORTED)
+ clip_region = _cairo_clip_get_region (clip);
+ if (clip_region == NULL)
i965_shader_set_clip (&shader, clip);
}
@@ -994,7 +989,6 @@ _composite_boxes (i965_surface_t *dst,
const cairo_clip_t *clip,
const cairo_composite_rectangles_t *extents)
{
- cairo_bool_t need_clip_surface = FALSE;
cairo_region_t *clip_region = NULL;
const struct _cairo_boxes_chunk *chunk;
cairo_int_status_t status;
@@ -1018,10 +1012,8 @@ _composite_boxes (i965_surface_t *dst,
return status;
if (clip != NULL) {
- status = _cairo_clip_get_region (clip, &clip_region);
- assert (status == CAIRO_STATUS_SUCCESS || CAIRO_INT_STATUS_UNSUPPORTED);
- need_clip_surface = status == CAIRO_INT_STATUS_UNSUPPORTED;
- if (need_clip_surface)
+ clip_region = _cairo_clip_get_region (clip);
+ if (clip_region == NULL)
i965_shader_set_clip (&shader, clip);
}
@@ -1099,8 +1091,7 @@ i965_surface_paint (void *abstract_dst,
cairo_composite_rectangles_t extents;
cairo_boxes_t boxes;
cairo_box_t *clip_boxes = boxes.boxes_embedded;
- cairo_clip_t local_clip;
- cairo_bool_t have_clip = FALSE;
+ cairo_clip_t *local_clip = NULL;
int num_boxes = ARRAY_LENGTH (boxes.boxes_embedded);
cairo_status_t status;
@@ -1116,16 +1107,12 @@ i965_surface_paint (void *abstract_dst,
if (clip != NULL && _cairo_clip_contains_extents (clip, &extents))
clip = NULL;
- if (clip != NULL) {
- clip = _cairo_clip_init_copy (&local_clip, clip);
- have_clip = TRUE;
- }
+ if (clip != NULL)
+ clip = local_clip = _cairo_clip_copy (clip);
status = _cairo_clip_to_boxes (&clip, &extents, &clip_boxes, &num_boxes);
if (unlikely (status)) {
- if (have_clip)
- _cairo_clip_fini (&local_clip);
-
+ _cairo_clip_destroy (local_clip);
return status;
}
@@ -1136,8 +1123,7 @@ i965_surface_paint (void *abstract_dst,
if (clip_boxes != boxes.boxes_embedded)
free (clip_boxes);
- if (have_clip)
- _cairo_clip_fini (&local_clip);
+ _cairo_clip_destroy (local_clip);
return status;
}
@@ -1153,10 +1139,8 @@ i965_surface_mask (void *abstract_dst,
cairo_composite_rectangles_t extents;
i965_shader_t shader;
i965_device_t *device;
- cairo_clip_t local_clip;
+ cairo_clip_t *local_clip = NULL;
cairo_region_t *clip_region = NULL;
- cairo_bool_t need_clip_surface = FALSE;
- cairo_bool_t have_clip = FALSE;
cairo_status_t status;
status = _cairo_composite_rectangles_init_for_mask (&extents,
@@ -1168,16 +1152,8 @@ i965_surface_mask (void *abstract_dst,
if (clip != NULL && _cairo_clip_contains_extents (clip, &extents))
clip = NULL;
- if (clip != NULL && extents.is_bounded) {
- clip = _cairo_clip_init_copy (&local_clip, clip);
- status = _cairo_clip_rectangle (clip, &extents.bounded);
- if (unlikely (status)) {
- _cairo_clip_fini (&local_clip);
- return status;
- }
-
- have_clip = TRUE;
- }
+ if (clip != NULL && extents.is_bounded)
+ clip = local_clip = _cairo_clip_copy_intersect_rectangle (clip, &extents.bounded);
i965_shader_init (&shader, dst, op);
@@ -1196,10 +1172,8 @@ i965_surface_mask (void *abstract_dst,
goto err_shader;
if (clip != NULL) {
- status = _cairo_clip_get_region (clip, &clip_region);
- assert (status == CAIRO_STATUS_SUCCESS || CAIRO_INT_STATUS_UNSUPPORTED);
- need_clip_surface = status == CAIRO_INT_STATUS_UNSUPPORTED;
- if (need_clip_surface)
+ clip_region = _cairo_clip_get_region (clip);
+ if (clip_region == NULL)
i965_shader_set_clip (&shader, clip);
}
@@ -1240,8 +1214,7 @@ i965_surface_mask (void *abstract_dst,
cairo_device_release (&device->intel.base.base);
err_shader:
i965_shader_fini (&shader);
- if (have_clip)
- _cairo_clip_fini (&local_clip);
+ _cairo_clip_destroy (local_clip);
return status;
}
@@ -1295,8 +1268,7 @@ i965_surface_stroke (void *abstract_dst,
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;
- cairo_bool_t have_clip = FALSE;
+ cairo_clip_t *local_clip = NULL;
cairo_int_status_t status;
status = _cairo_composite_rectangles_init_for_stroke (&extents,
@@ -1310,16 +1282,12 @@ i965_surface_stroke (void *abstract_dst,
if (clip != NULL && _cairo_clip_contains_extents (clip, &extents))
clip = NULL;
- if (clip != NULL) {
- clip = _cairo_clip_init_copy (&local_clip, clip);
- have_clip = TRUE;
- }
+ if (clip != NULL)
+ clip = local_clip = _cairo_clip_copy (clip);
status = _cairo_clip_to_boxes (&clip, &extents, &clip_boxes, &num_boxes);
if (unlikely (status)) {
- if (have_clip)
- _cairo_clip_fini (&local_clip);
-
+ _cairo_clip_destroy (local_clip);
return status;
}
@@ -1381,8 +1349,7 @@ CLEANUP_BOXES:
if (clip_boxes != boxes_stack)
free (clip_boxes);
- if (have_clip)
- _cairo_clip_fini (&local_clip);
+ _cairo_clip_destroy (local_clip);
return status;
}
@@ -1401,8 +1368,7 @@ i965_surface_fill (void *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;
- cairo_bool_t have_clip = FALSE;
+ cairo_clip_t *local_clip = NULL;
int num_boxes = ARRAY_LENGTH (boxes_stack);
cairo_int_status_t status;
@@ -1418,16 +1384,12 @@ i965_surface_fill (void *abstract_dst,
if (clip != NULL && _cairo_clip_contains_extents (clip, &extents))
clip = NULL;
- if (clip != NULL) {
- clip = _cairo_clip_init_copy (&local_clip, clip);
- have_clip = TRUE;
- }
+ if (clip != NULL)
+ clip = local_clip = _cairo_clip_copy (clip);
status = _cairo_clip_to_boxes (&clip, &extents, &clip_boxes, &num_boxes);
if (unlikely (status)) {
- if (have_clip)
- _cairo_clip_fini (&local_clip);
-
+ _cairo_clip_destroy (local_clip);
return status;
}
@@ -1486,8 +1448,7 @@ CLEANUP_BOXES:
if (clip_boxes != boxes_stack)
free (clip_boxes);
- if (have_clip)
- _cairo_clip_fini (&local_clip);
+ _cairo_clip_destroy (local_clip);
return status;
}
--
2.6.4.442.g545299f
More information about the cairo
mailing list