cogl/framebuffer: Move clear() to CoglFramebufferDriver

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/1514>
This commit is contained in:
Jonas Ådahl 2020-10-20 09:20:57 +02:00 committed by Robert Mader
parent 4f3b57c841
commit 1b3937491c
12 changed files with 71 additions and 49 deletions

View File

@ -85,14 +85,6 @@ struct _CoglDriverVtable
CoglFramebuffer *read_buffer, CoglFramebuffer *read_buffer,
CoglFramebufferState state); CoglFramebufferState state);
void
(* framebuffer_clear) (CoglFramebuffer *framebuffer,
unsigned long buffers,
float red,
float green,
float blue,
float alpha);
void void
(* framebuffer_finish) (CoglFramebuffer *framebuffer); (* framebuffer_finish) (CoglFramebuffer *framebuffer);

View File

@ -65,6 +65,22 @@ cogl_framebuffer_driver_query_bits (CoglFramebufferDriver *driver,
COGL_FRAMEBUFFER_DRIVER_GET_CLASS (driver)->query_bits (driver, bits); 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 static void
cogl_framebuffer_driver_get_property (GObject *object, cogl_framebuffer_driver_get_property (GObject *object,
guint prop_id, guint prop_id,

View File

@ -44,6 +44,13 @@ struct _CoglFramebufferDriverClass
void (* query_bits) (CoglFramebufferDriver *driver, void (* query_bits) (CoglFramebufferDriver *driver,
CoglFramebufferBits *bits); CoglFramebufferBits *bits);
void (* clear) (CoglFramebufferDriver *driver,
unsigned long buffers,
float red,
float green,
float blue,
float alpha);
}; };
CoglFramebuffer * CoglFramebuffer *
@ -53,4 +60,12 @@ void
cogl_framebuffer_driver_query_bits (CoglFramebufferDriver *driver, cogl_framebuffer_driver_query_bits (CoglFramebufferDriver *driver,
CoglFramebufferBits *bits); 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 */ #endif /* COGL_FRAMEBUFFER_DRIVER_H */

View File

@ -443,7 +443,6 @@ _cogl_framebuffer_clear_without_flush4f (CoglFramebuffer *framebuffer,
{ {
CoglFramebufferPrivate *priv = CoglFramebufferPrivate *priv =
cogl_framebuffer_get_instance_private (framebuffer); cogl_framebuffer_get_instance_private (framebuffer);
CoglContext *ctx = priv->context;
if (!buffers) if (!buffers)
{ {
@ -458,9 +457,12 @@ _cogl_framebuffer_clear_without_flush4f (CoglFramebuffer *framebuffer,
return; return;
} }
ctx->driver_vtable->framebuffer_clear (framebuffer, cogl_framebuffer_driver_clear (priv->driver,
buffers, buffers,
red, green, blue, alpha); red,
green,
blue,
alpha);
} }
void void

View File

@ -51,14 +51,6 @@ struct _CoglGlFramebufferClass
GLenum target); GLenum target);
}; };
void
_cogl_framebuffer_gl_clear (CoglFramebuffer *framebuffer,
unsigned long buffers,
float red,
float green,
float blue,
float alpha);
void void
_cogl_framebuffer_gl_finish (CoglFramebuffer *framebuffer); _cogl_framebuffer_gl_finish (CoglFramebuffer *framebuffer);

View File

@ -47,6 +47,15 @@
G_DEFINE_ABSTRACT_TYPE (CoglGlFramebuffer, cogl_gl_framebuffer, G_DEFINE_ABSTRACT_TYPE (CoglGlFramebuffer, cogl_gl_framebuffer,
COGL_TYPE_FRAMEBUFFER_DRIVER) 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 static void
_cogl_framebuffer_gl_flush_viewport_state (CoglFramebuffer *framebuffer) _cogl_framebuffer_gl_flush_viewport_state (CoglFramebuffer *framebuffer)
{ {
@ -256,15 +265,15 @@ cogl_gl_framebuffer_bind (CoglGlFramebuffer *gl_framebuffer,
target); target);
} }
void static void
_cogl_framebuffer_gl_clear (CoglFramebuffer *framebuffer, cogl_gl_framebuffer_clear (CoglFramebufferDriver *driver,
unsigned long buffers, unsigned long buffers,
float red, float red,
float green, float green,
float blue, float blue,
float alpha) float alpha)
{ {
CoglContext *ctx = cogl_framebuffer_get_context (framebuffer); CoglContext *ctx = context_from_driver (driver);
GLbitfield gl_buffers = 0; GLbitfield gl_buffers = 0;
if (buffers & COGL_BUFFER_BIT_COLOR) if (buffers & COGL_BUFFER_BIT_COLOR)
@ -275,6 +284,8 @@ _cogl_framebuffer_gl_clear (CoglFramebuffer *framebuffer,
if (buffers & COGL_BUFFER_BIT_DEPTH) if (buffers & COGL_BUFFER_BIT_DEPTH)
{ {
CoglFramebuffer *framebuffer =
cogl_framebuffer_driver_get_framebuffer (driver);
gboolean is_depth_writing_enabled; gboolean is_depth_writing_enabled;
gl_buffers |= GL_DEPTH_BUFFER_BIT; gl_buffers |= GL_DEPTH_BUFFER_BIT;
@ -702,4 +713,8 @@ cogl_gl_framebuffer_init (CoglGlFramebuffer *gl_framebuffer)
static void static void
cogl_gl_framebuffer_class_init (CoglGlFramebufferClass *klass) cogl_gl_framebuffer_class_init (CoglGlFramebufferClass *klass)
{ {
CoglFramebufferDriverClass *driver_class =
COGL_FRAMEBUFFER_DRIVER_CLASS (klass);
driver_class->clear = cogl_gl_framebuffer_clear;
} }

View File

@ -571,7 +571,6 @@ _cogl_driver_gl =
_cogl_driver_update_features, _cogl_driver_update_features,
_cogl_driver_gl_create_framebuffer_driver, _cogl_driver_gl_create_framebuffer_driver,
_cogl_driver_gl_flush_framebuffer_state, _cogl_driver_gl_flush_framebuffer_state,
_cogl_framebuffer_gl_clear,
_cogl_framebuffer_gl_finish, _cogl_framebuffer_gl_finish,
_cogl_framebuffer_gl_flush, _cogl_framebuffer_gl_flush,
_cogl_framebuffer_gl_discard_buffers, _cogl_framebuffer_gl_discard_buffers,

View File

@ -459,7 +459,6 @@ _cogl_driver_gles =
_cogl_driver_update_features, _cogl_driver_update_features,
_cogl_driver_gl_create_framebuffer_driver, _cogl_driver_gl_create_framebuffer_driver,
_cogl_driver_gl_flush_framebuffer_state, _cogl_driver_gl_flush_framebuffer_state,
_cogl_framebuffer_gl_clear,
_cogl_framebuffer_gl_finish, _cogl_framebuffer_gl_finish,
_cogl_framebuffer_gl_flush, _cogl_framebuffer_gl_flush,
_cogl_framebuffer_gl_discard_buffers, _cogl_framebuffer_gl_discard_buffers,

View File

@ -99,7 +99,6 @@ _cogl_driver_nop =
_cogl_driver_update_features, _cogl_driver_update_features,
_cogl_driver_nop_create_framebuffer_driver, _cogl_driver_nop_create_framebuffer_driver,
_cogl_driver_nop_flush_framebuffer_state, _cogl_driver_nop_flush_framebuffer_state,
_cogl_framebuffer_nop_clear,
_cogl_framebuffer_nop_finish, _cogl_framebuffer_nop_finish,
_cogl_framebuffer_nop_flush, _cogl_framebuffer_nop_flush,
_cogl_framebuffer_nop_discard_buffers, _cogl_framebuffer_nop_discard_buffers,

View File

@ -37,14 +37,6 @@
#include "cogl-types.h" #include "cogl-types.h"
#include "cogl-context-private.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 void
_cogl_framebuffer_nop_finish (CoglFramebuffer *framebuffer); _cogl_framebuffer_nop_finish (CoglFramebuffer *framebuffer);

View File

@ -35,16 +35,6 @@
#include <glib.h> #include <glib.h>
#include <string.h> #include <string.h>
void
_cogl_framebuffer_nop_clear (CoglFramebuffer *framebuffer,
unsigned long buffers,
float red,
float green,
float blue,
float alpha)
{
}
void void
_cogl_framebuffer_nop_finish (CoglFramebuffer *framebuffer) _cogl_framebuffer_nop_finish (CoglFramebuffer *framebuffer)
{ {

View File

@ -44,6 +44,16 @@ cogl_nop_framebuffer_query_bits (CoglFramebufferDriver *driver,
memset (bits, 0, sizeof (CoglFramebufferBits)); 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 static void
cogl_nop_framebuffer_init (CoglNopFramebuffer *nop_framebuffer) cogl_nop_framebuffer_init (CoglNopFramebuffer *nop_framebuffer)
{ {
@ -56,4 +66,5 @@ cogl_nop_framebuffer_class_init (CoglNopFramebufferClass *klass)
COGL_FRAMEBUFFER_DRIVER_CLASS (klass); COGL_FRAMEBUFFER_DRIVER_CLASS (klass);
driver_class->query_bits = cogl_nop_framebuffer_query_bits; driver_class->query_bits = cogl_nop_framebuffer_query_bits;
driver_class->clear = cogl_nop_framebuffer_clear;
} }