[gtk+/wip/ebassi/gles] fixup! glarea: Relay the use-es flag to context creation



commit e479857646348429b7f3ef4daaa8a2a4bc49b727
Author: Emmanuele Bassi <ebassi gnome org>
Date:   Sat Apr 23 10:31:56 2016 +0100

    fixup! glarea: Relay the use-es flag to context creation

 gtk/gtkglarea.c |   62 +++++++++++++++++++++++++++++++++++++++++++++++++++++-
 1 files changed, 60 insertions(+), 2 deletions(-)
---
diff --git a/gtk/gtkglarea.c b/gtk/gtkglarea.c
index efd7d03..4803886 100644
--- a/gtk/gtkglarea.c
+++ b/gtk/gtkglarea.c
@@ -167,6 +167,7 @@ enum {
   PROP_HAS_ALPHA,
   PROP_HAS_DEPTH_BUFFER,
   PROP_HAS_STENCIL_BUFFER,
+  PROP_USE_ES,
 
   PROP_AUTO_RENDER,
 
@@ -226,6 +227,10 @@ gtk_gl_area_set_property (GObject      *gobject,
       gtk_gl_area_set_has_stencil_buffer (self, g_value_get_boolean (value));
       break;
 
+    case PROP_USE_ES:
+      gtk_gl_area_set_use_es (self, g_value_get_boolean (value));
+      break;
+
     default:
       G_OBJECT_WARN_INVALID_PROPERTY_ID (gobject, prop_id, pspec);
     }
@@ -261,6 +266,10 @@ gtk_gl_area_get_property (GObject    *gobject,
       g_value_set_object (value, priv->context);
       break;
 
+    case PROP_USE_ES:
+      g_value_set_boolean (value, priv->use_es);
+      break;
+
     default:
       G_OBJECT_WARN_INVALID_PROPERTY_ID (gobject, prop_id, pspec);
     }
@@ -852,6 +861,25 @@ gtk_gl_area_class_init (GtkGLAreaClass *klass)
                           G_PARAM_STATIC_STRINGS |
                           G_PARAM_EXPLICIT_NOTIFY);
 
+  /**
+   * GtkGLArea:use-es:
+   *
+   * If set to %TRUE the widget will try to create a #GdkGLContext using
+   * OpenGL ES instead of OpenGL.
+   *
+   * See also: gdk_gl_context_set_use_es()
+   *
+   * Since: 3.22
+   */
+  obj_props[PROP_USE_ES] =
+    g_param_spec_boolean ("use-es",
+                          P_("Use OpenGL ES"),
+                          P_("Whether the context uses OpenGL or OpenGL ES"),
+                          FALSE,
+                          GTK_PARAM_READWRITE |
+                          G_PARAM_STATIC_STRINGS |
+                          G_PARAM_EXPLICIT_NOTIFY);
+
   gobject_class->set_property = gtk_gl_area_set_property;
   gobject_class->get_property = gtk_gl_area_get_property;
   gobject_class->dispose = gtk_gl_area_dispose;
@@ -1014,6 +1042,18 @@ gtk_gl_area_get_error (GtkGLArea *area)
   return priv->error;
 }
 
+/**
+ * gtk_gl_area_set_use_es:
+ * @area: a #GtkGLArea
+ * @use_es: whether to use OpenGL or OpenGL ES
+ *
+ * Sets whether the @area should create an OpenGL or an OpenGL ES context.
+ *
+ * You should check the capabilities of the #GdkGLContext before drawing
+ * with either API.
+ *
+ * Since: 3.22
+ */
 void
 gtk_gl_area_set_use_es (GtkGLArea *area,
                         gboolean   use_es)
@@ -1023,15 +1063,33 @@ gtk_gl_area_set_use_es (GtkGLArea *area,
   g_return_if_fail (GTK_IS_GL_AREA (area));
   g_return_if_fail (!gtk_widget_get_realized (GTK_WIDGET (area)));
 
-  priv->use_es = use_es;
+  use_es = !!use_es;
+
+  if (priv->use_es != use_es)
+    {
+      priv->use_es = use_es;
+
+      g_object_notify_by_pspec (G_OBJECT (area), obj_props[PROP_USE_ES]);
+    }
 }
 
+/**
+ * gtk_gl_area_get_use_es:
+ * @area: a #GtkGLArea
+ *
+ * Retrieves the value set by gtk_gl_area_set_use_es().
+ *
+ * Returns: %TRUE if the #GtkGLArea should create an OpenGL ES context
+ *   and %FALSE otherwise
+ *
+ * Since: 3.22
+ */
 gboolean
 gtk_gl_area_get_use_es (GtkGLArea *area)
 {
   GtkGLAreaPrivate *priv = gtk_gl_area_get_instance_private (area);
 
-  g_return_if_fail (GTK_IS_GL_AREA (area));
+  g_return_val_if_fail (GTK_IS_GL_AREA (area), FALSE);
 
   return priv->use_es;
 }


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