1
0
Fork 0

cogl: Fix opaque formats on GLES2 getting premultiplied

On GLES2 reading and writing some Cogl formats is not supported
natively. In those cases we use another format to do the reading and
writing. When the internal format and the temporary format differ in
premultiplication, Cogl tries to adjust for it.

Opaque Cogl formats don't have the premult bit set but our internal
format is a premult format. Cogl tries to adjust for it but completely
misses that the opaque format doesn't have an alpha channel and it
should not do so at all.

So skip the premult adjusting when the Cogl format has no alpha channel.

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/3065>
This commit is contained in:
Sebastian Wick 2023-07-12 20:06:26 +02:00 committed by Marge Bot
parent 42336f69cc
commit 5696d61a67

View file

@ -537,8 +537,16 @@ cogl_gl_framebuffer_read_pixels_into_bitmap (CoglFramebufferDriver *driver,
_cogl_bitmap_gl_unbind (tmp_bmp);
if (!(internal_format & COGL_A_BIT))
{
_cogl_bitmap_set_format (tmp_bmp, read_format & ~COGL_PREMULT_BIT);
_cogl_bitmap_set_format (bitmap, format & ~COGL_PREMULT_BIT);
}
succeeded = _cogl_bitmap_convert_into_bitmap (tmp_bmp, bitmap, error);
_cogl_bitmap_set_format (bitmap, format);
cogl_object_unref (tmp_bmp);
if (!succeeded)
@ -603,7 +611,8 @@ cogl_gl_framebuffer_read_pixels_into_bitmap (CoglFramebufferDriver *driver,
/* Convert to the premult format specified by the caller
in-place. This will do nothing if the premult status is already
correct. */
if (_cogl_bitmap_convert_premult_status (shared_bmp, format, error))
if (!(internal_format & COGL_A_BIT) ||
_cogl_bitmap_convert_premult_status (shared_bmp, format, error))
succeeded = TRUE;
cogl_object_unref (shared_bmp);