[cairo] [PATCH 46/51] drm: fixed _cairo_clip_*() calls
Enrico Weigelt, metux IT consult
enrico.weigelt at gr13.net
Fri Dec 18 05:29:25 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 4ae74a1..211c964 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>
@@ -1878,8 +1879,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;
@@ -1906,15 +1906,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;
}
@@ -1977,8 +1974,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;
}
@@ -1993,8 +1989,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);
@@ -2012,15 +2007,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;
}
@@ -2051,8 +2043,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;
}
@@ -2086,10 +2077,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) {
@@ -2109,16 +2099,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.);
@@ -2213,8 +2195,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;
}
@@ -2236,8 +2217,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,
@@ -2254,15 +2234,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;
}
@@ -2327,8 +2304,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 8604160..ef32e41 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 &&
@@ -890,9 +886,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);
}
@@ -995,7 +990,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;
@@ -1019,10 +1013,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);
}
@@ -1100,8 +1092,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;
@@ -1117,16 +1108,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;
}
@@ -1137,8 +1124,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;
}
@@ -1154,10 +1140,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,
@@ -1169,16 +1153,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);
@@ -1197,10 +1173,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);
}
@@ -1241,8 +1215,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;
}
@@ -1296,8 +1269,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,
@@ -1311,16 +1283,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;
}
@@ -1382,8 +1350,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;
}
@@ -1402,8 +1369,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;
@@ -1419,16 +1385,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;
}
@@ -1487,8 +1449,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