From b7c6865225afbd8c30861e2f840df44d24a6983e Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jonas=20=C3=85dahl?= Date: Tue, 20 Oct 2020 09:42:57 +0200 Subject: [PATCH] cogl/framebuffer: Move flush() and finish() to driver class Part-of: --- cogl/cogl/cogl-driver.h | 6 ------ cogl/cogl/cogl-framebuffer-driver.c | 12 ++++++++++++ cogl/cogl/cogl-framebuffer-driver.h | 10 ++++++++++ cogl/cogl/cogl-framebuffer.c | 6 ++---- .../driver/gl/cogl-framebuffer-gl-private.h | 6 ------ cogl/cogl/driver/gl/cogl-framebuffer-gl.c | 18 ++++++++++++------ cogl/cogl/driver/gl/gl/cogl-driver-gl.c | 2 -- cogl/cogl/driver/gl/gles/cogl-driver-gles.c | 2 -- cogl/cogl/driver/nop/cogl-driver-nop.c | 2 -- .../driver/nop/cogl-framebuffer-nop-private.h | 6 ------ cogl/cogl/driver/nop/cogl-framebuffer-nop.c | 10 ---------- cogl/cogl/driver/nop/cogl-nop-framebuffer.c | 12 ++++++++++++ 12 files changed, 48 insertions(+), 44 deletions(-) diff --git a/cogl/cogl/cogl-driver.h b/cogl/cogl/cogl-driver.h index de195efc8..6d79e3a75 100644 --- a/cogl/cogl/cogl-driver.h +++ b/cogl/cogl/cogl-driver.h @@ -85,12 +85,6 @@ struct _CoglDriverVtable CoglFramebuffer *read_buffer, CoglFramebufferState state); - void - (* framebuffer_finish) (CoglFramebuffer *framebuffer); - - void - (* framebuffer_flush) (CoglFramebuffer *framebuffer); - void (* framebuffer_discard_buffers) (CoglFramebuffer *framebuffer, unsigned long buffers); diff --git a/cogl/cogl/cogl-framebuffer-driver.c b/cogl/cogl/cogl-framebuffer-driver.c index 9616cec8b..4e9c92707 100644 --- a/cogl/cogl/cogl-framebuffer-driver.c +++ b/cogl/cogl/cogl-framebuffer-driver.c @@ -81,6 +81,18 @@ cogl_framebuffer_driver_clear (CoglFramebufferDriver *driver, alpha); } +void +cogl_framebuffer_driver_finish (CoglFramebufferDriver *driver) +{ + COGL_FRAMEBUFFER_DRIVER_GET_CLASS (driver)->finish (driver); +} + +void +cogl_framebuffer_driver_flush (CoglFramebufferDriver *driver) +{ + COGL_FRAMEBUFFER_DRIVER_GET_CLASS (driver)->flush (driver); +} + 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 39883f29f..416db1098 100644 --- a/cogl/cogl/cogl-framebuffer-driver.h +++ b/cogl/cogl/cogl-framebuffer-driver.h @@ -51,6 +51,10 @@ struct _CoglFramebufferDriverClass float green, float blue, float alpha); + + void (* finish) (CoglFramebufferDriver *driver); + + void (* flush) (CoglFramebufferDriver *driver); }; CoglFramebuffer * @@ -68,4 +72,10 @@ cogl_framebuffer_driver_clear (CoglFramebufferDriver *driver, float blue, float alpha); +void +cogl_framebuffer_driver_finish (CoglFramebufferDriver *driver); + +void +cogl_framebuffer_driver_flush (CoglFramebufferDriver *driver); + #endif /* COGL_FRAMEBUFFER_DRIVER_H */ diff --git a/cogl/cogl/cogl-framebuffer.c b/cogl/cogl/cogl-framebuffer.c index 53d2cbcc5..9e0739d36 100644 --- a/cogl/cogl/cogl-framebuffer.c +++ b/cogl/cogl/cogl-framebuffer.c @@ -1707,11 +1707,10 @@ cogl_framebuffer_finish (CoglFramebuffer *framebuffer) { CoglFramebufferPrivate *priv = cogl_framebuffer_get_instance_private (framebuffer); - CoglContext *ctx = priv->context; _cogl_framebuffer_flush_journal (framebuffer); - ctx->driver_vtable->framebuffer_finish (framebuffer); + cogl_framebuffer_driver_finish (priv->driver); } void @@ -1719,11 +1718,10 @@ cogl_framebuffer_flush (CoglFramebuffer *framebuffer) { CoglFramebufferPrivate *priv = cogl_framebuffer_get_instance_private (framebuffer); - CoglContext *ctx = priv->context; _cogl_framebuffer_flush_journal (framebuffer); - ctx->driver_vtable->framebuffer_flush (framebuffer); + cogl_framebuffer_driver_flush (priv->driver); } void diff --git a/cogl/cogl/driver/gl/cogl-framebuffer-gl-private.h b/cogl/cogl/driver/gl/cogl-framebuffer-gl-private.h index 02d7e86f4..9e2205cdf 100644 --- a/cogl/cogl/driver/gl/cogl-framebuffer-gl-private.h +++ b/cogl/cogl/driver/gl/cogl-framebuffer-gl-private.h @@ -51,12 +51,6 @@ struct _CoglGlFramebufferClass GLenum target); }; -void -_cogl_framebuffer_gl_finish (CoglFramebuffer *framebuffer); - -void -_cogl_framebuffer_gl_flush (CoglFramebuffer *framebuffer); - void _cogl_framebuffer_gl_discard_buffers (CoglFramebuffer *framebuffer, unsigned long buffers); diff --git a/cogl/cogl/driver/gl/cogl-framebuffer-gl.c b/cogl/cogl/driver/gl/cogl-framebuffer-gl.c index 944547e30..d2040a5ab 100644 --- a/cogl/cogl/driver/gl/cogl-framebuffer-gl.c +++ b/cogl/cogl/driver/gl/cogl-framebuffer-gl.c @@ -312,16 +312,20 @@ cogl_gl_framebuffer_clear (CoglFramebufferDriver *driver, GE (ctx, glClear (gl_buffers)); } -void -_cogl_framebuffer_gl_finish (CoglFramebuffer *framebuffer) +static void +cogl_gl_framebuffer_finish (CoglFramebufferDriver *driver) { - GE (cogl_framebuffer_get_context (framebuffer), glFinish ()); + CoglContext *ctx = context_from_driver (driver); + + GE (ctx, glFinish ()); } -void -_cogl_framebuffer_gl_flush (CoglFramebuffer *framebuffer) +static void +cogl_gl_framebuffer_flush (CoglFramebufferDriver *driver) { - GE (cogl_framebuffer_get_context (framebuffer), glFlush ()); + CoglContext *ctx = context_from_driver (driver); + + GE (ctx, glFlush ()); } void @@ -717,4 +721,6 @@ cogl_gl_framebuffer_class_init (CoglGlFramebufferClass *klass) COGL_FRAMEBUFFER_DRIVER_CLASS (klass); driver_class->clear = cogl_gl_framebuffer_clear; + driver_class->finish = cogl_gl_framebuffer_finish; + driver_class->flush = cogl_gl_framebuffer_flush; } diff --git a/cogl/cogl/driver/gl/gl/cogl-driver-gl.c b/cogl/cogl/driver/gl/gl/cogl-driver-gl.c index 1191987cf..d4e56c4c9 100644 --- a/cogl/cogl/driver/gl/gl/cogl-driver-gl.c +++ b/cogl/cogl/driver/gl/gl/cogl-driver-gl.c @@ -571,8 +571,6 @@ _cogl_driver_gl = _cogl_driver_update_features, _cogl_driver_gl_create_framebuffer_driver, _cogl_driver_gl_flush_framebuffer_state, - _cogl_framebuffer_gl_finish, - _cogl_framebuffer_gl_flush, _cogl_framebuffer_gl_discard_buffers, _cogl_framebuffer_gl_draw_attributes, _cogl_framebuffer_gl_draw_indexed_attributes, diff --git a/cogl/cogl/driver/gl/gles/cogl-driver-gles.c b/cogl/cogl/driver/gl/gles/cogl-driver-gles.c index 45b44bcb3..7a031ae41 100644 --- a/cogl/cogl/driver/gl/gles/cogl-driver-gles.c +++ b/cogl/cogl/driver/gl/gles/cogl-driver-gles.c @@ -459,8 +459,6 @@ _cogl_driver_gles = _cogl_driver_update_features, _cogl_driver_gl_create_framebuffer_driver, _cogl_driver_gl_flush_framebuffer_state, - _cogl_framebuffer_gl_finish, - _cogl_framebuffer_gl_flush, _cogl_framebuffer_gl_discard_buffers, _cogl_framebuffer_gl_draw_attributes, _cogl_framebuffer_gl_draw_indexed_attributes, diff --git a/cogl/cogl/driver/nop/cogl-driver-nop.c b/cogl/cogl/driver/nop/cogl-driver-nop.c index c8fe732c5..96afa3bd0 100644 --- a/cogl/cogl/driver/nop/cogl-driver-nop.c +++ b/cogl/cogl/driver/nop/cogl-driver-nop.c @@ -99,8 +99,6 @@ _cogl_driver_nop = _cogl_driver_update_features, _cogl_driver_nop_create_framebuffer_driver, _cogl_driver_nop_flush_framebuffer_state, - _cogl_framebuffer_nop_finish, - _cogl_framebuffer_nop_flush, _cogl_framebuffer_nop_discard_buffers, _cogl_framebuffer_nop_draw_attributes, _cogl_framebuffer_nop_draw_indexed_attributes, diff --git a/cogl/cogl/driver/nop/cogl-framebuffer-nop-private.h b/cogl/cogl/driver/nop/cogl-framebuffer-nop-private.h index e31c31b68..7efe883de 100644 --- a/cogl/cogl/driver/nop/cogl-framebuffer-nop-private.h +++ b/cogl/cogl/driver/nop/cogl-framebuffer-nop-private.h @@ -37,12 +37,6 @@ #include "cogl-types.h" #include "cogl-context-private.h" -void -_cogl_framebuffer_nop_finish (CoglFramebuffer *framebuffer); - -void -_cogl_framebuffer_nop_flush (CoglFramebuffer *framebuffer); - void _cogl_framebuffer_nop_discard_buffers (CoglFramebuffer *framebuffer, unsigned long buffers); diff --git a/cogl/cogl/driver/nop/cogl-framebuffer-nop.c b/cogl/cogl/driver/nop/cogl-framebuffer-nop.c index 9cfe0becc..757ce268c 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_finish (CoglFramebuffer *framebuffer) -{ -} - -void -_cogl_framebuffer_nop_flush (CoglFramebuffer *framebuffer) -{ -} - void _cogl_framebuffer_nop_discard_buffers (CoglFramebuffer *framebuffer, unsigned long buffers) diff --git a/cogl/cogl/driver/nop/cogl-nop-framebuffer.c b/cogl/cogl/driver/nop/cogl-nop-framebuffer.c index f37056094..39df6833a 100644 --- a/cogl/cogl/driver/nop/cogl-nop-framebuffer.c +++ b/cogl/cogl/driver/nop/cogl-nop-framebuffer.c @@ -54,6 +54,16 @@ cogl_nop_framebuffer_clear (CoglFramebufferDriver *driver, { } +static void +cogl_nop_framebuffer_finish (CoglFramebufferDriver *driver) +{ +} + +static void +cogl_nop_framebuffer_flush (CoglFramebufferDriver *driver) +{ +} + static void cogl_nop_framebuffer_init (CoglNopFramebuffer *nop_framebuffer) { @@ -67,4 +77,6 @@ cogl_nop_framebuffer_class_init (CoglNopFramebufferClass *klass) driver_class->query_bits = cogl_nop_framebuffer_query_bits; driver_class->clear = cogl_nop_framebuffer_clear; + driver_class->finish = cogl_nop_framebuffer_finish; + driver_class->flush = cogl_nop_framebuffer_flush; }