mirror of
https://gitlab.gnome.org/GNOME/gtk.git
synced 2024-12-27 06:00:22 +00:00
gdk: Create our egl surface with srgb colorspace
For GDK_MEMORY_U8_SRGB depth, try to create an SRGB surface. This requires the EXT_KHR_gl_colorspace extension, which isn't super-common in the wild (37%), so we fall back to regular U8 if that fails. But if we have the extension, create our egl surface with the srgb colorspace, and report that fact in gdk_surface_gl_is_srgb().
This commit is contained in:
parent
db3b3c62bb
commit
ad6fd451fb
@ -1870,6 +1870,8 @@ gdk_display_init_egl (GdkDisplay *self,
|
||||
epoxy_has_egl_extension (priv->egl_display, "EGL_EXT_image_dma_buf_import_modifiers");
|
||||
self->have_egl_dma_buf_export =
|
||||
epoxy_has_egl_extension (priv->egl_display, "EGL_MESA_image_dma_buf_export");
|
||||
self->have_egl_gl_colorspace =
|
||||
epoxy_has_egl_extension (priv->egl_display, "EGL_KHR_gl_colorspace");
|
||||
|
||||
if (self->have_egl_no_config_context)
|
||||
priv->egl_config_high_depth = gdk_display_create_egl_config (self,
|
||||
|
@ -131,6 +131,7 @@ struct _GdkDisplay
|
||||
guint have_egl_pixel_format_float : 1;
|
||||
guint have_egl_dma_buf_import : 1;
|
||||
guint have_egl_dma_buf_export : 1;
|
||||
guint have_egl_gl_colorspace : 1;
|
||||
|
||||
GdkDmabufFormats *dmabuf_formats;
|
||||
GdkDmabufDownloader *dmabuf_downloaders[4];
|
||||
|
@ -1159,10 +1159,32 @@ gdk_surface_ensure_egl_surface (GdkSurface *self,
|
||||
|
||||
if (priv->egl_surface == NULL)
|
||||
{
|
||||
EGLint attribs[4];
|
||||
int i;
|
||||
|
||||
i = 0;
|
||||
if (depth == GDK_MEMORY_U8_SRGB && display->have_egl_gl_colorspace)
|
||||
{
|
||||
attribs[i++] = EGL_GL_COLORSPACE_KHR;
|
||||
attribs[i++] = EGL_GL_COLORSPACE_SRGB_KHR;
|
||||
self->is_srgb = TRUE;
|
||||
}
|
||||
g_assert (i < G_N_ELEMENTS (attribs));
|
||||
attribs[i++] = EGL_NONE;
|
||||
|
||||
priv->egl_surface = eglCreateWindowSurface (gdk_display_get_egl_display (display),
|
||||
gdk_display_get_egl_config (display, depth),
|
||||
(EGLNativeWindowType) priv->egl_native_window,
|
||||
NULL);
|
||||
attribs);
|
||||
if (priv->egl_surface == EGL_NO_SURFACE)
|
||||
{
|
||||
/* just assume the error is no srgb support and try again without */
|
||||
self->is_srgb = FALSE;
|
||||
priv->egl_surface = eglCreateWindowSurface (gdk_display_get_egl_display (display),
|
||||
gdk_display_get_egl_config (display, depth),
|
||||
(EGLNativeWindowType) priv->egl_native_window,
|
||||
NULL);
|
||||
}
|
||||
priv->egl_surface_depth = depth;
|
||||
}
|
||||
#endif
|
||||
|
Loading…
Reference in New Issue
Block a user