cogl/pixel-format: Make CAN_HAVE_PREMULT an inlined function
To avoid exposing the function macro in the gir file & so the docs Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/3910>
This commit is contained in:
parent
162b8e1a15
commit
716f23c7c1
@ -82,12 +82,12 @@ _cogl_bitmap_convert_premult_status (CoglBitmap *bmp,
|
|||||||
/* Do we need to unpremultiply? */
|
/* Do we need to unpremultiply? */
|
||||||
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))
|
||||||
return _cogl_bitmap_unpremult (bmp, error);
|
return _cogl_bitmap_unpremult (bmp, error);
|
||||||
|
|
||||||
/* 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, error);
|
return _cogl_bitmap_premult (bmp, error);
|
||||||
|
@ -265,7 +265,7 @@ typedef enum /*< prefix=COGL_PIXEL_FORMAT >*/
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* COGL_PIXEL_FORMAT_CAIRO_ARGB32_COMPAT:
|
* COGL_PIXEL_FORMAT_CAIRO_ARGB32_COMPAT:
|
||||||
*
|
*
|
||||||
* Architecture dependant format, similar to CAIRO_ARGB32.
|
* Architecture dependant format, similar to CAIRO_ARGB32.
|
||||||
*/
|
*/
|
||||||
#if G_BYTE_ORDER == G_LITTLE_ENDIAN
|
#if G_BYTE_ORDER == G_LITTLE_ENDIAN
|
||||||
@ -324,7 +324,7 @@ gboolean
|
|||||||
_cogl_pixel_format_is_endian_dependant (CoglPixelFormat format);
|
_cogl_pixel_format_is_endian_dependant (CoglPixelFormat format);
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* COGL_PIXEL_FORMAT_CAN_HAVE_PREMULT(format):
|
* _cogl_pixel_format_can_have_premult:
|
||||||
* @format: a #CoglPixelFormat
|
* @format: a #CoglPixelFormat
|
||||||
*
|
*
|
||||||
* Returns TRUE if the pixel format can take a premult bit. This is
|
* Returns TRUE if the pixel format can take a premult bit. This is
|
||||||
@ -332,8 +332,11 @@ _cogl_pixel_format_is_endian_dependant (CoglPixelFormat format);
|
|||||||
* COGL_PIXEL_FORMAT_A_8 (because that doesn't have any other
|
* COGL_PIXEL_FORMAT_A_8 (because that doesn't have any other
|
||||||
* components to multiply by the alpha).
|
* components to multiply by the alpha).
|
||||||
*/
|
*/
|
||||||
#define COGL_PIXEL_FORMAT_CAN_HAVE_PREMULT(format) \
|
static inline gboolean
|
||||||
(((format) & COGL_A_BIT) && (format) != COGL_PIXEL_FORMAT_A_8)
|
_cogl_pixel_format_can_have_premult (CoglPixelFormat format)
|
||||||
|
{
|
||||||
|
return (((format) & COGL_A_BIT) && (format) != COGL_PIXEL_FORMAT_A_8);
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* cogl_pixel_format_get_n_planes:
|
* cogl_pixel_format_get_n_planes:
|
||||||
|
@ -808,7 +808,7 @@ cogl_texture_get_data (CoglTexture *texture,
|
|||||||
|
|
||||||
/* We can assume that whatever data GL gives us will have the
|
/* We can assume that whatever data GL gives us will have the
|
||||||
premult status of the original texture */
|
premult status of the original texture */
|
||||||
if (COGL_PIXEL_FORMAT_CAN_HAVE_PREMULT (closest_format))
|
if (_cogl_pixel_format_can_have_premult (closest_format))
|
||||||
closest_format = ((closest_format & ~COGL_PREMULT_BIT) |
|
closest_format = ((closest_format & ~COGL_PREMULT_BIT) |
|
||||||
(texture_format & COGL_PREMULT_BIT));
|
(texture_format & COGL_PREMULT_BIT));
|
||||||
|
|
||||||
@ -1202,7 +1202,7 @@ _cogl_texture_determine_internal_format (CoglTexture *texture,
|
|||||||
|
|
||||||
if (cogl_texture_get_premultiplied (texture))
|
if (cogl_texture_get_premultiplied (texture))
|
||||||
{
|
{
|
||||||
if (COGL_PIXEL_FORMAT_CAN_HAVE_PREMULT (format))
|
if (_cogl_pixel_format_can_have_premult (format))
|
||||||
return format |= COGL_PREMULT_BIT;
|
return format |= COGL_PREMULT_BIT;
|
||||||
else
|
else
|
||||||
return COGL_PIXEL_FORMAT_RGBA_8888_PRE;
|
return COGL_PIXEL_FORMAT_RGBA_8888_PRE;
|
||||||
|
@ -472,7 +472,7 @@ cogl_gl_framebuffer_read_pixels_into_bitmap (CoglFramebufferDriver *driver,
|
|||||||
uint8_t *tmp_data;
|
uint8_t *tmp_data;
|
||||||
gboolean succeeded;
|
gboolean succeeded;
|
||||||
|
|
||||||
if (COGL_PIXEL_FORMAT_CAN_HAVE_PREMULT (read_format))
|
if (_cogl_pixel_format_can_have_premult (read_format))
|
||||||
{
|
{
|
||||||
read_format = ((read_format & ~COGL_PREMULT_BIT) |
|
read_format = ((read_format & ~COGL_PREMULT_BIT) |
|
||||||
(internal_format & COGL_PREMULT_BIT));
|
(internal_format & COGL_PREMULT_BIT));
|
||||||
@ -536,7 +536,7 @@ cogl_gl_framebuffer_read_pixels_into_bitmap (CoglFramebufferDriver *driver,
|
|||||||
/* We match the premultiplied state of the target buffer to the
|
/* We match the premultiplied state of the target buffer to the
|
||||||
* premultiplied state of the framebuffer so that it will get
|
* premultiplied state of the framebuffer so that it will get
|
||||||
* converted to the right format below */
|
* converted to the right format below */
|
||||||
if (COGL_PIXEL_FORMAT_CAN_HAVE_PREMULT (format))
|
if (_cogl_pixel_format_can_have_premult (format))
|
||||||
bmp_format = ((format & ~COGL_PREMULT_BIT) |
|
bmp_format = ((format & ~COGL_PREMULT_BIT) |
|
||||||
(internal_format & COGL_PREMULT_BIT));
|
(internal_format & COGL_PREMULT_BIT));
|
||||||
else
|
else
|
||||||
|
Loading…
x
Reference in New Issue
Block a user