[cairo] [PATCH 34/41] drm/i915: fixed _cairo_clip_*() calls
Enrico Weigelt, metux IT consult
enrico.weigelt at gr13.net
Thu Dec 10 14:17:10 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-surface.c | 64 +++++++++++++---------------------------
2 files changed, 25 insertions(+), 58 deletions(-)
diff --git a/src/drm/cairo-drm-i915-glyphs.c b/src/drm/cairo-drm-i915-glyphs.c
index 8f27df5..7066985 100644
--- a/src/drm/cairo-drm-i915-glyphs.c
+++ b/src/drm/cairo-drm-i915-glyphs.c
@@ -287,8 +287,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;
cairo_bool_t overlap;
cairo_region_t *clip_region = NULL;
intel_bo_t *last_bo = NULL;
@@ -312,21 +311,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;
}
}
@@ -554,8 +546,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-surface.c b/src/drm/cairo-drm-i915-surface.c
index 2ce263b..8da17c0 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>
@@ -1872,8 +1873,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;
@@ -1900,15 +1900,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;
}
@@ -1971,8 +1968,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;
}
@@ -1986,8 +1982,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;
cairo_clip_path_t *clip_path;
cairo_boxes_t boxes;
int num_boxes = ARRAY_LENGTH (boxes.boxes_embedded);
@@ -2005,15 +2000,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;
}
@@ -2044,8 +2036,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;
}
@@ -2079,10 +2070,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;
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) {
@@ -2102,16 +2092,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.);
@@ -2206,8 +2188,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;
}
@@ -2229,8 +2210,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;
cairo_int_status_t status;
status = _cairo_composite_rectangles_init_for_stroke (&extents,
@@ -2247,15 +2227,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;
}
@@ -2320,8 +2297,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