[gtk/ngl-is-the-new-gl] gsk: provide an ngl renderer



commit b7eb1d33100cb403f111e1665bb334f2e2adf02c
Author: Matthias Clasen <mclasen redhat com>
Date:   Thu Oct 7 16:46:29 2021 -0400

    gsk: provide an ngl renderer
    
    Provide a minimal renderer implementation that fails
    in realize. This avoids reusing the same type, which
    might give bindings trouble.

 gsk/gl/gskglrenderer.c | 36 ++++++++++++++++++++++++++++++++----
 1 file changed, 32 insertions(+), 4 deletions(-)
---
diff --git a/gsk/gl/gskglrenderer.c b/gsk/gl/gskglrenderer.c
index 7d0eebfaa7..0b1e9eddda 100644
--- a/gsk/gl/gskglrenderer.c
+++ b/gsk/gl/gskglrenderer.c
@@ -321,10 +321,36 @@ gsk_gl_renderer_try_compile_gl_shader (GskGLRenderer  *renderer,
   return program != NULL;
 }
 
-GType
-gsk_ngl_renderer_get_type (void)
+typedef struct {
+  GskRenderer parent_instance;
+} GskNglRenderer;
+
+typedef struct {
+  GskRendererClass parent_class;
+} GskNglRendererClass;
+
+G_DEFINE_TYPE (GskNglRenderer, gsk_ngl_renderer, GSK_TYPE_RENDERER)
+
+static void
+gsk_ngl_renderer_init (GskNglRenderer *renderer)
+{
+}
+
+static gboolean
+gsk_ngl_renderer_realize (GskRenderer  *renderer,
+                          GdkSurface   *surface,
+                          GError      **error)
+{
+  g_set_error_literal (error,
+                       G_IO_ERROR, G_IO_ERROR_FAILED,
+                       "please use the GL renderer instead");
+  return FALSE;
+}
+
+static void
+gsk_ngl_renderer_class_init (GskNglRendererClass *class)
 {
-  return gsk_gl_renderer_get_type ();
+  GSK_RENDERER_CLASS (class)->realize = gsk_ngl_renderer_realize;
 }
 
 /**
@@ -339,5 +365,7 @@ gsk_ngl_renderer_get_type (void)
 GskRenderer *
 gsk_ngl_renderer_new (void)
 {
-  return gsk_gl_renderer_new ();
+G_GNUC_BEGIN_IGNORE_DEPRECATIONS
+  return g_object_new (gsk_ngl_renderer_get_type (), NULL);
+G_GNUC_END_IGNORE_DEPRECATIONS
 }


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