From 1b3937491c07c8c8fe41e5061d60597a7125a0b1 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jonas=20=C3=85dahl?= Date: Tue, 20 Oct 2020 09:20:57 +0200 Subject: [PATCH] cogl/framebuffer: Move clear() to CoglFramebufferDriver Part-of: --- cogl/cogl/cogl-driver.h | 8 ----- cogl/cogl/cogl-framebuffer-driver.c | 16 ++++++++++ cogl/cogl/cogl-framebuffer-driver.h | 15 +++++++++ cogl/cogl/cogl-framebuffer.c | 10 +++--- .../driver/gl/cogl-framebuffer-gl-private.h | 8 ----- cogl/cogl/driver/gl/cogl-framebuffer-gl.c | 31 ++++++++++++++----- 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 | 1 - .../driver/nop/cogl-framebuffer-nop-private.h | 8 ----- cogl/cogl/driver/nop/cogl-framebuffer-nop.c | 10 ------ cogl/cogl/driver/nop/cogl-nop-framebuffer.c | 11 +++++++ 12 files changed, 71 insertions(+), 49 deletions(-) diff --git a/cogl/cogl/cogl-driver.h b/cogl/cogl/cogl-driver.h index 5e698debd..de195efc8 100644 --- a/cogl/cogl/cogl-driver.h +++ b/cogl/cogl/cogl-driver.h @@ -85,14 +85,6 @@ struct _CoglDriverVtable CoglFramebuffer *read_buffer, CoglFramebufferState state); - void - (* framebuffer_clear) (CoglFramebuffer *framebuffer, - unsigned long buffers, - float red, - float green, - float blue, - float alpha); - void (* framebuffer_finish) (CoglFramebuffer *framebuffer); diff --git a/cogl/cogl/cogl-framebuffer-driver.c b/cogl/cogl/cogl-framebuffer-driver.c index d1bbf82a0..9616cec8b 100644 --- a/cogl/cogl/cogl-framebuffer-driver.c +++ b/cogl/cogl/cogl-framebuffer-driver.c @@ -65,6 +65,22 @@ cogl_framebuffer_driver_query_bits (CoglFramebufferDriver *driver, COGL_FRAMEBUFFER_DRIVER_GET_CLASS (driver)->query_bits (driver, bits); } +void +cogl_framebuffer_driver_clear (CoglFramebufferDriver *driver, + unsigned long buffers, + float red, + float green, + float blue, + float alpha) +{ + COGL_FRAMEBUFFER_DRIVER_GET_CLASS (driver)->clear (driver, + buffers, + red, + green, + blue, + alpha); +} + 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 8f06e9e05..39883f29f 100644 --- a/cogl/cogl/cogl-framebuffer-driver.h +++ b/cogl/cogl/cogl-framebuffer-driver.h @@ -44,6 +44,13 @@ struct _CoglFramebufferDriverClass void (* query_bits) (CoglFramebufferDriver *driver, CoglFramebufferBits *bits); + + void (* clear) (CoglFramebufferDriver *driver, + unsigned long buffers, + float red, + float green, + float blue, + float alpha); }; CoglFramebuffer * @@ -53,4 +60,12 @@ void cogl_framebuffer_driver_query_bits (CoglFramebufferDriver *driver, CoglFramebufferBits *bits); +void +cogl_framebuffer_driver_clear (CoglFramebufferDriver *driver, + unsigned long buffers, + float red, + float green, + float blue, + float alpha); + #endif /* COGL_FRAMEBUFFER_DRIVER_H */ diff --git a/cogl/cogl/cogl-framebuffer.c b/cogl/cogl/cogl-framebuffer.c index 4bd4673da..53d2cbcc5 100644 --- a/cogl/cogl/cogl-framebuffer.c +++ b/cogl/cogl/cogl-framebuffer.c @@ -443,7 +443,6 @@ _cogl_framebuffer_clear_without_flush4f (CoglFramebuffer *framebuffer, { CoglFramebufferPrivate *priv = cogl_framebuffer_get_instance_private (framebuffer); - CoglContext *ctx = priv->context; if (!buffers) { @@ -458,9 +457,12 @@ _cogl_framebuffer_clear_without_flush4f (CoglFramebuffer *framebuffer, return; } - ctx->driver_vtable->framebuffer_clear (framebuffer, - buffers, - red, green, blue, alpha); + cogl_framebuffer_driver_clear (priv->driver, + buffers, + red, + green, + blue, + alpha); } void diff --git a/cogl/cogl/driver/gl/cogl-framebuffer-gl-private.h b/cogl/cogl/driver/gl/cogl-framebuffer-gl-private.h index 3f0ddb539..02d7e86f4 100644 --- a/cogl/cogl/driver/gl/cogl-framebuffer-gl-private.h +++ b/cogl/cogl/driver/gl/cogl-framebuffer-gl-private.h @@ -51,14 +51,6 @@ struct _CoglGlFramebufferClass GLenum target); }; -void -_cogl_framebuffer_gl_clear (CoglFramebuffer *framebuffer, - unsigned long buffers, - float red, - float green, - float blue, - float alpha); - void _cogl_framebuffer_gl_finish (CoglFramebuffer *framebuffer); diff --git a/cogl/cogl/driver/gl/cogl-framebuffer-gl.c b/cogl/cogl/driver/gl/cogl-framebuffer-gl.c index 4700e449b..944547e30 100644 --- a/cogl/cogl/driver/gl/cogl-framebuffer-gl.c +++ b/cogl/cogl/driver/gl/cogl-framebuffer-gl.c @@ -47,6 +47,15 @@ G_DEFINE_ABSTRACT_TYPE (CoglGlFramebuffer, cogl_gl_framebuffer, COGL_TYPE_FRAMEBUFFER_DRIVER) +static CoglContext * +context_from_driver (CoglFramebufferDriver *driver) +{ + CoglFramebuffer *framebuffer = + cogl_framebuffer_driver_get_framebuffer (driver); + + return cogl_framebuffer_get_context (framebuffer); +} + static void _cogl_framebuffer_gl_flush_viewport_state (CoglFramebuffer *framebuffer) { @@ -256,15 +265,15 @@ cogl_gl_framebuffer_bind (CoglGlFramebuffer *gl_framebuffer, target); } -void -_cogl_framebuffer_gl_clear (CoglFramebuffer *framebuffer, - unsigned long buffers, - float red, - float green, - float blue, - float alpha) +static void +cogl_gl_framebuffer_clear (CoglFramebufferDriver *driver, + unsigned long buffers, + float red, + float green, + float blue, + float alpha) { - CoglContext *ctx = cogl_framebuffer_get_context (framebuffer); + CoglContext *ctx = context_from_driver (driver); GLbitfield gl_buffers = 0; if (buffers & COGL_BUFFER_BIT_COLOR) @@ -275,6 +284,8 @@ _cogl_framebuffer_gl_clear (CoglFramebuffer *framebuffer, if (buffers & COGL_BUFFER_BIT_DEPTH) { + CoglFramebuffer *framebuffer = + cogl_framebuffer_driver_get_framebuffer (driver); gboolean is_depth_writing_enabled; gl_buffers |= GL_DEPTH_BUFFER_BIT; @@ -702,4 +713,8 @@ cogl_gl_framebuffer_init (CoglGlFramebuffer *gl_framebuffer) static void cogl_gl_framebuffer_class_init (CoglGlFramebufferClass *klass) { + CoglFramebufferDriverClass *driver_class = + COGL_FRAMEBUFFER_DRIVER_CLASS (klass); + + driver_class->clear = cogl_gl_framebuffer_clear; } diff --git a/cogl/cogl/driver/gl/gl/cogl-driver-gl.c b/cogl/cogl/driver/gl/gl/cogl-driver-gl.c index bcb7f566e..1191987cf 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_clear, _cogl_framebuffer_gl_finish, _cogl_framebuffer_gl_flush, _cogl_framebuffer_gl_discard_buffers, diff --git a/cogl/cogl/driver/gl/gles/cogl-driver-gles.c b/cogl/cogl/driver/gl/gles/cogl-driver-gles.c index a0688bd51..45b44bcb3 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_clear, _cogl_framebuffer_gl_finish, _cogl_framebuffer_gl_flush, _cogl_framebuffer_gl_discard_buffers, diff --git a/cogl/cogl/driver/nop/cogl-driver-nop.c b/cogl/cogl/driver/nop/cogl-driver-nop.c index c52a2c299..c8fe732c5 100644 --- a/cogl/cogl/driver/nop/cogl-driver-nop.c +++ b/cogl/cogl/driver/nop/cogl-driver-nop.c @@ -99,7 +99,6 @@ _cogl_driver_nop = _cogl_driver_update_features, _cogl_driver_nop_create_framebuffer_driver, _cogl_driver_nop_flush_framebuffer_state, - _cogl_framebuffer_nop_clear, _cogl_framebuffer_nop_finish, _cogl_framebuffer_nop_flush, _cogl_framebuffer_nop_discard_buffers, diff --git a/cogl/cogl/driver/nop/cogl-framebuffer-nop-private.h b/cogl/cogl/driver/nop/cogl-framebuffer-nop-private.h index a1cf77c89..e31c31b68 100644 --- a/cogl/cogl/driver/nop/cogl-framebuffer-nop-private.h +++ b/cogl/cogl/driver/nop/cogl-framebuffer-nop-private.h @@ -37,14 +37,6 @@ #include "cogl-types.h" #include "cogl-context-private.h" -void -_cogl_framebuffer_nop_clear (CoglFramebuffer *framebuffer, - unsigned long buffers, - float red, - float green, - float blue, - float alpha); - void _cogl_framebuffer_nop_finish (CoglFramebuffer *framebuffer); diff --git a/cogl/cogl/driver/nop/cogl-framebuffer-nop.c b/cogl/cogl/driver/nop/cogl-framebuffer-nop.c index 70488a1b5..9cfe0becc 100644 --- a/cogl/cogl/driver/nop/cogl-framebuffer-nop.c +++ b/cogl/cogl/driver/nop/cogl-framebuffer-nop.c @@ -35,16 +35,6 @@ #include #include -void -_cogl_framebuffer_nop_clear (CoglFramebuffer *framebuffer, - unsigned long buffers, - float red, - float green, - float blue, - float alpha) -{ -} - void _cogl_framebuffer_nop_finish (CoglFramebuffer *framebuffer) { diff --git a/cogl/cogl/driver/nop/cogl-nop-framebuffer.c b/cogl/cogl/driver/nop/cogl-nop-framebuffer.c index 3e155f3c3..f37056094 100644 --- a/cogl/cogl/driver/nop/cogl-nop-framebuffer.c +++ b/cogl/cogl/driver/nop/cogl-nop-framebuffer.c @@ -44,6 +44,16 @@ cogl_nop_framebuffer_query_bits (CoglFramebufferDriver *driver, memset (bits, 0, sizeof (CoglFramebufferBits)); } +static void +cogl_nop_framebuffer_clear (CoglFramebufferDriver *driver, + unsigned long buffers, + float red, + float green, + float blue, + float alpha) +{ +} + static void cogl_nop_framebuffer_init (CoglNopFramebuffer *nop_framebuffer) { @@ -56,4 +66,5 @@ cogl_nop_framebuffer_class_init (CoglNopFramebufferClass *klass) COGL_FRAMEBUFFER_DRIVER_CLASS (klass); driver_class->query_bits = cogl_nop_framebuffer_query_bits; + driver_class->clear = cogl_nop_framebuffer_clear; }