[mutter] cogl/framebuffer: Move read_pixels_into_bitmap() to driver class



commit 0fcb26075fcc6e5879f50b1addb1b97cc06f3200
Author: Jonas Ã…dahl <jadahl gmail com>
Date:   Tue Oct 20 11:14:38 2020 +0200

    cogl/framebuffer: Move read_pixels_into_bitmap() to driver class
    
    This was the last driver vfunc used specifically to implement the
    CoglFramebuffer driver.
    
    Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/1514>

 cogl/cogl/cogl-driver.h                            |  8 ----
 cogl/cogl/cogl-framebuffer-driver.c                | 14 +++++++
 cogl/cogl/cogl-framebuffer-driver.h                | 15 +++++++
 cogl/cogl/cogl-framebuffer.c                       | 13 +++---
 cogl/cogl/driver/gl/cogl-framebuffer-gl-private.h  |  8 ----
 cogl/cogl/driver/gl/cogl-framebuffer-gl.c          | 18 ++++----
 cogl/cogl/driver/gl/gl/cogl-driver-gl.c            |  1 -
 cogl/cogl/driver/gl/gles/cogl-driver-gles.c        |  1 -
 cogl/cogl/driver/nop/cogl-driver-nop.c             |  2 -
 .../cogl/driver/nop/cogl-framebuffer-nop-private.h | 48 ----------------------
 cogl/cogl/driver/nop/cogl-framebuffer-nop.c        | 47 ---------------------
 cogl/cogl/driver/nop/cogl-nop-framebuffer.c        | 13 ++++++
 cogl/cogl/meson.build                              |  2 -
 13 files changed, 58 insertions(+), 132 deletions(-)
---
diff --git a/cogl/cogl/cogl-driver.h b/cogl/cogl/cogl-driver.h
index f2ae3e7b93..21519085b2 100644
--- a/cogl/cogl/cogl-driver.h
+++ b/cogl/cogl/cogl-driver.h
@@ -85,14 +85,6 @@ struct _CoglDriverVtable
                                CoglFramebuffer      *read_buffer,
                                CoglFramebufferState  state);
 
-  gboolean
-  (* framebuffer_read_pixels_into_bitmap) (CoglFramebuffer *framebuffer,
-                                           int x,
-                                           int y,
-                                           CoglReadPixelsFlags source,
-                                           CoglBitmap *bitmap,
-                                           GError **error);
-
   /* Destroys any driver specific resources associated with the given
    * 2D texture. */
   void
diff --git a/cogl/cogl/cogl-framebuffer-driver.c b/cogl/cogl/cogl-framebuffer-driver.c
index d49f90d291..bd99a795d6 100644
--- a/cogl/cogl/cogl-framebuffer-driver.c
+++ b/cogl/cogl/cogl-framebuffer-driver.c
@@ -145,6 +145,20 @@ cogl_framebuffer_driver_draw_indexed_attributes (CoglFramebufferDriver  *driver,
                                   flags);
 }
 
+gboolean
+cogl_framebuffer_driver_read_pixels_into_bitmap (CoglFramebufferDriver  *driver,
+                                                 int                     x,
+                                                 int                     y,
+                                                 CoglReadPixelsFlags     source,
+                                                 CoglBitmap             *bitmap,
+                                                 GError                **error)
+{
+  CoglFramebufferDriverClass *klass =
+    COGL_FRAMEBUFFER_DRIVER_GET_CLASS (driver);
+
+  return klass->read_pixels_into_bitmap (driver, x, y, source, bitmap, error);
+}
+
 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 7608701e0c..d8815234b1 100644
--- a/cogl/cogl/cogl-framebuffer-driver.h
+++ b/cogl/cogl/cogl-framebuffer-driver.h
@@ -78,6 +78,13 @@ struct _CoglFramebufferDriverClass
                                     CoglAttribute         **attributes,
                                     int                     n_attributes,
                                     CoglDrawFlags           flags);
+
+  gboolean (* read_pixels_into_bitmap) (CoglFramebufferDriver  *driver,
+                                        int                     x,
+                                        int                     y,
+                                        CoglReadPixelsFlags     source,
+                                        CoglBitmap             *bitmap,
+                                        GError                **error);
 };
 
 CoglFramebuffer *
@@ -126,4 +133,12 @@ cogl_framebuffer_driver_draw_indexed_attributes (CoglFramebufferDriver  *driver,
                                                  int                     n_attributes,
                                                  CoglDrawFlags           flags);
 
+gboolean
+cogl_framebuffer_driver_read_pixels_into_bitmap (CoglFramebufferDriver  *driver,
+                                                 int                     x,
+                                                 int                     y,
+                                                 CoglReadPixelsFlags     source,
+                                                 CoglBitmap             *bitmap,
+                                                 GError                **error);
+
 #endif /* COGL_FRAMEBUFFER_DRIVER_H */
diff --git a/cogl/cogl/cogl-framebuffer.c b/cogl/cogl/cogl-framebuffer.c
index c02eabd9c0..41194829c7 100644
--- a/cogl/cogl/cogl-framebuffer.c
+++ b/cogl/cogl/cogl-framebuffer.c
@@ -1483,7 +1483,6 @@ _cogl_framebuffer_read_pixels_into_bitmap (CoglFramebuffer *framebuffer,
 {
   CoglFramebufferPrivate *priv =
     cogl_framebuffer_get_instance_private (framebuffer);
-  CoglContext *ctx;
   int width;
   int height;
 
@@ -1511,18 +1510,16 @@ _cogl_framebuffer_read_pixels_into_bitmap (CoglFramebuffer *framebuffer,
         return TRUE;
     }
 
-  ctx = cogl_framebuffer_get_context (framebuffer);
-
   /* make sure any batched primitives get emitted to the driver
    * before issuing our read pixels...
    */
   _cogl_framebuffer_flush_journal (framebuffer);
 
-  return ctx->driver_vtable->framebuffer_read_pixels_into_bitmap (framebuffer,
-                                                                  x, y,
-                                                                  source,
-                                                                  bitmap,
-                                                                  error);
+  return cogl_framebuffer_driver_read_pixels_into_bitmap (priv->driver,
+                                                          x, y,
+                                                          source,
+                                                          bitmap,
+                                                          error);
 }
 
 gboolean
diff --git a/cogl/cogl/driver/gl/cogl-framebuffer-gl-private.h 
b/cogl/cogl/driver/gl/cogl-framebuffer-gl-private.h
index c7e2995c67..4bdd076a67 100644
--- a/cogl/cogl/driver/gl/cogl-framebuffer-gl-private.h
+++ b/cogl/cogl/driver/gl/cogl-framebuffer-gl-private.h
@@ -55,14 +55,6 @@ void
 cogl_gl_framebuffer_bind (CoglGlFramebuffer *gl_framebuffer,
                           GLenum             target);
 
-gboolean
-_cogl_framebuffer_gl_read_pixels_into_bitmap (CoglFramebuffer *framebuffer,
-                                              int x,
-                                              int y,
-                                              CoglReadPixelsFlags source,
-                                              CoglBitmap *bitmap,
-                                              GError **error);
-
 void
 cogl_gl_framebuffer_flush_state_differences (CoglGlFramebuffer *gl_framebuffer,
                                              unsigned long      differences);
diff --git a/cogl/cogl/driver/gl/cogl-framebuffer-gl.c b/cogl/cogl/driver/gl/cogl-framebuffer-gl.c
index fee3f22334..e053d0ad4d 100644
--- a/cogl/cogl/driver/gl/cogl-framebuffer-gl.c
+++ b/cogl/cogl/driver/gl/cogl-framebuffer-gl.c
@@ -419,14 +419,16 @@ cogl_gl_framebuffer_draw_indexed_attributes (CoglFramebufferDriver  *driver,
   _cogl_buffer_gl_unbind (buffer);
 }
 
-gboolean
-_cogl_framebuffer_gl_read_pixels_into_bitmap (CoglFramebuffer *framebuffer,
-                                              int x,
-                                              int y,
-                                              CoglReadPixelsFlags source,
-                                              CoglBitmap *bitmap,
-                                              GError **error)
+static gboolean
+cogl_gl_framebuffer_read_pixels_into_bitmap (CoglFramebufferDriver  *driver,
+                                             int                     x,
+                                             int                     y,
+                                             CoglReadPixelsFlags     source,
+                                             CoglBitmap             *bitmap,
+                                             GError                **error)
 {
+  CoglFramebuffer *framebuffer =
+    cogl_framebuffer_driver_get_framebuffer (driver);
   CoglContext *ctx = cogl_framebuffer_get_context (framebuffer);
   int framebuffer_height = cogl_framebuffer_get_height (framebuffer);
   int width = cogl_bitmap_get_width (bitmap);
@@ -693,4 +695,6 @@ cogl_gl_framebuffer_class_init (CoglGlFramebufferClass *klass)
   driver_class->draw_attributes = cogl_gl_framebuffer_draw_attributes;
   driver_class->draw_indexed_attributes =
     cogl_gl_framebuffer_draw_indexed_attributes;
+  driver_class->read_pixels_into_bitmap =
+    cogl_gl_framebuffer_read_pixels_into_bitmap;
 }
diff --git a/cogl/cogl/driver/gl/gl/cogl-driver-gl.c b/cogl/cogl/driver/gl/gl/cogl-driver-gl.c
index 76f213b74d..35577518d0 100644
--- a/cogl/cogl/driver/gl/gl/cogl-driver-gl.c
+++ b/cogl/cogl/driver/gl/gl/cogl-driver-gl.c
@@ -571,7 +571,6 @@ _cogl_driver_gl =
     _cogl_driver_update_features,
     _cogl_driver_gl_create_framebuffer_driver,
     _cogl_driver_gl_flush_framebuffer_state,
-    _cogl_framebuffer_gl_read_pixels_into_bitmap,
     _cogl_texture_2d_gl_free,
     _cogl_texture_2d_gl_can_create,
     _cogl_texture_2d_gl_init,
diff --git a/cogl/cogl/driver/gl/gles/cogl-driver-gles.c b/cogl/cogl/driver/gl/gles/cogl-driver-gles.c
index 5b50b76914..3e8ea8a0a2 100644
--- a/cogl/cogl/driver/gl/gles/cogl-driver-gles.c
+++ b/cogl/cogl/driver/gl/gles/cogl-driver-gles.c
@@ -459,7 +459,6 @@ _cogl_driver_gles =
     _cogl_driver_update_features,
     _cogl_driver_gl_create_framebuffer_driver,
     _cogl_driver_gl_flush_framebuffer_state,
-    _cogl_framebuffer_gl_read_pixels_into_bitmap,
     _cogl_texture_2d_gl_free,
     _cogl_texture_2d_gl_can_create,
     _cogl_texture_2d_gl_init,
diff --git a/cogl/cogl/driver/nop/cogl-driver-nop.c b/cogl/cogl/driver/nop/cogl-driver-nop.c
index 0d47bf28bc..2cde8576b9 100644
--- a/cogl/cogl/driver/nop/cogl-driver-nop.c
+++ b/cogl/cogl/driver/nop/cogl-driver-nop.c
@@ -36,7 +36,6 @@
 #include "cogl-context-private.h"
 #include "cogl-feature-private.h"
 #include "cogl-renderer-private.h"
-#include "cogl-framebuffer-nop-private.h"
 #include "cogl-texture-2d-nop-private.h"
 #include "cogl-attribute-nop-private.h"
 #include "cogl-clip-stack-nop-private.h"
@@ -99,7 +98,6 @@ _cogl_driver_nop =
     _cogl_driver_update_features,
     _cogl_driver_nop_create_framebuffer_driver,
     _cogl_driver_nop_flush_framebuffer_state,
-    _cogl_framebuffer_nop_read_pixels_into_bitmap,
     _cogl_texture_2d_nop_free,
     _cogl_texture_2d_nop_can_create,
     _cogl_texture_2d_nop_init,
diff --git a/cogl/cogl/driver/nop/cogl-nop-framebuffer.c b/cogl/cogl/driver/nop/cogl-nop-framebuffer.c
index 20ec514a5d..3ab05338ea 100644
--- a/cogl/cogl/driver/nop/cogl-nop-framebuffer.c
+++ b/cogl/cogl/driver/nop/cogl-nop-framebuffer.c
@@ -95,6 +95,17 @@ cogl_nop_framebuffer_draw_indexed_attributes (CoglFramebufferDriver *driver,
 {
 }
 
+static gboolean
+cogl_nop_framebuffer_read_pixels_into_bitmap (CoglFramebufferDriver  *framebuffer,
+                                              int                     x,
+                                              int                     y,
+                                              CoglReadPixelsFlags     source,
+                                              CoglBitmap             *bitmap,
+                                              GError                **error)
+{
+  return TRUE;
+}
+
 static void
 cogl_nop_framebuffer_init (CoglNopFramebuffer *nop_framebuffer)
 {
@@ -114,4 +125,6 @@ cogl_nop_framebuffer_class_init (CoglNopFramebufferClass *klass)
   driver_class->draw_attributes = cogl_nop_framebuffer_draw_attributes;
   driver_class->draw_indexed_attributes =
     cogl_nop_framebuffer_draw_indexed_attributes;
+  driver_class->read_pixels_into_bitmap =
+    cogl_nop_framebuffer_read_pixels_into_bitmap;
 }
diff --git a/cogl/cogl/meson.build b/cogl/cogl/meson.build
index f8ae283a83..a76b9685c5 100644
--- a/cogl/cogl/meson.build
+++ b/cogl/cogl/meson.build
@@ -130,8 +130,6 @@ cogl_nodist_headers = [
 
 cogl_noop_driver_sources = [
   'driver/nop/cogl-driver-nop.c',
-  'driver/nop/cogl-framebuffer-nop-private.h',
-  'driver/nop/cogl-framebuffer-nop.c',
   'driver/nop/cogl-nop-framebuffer.c',
   'driver/nop/cogl-nop-framebuffer.h',
   'driver/nop/cogl-attribute-nop-private.h',


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