[gtk/wip/otte/glcontext: 5/7] glcontext: Deprecate gdk_gl_context_set_use_es()




commit 8c1f7f7531a98fc6e87c3389a675c7a1648c9b97
Author: Benjamin Otte <otte redhat com>
Date:   Thu Oct 7 18:13:36 2021 +0200

    glcontext: Deprecate gdk_gl_context_set_use_es()
    
    Make it call gdk_gl_context_set_allowed_apis().
    
    Also port callers to use this function.

 gdk/gdkglcontext.c | 19 +++++++++++++++++--
 gdk/gdkglcontext.h |  2 +-
 gtk/gtkglarea.c    |  2 +-
 3 files changed, 19 insertions(+), 4 deletions(-)
---
diff --git a/gdk/gdkglcontext.c b/gdk/gdkglcontext.c
index 8f932df84f..138f774d3a 100644
--- a/gdk/gdkglcontext.c
+++ b/gdk/gdkglcontext.c
@@ -1246,6 +1246,8 @@ gdk_gl_context_get_allowed_apis (GdkGLContext *self)
  * You should check the return value of [method@Gdk.GLContext.get_use_es]
  * after calling [method@Gdk.GLContext.realize] to decide whether to use
  * the OpenGL or OpenGL ES API, extensions, or shaders.
+ *
+ * Deprecated: 4.6: Use gdk_gl_context_set_allowed_apis() instead.
  */
 void
 gdk_gl_context_set_use_es (GdkGLContext *context,
@@ -1256,8 +1258,21 @@ gdk_gl_context_set_use_es (GdkGLContext *context,
   g_return_if_fail (GDK_IS_GL_CONTEXT (context));
   g_return_if_fail (!priv->realized);
 
-  if (priv->use_es != use_es)
-    priv->use_es = use_es;
+  switch (use_es)
+  {
+    case -1:
+      gdk_gl_context_set_allowed_apis (context, DEFAULT_ALLOWED_APIS);
+      break;
+    case 0:
+      gdk_gl_context_set_allowed_apis (context, GDK_GL_API_GL);
+      break;
+    case 1:
+      gdk_gl_context_set_allowed_apis (context, GDK_GL_API_GLES);
+      break;
+    default:
+      /* Just ignore the call */
+      break;
+  }
 }
 
 /**
diff --git a/gdk/gdkglcontext.h b/gdk/gdkglcontext.h
index 8205d85339..7e8e0d1e36 100644
--- a/gdk/gdkglcontext.h
+++ b/gdk/gdkglcontext.h
@@ -95,7 +95,7 @@ void                    gdk_gl_context_set_allowed_apis         (GdkGLContext  *
                                                                  GdkGLAPI       apis);
 GDK_AVAILABLE_IN_4_6
 GdkGLAPI                gdk_gl_context_get_allowed_apis         (GdkGLContext  *self);
-GDK_AVAILABLE_IN_ALL
+GDK_DEPRECATED_IN_4_6_FOR(gdk_gl_context_set_allowed_apis)
 void                    gdk_gl_context_set_use_es               (GdkGLContext  *context,
                                                                  int            use_es);
 GDK_AVAILABLE_IN_ALL
diff --git a/gtk/gtkglarea.c b/gtk/gtkglarea.c
index 610ac97c4f..655c102cd7 100644
--- a/gtk/gtkglarea.c
+++ b/gtk/gtkglarea.c
@@ -319,7 +319,7 @@ gtk_gl_area_real_create_context (GtkGLArea *area)
       return NULL;
     }
 
-  gdk_gl_context_set_use_es (context, priv->use_es);
+  gdk_gl_context_set_allowed_apis (context, priv->use_es ? GDK_GL_API_GLES : GDK_GL_API_GL);
   gdk_gl_context_set_required_version (context,
                                        priv->required_gl_version / 10,
                                        priv->required_gl_version % 10);


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]