summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorChris Wilson <chris@chris-wilson.co.uk>2009-09-23 15:33:23 +0100
committerChris Wilson <chris@chris-wilson.co.uk>2009-09-23 15:37:35 +0100
commit07ee9cfbf07deba228e73d26b419a4e130de24e3 (patch)
treeb10c8f53c3d693c230801919da15ab1e1f5df5ba
parent9948b5180aa4312b3184d9ba46e9ad6f0d8e700c (diff)
[image] Do assumption initial user data is cleared.
Benjamin Otte pointed out the error of my ways that a clear on a cairo_image_surface_create_for_data() was not working. This is because I modified the image surface to skip clears when it knows the target data has been cleared. This flag must be reset when the user interacts with the surface, such as providing the initial surface data.
-rw-r--r--src/cairo-image-surface.c26
1 files changed, 22 insertions, 4 deletions
diff --git a/src/cairo-image-surface.c b/src/cairo-image-surface.c
index 3b232006..8ad259d2 100644
--- a/src/cairo-image-surface.c
+++ b/src/cairo-image-surface.c
@@ -542,6 +542,7 @@ cairo_image_surface_create_for_data (unsigned char *data,
int stride)
{
pixman_format_code_t pixman_format;
+ cairo_surface_t *surface;
int minstride;
if (! CAIRO_FORMAT_VALID (format))
@@ -562,9 +563,16 @@ cairo_image_surface_create_for_data (unsigned char *data,
}
pixman_format = _cairo_format_to_pixman_format_code (format);
-
- return _cairo_image_surface_create_with_pixman_format (data, pixman_format,
- width, height, stride);
+ surface = _cairo_image_surface_create_with_pixman_format (data,
+ pixman_format,
+ width, height,
+ stride);
+ if (unlikely (surface->status))
+ return surface;
+
+ /* we can not make any assumptions by the initial state of the data */
+ ((cairo_image_surface_t *) surface)->is_clear = FALSE;
+ return surface;
}
slim_hidden_def (cairo_image_surface_create_for_data);
@@ -1610,6 +1618,16 @@ _cairo_image_surface_get_font_options (void *abstract_surface,
cairo_font_options_set_hint_metrics (options, CAIRO_HINT_METRICS_ON);
}
+static cairo_status_t
+_cairo_image_surface_mark_dirty_rectangle (void *abstract_surface,
+ int x, int y,
+ int width, int height)
+{
+ cairo_image_surface_t *surface = abstract_surface;
+ surface->is_clear = FALSE;
+ return CAIRO_STATUS_SUCCESS;
+}
+
static cairo_int_status_t
_cairo_image_surface_paint (void *abstract_surface,
cairo_operator_t op,
@@ -1663,7 +1681,7 @@ const cairo_surface_backend_t _cairo_image_surface_backend = {
NULL, /* old_show_glyphs */
_cairo_image_surface_get_font_options,
NULL, /* flush */
- NULL, /* mark_dirty_rectangle */
+ _cairo_image_surface_mark_dirty_rectangle,
NULL, /* font_fini */
NULL, /* glyph_fini */