[gtk+] Export API to set GL flags



commit 5d0d1e524e6b6a6e190cbbf48d467ed80ee9118f
Author: Matthias Clasen <mclasen redhat com>
Date:   Thu Nov 6 23:29:16 2014 -0500

    Export API to set GL flags
    
    This will be used in the inspector.

 gdk/gdk.c          |   12 ++++++------
 gdk/gdkgl.c        |    6 +++---
 gdk/gdkglcontext.c |   33 +++++++++++++++++++++++++++++++--
 gdk/gdkglcontext.h |   28 ++++++++++++++++++++++++++++
 gdk/gdkinternals.h |    9 ---------
 gdk/gdkwindow.c    |    4 ++--
 6 files changed, 70 insertions(+), 22 deletions(-)
---
diff --git a/gdk/gdk.c b/gdk/gdk.c
index a4f1f62..951a01c 100644
--- a/gdk/gdk.c
+++ b/gdk/gdk.c
@@ -135,12 +135,12 @@ static GCallback gdk_threads_lock = NULL;
 static GCallback gdk_threads_unlock = NULL;
 
 static const GDebugKey gdk_gl_keys[] = {
-  {"disable",               GDK_GL_FLAGS_DISABLE},
-  {"always",                GDK_GL_FLAGS_ALWAYS},
-  {"software-draw",         GDK_GL_FLAGS_SOFTWARE_DRAW_GL | GDK_GL_FLAGS_SOFTWARE_DRAW_SURFACE},
-  {"software-draw-gl",      GDK_GL_FLAGS_SOFTWARE_DRAW_GL},
-  {"software-draw-surface", GDK_GL_FLAGS_SOFTWARE_DRAW_SURFACE},
-  {"texture-rectangle",     GDK_GL_FLAGS_TEXTURE_RECTANGLE},
+  {"disable",               GDK_GL_DISABLE},
+  {"always",                GDK_GL_ALWAYS},
+  {"software-draw",         GDK_GL_SOFTWARE_DRAW_GL | GDK_GL_SOFTWARE_DRAW_SURFACE},
+  {"software-draw-gl",      GDK_GL_SOFTWARE_DRAW_GL},
+  {"software-draw-surface", GDK_GL_SOFTWARE_DRAW_SURFACE},
+  {"texture-rectangle",     GDK_GL_TEXTURE_RECTANGLE},
 };
 
 #ifdef G_ENABLE_DEBUG
diff --git a/gdk/gdkgl.c b/gdk/gdkgl.c
index 3b843f1..1529411 100644
--- a/gdk/gdkgl.c
+++ b/gdk/gdkgl.c
@@ -393,7 +393,7 @@ gdk_cairo_draw_from_gl (cairo_t              *cr,
 
   /* For direct paint of non-alpha renderbuffer, we can
      just do a bitblit */
-  if ((_gdk_gl_flags & GDK_GL_FLAGS_SOFTWARE_DRAW_GL) == 0 &&
+  if ((_gdk_gl_flags & GDK_GL_SOFTWARE_DRAW_GL) == 0 &&
       source_type == GL_RENDERBUFFER &&
       alpha_size == 0 &&
       direct_window != NULL &&
@@ -474,7 +474,7 @@ gdk_cairo_draw_from_gl (cairo_t              *cr,
 
     }
   /* For direct paint of alpha or non-alpha textures we can use texturing */
-  else if ((_gdk_gl_flags & GDK_GL_FLAGS_SOFTWARE_DRAW_GL) == 0 &&
+  else if ((_gdk_gl_flags & GDK_GL_SOFTWARE_DRAW_GL) == 0 &&
            source_type == GL_TEXTURE &&
            direct_window != NULL &&
            direct_window->current_paint.use_gl &&
@@ -663,7 +663,7 @@ gdk_gl_texture_from_surface (cairo_surface_t *surface,
   guint target;
 
   paint_context = gdk_gl_context_get_current ();
-  if ((_gdk_gl_flags & GDK_GL_FLAGS_SOFTWARE_DRAW_SURFACE) == 0 &&
+  if ((_gdk_gl_flags & GDK_GL_SOFTWARE_DRAW_SURFACE) == 0 &&
       paint_context &&
       GDK_GL_CONTEXT_GET_CLASS (paint_context)->texture_from_surface &&
       GDK_GL_CONTEXT_GET_CLASS (paint_context)->texture_from_surface (paint_context, surface, region))
diff --git a/gdk/gdkglcontext.c b/gdk/gdkglcontext.c
index e1b8f98..f9c874f 100644
--- a/gdk/gdkglcontext.c
+++ b/gdk/gdkglcontext.c
@@ -380,14 +380,14 @@ gdk_gl_context_realize (GdkGLContext *context)
   priv->has_gl_framebuffer_blit = epoxy_has_gl_extension ("GL_EXT_framebuffer_blit");
   priv->has_frame_terminator = epoxy_has_gl_extension ("GL_GREMEDY_frame_terminator");
 
-  if (_gdk_gl_flags & GDK_GL_FLAGS_TEXTURE_RECTANGLE)
+  if (_gdk_gl_flags & GDK_GL_TEXTURE_RECTANGLE)
     priv->use_texture_rectangle = TRUE;
   else if (has_npot)
     priv->use_texture_rectangle = FALSE;
   else if (has_texture_rectangle)
     priv->use_texture_rectangle = TRUE;
   else
-    g_warning ("Gl implementation doesn't support any form of non-power-of-two textures");
+    g_warning ("GL implementation doesn't support any form of non-power-of-two textures");
 
   priv->realized = TRUE;
 }
@@ -543,3 +543,32 @@ gdk_gl_context_get_current (void)
 
   return current;
 }
+
+/**
+ * gdk_gl_get_flags:
+ *
+ * Returns the currently active GL flags.
+ *
+ * Returns: the GL flags
+ *
+ * Since: 3.16
+ */
+GdkGLFlags
+gdk_gl_get_flags (void)
+{
+  return _gdk_gl_flags;
+}
+
+/**
+ * gdk_gl_set_flags:
+ * @flags: #GdkGLFlags to set
+ *
+ * Sets GL flags.
+ *
+ * Since: 3.16
+ */
+void
+gdk_gl_set_flags (GdkGLFlags flags)
+{
+  _gdk_gl_flags = flags;
+}
diff --git a/gdk/gdkglcontext.h b/gdk/gdkglcontext.h
index be71ae4..73660d2 100644
--- a/gdk/gdkglcontext.h
+++ b/gdk/gdkglcontext.h
@@ -56,6 +56,34 @@ GdkGLContext *          gdk_gl_context_get_current      (void);
 GDK_AVAILABLE_IN_3_16
 void                    gdk_gl_context_clear_current    (void);
 
+/**
+ * GdkGLFlags:
+ * @GDK_GL_DISABLE: Disable creating new windows with GL rendering
+ * @GDK_GL_ALWAYS: Make all newly created windows use GL rendering
+ * @GDK_GL_SOFTWARE_DRAW_GL: Always use software fallback for drawing
+ *     GL content to a cairo_t. This disables the fast paths that exist for
+ *     drawing directly to a window and instead reads back the pixels into
+ *     a cairo image surface.
+ * @GDK_GL_SOFTWARE_DRAW_SURFACE: Always use software fallback for
+ *     drawing cairo surfaces onto a GL-using window. This disables e.g.
+ *     texture-from-pixmap on X11.
+ * @GDK_GL_TEXTURE_RECTANGLE: Use the GL_ARB_texture_rectangle extension
+ *
+ * Flags that influence the OpenGL rendering used by GDK.
+ */
+typedef enum {
+  GDK_GL_DISABLE                = 1 << 0,
+  GDK_GL_ALWAYS                 = 1 << 1,
+  GDK_GL_SOFTWARE_DRAW_GL       = 1 << 2,
+  GDK_GL_SOFTWARE_DRAW_SURFACE  = 1 << 3,
+  GDK_GL_TEXTURE_RECTANGLE      = 1 << 4
+} GdkGLFlags;
+
+GDK_AVAILABLE_IN_3_16
+GdkGLFlags              gdk_gl_get_flags (void);
+GDK_AVAILABLE_IN_3_16
+void                    gdk_gl_set_flags (GdkGLFlags flags);
+
 G_END_DECLS
 
 #endif /* __GDK_GL_CONTEXT_H__ */
diff --git a/gdk/gdkinternals.h b/gdk/gdkinternals.h
index 6543f55..5893cf6 100644
--- a/gdk/gdkinternals.h
+++ b/gdk/gdkinternals.h
@@ -89,15 +89,6 @@ typedef enum {
 } GdkDebugFlag;
 
 typedef enum {
-  GDK_GL_FLAGS_DISABLE                = 1 << 0,
-  GDK_GL_FLAGS_ALWAYS                 = 1 << 1,
-  GDK_GL_FLAGS_SOFTWARE_DRAW_GL       = 1 << 2,
-  GDK_GL_FLAGS_SOFTWARE_DRAW_SURFACE  = 1 << 3,
-  GDK_GL_FLAGS_TEXTURE_RECTANGLE      = 1 << 4,
-} GdkGLFlags;
-
-
-typedef enum {
   GDK_RENDERING_MODE_SIMILAR = 0,
   GDK_RENDERING_MODE_IMAGE,
   GDK_RENDERING_MODE_RECORDING
diff --git a/gdk/gdkwindow.c b/gdk/gdkwindow.c
index 0c09836..f90d41c 100644
--- a/gdk/gdkwindow.c
+++ b/gdk/gdkwindow.c
@@ -1419,7 +1419,7 @@ gdk_window_new (GdkWindow     *parent,
                     G_CALLBACK (device_removed_cb), window);
 
 
-  if ((_gdk_gl_flags & (GDK_GL_FLAGS_ALWAYS | GDK_GL_FLAGS_DISABLE)) == GDK_GL_FLAGS_ALWAYS)
+  if ((_gdk_gl_flags & (GDK_GL_ALWAYS | GDK_GL_DISABLE)) == GDK_GL_ALWAYS)
     {
       GError *error = NULL;
 
@@ -2725,7 +2725,7 @@ gdk_window_ref_impl_surface (GdkWindow *window)
 GdkGLContext *
 gdk_window_get_paint_gl_context (GdkWindow *window, GError **error)
 {
-  if (_gdk_gl_flags & GDK_GL_FLAGS_DISABLE)
+  if (_gdk_gl_flags & GDK_GL_DISABLE)
     {
       g_set_error_literal (error, GDK_GL_ERROR,
                            GDK_GL_ERROR_NOT_AVAILABLE,


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