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>
This commit is contained in:
Neil Roberts 2012-03-01 13:14:10 +00:00
parent b85f2e907a
commit 8ce5f5ade8
5 changed files with 17 additions and 106 deletions

View File

@ -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 \

View File

@ -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;
}

View File

@ -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

View File

@ -83,40 +83,19 @@ _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);
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_unpremult (CoglBitmap *dst_bmp);
gboolean
_cogl_bitmap_premult (CoglBitmap *dst_bmp);
gboolean
_cogl_bitmap_convert_premult_status (CoglBitmap *bmp,

View File

@ -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 *