mirror of
https://github.com/brl/mutter.git
synced 2024-12-25 12:32:05 +00:00
[premultiplication] Be more conservative with what data gets premultiplied
We don't want to force texture data to be premultipled if the user explicitly specifies a non premultiplied internal_format such as COGL_PIXEL_FORMAT_RGBA_8888. So now Cogl will only automatically premultiply data when COGL_PIXEL_FORMAT_ANY is given for the internal_format, or a premultiplied internal format such as COGL_PIXEL_FORMAT_RGBA_8888_PRE is requested but non-premultiplied source data is given. This approach is consistent with OpenVG image formats which have already influenced Cogl's pixel format semantics.
This commit is contained in:
parent
7cb4b93432
commit
e6da6df8a8
@ -1085,17 +1085,9 @@ _cogl_pixel_format_to_gl (CoglPixelFormat format,
|
|||||||
GLenum glformat = 0;
|
GLenum glformat = 0;
|
||||||
GLenum gltype = 0;
|
GLenum gltype = 0;
|
||||||
|
|
||||||
/* If PREMULT_BIT isn't specified, that means that we premultiply
|
/* FIXME: check YUV support */
|
||||||
* textures with alpha before uploading to GL; once we are in GL land,
|
|
||||||
* everything is premultiplied.
|
required_format = format;
|
||||||
*
|
|
||||||
* Everything else accepted (FIXME: check YUV support)
|
|
||||||
*/
|
|
||||||
if ((format & COGL_A_BIT) != 0 &&
|
|
||||||
format != COGL_PIXEL_FORMAT_A_8)
|
|
||||||
required_format = format | COGL_PREMULT_BIT;
|
|
||||||
else
|
|
||||||
required_format = format;
|
|
||||||
|
|
||||||
/* Find GL equivalents */
|
/* Find GL equivalents */
|
||||||
switch (format & COGL_UNPREMULT_MASK)
|
switch (format & COGL_UNPREMULT_MASK)
|
||||||
@ -1197,9 +1189,15 @@ _cogl_texture_bitmap_prepare (CoglTexture *tex,
|
|||||||
CoglPixelFormat new_data_format;
|
CoglPixelFormat new_data_format;
|
||||||
gboolean success;
|
gboolean success;
|
||||||
|
|
||||||
/* Was there any internal conversion requested? */
|
/* Was there any internal conversion requested?
|
||||||
|
* By default Cogl will use a premultiplied internal format. Later we will
|
||||||
|
* add control over this. */
|
||||||
if (internal_format == COGL_PIXEL_FORMAT_ANY)
|
if (internal_format == COGL_PIXEL_FORMAT_ANY)
|
||||||
internal_format = tex->bitmap.format;
|
{
|
||||||
|
if ((tex->bitmap.format & COGL_A_BIT) &&
|
||||||
|
tex->bitmap.format != COGL_PIXEL_FORMAT_A_8)
|
||||||
|
internal_format = tex->bitmap.format | COGL_PREMULT_BIT;
|
||||||
|
}
|
||||||
|
|
||||||
/* Find closest format accepted by GL */
|
/* Find closest format accepted by GL */
|
||||||
new_data_format = _cogl_pixel_format_to_gl (internal_format,
|
new_data_format = _cogl_pixel_format_to_gl (internal_format,
|
||||||
|
@ -1184,17 +1184,9 @@ _cogl_pixel_format_to_gl (CoglPixelFormat format,
|
|||||||
GLenum glformat = 0;
|
GLenum glformat = 0;
|
||||||
GLenum gltype = 0;
|
GLenum gltype = 0;
|
||||||
|
|
||||||
/* If PREMULT_BIT isn't specified, that means that we premultiply
|
/* FIXME: check YUV support */
|
||||||
* textures with alpha before uploading to GL; once we are in GL land,
|
|
||||||
* everything is premultiplied.
|
required_format = format;
|
||||||
*
|
|
||||||
* Everything else accepted (FIXME: check YUV support)
|
|
||||||
*/
|
|
||||||
if ((format & COGL_A_BIT) != 0 &&
|
|
||||||
format != COGL_PIXEL_FORMAT_A_8)
|
|
||||||
required_format = format | COGL_PREMULT_BIT;
|
|
||||||
else
|
|
||||||
required_format = format;
|
|
||||||
|
|
||||||
/* Find GL equivalents */
|
/* Find GL equivalents */
|
||||||
switch (format & COGL_UNPREMULT_MASK)
|
switch (format & COGL_UNPREMULT_MASK)
|
||||||
@ -1273,9 +1265,15 @@ _cogl_texture_bitmap_prepare (CoglTexture *tex,
|
|||||||
CoglPixelFormat new_data_format;
|
CoglPixelFormat new_data_format;
|
||||||
gboolean success;
|
gboolean success;
|
||||||
|
|
||||||
/* Was there any internal conversion requested? */
|
/* Was there any internal conversion requested?
|
||||||
|
* By default Cogl will use a premultiplied internal format. Later we will
|
||||||
|
* add control over this. */
|
||||||
if (internal_format == COGL_PIXEL_FORMAT_ANY)
|
if (internal_format == COGL_PIXEL_FORMAT_ANY)
|
||||||
internal_format = tex->bitmap.format;
|
{
|
||||||
|
if ((tex->bitmap.format & COGL_A_BIT) &&
|
||||||
|
tex->bitmap.format != COGL_PIXEL_FORMAT_A_8)
|
||||||
|
internal_format = tex->bitmap.format | COGL_PREMULT_BIT;
|
||||||
|
}
|
||||||
|
|
||||||
/* Find closest format accepted by GL */
|
/* Find closest format accepted by GL */
|
||||||
new_data_format = _cogl_pixel_format_to_gl (internal_format,
|
new_data_format = _cogl_pixel_format_to_gl (internal_format,
|
||||||
|
Loading…
Reference in New Issue
Block a user