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-util.c \
$(srcdir)/cogl-bitmap-private.h \ $(srcdir)/cogl-bitmap-private.h \
$(srcdir)/cogl-bitmap.c \ $(srcdir)/cogl-bitmap.c \
$(srcdir)/cogl-bitmap-fallback.c \ $(srcdir)/cogl-bitmap-conversion.c \
$(srcdir)/cogl-primitives-private.h \ $(srcdir)/cogl-primitives-private.h \
$(srcdir)/cogl-primitives.h \ $(srcdir)/cogl-primitives.h \
$(srcdir)/cogl-primitives.c \ $(srcdir)/cogl-primitives.c \

View File

@ -204,7 +204,7 @@ _cogl_premult_alpha_last_four_pixels_sse2 (guint8 *p)
#endif /* COGL_USE_PREMULT_SSE2 */ #endif /* COGL_USE_PREMULT_SSE2 */
static gboolean static gboolean
_cogl_bitmap_fallback_can_premult (CoglPixelFormat format) _cogl_bitmap_can_premult (CoglPixelFormat format)
{ {
switch (format & ~COGL_PREMULT_BIT) switch (format & ~COGL_PREMULT_BIT)
{ {
@ -268,8 +268,8 @@ _cogl_bitmap_needs_short_temp_buffer (CoglPixelFormat format)
} }
CoglBitmap * CoglBitmap *
_cogl_bitmap_fallback_convert (CoglBitmap *src_bmp, _cogl_bitmap_convert (CoglBitmap *src_bmp,
CoglPixelFormat dst_format) CoglPixelFormat dst_format)
{ {
guint8 *src_data; guint8 *src_data;
guint8 *dst_data; guint8 *dst_data;
@ -339,7 +339,7 @@ _cogl_bitmap_fallback_convert (CoglBitmap *src_bmp,
} }
gboolean gboolean
_cogl_bitmap_fallback_unpremult (CoglBitmap *bmp) _cogl_bitmap_unpremult (CoglBitmap *bmp)
{ {
guint8 *p, *data; guint8 *p, *data;
int x,y; int x,y;
@ -353,7 +353,7 @@ _cogl_bitmap_fallback_unpremult (CoglBitmap *bmp)
rowstride = _cogl_bitmap_get_rowstride (bmp); rowstride = _cogl_bitmap_get_rowstride (bmp);
/* If we can premult that implies we can un-premult too... */ /* 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; return FALSE;
if ((data = _cogl_bitmap_map (bmp, if ((data = _cogl_bitmap_map (bmp,
@ -398,7 +398,7 @@ _cogl_bitmap_fallback_unpremult (CoglBitmap *bmp)
} }
gboolean gboolean
_cogl_bitmap_fallback_premult (CoglBitmap *bmp) _cogl_bitmap_premult (CoglBitmap *bmp)
{ {
guint8 *p, *data; guint8 *p, *data;
int x,y; int x,y;
@ -412,7 +412,7 @@ _cogl_bitmap_fallback_premult (CoglBitmap *bmp)
rowstride = _cogl_bitmap_get_rowstride (bmp); rowstride = _cogl_bitmap_get_rowstride (bmp);
/* Make sure format supported for un-premultiplication */ /* Make sure format supported for un-premultiplication */
if (!_cogl_bitmap_fallback_can_premult (format)) if (!_cogl_bitmap_can_premult (format))
return FALSE; return FALSE;
if ((data = _cogl_bitmap_map (bmp, if ((data = _cogl_bitmap_map (bmp,
@ -466,10 +466,3 @@ _cogl_bitmap_fallback_premult (CoglBitmap *bmp)
return TRUE; 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> #include <gdk-pixbuf/gdk-pixbuf.h>
#endif #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 #ifdef USE_QUARTZ
gboolean gboolean

View File

@ -83,40 +83,19 @@ _cogl_bitmap_new_shared (CoglBitmap *shared_bmp,
int height, int height,
int rowstride); 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 * CoglBitmap *
_cogl_bitmap_convert (CoglBitmap *bmp, _cogl_bitmap_convert (CoglBitmap *bmp,
CoglPixelFormat dst_format); 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 * CoglBitmap *
_cogl_bitmap_from_file (const char *filename, _cogl_bitmap_from_file (const char *filename,
GError **error); GError **error);
CoglBitmap * gboolean
_cogl_bitmap_fallback_from_file (const char *filename); _cogl_bitmap_unpremult (CoglBitmap *dst_bmp);
gboolean
_cogl_bitmap_premult (CoglBitmap *dst_bmp);
gboolean gboolean
_cogl_bitmap_convert_premult_status (CoglBitmap *bmp, _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 && if ((bmp->format & COGL_PREMULT_BIT) > 0 &&
(dst_format & COGL_PREMULT_BIT) == 0 && (dst_format & COGL_PREMULT_BIT) == 0 &&
COGL_PIXEL_FORMAT_CAN_HAVE_PREMULT (dst_format)) COGL_PIXEL_FORMAT_CAN_HAVE_PREMULT (dst_format))
/* Try unpremultiplying using imaging library */ return _cogl_bitmap_unpremult (bmp);
return (_cogl_bitmap_unpremult (bmp)
/* ... or try fallback */
|| _cogl_bitmap_fallback_unpremult (bmp));
/* Do we need to premultiply? */ /* Do we need to premultiply? */
if ((bmp->format & COGL_PREMULT_BIT) == 0 && if ((bmp->format & COGL_PREMULT_BIT) == 0 &&
COGL_PIXEL_FORMAT_CAN_HAVE_PREMULT (bmp->format) && COGL_PIXEL_FORMAT_CAN_HAVE_PREMULT (bmp->format) &&
(dst_format & COGL_PREMULT_BIT) > 0) (dst_format & COGL_PREMULT_BIT) > 0)
/* Try premultiplying using imaging library */ /* Try premultiplying using imaging library */
return (_cogl_bitmap_premult (bmp) return _cogl_bitmap_premult (bmp);
/* ... or try fallback */
|| _cogl_bitmap_fallback_premult (bmp));
return TRUE; return TRUE;
} }
@ -115,14 +110,8 @@ _cogl_bitmap_convert_format_and_premult (CoglBitmap *bmp,
if ((src_format & ~COGL_PREMULT_BIT) != if ((src_format & ~COGL_PREMULT_BIT) !=
(dst_format & ~COGL_PREMULT_BIT)) (dst_format & ~COGL_PREMULT_BIT))
{ {
/* Try converting using imaging library */
if ((dst_bmp = _cogl_bitmap_convert (bmp, dst_format)) == NULL) if ((dst_bmp = _cogl_bitmap_convert (bmp, dst_format)) == NULL)
{ return NULL;
/* ... or try fallback */
if ((dst_bmp = _cogl_bitmap_fallback_convert (bmp,
dst_format)) == NULL)
return NULL;
}
} }
else else
{ {
@ -292,22 +281,9 @@ CoglBitmap *
cogl_bitmap_new_from_file (const char *filename, cogl_bitmap_new_from_file (const char *filename,
GError **error) GError **error)
{ {
CoglBitmap *bmp;
_COGL_RETURN_VAL_IF_FAIL (error == NULL || *error == NULL, COGL_INVALID_HANDLE); _COGL_RETURN_VAL_IF_FAIL (error == NULL || *error == NULL, COGL_INVALID_HANDLE);
if ((bmp = _cogl_bitmap_from_file (filename, error)) == NULL) return _cogl_bitmap_from_file (filename, error);
{
/* Try fallback */
if ((bmp = _cogl_bitmap_fallback_from_file (filename))
&& error && *error)
{
g_error_free (*error);
*error = NULL;
}
}
return bmp;
} }
CoglBitmap * CoglBitmap *