From f56b0abaeff110616a23f2cc8e8ef0191632fdf2 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jonas=20=C3=85dahl?= Date: Sun, 18 Oct 2020 20:04:46 +0200 Subject: [PATCH] cogl/gl-framebuffer: Make it a GObject This way we can have separate types per modes of operation (e.g. if it's backed by an EGLSurface or single texture), instead of being dependent on a certain type (onscreen vs offscreen). Part-of: --- .../driver/gl/cogl-framebuffer-gl-private.h | 5 ++++ cogl/cogl/driver/gl/cogl-framebuffer-gl.c | 23 +++++++++++++++---- 2 files changed, 24 insertions(+), 4 deletions(-) diff --git a/cogl/cogl/driver/gl/cogl-framebuffer-gl-private.h b/cogl/cogl/driver/gl/cogl-framebuffer-gl-private.h index 3e9333a24..301bd8aba 100644 --- a/cogl/cogl/driver/gl/cogl-framebuffer-gl-private.h +++ b/cogl/cogl/driver/gl/cogl-framebuffer-gl-private.h @@ -34,6 +34,11 @@ #ifndef __COGL_FRAMEBUFFER_GL_PRIVATE_H__ #define __COGL_FRAMEBUFFER_GL_PRIVATE_H__ +#define COGL_TYPE_GL_FRAMEBUFFER (cogl_gl_framebuffer_get_type ()) +G_DECLARE_FINAL_TYPE (CoglGlFramebuffer, cogl_gl_framebuffer, + COGL, GL_FRAMEBUFFER, + GObject) + gboolean _cogl_offscreen_gl_allocate (CoglOffscreen *offscreen, GError **error); diff --git a/cogl/cogl/driver/gl/cogl-framebuffer-gl.c b/cogl/cogl/driver/gl/cogl-framebuffer-gl.c index a3801e664..a6b2aa583 100644 --- a/cogl/cogl/driver/gl/cogl-framebuffer-gl.c +++ b/cogl/cogl/driver/gl/cogl-framebuffer-gl.c @@ -127,11 +127,16 @@ #define GL_STENCIL 0x1802 #endif -typedef struct _CoglGlFramebuffer +struct _CoglGlFramebuffer { + GObject parent; + gboolean dirty_bitmasks; CoglFramebufferBits bits; -} CoglGlFramebuffer; +}; + +G_DEFINE_TYPE (CoglGlFramebuffer, cogl_gl_framebuffer, + G_TYPE_OBJECT) static void _cogl_framebuffer_gl_flush_viewport_state (CoglFramebuffer *framebuffer) @@ -957,10 +962,10 @@ ensure_gl_framebuffer (CoglFramebuffer *framebuffer) gl_framebuffer = cogl_framebuffer_get_driver_private (framebuffer); if (!gl_framebuffer) { - gl_framebuffer = g_new0 (CoglGlFramebuffer, 1); + gl_framebuffer = g_object_new (COGL_TYPE_GL_FRAMEBUFFER, NULL); cogl_framebuffer_set_driver_private (framebuffer, gl_framebuffer, - g_free); + g_object_unref); gl_framebuffer->dirty_bitmasks = TRUE; } @@ -1465,3 +1470,13 @@ EXIT: return status; } + +static void +cogl_gl_framebuffer_init (CoglGlFramebuffer *gl_framebuffer) +{ +} + +static void +cogl_gl_framebuffer_class_init (CoglGlFramebufferClass *klass) +{ +}