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
4 changed files with 13 additions and 10 deletions
|
@ -82,12 +82,12 @@ _cogl_bitmap_convert_premult_status (CoglBitmap *bmp,
|
|||
/* Do we need to unpremultiply? */
|
||||
if ((bmp->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);
|
||||
|
||||
/* Do we need to premultiply? */
|
||||
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)
|
||||
/* Try premultiplying using imaging library */
|
||||
return _cogl_bitmap_premult (bmp, error);
|
||||
|
|
|
@ -324,7 +324,7 @@ gboolean
|
|||
_cogl_pixel_format_is_endian_dependant (CoglPixelFormat format);
|
||||
|
||||
/*
|
||||
* COGL_PIXEL_FORMAT_CAN_HAVE_PREMULT(format):
|
||||
* _cogl_pixel_format_can_have_premult:
|
||||
* @format: a #CoglPixelFormat
|
||||
*
|
||||
* 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
|
||||
* components to multiply by the alpha).
|
||||
*/
|
||||
#define COGL_PIXEL_FORMAT_CAN_HAVE_PREMULT(format) \
|
||||
(((format) & COGL_A_BIT) && (format) != COGL_PIXEL_FORMAT_A_8)
|
||||
static inline gboolean
|
||||
_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:
|
||||
|
|
|
@ -808,7 +808,7 @@ cogl_texture_get_data (CoglTexture *texture,
|
|||
|
||||
/* We can assume that whatever data GL gives us will have the
|
||||
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) |
|
||||
(texture_format & COGL_PREMULT_BIT));
|
||||
|
||||
|
@ -1202,7 +1202,7 @@ _cogl_texture_determine_internal_format (CoglTexture *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;
|
||||
else
|
||||
return COGL_PIXEL_FORMAT_RGBA_8888_PRE;
|
||||
|
|
|
@ -472,7 +472,7 @@ cogl_gl_framebuffer_read_pixels_into_bitmap (CoglFramebufferDriver *driver,
|
|||
uint8_t *tmp_data;
|
||||
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) |
|
||||
(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
|
||||
* premultiplied state of the framebuffer so that it will get
|
||||
* 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) |
|
||||
(internal_format & COGL_PREMULT_BIT));
|
||||
else
|
||||
|
|
Loading…
Reference in a new issue