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: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/1514>
This commit is contained in:
Jonas Ådahl 2020-10-18 20:04:46 +02:00 committed by Robert Mader
parent 0e376f4dda
commit f56b0abaef
2 changed files with 24 additions and 4 deletions

View File

@ -34,6 +34,11 @@
#ifndef __COGL_FRAMEBUFFER_GL_PRIVATE_H__ #ifndef __COGL_FRAMEBUFFER_GL_PRIVATE_H__
#define __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 gboolean
_cogl_offscreen_gl_allocate (CoglOffscreen *offscreen, _cogl_offscreen_gl_allocate (CoglOffscreen *offscreen,
GError **error); GError **error);

View File

@ -127,11 +127,16 @@
#define GL_STENCIL 0x1802 #define GL_STENCIL 0x1802
#endif #endif
typedef struct _CoglGlFramebuffer struct _CoglGlFramebuffer
{ {
GObject parent;
gboolean dirty_bitmasks; gboolean dirty_bitmasks;
CoglFramebufferBits bits; CoglFramebufferBits bits;
} CoglGlFramebuffer; };
G_DEFINE_TYPE (CoglGlFramebuffer, cogl_gl_framebuffer,
G_TYPE_OBJECT)
static void static void
_cogl_framebuffer_gl_flush_viewport_state (CoglFramebuffer *framebuffer) _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); gl_framebuffer = cogl_framebuffer_get_driver_private (framebuffer);
if (!gl_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, cogl_framebuffer_set_driver_private (framebuffer,
gl_framebuffer, gl_framebuffer,
g_free); g_object_unref);
gl_framebuffer->dirty_bitmasks = TRUE; gl_framebuffer->dirty_bitmasks = TRUE;
} }
@ -1465,3 +1470,13 @@ EXIT:
return status; return status;
} }
static void
cogl_gl_framebuffer_init (CoglGlFramebuffer *gl_framebuffer)
{
}
static void
cogl_gl_framebuffer_class_init (CoglGlFramebufferClass *klass)
{
}