egl: Pass depth through the fbconfig selection code

We still only differentiate between high bit depth or not, but we now
choose at the end instead of the start, which makes it easier to adapt
to a different method of choosing.
This commit is contained in:
Benjamin Otte 2024-06-26 20:58:25 +02:00
parent 16c29a7db5
commit b707568fc1
6 changed files with 26 additions and 30 deletions

View File

@ -1570,19 +1570,15 @@ describe_egl_config (EGLDisplay egl_display,
}
gpointer
gdk_display_get_egl_config (GdkDisplay *self)
gdk_display_get_egl_config (GdkDisplay *self,
GdkMemoryDepth depth)
{
GdkDisplayPrivate *priv = gdk_display_get_instance_private (self);
return priv->egl_config;
}
gpointer
gdk_display_get_egl_config_high_depth (GdkDisplay *self)
{
GdkDisplayPrivate *priv = gdk_display_get_instance_private (self);
return priv->egl_config_high_depth;
if (depth == GDK_MEMORY_U8 || depth == GDK_MEMORY_U8_SRGB)
return priv->egl_config;
else
return priv->egl_config_high_depth;
}
static EGLDisplay

View File

@ -18,15 +18,16 @@
#pragma once
#include "gdkdisplay.h"
#include "gdksurface.h"
#include "gdkcursor.h"
#include "gdkmonitor.h"
#include "gdkdebugprivate.h"
#include "gdksurfaceprivate.h"
#include "gdkkeysprivate.h"
#include "gdkdeviceprivate.h"
#include "gdkdmabufprivate.h"
#include "gdkdmabufdownloaderprivate.h"
#include "gdkdmabufprivate.h"
#include "gdkkeysprivate.h"
#include "gdkmemoryformatprivate.h"
#include "gdkmonitor.h"
#include "gdksurfaceprivate.h"
#ifdef GDK_RENDERING_VULKAN
#include <vulkan/vulkan.h>
@ -247,9 +248,8 @@ gboolean gdk_display_init_egl (GdkDisplay *display
gboolean allow_any,
GError **error);
gpointer gdk_display_get_egl_display (GdkDisplay *display);
gpointer gdk_display_get_egl_config (GdkDisplay *display);
gpointer gdk_display_get_egl_config_high_depth
(GdkDisplay *display);
gpointer gdk_display_get_egl_config (GdkDisplay *display,
GdkMemoryDepth depth);
void gdk_display_set_rgba (GdkDisplay *display,
gboolean rgba);

View File

@ -329,7 +329,7 @@ gdk_gl_context_create_egl_context (GdkGLContext *context,
if (display->have_egl_no_config_context)
egl_config = NULL;
else
egl_config = gdk_display_get_egl_config (display);
egl_config = gdk_display_get_egl_config (display, GDK_MEMORY_U8);
if (debug_bit)
flags |= EGL_CONTEXT_OPENGL_DEBUG_BIT_KHR;
@ -626,7 +626,7 @@ gdk_gl_context_real_begin_frame (GdkDrawContext *draw_context,
#ifdef HAVE_EGL
if (priv->egl_context)
gdk_surface_ensure_egl_surface (surface, depth != GDK_MEMORY_U8);
gdk_surface_ensure_egl_surface (surface, depth);
#endif
damage = GDK_GL_CONTEXT_GET_CLASS (context)->get_damage (context);

View File

@ -72,7 +72,7 @@ struct _GdkSurfacePrivate
gpointer egl_native_window;
#ifdef HAVE_EGL
EGLSurface egl_surface;
gboolean egl_surface_high_depth;
GdkMemoryDepth egl_surface_depth;
#endif
gpointer widget;
@ -1140,17 +1140,17 @@ gdk_surface_get_egl_surface (GdkSurface *self)
}
void
gdk_surface_ensure_egl_surface (GdkSurface *self,
gboolean high_depth)
gdk_surface_ensure_egl_surface (GdkSurface *self,
GdkMemoryDepth depth)
{
GdkSurfacePrivate *priv = gdk_surface_get_instance_private (self);
GdkDisplay *display = gdk_surface_get_display (self);
g_return_if_fail (priv->egl_native_window != NULL);
if (priv->egl_surface_high_depth != high_depth &&
if (priv->egl_surface_depth != depth &&
priv->egl_surface != NULL &&
gdk_display_get_egl_config_high_depth (display) != gdk_display_get_egl_config (display))
gdk_display_get_egl_config (display, priv->egl_surface_depth) != gdk_display_get_egl_config (display, depth))
{
gdk_gl_context_clear_current_if_surface (self);
eglDestroySurface (gdk_display_get_egl_display (display), priv->egl_surface);
@ -1160,11 +1160,10 @@ gdk_surface_ensure_egl_surface (GdkSurface *self,
if (priv->egl_surface == NULL)
{
priv->egl_surface = eglCreateWindowSurface (gdk_display_get_egl_display (display),
high_depth ? gdk_display_get_egl_config_high_depth (display)
: gdk_display_get_egl_config (display),
gdk_display_get_egl_config (display, depth),
(EGLNativeWindowType) priv->egl_native_window,
NULL);
priv->egl_surface_high_depth = high_depth;
priv->egl_surface_depth = depth;
}
#endif
}

View File

@ -21,6 +21,7 @@
#include <gdk-pixbuf/gdk-pixbuf.h>
#include "gdkenumtypes.h"
#include "gdkmemoryformatprivate.h"
#include "gdksurface.h"
#include "gdktoplevel.h"
#include <graphene.h>
@ -299,7 +300,7 @@ void gdk_surface_set_frame_clock (GdkSurface
void gdk_surface_set_egl_native_window (GdkSurface *self,
gpointer native_window);
void gdk_surface_ensure_egl_surface (GdkSurface *self,
gboolean hdr);
GdkMemoryDepth depth);
gpointer /*EGLSurface*/ gdk_surface_get_egl_surface (GdkSurface *self);
void gdk_surface_set_widget (GdkSurface *self,

View File

@ -2993,7 +2993,7 @@ gdk_x11_display_init_gl_backend (GdkX11Display *self,
}
if (!eglGetConfigAttrib (gdk_display_get_egl_display (display),
gdk_display_get_egl_config (display),
gdk_display_get_egl_config (display, GDK_MEMORY_U8),
EGL_NATIVE_VISUAL_ID,
&visualid))
{