[mutter] cogl/framebuffer: Move flush() and finish() to driver class



commit b7c6865225afbd8c30861e2f840df44d24a6983e
Author: Jonas Ã…dahl <jadahl gmail com>
Date:   Tue Oct 20 09:42:57 2020 +0200

    cogl/framebuffer: Move flush() and finish() to driver class
    
    Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/1514>

 cogl/cogl/cogl-driver.h                             |  6 ------
 cogl/cogl/cogl-framebuffer-driver.c                 | 12 ++++++++++++
 cogl/cogl/cogl-framebuffer-driver.h                 | 10 ++++++++++
 cogl/cogl/cogl-framebuffer.c                        |  6 ++----
 cogl/cogl/driver/gl/cogl-framebuffer-gl-private.h   |  6 ------
 cogl/cogl/driver/gl/cogl-framebuffer-gl.c           | 18 ++++++++++++------
 cogl/cogl/driver/gl/gl/cogl-driver-gl.c             |  2 --
 cogl/cogl/driver/gl/gles/cogl-driver-gles.c         |  2 --
 cogl/cogl/driver/nop/cogl-driver-nop.c              |  2 --
 cogl/cogl/driver/nop/cogl-framebuffer-nop-private.h |  6 ------
 cogl/cogl/driver/nop/cogl-framebuffer-nop.c         | 10 ----------
 cogl/cogl/driver/nop/cogl-nop-framebuffer.c         | 12 ++++++++++++
 12 files changed, 48 insertions(+), 44 deletions(-)
---
diff --git a/cogl/cogl/cogl-driver.h b/cogl/cogl/cogl-driver.h
index de195efc8a..6d79e3a752 100644
--- a/cogl/cogl/cogl-driver.h
+++ b/cogl/cogl/cogl-driver.h
@@ -85,12 +85,6 @@ struct _CoglDriverVtable
                                CoglFramebuffer      *read_buffer,
                                CoglFramebufferState  state);
 
-  void
-  (* framebuffer_finish) (CoglFramebuffer *framebuffer);
-
-  void
-  (* framebuffer_flush) (CoglFramebuffer *framebuffer);
-
   void
   (* framebuffer_discard_buffers) (CoglFramebuffer *framebuffer,
                                    unsigned long buffers);
diff --git a/cogl/cogl/cogl-framebuffer-driver.c b/cogl/cogl/cogl-framebuffer-driver.c
index 9616cec8b1..4e9c92707e 100644
--- a/cogl/cogl/cogl-framebuffer-driver.c
+++ b/cogl/cogl/cogl-framebuffer-driver.c
@@ -81,6 +81,18 @@ cogl_framebuffer_driver_clear (CoglFramebufferDriver *driver,
                                                      alpha);
 }
 
+void
+cogl_framebuffer_driver_finish (CoglFramebufferDriver *driver)
+{
+  COGL_FRAMEBUFFER_DRIVER_GET_CLASS (driver)->finish (driver);
+}
+
+void
+cogl_framebuffer_driver_flush (CoglFramebufferDriver *driver)
+{
+  COGL_FRAMEBUFFER_DRIVER_GET_CLASS (driver)->flush (driver);
+}
+
 static void
 cogl_framebuffer_driver_get_property (GObject    *object,
                                       guint       prop_id,
diff --git a/cogl/cogl/cogl-framebuffer-driver.h b/cogl/cogl/cogl-framebuffer-driver.h
index 39883f29f7..416db10987 100644
--- a/cogl/cogl/cogl-framebuffer-driver.h
+++ b/cogl/cogl/cogl-framebuffer-driver.h
@@ -51,6 +51,10 @@ struct _CoglFramebufferDriverClass
                   float                  green,
                   float                  blue,
                   float                  alpha);
+
+  void (* finish) (CoglFramebufferDriver *driver);
+
+  void (* flush) (CoglFramebufferDriver *driver);
 };
 
 CoglFramebuffer *
@@ -68,4 +72,10 @@ cogl_framebuffer_driver_clear (CoglFramebufferDriver *driver,
                                float                  blue,
                                float                  alpha);
 
+void
+cogl_framebuffer_driver_finish (CoglFramebufferDriver *driver);
+
+void
+cogl_framebuffer_driver_flush (CoglFramebufferDriver *driver);
+
 #endif /* COGL_FRAMEBUFFER_DRIVER_H */
diff --git a/cogl/cogl/cogl-framebuffer.c b/cogl/cogl/cogl-framebuffer.c
index 53d2cbcc52..9e0739d36f 100644
--- a/cogl/cogl/cogl-framebuffer.c
+++ b/cogl/cogl/cogl-framebuffer.c
@@ -1707,11 +1707,10 @@ cogl_framebuffer_finish (CoglFramebuffer *framebuffer)
 {
   CoglFramebufferPrivate *priv =
     cogl_framebuffer_get_instance_private (framebuffer);
-  CoglContext *ctx = priv->context;
 
   _cogl_framebuffer_flush_journal (framebuffer);
 
-  ctx->driver_vtable->framebuffer_finish (framebuffer);
+  cogl_framebuffer_driver_finish (priv->driver);
 }
 
 void
@@ -1719,11 +1718,10 @@ cogl_framebuffer_flush (CoglFramebuffer *framebuffer)
 {
   CoglFramebufferPrivate *priv =
     cogl_framebuffer_get_instance_private (framebuffer);
-  CoglContext *ctx = priv->context;
 
   _cogl_framebuffer_flush_journal (framebuffer);
 
-  ctx->driver_vtable->framebuffer_flush (framebuffer);
+  cogl_framebuffer_driver_flush (priv->driver);
 }
 
 void
diff --git a/cogl/cogl/driver/gl/cogl-framebuffer-gl-private.h 
b/cogl/cogl/driver/gl/cogl-framebuffer-gl-private.h
index 02d7e86f4b..9e2205cdf2 100644
--- a/cogl/cogl/driver/gl/cogl-framebuffer-gl-private.h
+++ b/cogl/cogl/driver/gl/cogl-framebuffer-gl-private.h
@@ -51,12 +51,6 @@ struct _CoglGlFramebufferClass
                  GLenum             target);
 };
 
-void
-_cogl_framebuffer_gl_finish (CoglFramebuffer *framebuffer);
-
-void
-_cogl_framebuffer_gl_flush (CoglFramebuffer *framebuffer);
-
 void
 _cogl_framebuffer_gl_discard_buffers (CoglFramebuffer *framebuffer,
                                       unsigned long buffers);
diff --git a/cogl/cogl/driver/gl/cogl-framebuffer-gl.c b/cogl/cogl/driver/gl/cogl-framebuffer-gl.c
index 944547e30d..d2040a5abc 100644
--- a/cogl/cogl/driver/gl/cogl-framebuffer-gl.c
+++ b/cogl/cogl/driver/gl/cogl-framebuffer-gl.c
@@ -312,16 +312,20 @@ cogl_gl_framebuffer_clear (CoglFramebufferDriver *driver,
   GE (ctx, glClear (gl_buffers));
 }
 
-void
-_cogl_framebuffer_gl_finish (CoglFramebuffer *framebuffer)
+static void
+cogl_gl_framebuffer_finish (CoglFramebufferDriver *driver)
 {
-  GE (cogl_framebuffer_get_context (framebuffer), glFinish ());
+  CoglContext *ctx = context_from_driver (driver);
+
+  GE (ctx, glFinish ());
 }
 
-void
-_cogl_framebuffer_gl_flush (CoglFramebuffer *framebuffer)
+static void
+cogl_gl_framebuffer_flush (CoglFramebufferDriver *driver)
 {
-  GE (cogl_framebuffer_get_context (framebuffer), glFlush ());
+  CoglContext *ctx = context_from_driver (driver);
+
+  GE (ctx, glFlush ());
 }
 
 void
@@ -717,4 +721,6 @@ cogl_gl_framebuffer_class_init (CoglGlFramebufferClass *klass)
     COGL_FRAMEBUFFER_DRIVER_CLASS (klass);
 
   driver_class->clear = cogl_gl_framebuffer_clear;
+  driver_class->finish = cogl_gl_framebuffer_finish;
+  driver_class->flush = cogl_gl_framebuffer_flush;
 }
diff --git a/cogl/cogl/driver/gl/gl/cogl-driver-gl.c b/cogl/cogl/driver/gl/gl/cogl-driver-gl.c
index 1191987cfe..d4e56c4c97 100644
--- a/cogl/cogl/driver/gl/gl/cogl-driver-gl.c
+++ b/cogl/cogl/driver/gl/gl/cogl-driver-gl.c
@@ -571,8 +571,6 @@ _cogl_driver_gl =
     _cogl_driver_update_features,
     _cogl_driver_gl_create_framebuffer_driver,
     _cogl_driver_gl_flush_framebuffer_state,
-    _cogl_framebuffer_gl_finish,
-    _cogl_framebuffer_gl_flush,
     _cogl_framebuffer_gl_discard_buffers,
     _cogl_framebuffer_gl_draw_attributes,
     _cogl_framebuffer_gl_draw_indexed_attributes,
diff --git a/cogl/cogl/driver/gl/gles/cogl-driver-gles.c b/cogl/cogl/driver/gl/gles/cogl-driver-gles.c
index 45b44bcb33..7a031ae419 100644
--- a/cogl/cogl/driver/gl/gles/cogl-driver-gles.c
+++ b/cogl/cogl/driver/gl/gles/cogl-driver-gles.c
@@ -459,8 +459,6 @@ _cogl_driver_gles =
     _cogl_driver_update_features,
     _cogl_driver_gl_create_framebuffer_driver,
     _cogl_driver_gl_flush_framebuffer_state,
-    _cogl_framebuffer_gl_finish,
-    _cogl_framebuffer_gl_flush,
     _cogl_framebuffer_gl_discard_buffers,
     _cogl_framebuffer_gl_draw_attributes,
     _cogl_framebuffer_gl_draw_indexed_attributes,
diff --git a/cogl/cogl/driver/nop/cogl-driver-nop.c b/cogl/cogl/driver/nop/cogl-driver-nop.c
index c8fe732c5c..96afa3bd0d 100644
--- a/cogl/cogl/driver/nop/cogl-driver-nop.c
+++ b/cogl/cogl/driver/nop/cogl-driver-nop.c
@@ -99,8 +99,6 @@ _cogl_driver_nop =
     _cogl_driver_update_features,
     _cogl_driver_nop_create_framebuffer_driver,
     _cogl_driver_nop_flush_framebuffer_state,
-    _cogl_framebuffer_nop_finish,
-    _cogl_framebuffer_nop_flush,
     _cogl_framebuffer_nop_discard_buffers,
     _cogl_framebuffer_nop_draw_attributes,
     _cogl_framebuffer_nop_draw_indexed_attributes,
diff --git a/cogl/cogl/driver/nop/cogl-framebuffer-nop-private.h 
b/cogl/cogl/driver/nop/cogl-framebuffer-nop-private.h
index e31c31b681..7efe883de5 100644
--- a/cogl/cogl/driver/nop/cogl-framebuffer-nop-private.h
+++ b/cogl/cogl/driver/nop/cogl-framebuffer-nop-private.h
@@ -37,12 +37,6 @@
 #include "cogl-types.h"
 #include "cogl-context-private.h"
 
-void
-_cogl_framebuffer_nop_finish (CoglFramebuffer *framebuffer);
-
-void
-_cogl_framebuffer_nop_flush (CoglFramebuffer *framebuffer);
-
 void
 _cogl_framebuffer_nop_discard_buffers (CoglFramebuffer *framebuffer,
                                        unsigned long buffers);
diff --git a/cogl/cogl/driver/nop/cogl-framebuffer-nop.c b/cogl/cogl/driver/nop/cogl-framebuffer-nop.c
index 9cfe0becca..757ce268cb 100644
--- a/cogl/cogl/driver/nop/cogl-framebuffer-nop.c
+++ b/cogl/cogl/driver/nop/cogl-framebuffer-nop.c
@@ -35,16 +35,6 @@
 #include <glib.h>
 #include <string.h>
 
-void
-_cogl_framebuffer_nop_finish (CoglFramebuffer *framebuffer)
-{
-}
-
-void
-_cogl_framebuffer_nop_flush (CoglFramebuffer *framebuffer)
-{
-}
-
 void
 _cogl_framebuffer_nop_discard_buffers (CoglFramebuffer *framebuffer,
                                        unsigned long buffers)
diff --git a/cogl/cogl/driver/nop/cogl-nop-framebuffer.c b/cogl/cogl/driver/nop/cogl-nop-framebuffer.c
index f37056094c..39df6833a2 100644
--- a/cogl/cogl/driver/nop/cogl-nop-framebuffer.c
+++ b/cogl/cogl/driver/nop/cogl-nop-framebuffer.c
@@ -54,6 +54,16 @@ cogl_nop_framebuffer_clear (CoglFramebufferDriver *driver,
 {
 }
 
+static void
+cogl_nop_framebuffer_finish (CoglFramebufferDriver *driver)
+{
+}
+
+static void
+cogl_nop_framebuffer_flush (CoglFramebufferDriver *driver)
+{
+}
+
 static void
 cogl_nop_framebuffer_init (CoglNopFramebuffer *nop_framebuffer)
 {
@@ -67,4 +77,6 @@ cogl_nop_framebuffer_class_init (CoglNopFramebufferClass *klass)
 
   driver_class->query_bits = cogl_nop_framebuffer_query_bits;
   driver_class->clear = cogl_nop_framebuffer_clear;
+  driver_class->finish = cogl_nop_framebuffer_finish;
+  driver_class->flush = cogl_nop_framebuffer_flush;
 }


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