summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorCarl Worth <cworth@cworth.org>2006-10-04 14:56:33 -0700
committerBehdad Esfahbod <behdad@behdad.org>2006-10-31 21:17:09 -0500
commit20d7a556cef03405f57d1380370682a3579eb729 (patch)
tree463c1d41788e4c43c16e8ade57b5fd26166fa49e
parente4ff87ea596ce6316b1cad8008cb5436eef9a86b (diff)
Fix cairo_image_surface_create to report INVALID_FORMAT errors.
This adds a new nil cairo_image_surface to hold CAIRO_STATUS_INVALID_FORMAT. Previously the detected error was being lost and a nil surface was returned that erroneously reported CAIRO_STATUS_NO_MEMORY. (cherry picked from 4d2b54a271f722de9802ca68246ce6afba89f830 commit)
-rw-r--r--src/cairo-image-surface.c52
1 files changed, 50 insertions, 2 deletions
diff --git a/src/cairo-image-surface.c b/src/cairo-image-surface.c
index 7f869dccd..a9c610f2b 100644
--- a/src/cairo-image-surface.c
+++ b/src/cairo-image-surface.c
@@ -36,6 +36,52 @@
#include "cairoint.h"
+const cairo_image_surface_t _cairo_image_surface_nil_invalid_format = {
+ {
+ &cairo_image_surface_backend, /* backend */
+ CAIRO_SURFACE_TYPE_IMAGE,
+ CAIRO_CONTENT_COLOR,
+ CAIRO_REF_COUNT_INVALID, /* ref_count */
+ CAIRO_STATUS_INVALID_FORMAT, /* status */
+ FALSE, /* finished */
+ { 0, /* size */
+ 0, /* num_elements */
+ 0, /* element_size */
+ NULL, /* elements */
+ }, /* user_data */
+ { 1.0, 0.0,
+ 0.0, 1.0,
+ 0.0, 0.0
+ }, /* device_transform */
+ { 1.0, 0.0,
+ 0.0, 1.0,
+ 0.0, 0.0
+ }, /* device_transform_inverse */
+ 0.0, /* x_fallback_resolution */
+ 0.0, /* y_fallback_resolution */
+ NULL, /* clip */
+ 0, /* next_clip_serial */
+ 0, /* current_clip_serial */
+ FALSE, /* is_snapshot */
+ FALSE, /* has_font_options */
+ { CAIRO_ANTIALIAS_DEFAULT,
+ CAIRO_SUBPIXEL_ORDER_DEFAULT,
+ CAIRO_HINT_STYLE_DEFAULT,
+ CAIRO_HINT_METRICS_DEFAULT
+ } /* font_options */
+ }, /* base */
+ CAIRO_FORMAT_ARGB32, /* format */
+ NULL, /* data */
+ FALSE, /* owns_data */
+ FALSE, /* has_clip */
+ 0, /* width */
+ 0, /* height */
+ 0, /* stride */
+ 0, /* depth */
+ NULL /* pixman_image */
+};
+
+
static int
_cairo_format_bpp (cairo_format_t format)
{
@@ -253,8 +299,10 @@ cairo_image_surface_create (cairo_format_t format,
pixman_format_t *pixman_format;
pixman_image_t *pixman_image;
- if (! CAIRO_FORMAT_VALID (format))
- return (cairo_surface_t*) &_cairo_surface_nil;
+ if (! CAIRO_FORMAT_VALID (format)) {
+ _cairo_error (CAIRO_STATUS_INVALID_FORMAT);
+ return (cairo_surface_t*) &_cairo_image_surface_nil_invalid_format;
+ }
pixman_format = _create_pixman_format (format);
if (pixman_format == NULL) {