[cairo] [PATCH 55/71] drm: fixed _cairo_clip_*() calls
Enrico Weigelt, metux IT consult
enrico.weigelt at gr13.net
Mon Apr 17 16:57:34 UTC 2017
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 32d53398f..850c3157f 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 1f979e85e..8753f8abd 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 c5b66e4fb..cebcb43a4 100644
--- a/src/drm/cairo-drm-i915-surface.c
+++ b/src/drm/cairo-drm-i915-surface.c
@@ -111,6 +111,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>
@@ -1875,8 +1876,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;
@@ -1903,15 +1903,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;
}
@@ -1974,8 +1971,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;
}
@@ -1990,8 +1986,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);
@@ -2009,15 +2004,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;
}
@@ -2048,8 +2040,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;
}
@@ -2083,10 +2074,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) {
@@ -2106,16 +2096,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.);
@@ -2210,8 +2192,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;
}
@@ -2233,8 +2214,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,
@@ -2251,15 +2231,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;
}
@@ -2324,8 +2301,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 814c98faa..2ff338acb 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 499e53de0..5b9e136f0 100644
--- a/src/drm/cairo-drm-i965-surface.c
+++ b/src/drm/cairo-drm-i965-surface.c
@@ -59,6 +59,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>
@@ -764,13 +765,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 &&
@@ -888,9 +884,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);
}
@@ -993,7 +988,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;
@@ -1017,10 +1011,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);
}
@@ -1098,8 +1090,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;
@@ -1115,16 +1106,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;
}
@@ -1135,8 +1122,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;
}
@@ -1152,10 +1138,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,
@@ -1167,16 +1151,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);
@@ -1195,10 +1171,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);
}
@@ -1239,8 +1213,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;
}
@@ -1294,8 +1267,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,
@@ -1309,16 +1281,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;
}
@@ -1380,8 +1348,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;
}
@@ -1400,8 +1367,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;
@@ -1417,16 +1383,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;
}
@@ -1485,8 +1447,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.11.0.rc0.7.gbe5a750
More information about the cairo
mailing list