From 42dcffbc3a02df2dfdcbfce79f4f0170c40ab751 Mon Sep 17 00:00:00 2001 From: Neil Roberts Date: Thu, 1 Jul 2010 21:49:16 +0100 Subject: [PATCH] Make a public CoglBitmapError enum There are many places in the texture backend that need to do conversion using the CoglBitmap code. Currently none of these functions can throw an error but they do return a value to indicate failure. In future it would make sense if new texture functions could throw an error and in that case they would want to use a CoglBitmap error if the failure was due to the conversion. This moves the internal CoglBitmap error from the quartz backend to be public in cogl-bitmap.h so that it can be used in this way. --- cogl/cogl-bitmap-pixbuf.c | 16 -------------- cogl/cogl-bitmap.c | 5 +++++ cogl/cogl-bitmap.h | 32 ++++++++++++++++++++++++++++ doc/reference/cogl/cogl-sections.txt | 2 ++ 4 files changed, 39 insertions(+), 16 deletions(-) diff --git a/cogl/cogl-bitmap-pixbuf.c b/cogl/cogl-bitmap-pixbuf.c index 3e3dfbd49..9d2e0dd45 100644 --- a/cogl/cogl-bitmap-pixbuf.c +++ b/cogl/cogl-bitmap-pixbuf.c @@ -77,22 +77,6 @@ _cogl_bitmap_premult (CoglBitmap *dst_bmp) #ifdef USE_QUARTZ -/* lacking GdkPixbuf and other useful GError domains, define one of our own */ - -#define COGL_BITMAP_ERROR cogl_bitmap_error_quark () - -typedef enum { - COGL_BITMAP_ERROR_FAILED, - COGL_BITMAP_ERROR_UNKNOWN_TYPE, - COGL_BITMAP_ERROR_CORRUPT_IMAGE -} CoglBitmapError; - -GQuark -cogl_bitmap_error_quark (void) -{ - return g_quark_from_static_string ("cogl-bitmap-error-quark"); -} - gboolean _cogl_bitmap_get_size_from_file (const char *filename, int *width, diff --git a/cogl/cogl-bitmap.c b/cogl/cogl-bitmap.c index 36219ae10..551409287 100644 --- a/cogl/cogl-bitmap.c +++ b/cogl/cogl-bitmap.c @@ -188,3 +188,8 @@ cogl_bitmap_new_from_file (const char *filename, return _cogl_bitmap_object_new (ret); } +GQuark +cogl_bitmap_error_quark (void) +{ + return g_quark_from_static_string ("cogl-bitmap-error-quark"); +} diff --git a/cogl/cogl-bitmap.h b/cogl/cogl-bitmap.h index 6368841ae..8d1c42d8d 100644 --- a/cogl/cogl-bitmap.h +++ b/cogl/cogl-bitmap.h @@ -94,6 +94,38 @@ cogl_bitmap_get_size_from_file (const char *filename, gboolean cogl_is_bitmap (CoglHandle handle); +/** + * COGL_BITMAP_ERROR: + * + * #GError domain for bitmap errors. + * + * Since: 1.4 + */ +#define COGL_BITMAP_ERROR (cogl_bitmap_error_quark ()) + +/** + * CoglBitmapError: + * @COGL_BITMAP_ERROR_FAILED: Generic failure code, something went + * wrong. + * @COGL_ERROR_UNKNOWN_TYPE: Unknown image type. + * @COGL_ERROR_CORRUPT_IMAGE: An image file was broken somehow. + * + * Error codes that can be thrown when performing bitmap + * operations. Note that gdk_pixbuf_new_from_file() can also throw + * errors directly from the underlying image loading library. For + * example, if GdkPixbuf is used then errors #GdkPixbufErrors + * will be used directly. + * + * Since: 1.4 + */ +typedef enum { + COGL_BITMAP_ERROR_FAILED, + COGL_BITMAP_ERROR_UNKNOWN_TYPE, + COGL_BITMAP_ERROR_CORRUPT_IMAGE +} CoglBitmapError; + +GQuark cogl_bitmap_error_quark (void); + G_END_DECLS #endif /* __COGL_BITMAP_H__ */ diff --git a/doc/reference/cogl/cogl-sections.txt b/doc/reference/cogl/cogl-sections.txt index b75a10e4f..67cda3aa5 100644 --- a/doc/reference/cogl/cogl-sections.txt +++ b/doc/reference/cogl/cogl-sections.txt @@ -198,6 +198,8 @@ cogl_path_stroke_preserve cogl_bitmap_new_from_file cogl_bitmap_get_size_from_file cogl_is_bitmap +CoglBitmapError +COGL_BITMAP_ERROR