Fix to accept a cairo_pattern_t rather than a cairo_surface_t as the primary argument.

Track change in _cairo_pattern_release_surface and also pass the appropriate pattern for each acquired surface. The previous backend mismatch was causing memory leaks.
Remove stale comment.
Add missing fclose to keep valgrind happy about memory leaks.
This commit is contained in:
Carl Worth 2005-07-14 15:10:47 +00:00
parent 288f0f7f49
commit 3cd006bb2b
6 changed files with 36 additions and 9 deletions

View file

@ -1,3 +1,22 @@
2005-07-14 Carl Worth <cworth@cworth.org>
* src/cairoint.h:
* src/cairo-pattern.c: (_cairo_pattern_release_surface): Fix to
accept a cairo_pattern_t rather than a cairo_surface_t as the
primary argument.
* src/cairo-image-surface.c: (_cairo_image_surface_composite),
(_cairo_image_surface_composite_trapezoids): Track change in
_cairo_pattern_release_surface and also pass the appropriate
pattern for each acquired surface. The previous backend mismatch
was causing memory leaks.
* src/cairo-xlib-surface.c: (_get_image_surface): Remove stale
comment.
* test/xlib-surface.c: (main): Add missing fclose to keep valgrind
happy about memory leaks.
2005-07-14 Carl Worth <cworth@cworth.org>
* test/cairo-test.c: (cairo_test_expecting),

View file

@ -595,9 +595,9 @@ _cairo_image_surface_composite (cairo_operator_t operator,
}
if (mask)
_cairo_pattern_release_surface (&dst->base, &mask->base, &mask_attr);
_cairo_pattern_release_surface (mask_pattern, &mask->base, &mask_attr);
_cairo_pattern_release_surface (&dst->base, &src->base, &src_attr);
_cairo_pattern_release_surface (src_pattern, &src->base, &src_attr);
return status;
}
@ -674,7 +674,7 @@ _cairo_image_surface_composite_trapezoids (cairo_operator_t operator,
render_src_y + attributes.y_offset,
(pixman_trapezoid_t *) traps, num_traps);
_cairo_pattern_release_surface (&dst->base, &src->base, &attributes);
_cairo_pattern_release_surface (pattern, &src->base, &attributes);
return status;
}

View file

@ -1409,19 +1409,24 @@ _cairo_pattern_acquire_surface (cairo_pattern_t *pattern,
/**
* _cairo_pattern_release_surface:
* @pattern: a #cairo_pattern_t
* @info: pointer to #cairo_surface_attributes_t filled in by
* _cairo_pattern_acquire_surface
* @surface: a surface obtained by _cairo_pattern_acquire_surface
* @attributes: attributes obtained by _cairo_pattern_acquire_surface
*
* Releases resources obtained by _cairo_pattern_acquire_surface.
**/
void
_cairo_pattern_release_surface (cairo_surface_t *dst,
_cairo_pattern_release_surface (cairo_pattern_t *pattern,
cairo_surface_t *surface,
cairo_surface_attributes_t *attributes)
{
if (attributes->acquired)
{
_cairo_surface_release_source_image (dst,
cairo_surface_pattern_t *surface_pattern;
assert (pattern->type == CAIRO_PATTERN_SURFACE);
surface_pattern = (cairo_surface_pattern_t *) pattern;
_cairo_surface_release_source_image (surface_pattern->surface,
(cairo_image_surface_t *) surface,
attributes->extra);
}

View file

@ -450,7 +450,6 @@ _get_image_surface (cairo_xlib_surface_t *surface,
}
/* Let the surface take ownership of the data */
/* XXX: Can probably come up with a cleaner API here. */
_cairo_image_surface_assume_ownership_of_data (image);
ximage->data = NULL;
XDestroyImage (ximage);

View file

@ -1817,7 +1817,7 @@ _cairo_pattern_acquire_surface (cairo_pattern_t *pattern,
cairo_surface_attributes_t *attributes);
cairo_private void
_cairo_pattern_release_surface (cairo_surface_t *dst,
_cairo_pattern_release_surface (cairo_pattern_t *pattern,
cairo_surface_t *surface,
cairo_surface_attributes_t *attributes);

View file

@ -221,11 +221,13 @@ main (void)
dpy = XOpenDisplay (NULL);
if (!dpy) {
fprintf (log_file, "xlib-surface: Cannot open display, skipping\n");
fclose (log_file);
return 0;
}
if (!check_visual (dpy)) {
fprintf (log_file, "xlib-surface: default visual is not RGB24 or BGR24, skipping\n");
fclose (log_file);
return 0;
}
@ -264,6 +266,8 @@ main (void)
free (diff_data);
XCloseDisplay (dpy);
fclose (log_file);
return result;
}