Remove COGL_UNORDERED_MASK define
Although it's in a public header nothing should be using this define since it's not documented what it could be used for. The cases where we were using it internally were quite fragile because they were trying to mask information from the least significant nibble of CoglPixelFormat but really that nibble just has to be dealt with using lookup tables. The least significant nibble of a pixel format gives information about the bytes per pixel and whether the components are byte aligned but the information needs to be accessed using _cogl_pixel_format_get_byes_per_pixel() and _cogl_pixel_format_is_endian_dependant(). Reviewed-by: Neil Roberts <neil@linux.intel.com>
This commit is contained in:
parent
a203a5e396
commit
e43246fe1c
@ -300,23 +300,22 @@ _cogl_premult_alpha_last_four_pixels_sse2 (guint8 *p)
|
||||
|
||||
#endif /* COGL_USE_PREMULT_SSE2 */
|
||||
|
||||
gboolean
|
||||
static gboolean
|
||||
_cogl_bitmap_fallback_can_convert (CoglPixelFormat src, CoglPixelFormat dst)
|
||||
{
|
||||
if (src == dst)
|
||||
return FALSE;
|
||||
|
||||
switch (src & COGL_UNORDERED_MASK)
|
||||
switch (src & ~COGL_PREMULT_BIT)
|
||||
{
|
||||
case COGL_PIXEL_FORMAT_G_8:
|
||||
case COGL_PIXEL_FORMAT_24:
|
||||
case COGL_PIXEL_FORMAT_32:
|
||||
|
||||
if ((dst & COGL_UNORDERED_MASK) != COGL_PIXEL_FORMAT_24 &&
|
||||
(dst & COGL_UNORDERED_MASK) != COGL_PIXEL_FORMAT_32 &&
|
||||
(dst & COGL_UNORDERED_MASK) != COGL_PIXEL_FORMAT_G_8)
|
||||
return FALSE;
|
||||
break;
|
||||
case COGL_PIXEL_FORMAT_RGB_888:
|
||||
case COGL_PIXEL_FORMAT_BGR_888:
|
||||
case COGL_PIXEL_FORMAT_RGBA_8888:
|
||||
case COGL_PIXEL_FORMAT_BGRA_8888:
|
||||
case COGL_PIXEL_FORMAT_ARGB_8888:
|
||||
case COGL_PIXEL_FORMAT_ABGR_8888:
|
||||
return TRUE;
|
||||
|
||||
default:
|
||||
return FALSE;
|
||||
@ -325,16 +324,20 @@ _cogl_bitmap_fallback_can_convert (CoglPixelFormat src, CoglPixelFormat dst)
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
gboolean
|
||||
_cogl_bitmap_fallback_can_unpremult (CoglPixelFormat format)
|
||||
{
|
||||
return ((format & COGL_UNORDERED_MASK) == COGL_PIXEL_FORMAT_32);
|
||||
}
|
||||
|
||||
gboolean
|
||||
static gboolean
|
||||
_cogl_bitmap_fallback_can_premult (CoglPixelFormat format)
|
||||
{
|
||||
return ((format & COGL_UNORDERED_MASK) == COGL_PIXEL_FORMAT_32);
|
||||
switch (format & ~COGL_PREMULT_BIT)
|
||||
{
|
||||
case COGL_PIXEL_FORMAT_RGBA_8888:
|
||||
case COGL_PIXEL_FORMAT_BGRA_8888:
|
||||
case COGL_PIXEL_FORMAT_ARGB_8888:
|
||||
case COGL_PIXEL_FORMAT_ABGR_8888:
|
||||
return TRUE;
|
||||
|
||||
default:
|
||||
return FALSE;
|
||||
}
|
||||
}
|
||||
|
||||
CoglBitmap *
|
||||
@ -459,8 +462,8 @@ _cogl_bitmap_fallback_unpremult (CoglBitmap *bmp)
|
||||
height = _cogl_bitmap_get_height (bmp);
|
||||
rowstride = _cogl_bitmap_get_rowstride (bmp);
|
||||
|
||||
/* Make sure format supported for un-premultiplication */
|
||||
if (!_cogl_bitmap_fallback_can_unpremult (format))
|
||||
/* If we can premult that implies we can un-premult too... */
|
||||
if (!_cogl_bitmap_fallback_can_premult (format))
|
||||
return FALSE;
|
||||
|
||||
if ((data = _cogl_bitmap_map (bmp,
|
||||
|
@ -86,21 +86,12 @@ _cogl_bitmap_new_shared (CoglBitmap *shared_bmp,
|
||||
gboolean
|
||||
_cogl_bitmap_can_convert (CoglPixelFormat src, CoglPixelFormat dst);
|
||||
|
||||
gboolean
|
||||
_cogl_bitmap_fallback_can_convert (CoglPixelFormat src, CoglPixelFormat dst);
|
||||
|
||||
gboolean
|
||||
_cogl_bitmap_can_unpremult (CoglPixelFormat format);
|
||||
|
||||
gboolean
|
||||
_cogl_bitmap_fallback_can_unpremult (CoglPixelFormat format);
|
||||
|
||||
gboolean
|
||||
_cogl_bitmap_can_premult (CoglPixelFormat format);
|
||||
|
||||
gboolean
|
||||
_cogl_bitmap_fallback_can_premult (CoglPixelFormat format);
|
||||
|
||||
CoglBitmap *
|
||||
_cogl_bitmap_convert (CoglBitmap *bmp,
|
||||
CoglPixelFormat dst_format);
|
||||
|
@ -169,7 +169,6 @@ typedef struct _CoglTextureVertex CoglTextureVertex;
|
||||
#define COGL_BGR_BIT (1 << 5)
|
||||
#define COGL_AFIRST_BIT (1 << 6)
|
||||
#define COGL_PREMULT_BIT (1 << 7)
|
||||
#define COGL_UNORDERED_MASK 0x0F
|
||||
|
||||
/**
|
||||
* CoglPixelFormat:
|
||||
|
@ -163,7 +163,6 @@ COGL_BGR_BIT
|
||||
COGL_PIXEL_FORMAT_24
|
||||
COGL_PIXEL_FORMAT_32
|
||||
COGL_PREMULT_BIT
|
||||
COGL_UNORDERED_MASK
|
||||
</SECTION>
|
||||
|
||||
<SECTION>
|
||||
|
@ -125,7 +125,6 @@ COGL_BGR_BIT
|
||||
COGL_PIXEL_FORMAT_24
|
||||
COGL_PIXEL_FORMAT_32
|
||||
COGL_PREMULT_BIT
|
||||
COGL_UNORDERED_MASK
|
||||
</SECTION>
|
||||
|
||||
<SECTION>
|
||||
|
Loading…
Reference in New Issue
Block a user