[mutter] cogl/offscreen: Move CoglGlFbo struct to GL driver



commit 8910b3e7bc92cf7762cb939df09ee2ff6b1f7795
Author: Jonas Ã…dahl <jadahl gmail com>
Date:   Sun Oct 18 21:23:40 2020 +0200

    cogl/offscreen: Move CoglGlFbo struct to GL driver
    
    It was only used there, so put it in the driver private struct.
    
    Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/1514>

 cogl/cogl/cogl-offscreen-private.h        |  9 ---------
 cogl/cogl/driver/gl/cogl-framebuffer-gl.c | 31 ++++++++++++++++++++++++++-----
 2 files changed, 26 insertions(+), 14 deletions(-)
---
diff --git a/cogl/cogl/cogl-offscreen-private.h b/cogl/cogl/cogl-offscreen-private.h
index 2b6241edbc..a84815fe6e 100644
--- a/cogl/cogl/cogl-offscreen-private.h
+++ b/cogl/cogl/cogl-offscreen-private.h
@@ -44,19 +44,10 @@ typedef enum
   COGL_OFFSCREEN_ALLOCATE_FLAG_STENCIL = 1 << 2,
 } CoglOffscreenAllocateFlags;
 
-typedef struct _CoglGLFramebuffer
-{
-  GLuint fbo_handle;
-  GList *renderbuffers;
-  int samples_per_pixel;
-} CoglGlFbo;
-
 struct _CoglOffscreen
 {
   CoglFramebuffer parent;
 
-  CoglGlFbo gl_fbo;
-
   CoglTexture *texture;
   int texture_level;
 
diff --git a/cogl/cogl/driver/gl/cogl-framebuffer-gl.c b/cogl/cogl/driver/gl/cogl-framebuffer-gl.c
index 625d55367a..f2a2e1217a 100644
--- a/cogl/cogl/driver/gl/cogl-framebuffer-gl.c
+++ b/cogl/cogl/driver/gl/cogl-framebuffer-gl.c
@@ -128,10 +128,19 @@
 #define GL_STENCIL 0x1802
 #endif
 
+typedef struct _CoglGlFbo
+{
+  GLuint fbo_handle;
+  GList *renderbuffers;
+  int samples_per_pixel;
+} CoglGlFbo;
+
 struct _CoglGlFramebuffer
 {
   GObject parent;
 
+  CoglGlFbo gl_fbo;
+
   gboolean dirty_bitmasks;
   CoglFramebufferBits bits;
 };
@@ -139,6 +148,9 @@ struct _CoglGlFramebuffer
 G_DEFINE_TYPE (CoglGlFramebuffer, cogl_gl_framebuffer,
                G_TYPE_OBJECT)
 
+static CoglGlFramebuffer *
+ensure_gl_framebuffer (CoglFramebuffer *framebuffer);
+
 static void
 _cogl_framebuffer_gl_flush_viewport_state (CoglFramebuffer *framebuffer)
 {
@@ -298,9 +310,11 @@ _cogl_framebuffer_gl_bind (CoglFramebuffer *framebuffer, GLenum target)
 
   if (COGL_IS_OFFSCREEN (framebuffer))
     {
-      CoglOffscreen *offscreen = COGL_OFFSCREEN (framebuffer);
+      CoglGlFramebuffer *gl_framebuffer;
+
+      gl_framebuffer = ensure_gl_framebuffer (framebuffer);
       GE (ctx, glBindFramebuffer (target,
-                                  offscreen->gl_fbo.fbo_handle));
+                                  gl_framebuffer->gl_fbo.fbo_handle));
     }
   else
     {
@@ -762,7 +776,8 @@ _cogl_offscreen_gl_allocate (CoglOffscreen *offscreen,
   CoglFramebuffer *framebuffer = COGL_FRAMEBUFFER (offscreen);
   CoglContext *ctx = cogl_framebuffer_get_context (framebuffer);
   CoglOffscreenAllocateFlags flags;
-  CoglGlFbo *gl_fbo = &offscreen->gl_fbo;
+  CoglGlFramebuffer *gl_framebuffer;
+  CoglGlFbo *gl_fbo;
   const CoglFramebufferConfig *config;
   int level_width;
   int level_height;
@@ -792,6 +807,9 @@ _cogl_offscreen_gl_allocate (CoglOffscreen *offscreen,
 
   config = cogl_framebuffer_get_config (framebuffer);
 
+  gl_framebuffer = ensure_gl_framebuffer (framebuffer);
+  gl_fbo = &gl_framebuffer->gl_fbo;
+
   if (((offscreen->create_flags & COGL_OFFSCREEN_DISABLE_DEPTH_AND_STENCIL) &&
        try_creating_fbo (ctx,
                          offscreen->texture,
@@ -904,10 +922,13 @@ _cogl_offscreen_gl_free (CoglOffscreen *offscreen)
 {
   CoglFramebuffer *framebuffer = COGL_FRAMEBUFFER (offscreen);
   CoglContext *ctx = cogl_framebuffer_get_context (framebuffer);
+  CoglGlFramebuffer *gl_framebuffer;
+
+  gl_framebuffer = ensure_gl_framebuffer (framebuffer);
 
-  delete_renderbuffers (ctx, offscreen->gl_fbo.renderbuffers);
+  delete_renderbuffers (ctx, gl_framebuffer->gl_fbo.renderbuffers);
 
-  GE (ctx, glDeleteFramebuffers (1, &offscreen->gl_fbo.fbo_handle));
+  GE (ctx, glDeleteFramebuffers (1, &gl_framebuffer->gl_fbo.fbo_handle));
 }
 
 void


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