summaryrefslogtreecommitdiff
path: root/cogl
diff options
context:
space:
mode:
authorJonas Ã…dahl <jadahl@gmail.com>2020-10-20 09:20:57 +0200
committerRobert Mader <robert.mader@posteo.de>2021-01-30 09:11:46 +0000
commit1b3937491c07c8c8fe41e5061d60597a7125a0b1 (patch)
treed1d39b7a687ad67998ebc137194c14d04923ced1 /cogl
parent4f3b57c8416164f9649ab8bfd152c19a619efd75 (diff)
downloadmutter-1b3937491c07c8c8fe41e5061d60597a7125a0b1.tar.gz
cogl/framebuffer: Move clear() to CoglFramebufferDriver
Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/1514>
Diffstat (limited to 'cogl')
-rw-r--r--cogl/cogl/cogl-driver.h8
-rw-r--r--cogl/cogl/cogl-framebuffer-driver.c16
-rw-r--r--cogl/cogl/cogl-framebuffer-driver.h15
-rw-r--r--cogl/cogl/cogl-framebuffer.c10
-rw-r--r--cogl/cogl/driver/gl/cogl-framebuffer-gl-private.h8
-rw-r--r--cogl/cogl/driver/gl/cogl-framebuffer-gl.c31
-rw-r--r--cogl/cogl/driver/gl/gl/cogl-driver-gl.c1
-rw-r--r--cogl/cogl/driver/gl/gles/cogl-driver-gles.c1
-rw-r--r--cogl/cogl/driver/nop/cogl-driver-nop.c1
-rw-r--r--cogl/cogl/driver/nop/cogl-framebuffer-nop-private.h8
-rw-r--r--cogl/cogl/driver/nop/cogl-framebuffer-nop.c10
-rw-r--r--cogl/cogl/driver/nop/cogl-nop-framebuffer.c11
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
@@ -86,14 +86,6 @@ struct _CoglDriverVtable
CoglFramebufferState state);
void
- (* framebuffer_clear) (CoglFramebuffer *framebuffer,
- unsigned long buffers,
- float red,
- float green,
- float blue,
- float alpha);
-
- void
(* framebuffer_finish) (CoglFramebuffer *framebuffer);
void
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
@@ -52,14 +52,6 @@ struct _CoglGlFramebufferClass
};
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);
void
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
@@ -38,14 +38,6 @@
#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);
void
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
@@ -36,16 +36,6 @@
#include <string.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-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
@@ -45,6 +45,16 @@ cogl_nop_framebuffer_query_bits (CoglFramebufferDriver *driver,
}
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;
}