diff options
author | Paolo Bonzini <bonzini@gnu.org> | 2008-12-15 09:32:43 +0100 |
---|---|---|
committer | Chris Wilson <chris@chris-wilson.co.uk> | 2009-01-29 10:10:40 +0000 |
commit | 6394ec3048f31b867d9588853fa400c6c630c6f1 (patch) | |
tree | cc60f22408a66850bea9c3fb9924e09cee124aad /src | |
parent | 46acfd2e85dd6f7a73e1172d363d509c769376f2 (diff) | |
download | cairo-6394ec3048f31b867d9588853fa400c6c630c6f1.tar.gz |
[surface] add CAIRO_STATUS_INVALID_SIZE
Adds an error code replacing CAIRO_STATUS_NO_MEMORY in one case where it
is not really appropriate. CAIRO_STATUS_INVALID_SIZE is used by several
backends that do not support image sizes beyond 2^15 pixels on each side.
Signed-off-by: Chris Wilson <chris@chris-wilson.co.uk>
Diffstat (limited to 'src')
-rw-r--r-- | src/cairo-misc.c | 4 | ||||
-rw-r--r-- | src/cairo-os2-surface.c | 9 | ||||
-rw-r--r-- | src/cairo-quartz-image-surface.c | 5 | ||||
-rw-r--r-- | src/cairo-quartz-surface.c | 4 | ||||
-rw-r--r-- | src/cairo-spans.c | 2 | ||||
-rw-r--r-- | src/cairo-surface.c | 1 | ||||
-rw-r--r-- | src/cairo-xlib-surface.c | 7 | ||||
-rw-r--r-- | src/cairo.h | 6 | ||||
-rw-r--r-- | src/cairoint.h | 2 |
9 files changed, 24 insertions, 16 deletions
diff --git a/src/cairo-misc.c b/src/cairo-misc.c index 708ba52c4..729e6d539 100644 --- a/src/cairo-misc.c +++ b/src/cairo-misc.c @@ -120,7 +120,9 @@ cairo_status_to_string (cairo_status_t status) case CAIRO_STATUS_INVALID_SLANT: return "invalid value for an input #cairo_font_slant_t"; case CAIRO_STATUS_INVALID_WEIGHT: - return "input value for an input #cairo_font_weight_t"; + return "invalid value for an input #cairo_font_weight_t"; + case CAIRO_STATUS_INVALID_SIZE: + return "invalid value for the size of the input (surface, pattern, etc.)"; } return "<unknown error status>"; diff --git a/src/cairo-os2-surface.c b/src/cairo-os2-surface.c index 62b4ccdc6..fa678bd2d 100644 --- a/src/cairo-os2-surface.c +++ b/src/cairo-os2-surface.c @@ -770,7 +770,7 @@ cairo_os2_surface_create (HPS hps_client_window, (height <= 0)) { /* Invalid window size! */ - return _cairo_surface_create_in_error (_cairo_error (CAIRO_STATUS_NO_MEMORY)); + return _cairo_surface_create_in_error (_cairo_error (CAIRO_STATUS_INVALID_SIZE)); } local_os2_surface = (cairo_os2_surface_t *) malloc (sizeof (cairo_os2_surface_t)); @@ -875,8 +875,9 @@ cairo_os2_surface_create (HPS hps_client_window, * * Return value: %CAIRO_STATUS_SUCCESS if the surface could be resized, * %CAIRO_STATUS_SURFACE_TYPE_MISMATCH if the surface is not an OS/2 surface, - * %CAIRO_STATUS_NO_MEMORY if the new size could not be allocated, for invalid - * sizes, or if the timeout happened before all the buffers were released + * %CAIRO_STATUS_INVALID_SIZE for invalid sizes + * %CAIRO_STATUS_NO_MEMORY if the new size could not be allocated, or if the + * timeout happened before all the buffers were released * * Since: 1.4 **/ @@ -903,7 +904,7 @@ cairo_os2_surface_set_size (cairo_surface_t *surface, (new_height <= 0)) { /* Invalid size! */ - return _cairo_error (CAIRO_STATUS_NO_MEMORY); + return _cairo_error (CAIRO_STATUS_INVALID_SIZE); } /* Allocate memory for new stuffs */ diff --git a/src/cairo-quartz-image-surface.c b/src/cairo-quartz-image-surface.c index 3bfd9e21a..dab3dc87d 100644 --- a/src/cairo-quartz-image-surface.c +++ b/src/cairo-quartz-image-surface.c @@ -41,6 +41,7 @@ #define SURFACE_ERROR_NO_MEMORY (_cairo_surface_create_in_error(_cairo_error(CAIRO_STATUS_NO_MEMORY))) #define SURFACE_ERROR_TYPE_MISMATCH (_cairo_surface_create_in_error(_cairo_error(CAIRO_STATUS_SURFACE_TYPE_MISMATCH))) +#define SURFACE_ERROR_INVALID_SIZE (_cairo_surface_create_in_error(_cairo_error(CAIRO_STATUS_INVALID_SIZE))) #define SURFACE_ERROR_INVALID_FORMAT (_cairo_surface_create_in_error(_cairo_error(CAIRO_STATUS_INVALID_FORMAT))) static void @@ -227,10 +228,10 @@ cairo_quartz_image_surface_create (cairo_surface_t *surface) data = image_surface->data; if (!_cairo_quartz_verify_surface_size(width, height)) - return SURFACE_ERROR_NO_MEMORY; + return SURFACE_ERROR_INVALID_SIZE; if (width == 0 || height == 0) - return SURFACE_ERROR_NO_MEMORY; + return SURFACE_ERROR_INVALID_SIZE; if (format != CAIRO_FORMAT_ARGB32 && format != CAIRO_FORMAT_RGB24) return SURFACE_ERROR_INVALID_FORMAT; diff --git a/src/cairo-quartz-surface.c b/src/cairo-quartz-surface.c index 9dae70fb4..c827f97ac 100644 --- a/src/cairo-quartz-surface.c +++ b/src/cairo-quartz-surface.c @@ -1589,7 +1589,7 @@ _cairo_quartz_surface_create_similar (void *abstract_surface, // verify width and height of surface if (!_cairo_quartz_verify_surface_size(width, height)) { return _cairo_surface_create_in_error (_cairo_error - (CAIRO_STATUS_NO_MEMORY)); + (CAIRO_STATUS_INVALID_SIZE)); } return cairo_quartz_surface_create (format, width, height); @@ -2586,7 +2586,7 @@ cairo_quartz_surface_create (cairo_format_t format, // verify width and height of surface if (!_cairo_quartz_verify_surface_size(width, height)) - return _cairo_surface_create_in_error (_cairo_error (CAIRO_STATUS_NO_MEMORY)); + return _cairo_surface_create_in_error (_cairo_error (CAIRO_STATUS_INVALID_SIZE)); if (width == 0 || height == 0) { return (cairo_surface_t*) _cairo_quartz_surface_create_internal (NULL, _cairo_content_from_format (format), diff --git a/src/cairo-spans.c b/src/cairo-spans.c index a30da6182..b6ac2c564 100644 --- a/src/cairo-spans.c +++ b/src/cairo-spans.c @@ -288,6 +288,7 @@ _cairo_scan_converter_create_in_error (cairo_status_t status) case CAIRO_STATUS_INVALID_SLANT: RETURN_NIL; case CAIRO_STATUS_INVALID_WEIGHT: RETURN_NIL; case CAIRO_STATUS_NO_MEMORY: RETURN_NIL; + case CAIRO_STATUS_INVALID_SIZE: RETURN_NIL; default: break; } @@ -391,6 +392,7 @@ _cairo_span_renderer_create_in_error (cairo_status_t status) case CAIRO_STATUS_INVALID_SLANT: RETURN_NIL; case CAIRO_STATUS_INVALID_WEIGHT: RETURN_NIL; case CAIRO_STATUS_NO_MEMORY: RETURN_NIL; + case CAIRO_STATUS_INVALID_SIZE: RETURN_NIL; default: break; } diff --git a/src/cairo-surface.c b/src/cairo-surface.c index 4dd034eb1..d68e13553 100644 --- a/src/cairo-surface.c +++ b/src/cairo-surface.c @@ -2973,6 +2973,7 @@ _cairo_surface_create_in_error (cairo_status_t status) case CAIRO_STATUS_INVALID_CLUSTERS: case CAIRO_STATUS_INVALID_SLANT: case CAIRO_STATUS_INVALID_WEIGHT: + case CAIRO_STATUS_INVALID_SIZE: default: _cairo_error_throw (CAIRO_STATUS_NO_MEMORY); return (cairo_surface_t *) &_cairo_surface_nil; diff --git a/src/cairo-xlib-surface.c b/src/cairo-xlib-surface.c index 1826ed9ef..a18fc034f 100644 --- a/src/cairo-xlib-surface.c +++ b/src/cairo-xlib-surface.c @@ -136,8 +136,7 @@ _cairo_xlib_surface_create_similar_with_format (void *abstract_src, cairo_xlib_surface_t *surface; XRenderPictFormat *xrender_format; - if (width > XLIB_COORD_MAX || height > XLIB_COORD_MAX) - return NULL; + assert (width <= XLIB_COORD_MAX && height <= XLIB_COORD_MAX); /* As a good first approximation, if the display doesn't have even * the most elementary RENDER operation, then we're better off @@ -209,7 +208,7 @@ _cairo_xlib_surface_create_similar (void *abstract_src, Pixmap pix; if (width > XLIB_COORD_MAX || height > XLIB_COORD_MAX) - return _cairo_surface_create_in_error (_cairo_error(CAIRO_STATUS_NO_MEMORY)); + return _cairo_surface_create_in_error (_cairo_error(CAIRO_STATUS_INVALID_SIZE)); _cairo_xlib_display_notify (src->display); @@ -1200,7 +1199,7 @@ _cairo_xlib_surface_clone_similar (void *abstract_surface, return CAIRO_INT_STATUS_UNSUPPORTED; if (width > XLIB_COORD_MAX || height > XLIB_COORD_MAX) - return _cairo_error (CAIRO_STATUS_NO_MEMORY); + return _cairo_error (CAIRO_STATUS_INVALID_SIZE); clone = (cairo_xlib_surface_t *) _cairo_xlib_surface_create_similar_with_format (surface, diff --git a/src/cairo.h b/src/cairo.h index 8f57ae083..856f7afc5 100644 --- a/src/cairo.h +++ b/src/cairo.h @@ -239,6 +239,7 @@ typedef struct _cairo_user_data_key { * @CAIRO_STATUS_INVALID_CLUSTERS: input clusters do not represent the accompanying text and glyph array (Since 1.8) * @CAIRO_STATUS_INVALID_SLANT: invalid value for an input #cairo_font_slant_t (Since 1.8) * @CAIRO_STATUS_INVALID_WEIGHT: invalid value for an input #cairo_font_weight_t (Since 1.8) + * @CAIRO_STATUS_INVALID_SIZE: invalid value (typically too big) for a size (Since 1.10) * * #cairo_status_t is used to indicate errors that can occur when * using Cairo. In some cases it is returned directly by functions. @@ -280,8 +281,9 @@ typedef enum _cairo_status { CAIRO_STATUS_NEGATIVE_COUNT, CAIRO_STATUS_INVALID_CLUSTERS, CAIRO_STATUS_INVALID_SLANT, - CAIRO_STATUS_INVALID_WEIGHT - /* after adding a new error: update CAIRO_STATUS_LAST_STATUS in cairoint.h */ + CAIRO_STATUS_INVALID_WEIGHT, + CAIRO_STATUS_INVALID_SIZE + /* after adding a new error: update CAIRO_STATUS_LAST_STATUS in cairoint.h. */ } cairo_status_t; /** diff --git a/src/cairoint.h b/src/cairoint.h index e3869d377..fe9ea5f88 100644 --- a/src/cairoint.h +++ b/src/cairoint.h @@ -125,7 +125,7 @@ _cairo_win32_tmpfile (void); * a bit of a pain, but it should be easy to always catch as long as * one adds a new test case to test a trigger of the new status value. */ -#define CAIRO_STATUS_LAST_STATUS CAIRO_STATUS_INVALID_WEIGHT +#define CAIRO_STATUS_LAST_STATUS CAIRO_STATUS_INVALID_SIZE #ifdef __GNUC__ #define cairo_container_of(ptr, type, member) ({ \ |