diff options
author | Neil Roberts <neil@linux.intel.com> | 2012-03-01 13:14:10 +0000 |
---|---|---|
committer | Neil Roberts <neil@linux.intel.com> | 2012-03-05 17:44:52 +0000 |
commit | 8ce5f5ade895c7f9f7d266a56ef25ae9596ef787 (patch) | |
tree | e7ef8ccc753983be9c8ef2b45b9ab4f978b9d105 | |
parent | b85f2e907a38b6a6f19e5356a682bb72453bb11e (diff) | |
download | cogl-8ce5f5ade895c7f9f7d266a56ef25ae9596ef787.tar.gz |
bitmap: Remove the split between 'image library' and 'fallback'
Previously the bitmap code was setup so that there could be an image
library used to convert between formats and then some 'fallback' code
when the image library can't handle the conversion. However there was
never any implementation of the conversion in the image library so the
fallback was always used. I don't think this split really makes sense
so this patch renames cogl-bitmap-fallback to cogl-bitmap-conversion
and removes the stub conversion functions in the image library.
Reviewed-by: Robert Bragg <robert@linux.intel.com>
-rw-r--r-- | cogl/Makefile.am | 2 | ||||
-rw-r--r-- | cogl/cogl-bitmap-conversion.c (renamed from cogl/cogl-bitmap-fallback.c) | 21 | ||||
-rw-r--r-- | cogl/cogl-bitmap-pixbuf.c | 37 | ||||
-rw-r--r-- | cogl/cogl-bitmap-private.h | 27 | ||||
-rw-r--r-- | cogl/cogl-bitmap.c | 32 |
5 files changed, 15 insertions, 104 deletions
diff --git a/cogl/Makefile.am b/cogl/Makefile.am index 2a5dcfa6..824059f0 100644 --- a/cogl/Makefile.am +++ b/cogl/Makefile.am @@ -203,7 +203,7 @@ cogl_sources_c = \ $(srcdir)/cogl-util.c \ $(srcdir)/cogl-bitmap-private.h \ $(srcdir)/cogl-bitmap.c \ - $(srcdir)/cogl-bitmap-fallback.c \ + $(srcdir)/cogl-bitmap-conversion.c \ $(srcdir)/cogl-primitives-private.h \ $(srcdir)/cogl-primitives.h \ $(srcdir)/cogl-primitives.c \ diff --git a/cogl/cogl-bitmap-fallback.c b/cogl/cogl-bitmap-conversion.c index b74602b8..b085f6eb 100644 --- a/cogl/cogl-bitmap-fallback.c +++ b/cogl/cogl-bitmap-conversion.c @@ -204,7 +204,7 @@ _cogl_premult_alpha_last_four_pixels_sse2 (guint8 *p) #endif /* COGL_USE_PREMULT_SSE2 */ static gboolean -_cogl_bitmap_fallback_can_premult (CoglPixelFormat format) +_cogl_bitmap_can_premult (CoglPixelFormat format) { switch (format & ~COGL_PREMULT_BIT) { @@ -268,8 +268,8 @@ _cogl_bitmap_needs_short_temp_buffer (CoglPixelFormat format) } CoglBitmap * -_cogl_bitmap_fallback_convert (CoglBitmap *src_bmp, - CoglPixelFormat dst_format) +_cogl_bitmap_convert (CoglBitmap *src_bmp, + CoglPixelFormat dst_format) { guint8 *src_data; guint8 *dst_data; @@ -339,7 +339,7 @@ _cogl_bitmap_fallback_convert (CoglBitmap *src_bmp, } gboolean -_cogl_bitmap_fallback_unpremult (CoglBitmap *bmp) +_cogl_bitmap_unpremult (CoglBitmap *bmp) { guint8 *p, *data; int x,y; @@ -353,7 +353,7 @@ _cogl_bitmap_fallback_unpremult (CoglBitmap *bmp) rowstride = _cogl_bitmap_get_rowstride (bmp); /* If we can premult that implies we can un-premult too... */ - if (!_cogl_bitmap_fallback_can_premult (format)) + if (!_cogl_bitmap_can_premult (format)) return FALSE; if ((data = _cogl_bitmap_map (bmp, @@ -398,7 +398,7 @@ _cogl_bitmap_fallback_unpremult (CoglBitmap *bmp) } gboolean -_cogl_bitmap_fallback_premult (CoglBitmap *bmp) +_cogl_bitmap_premult (CoglBitmap *bmp) { guint8 *p, *data; int x,y; @@ -412,7 +412,7 @@ _cogl_bitmap_fallback_premult (CoglBitmap *bmp) rowstride = _cogl_bitmap_get_rowstride (bmp); /* Make sure format supported for un-premultiplication */ - if (!_cogl_bitmap_fallback_can_premult (format)) + if (!_cogl_bitmap_can_premult (format)) return FALSE; if ((data = _cogl_bitmap_map (bmp, @@ -466,10 +466,3 @@ _cogl_bitmap_fallback_premult (CoglBitmap *bmp) return TRUE; } - -CoglBitmap * -_cogl_bitmap_fallback_from_file (const char *filename) -{ - /* FIXME: use jpeglib, libpng, etc. manually maybe */ - return FALSE; -} diff --git a/cogl/cogl-bitmap-pixbuf.c b/cogl/cogl-bitmap-pixbuf.c index b64af5a2..3f566319 100644 --- a/cogl/cogl-bitmap-pixbuf.c +++ b/cogl/cogl-bitmap-pixbuf.c @@ -37,43 +37,6 @@ #include <gdk-pixbuf/gdk-pixbuf.h> #endif -gboolean -_cogl_bitmap_can_convert (CoglPixelFormat src, CoglPixelFormat dst) -{ - return FALSE; -} - -gboolean -_cogl_bitmap_can_unpremult (CoglPixelFormat format) -{ - return FALSE; -} - -gboolean -_cogl_bitmap_can_premult (CoglPixelFormat format) -{ - return FALSE; -} - -CoglBitmap * -_cogl_bitmap_convert (CoglBitmap *bmp, - CoglPixelFormat dst_format) -{ - return NULL; -} - -gboolean -_cogl_bitmap_unpremult (CoglBitmap *dst_bmp) -{ - return FALSE; -} - -gboolean -_cogl_bitmap_premult (CoglBitmap *dst_bmp) -{ - return FALSE; -} - #ifdef USE_QUARTZ gboolean diff --git a/cogl/cogl-bitmap-private.h b/cogl/cogl-bitmap-private.h index 7a398d59..7bbdc739 100644 --- a/cogl/cogl-bitmap-private.h +++ b/cogl/cogl-bitmap-private.h @@ -83,42 +83,21 @@ _cogl_bitmap_new_shared (CoglBitmap *shared_bmp, int height, int rowstride); -gboolean -_cogl_bitmap_can_convert (CoglPixelFormat src, CoglPixelFormat dst); - -gboolean -_cogl_bitmap_can_unpremult (CoglPixelFormat format); - -gboolean -_cogl_bitmap_can_premult (CoglPixelFormat format); - CoglBitmap * _cogl_bitmap_convert (CoglBitmap *bmp, CoglPixelFormat dst_format); + CoglBitmap * -_cogl_bitmap_fallback_convert (CoglBitmap *bmp, - CoglPixelFormat dst_format); +_cogl_bitmap_from_file (const char *filename, + GError **error); gboolean _cogl_bitmap_unpremult (CoglBitmap *dst_bmp); gboolean -_cogl_bitmap_fallback_unpremult (CoglBitmap *dst_bmp); - -gboolean _cogl_bitmap_premult (CoglBitmap *dst_bmp); gboolean -_cogl_bitmap_fallback_premult (CoglBitmap *dst_bmp); - -CoglBitmap * -_cogl_bitmap_from_file (const char *filename, - GError **error); - -CoglBitmap * -_cogl_bitmap_fallback_from_file (const char *filename); - -gboolean _cogl_bitmap_convert_premult_status (CoglBitmap *bmp, CoglPixelFormat dst_format); diff --git a/cogl/cogl-bitmap.c b/cogl/cogl-bitmap.c index bb178ce0..46930dee 100644 --- a/cogl/cogl-bitmap.c +++ b/cogl/cogl-bitmap.c @@ -87,19 +87,14 @@ _cogl_bitmap_convert_premult_status (CoglBitmap *bmp, if ((bmp->format & COGL_PREMULT_BIT) > 0 && (dst_format & COGL_PREMULT_BIT) == 0 && COGL_PIXEL_FORMAT_CAN_HAVE_PREMULT (dst_format)) - /* Try unpremultiplying using imaging library */ - return (_cogl_bitmap_unpremult (bmp) - /* ... or try fallback */ - || _cogl_bitmap_fallback_unpremult (bmp)); + return _cogl_bitmap_unpremult (bmp); /* Do we need to premultiply? */ if ((bmp->format & COGL_PREMULT_BIT) == 0 && COGL_PIXEL_FORMAT_CAN_HAVE_PREMULT (bmp->format) && (dst_format & COGL_PREMULT_BIT) > 0) /* Try premultiplying using imaging library */ - return (_cogl_bitmap_premult (bmp) - /* ... or try fallback */ - || _cogl_bitmap_fallback_premult (bmp)); + return _cogl_bitmap_premult (bmp); return TRUE; } @@ -115,14 +110,8 @@ _cogl_bitmap_convert_format_and_premult (CoglBitmap *bmp, if ((src_format & ~COGL_PREMULT_BIT) != (dst_format & ~COGL_PREMULT_BIT)) { - /* Try converting using imaging library */ if ((dst_bmp = _cogl_bitmap_convert (bmp, dst_format)) == NULL) - { - /* ... or try fallback */ - if ((dst_bmp = _cogl_bitmap_fallback_convert (bmp, - dst_format)) == NULL) - return NULL; - } + return NULL; } else { @@ -292,22 +281,9 @@ CoglBitmap * cogl_bitmap_new_from_file (const char *filename, GError **error) { - CoglBitmap *bmp; - _COGL_RETURN_VAL_IF_FAIL (error == NULL || *error == NULL, COGL_INVALID_HANDLE); - if ((bmp = _cogl_bitmap_from_file (filename, error)) == NULL) - { - /* Try fallback */ - if ((bmp = _cogl_bitmap_fallback_from_file (filename)) - && error && *error) - { - g_error_free (*error); - *error = NULL; - } - } - - return bmp; + return _cogl_bitmap_from_file (filename, error); } CoglBitmap * |