[mutter] cogl/framebuffer: Move attribute drawing to driver class
- From: Marge Bot <marge-bot src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [mutter] cogl/framebuffer: Move attribute drawing to driver class
- Date: Sat, 30 Jan 2021 09:39:50 +0000 (UTC)
commit 1e5f105836198d19d71135f30dd3122865dc116b
Author: Jonas Ã…dahl <jadahl gmail com>
Date: Tue Oct 20 10:55:56 2020 +0200
cogl/framebuffer: Move attribute drawing to driver class
Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/1514>
cogl/cogl/cogl-driver.h | 21 ----------
cogl/cogl/cogl-framebuffer-driver.c | 45 +++++++++++++++++++++
cogl/cogl/cogl-framebuffer-driver.h | 41 +++++++++++++++++++
cogl/cogl/cogl-framebuffer.c | 38 ++++++++----------
cogl/cogl/driver/gl/cogl-framebuffer-gl-private.h | 21 ----------
cogl/cogl/driver/gl/cogl-framebuffer-gl.c | 46 +++++++++++++---------
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 -
.../cogl/driver/nop/cogl-framebuffer-nop-private.h | 21 ----------
cogl/cogl/driver/nop/cogl-framebuffer-nop.c | 25 ------------
cogl/cogl/driver/nop/cogl-nop-framebuffer.c | 28 +++++++++++++
12 files changed, 158 insertions(+), 134 deletions(-)
---
diff --git a/cogl/cogl/cogl-driver.h b/cogl/cogl/cogl-driver.h
index aa30f3d343..f2ae3e7b93 100644
--- a/cogl/cogl/cogl-driver.h
+++ b/cogl/cogl/cogl-driver.h
@@ -85,27 +85,6 @@ struct _CoglDriverVtable
CoglFramebuffer *read_buffer,
CoglFramebufferState state);
- void
- (* framebuffer_draw_attributes) (CoglFramebuffer *framebuffer,
- CoglPipeline *pipeline,
- CoglVerticesMode mode,
- int first_vertex,
- int n_vertices,
- CoglAttribute **attributes,
- int n_attributes,
- CoglDrawFlags flags);
-
- void
- (* framebuffer_draw_indexed_attributes) (CoglFramebuffer *framebuffer,
- CoglPipeline *pipeline,
- CoglVerticesMode mode,
- int first_vertex,
- int n_vertices,
- CoglIndices *indices,
- CoglAttribute **attributes,
- int n_attributes,
- CoglDrawFlags flags);
-
gboolean
(* framebuffer_read_pixels_into_bitmap) (CoglFramebuffer *framebuffer,
int x,
diff --git a/cogl/cogl/cogl-framebuffer-driver.c b/cogl/cogl/cogl-framebuffer-driver.c
index 1e71f0c03e..d49f90d291 100644
--- a/cogl/cogl/cogl-framebuffer-driver.c
+++ b/cogl/cogl/cogl-framebuffer-driver.c
@@ -100,6 +100,51 @@ cogl_framebuffer_driver_discard_buffers (CoglFramebufferDriver *driver,
COGL_FRAMEBUFFER_DRIVER_GET_CLASS (driver)->discard_buffers (driver, buffers);
}
+void
+cogl_framebuffer_driver_draw_attributes (CoglFramebufferDriver *driver,
+ CoglPipeline *pipeline,
+ CoglVerticesMode mode,
+ int first_vertex,
+ int n_vertices,
+ CoglAttribute **attributes,
+ int n_attributes,
+ CoglDrawFlags flags)
+{
+ COGL_FRAMEBUFFER_DRIVER_GET_CLASS (driver)->draw_attributes (driver,
+ pipeline,
+ mode,
+ first_vertex,
+ n_vertices,
+ attributes,
+ n_attributes,
+ flags);
+}
+
+void
+cogl_framebuffer_driver_draw_indexed_attributes (CoglFramebufferDriver *driver,
+ CoglPipeline *pipeline,
+ CoglVerticesMode mode,
+ int first_vertex,
+ int n_vertices,
+ CoglIndices *indices,
+ CoglAttribute **attributes,
+ int n_attributes,
+ CoglDrawFlags flags)
+{
+ CoglFramebufferDriverClass *klass =
+ COGL_FRAMEBUFFER_DRIVER_GET_CLASS (driver);
+
+ klass->draw_indexed_attributes (driver,
+ pipeline,
+ mode,
+ first_vertex,
+ n_vertices,
+ indices,
+ attributes,
+ n_attributes,
+ flags);
+}
+
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 3c88c489d5..7608701e0c 100644
--- a/cogl/cogl/cogl-framebuffer-driver.h
+++ b/cogl/cogl/cogl-framebuffer-driver.h
@@ -28,6 +28,7 @@
#ifndef COGL_FRAMEBUFFER_DRIVER_H
#define COGL_FRAMEBUFFER_DRIVER_H
+#include "cogl-attribute-private.h"
#include "cogl-framebuffer.h"
typedef struct _CoglFramebufferBits CoglFramebufferBits;
@@ -58,6 +59,25 @@ struct _CoglFramebufferDriverClass
void (* discard_buffers) (CoglFramebufferDriver *driver,
unsigned long buffers);
+
+ void (* draw_attributes) (CoglFramebufferDriver *driver,
+ CoglPipeline *pipeline,
+ CoglVerticesMode mode,
+ int first_vertex,
+ int n_vertices,
+ CoglAttribute **attributes,
+ int n_attributes,
+ CoglDrawFlags flags);
+
+ void (* draw_indexed_attributes) (CoglFramebufferDriver *driver,
+ CoglPipeline *pipeline,
+ CoglVerticesMode mode,
+ int first_vertex,
+ int n_vertices,
+ CoglIndices *indices,
+ CoglAttribute **attributes,
+ int n_attributes,
+ CoglDrawFlags flags);
};
CoglFramebuffer *
@@ -85,4 +105,25 @@ void
cogl_framebuffer_driver_discard_buffers (CoglFramebufferDriver *driver,
unsigned long buffers);
+void
+cogl_framebuffer_driver_draw_attributes (CoglFramebufferDriver *driver,
+ CoglPipeline *pipeline,
+ CoglVerticesMode mode,
+ int first_vertex,
+ int n_vertices,
+ CoglAttribute **attributes,
+ int n_attributes,
+ CoglDrawFlags flags);
+
+void
+cogl_framebuffer_driver_draw_indexed_attributes (CoglFramebufferDriver *driver,
+ CoglPipeline *pipeline,
+ CoglVerticesMode mode,
+ int first_vertex,
+ int n_vertices,
+ CoglIndices *indices,
+ CoglAttribute **attributes,
+ int n_attributes,
+ CoglDrawFlags flags);
+
#endif /* COGL_FRAMEBUFFER_DRIVER_H */
diff --git a/cogl/cogl/cogl-framebuffer.c b/cogl/cogl/cogl-framebuffer.c
index 6c5ffa516f..c02eabd9c0 100644
--- a/cogl/cogl/cogl-framebuffer.c
+++ b/cogl/cogl/cogl-framebuffer.c
@@ -2478,16 +2478,14 @@ _cogl_framebuffer_draw_attributes (CoglFramebuffer *framebuffer,
else
#endif
{
- CoglContext *ctx = priv->context;
-
- ctx->driver_vtable->framebuffer_draw_attributes (framebuffer,
- pipeline,
- mode,
- first_vertex,
- n_vertices,
- attributes,
- n_attributes,
- flags);
+ cogl_framebuffer_driver_draw_attributes (priv->driver,
+ pipeline,
+ mode,
+ first_vertex,
+ n_vertices,
+ attributes,
+ n_attributes,
+ flags);
}
}
@@ -2519,17 +2517,15 @@ _cogl_framebuffer_draw_indexed_attributes (CoglFramebuffer *framebuffer,
else
#endif
{
- CoglContext *ctx = priv->context;
-
- ctx->driver_vtable->framebuffer_draw_indexed_attributes (framebuffer,
- pipeline,
- mode,
- first_vertex,
- n_vertices,
- indices,
- attributes,
- n_attributes,
- flags);
+ cogl_framebuffer_driver_draw_indexed_attributes (priv->driver,
+ pipeline,
+ mode,
+ first_vertex,
+ n_vertices,
+ indices,
+ attributes,
+ n_attributes,
+ flags);
}
}
diff --git a/cogl/cogl/driver/gl/cogl-framebuffer-gl-private.h
b/cogl/cogl/driver/gl/cogl-framebuffer-gl-private.h
index d6e2fd4171..c7e2995c67 100644
--- a/cogl/cogl/driver/gl/cogl-framebuffer-gl-private.h
+++ b/cogl/cogl/driver/gl/cogl-framebuffer-gl-private.h
@@ -55,27 +55,6 @@ void
cogl_gl_framebuffer_bind (CoglGlFramebuffer *gl_framebuffer,
GLenum target);
-void
-_cogl_framebuffer_gl_draw_attributes (CoglFramebuffer *framebuffer,
- CoglPipeline *pipeline,
- CoglVerticesMode mode,
- int first_vertex,
- int n_vertices,
- CoglAttribute **attributes,
- int n_attributes,
- CoglDrawFlags flags);
-
-void
-_cogl_framebuffer_gl_draw_indexed_attributes (CoglFramebuffer *framebuffer,
- CoglPipeline *pipeline,
- CoglVerticesMode mode,
- int first_vertex,
- int n_vertices,
- CoglIndices *indices,
- CoglAttribute **attributes,
- int n_attributes,
- CoglDrawFlags flags);
-
gboolean
_cogl_framebuffer_gl_read_pixels_into_bitmap (CoglFramebuffer *framebuffer,
int x,
diff --git a/cogl/cogl/driver/gl/cogl-framebuffer-gl.c b/cogl/cogl/driver/gl/cogl-framebuffer-gl.c
index b0d48fc16c..fee3f22334 100644
--- a/cogl/cogl/driver/gl/cogl-framebuffer-gl.c
+++ b/cogl/cogl/driver/gl/cogl-framebuffer-gl.c
@@ -328,16 +328,19 @@ cogl_gl_framebuffer_flush (CoglFramebufferDriver *driver)
GE (ctx, glFlush ());
}
-void
-_cogl_framebuffer_gl_draw_attributes (CoglFramebuffer *framebuffer,
- CoglPipeline *pipeline,
- CoglVerticesMode mode,
- int first_vertex,
- int n_vertices,
- CoglAttribute **attributes,
- int n_attributes,
- CoglDrawFlags flags)
+static void
+cogl_gl_framebuffer_draw_attributes (CoglFramebufferDriver *driver,
+ CoglPipeline *pipeline,
+ CoglVerticesMode mode,
+ int first_vertex,
+ int n_vertices,
+ CoglAttribute **attributes,
+ int n_attributes,
+ CoglDrawFlags flags)
{
+ CoglFramebuffer *framebuffer =
+ cogl_framebuffer_driver_get_framebuffer (driver);
+
_cogl_flush_attributes_state (framebuffer, pipeline, flags,
attributes, n_attributes);
@@ -360,17 +363,19 @@ sizeof_index_type (CoglIndicesType type)
g_return_val_if_reached (0);
}
-void
-_cogl_framebuffer_gl_draw_indexed_attributes (CoglFramebuffer *framebuffer,
- CoglPipeline *pipeline,
- CoglVerticesMode mode,
- int first_vertex,
- int n_vertices,
- CoglIndices *indices,
- CoglAttribute **attributes,
- int n_attributes,
- CoglDrawFlags flags)
+static void
+cogl_gl_framebuffer_draw_indexed_attributes (CoglFramebufferDriver *driver,
+ CoglPipeline *pipeline,
+ CoglVerticesMode mode,
+ int first_vertex,
+ int n_vertices,
+ CoglIndices *indices,
+ CoglAttribute **attributes,
+ int n_attributes,
+ CoglDrawFlags flags)
{
+ CoglFramebuffer *framebuffer =
+ cogl_framebuffer_driver_get_framebuffer (driver);
CoglBuffer *buffer;
uint8_t *base;
size_t buffer_offset;
@@ -685,4 +690,7 @@ cogl_gl_framebuffer_class_init (CoglGlFramebufferClass *klass)
driver_class->clear = cogl_gl_framebuffer_clear;
driver_class->finish = cogl_gl_framebuffer_finish;
driver_class->flush = cogl_gl_framebuffer_flush;
+ driver_class->draw_attributes = cogl_gl_framebuffer_draw_attributes;
+ driver_class->draw_indexed_attributes =
+ cogl_gl_framebuffer_draw_indexed_attributes;
}
diff --git a/cogl/cogl/driver/gl/gl/cogl-driver-gl.c b/cogl/cogl/driver/gl/gl/cogl-driver-gl.c
index ef44dceda8..76f213b74d 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_draw_attributes,
- _cogl_framebuffer_gl_draw_indexed_attributes,
_cogl_framebuffer_gl_read_pixels_into_bitmap,
_cogl_texture_2d_gl_free,
_cogl_texture_2d_gl_can_create,
diff --git a/cogl/cogl/driver/gl/gles/cogl-driver-gles.c b/cogl/cogl/driver/gl/gles/cogl-driver-gles.c
index c573884fb3..5b50b76914 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_draw_attributes,
- _cogl_framebuffer_gl_draw_indexed_attributes,
_cogl_framebuffer_gl_read_pixels_into_bitmap,
_cogl_texture_2d_gl_free,
_cogl_texture_2d_gl_can_create,
diff --git a/cogl/cogl/driver/nop/cogl-driver-nop.c b/cogl/cogl/driver/nop/cogl-driver-nop.c
index 55961e3a96..0d47bf28bc 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_draw_attributes,
- _cogl_framebuffer_nop_draw_indexed_attributes,
_cogl_framebuffer_nop_read_pixels_into_bitmap,
_cogl_texture_2d_nop_free,
_cogl_texture_2d_nop_can_create,
diff --git a/cogl/cogl/driver/nop/cogl-framebuffer-nop-private.h
b/cogl/cogl/driver/nop/cogl-framebuffer-nop-private.h
index 404985dd1d..1fd031e5c2 100644
--- a/cogl/cogl/driver/nop/cogl-framebuffer-nop-private.h
+++ b/cogl/cogl/driver/nop/cogl-framebuffer-nop-private.h
@@ -37,27 +37,6 @@
#include "cogl-types.h"
#include "cogl-context-private.h"
-void
-_cogl_framebuffer_nop_draw_attributes (CoglFramebuffer *framebuffer,
- CoglPipeline *pipeline,
- CoglVerticesMode mode,
- int first_vertex,
- int n_vertices,
- CoglAttribute **attributes,
- int n_attributes,
- CoglDrawFlags flags);
-
-void
-_cogl_framebuffer_nop_draw_indexed_attributes (CoglFramebuffer *framebuffer,
- CoglPipeline *pipeline,
- CoglVerticesMode mode,
- int first_vertex,
- int n_vertices,
- CoglIndices *indices,
- CoglAttribute **attributes,
- int n_attributes,
- CoglDrawFlags flags);
-
gboolean
_cogl_framebuffer_nop_read_pixels_into_bitmap (CoglFramebuffer *framebuffer,
int x,
diff --git a/cogl/cogl/driver/nop/cogl-framebuffer-nop.c b/cogl/cogl/driver/nop/cogl-framebuffer-nop.c
index 54811afbcf..e0e2905869 100644
--- a/cogl/cogl/driver/nop/cogl-framebuffer-nop.c
+++ b/cogl/cogl/driver/nop/cogl-framebuffer-nop.c
@@ -35,31 +35,6 @@
#include <glib.h>
#include <string.h>
-void
-_cogl_framebuffer_nop_draw_attributes (CoglFramebuffer *framebuffer,
- CoglPipeline *pipeline,
- CoglVerticesMode mode,
- int first_vertex,
- int n_vertices,
- CoglAttribute **attributes,
- int n_attributes,
- CoglDrawFlags flags)
-{
-}
-
-void
-_cogl_framebuffer_nop_draw_indexed_attributes (CoglFramebuffer *framebuffer,
- CoglPipeline *pipeline,
- CoglVerticesMode mode,
- int first_vertex,
- int n_vertices,
- CoglIndices *indices,
- CoglAttribute **attributes,
- int n_attributes,
- CoglDrawFlags flags)
-{
-}
-
gboolean
_cogl_framebuffer_nop_read_pixels_into_bitmap (CoglFramebuffer *framebuffer,
int x,
diff --git a/cogl/cogl/driver/nop/cogl-nop-framebuffer.c b/cogl/cogl/driver/nop/cogl-nop-framebuffer.c
index cea5ab9061..20ec514a5d 100644
--- a/cogl/cogl/driver/nop/cogl-nop-framebuffer.c
+++ b/cogl/cogl/driver/nop/cogl-nop-framebuffer.c
@@ -70,6 +70,31 @@ cogl_nop_framebuffer_discard_buffers (CoglFramebufferDriver *driver,
{
}
+static void
+cogl_nop_framebuffer_draw_attributes (CoglFramebufferDriver *driver,
+ CoglPipeline *pipeline,
+ CoglVerticesMode mode,
+ int first_vertex,
+ int n_vertices,
+ CoglAttribute **attributes,
+ int n_attributes,
+ CoglDrawFlags flags)
+{
+}
+
+static void
+cogl_nop_framebuffer_draw_indexed_attributes (CoglFramebufferDriver *driver,
+ CoglPipeline *pipeline,
+ CoglVerticesMode mode,
+ int first_vertex,
+ int n_vertices,
+ CoglIndices *indices,
+ CoglAttribute **attributes,
+ int n_attributes,
+ CoglDrawFlags flags)
+{
+}
+
static void
cogl_nop_framebuffer_init (CoglNopFramebuffer *nop_framebuffer)
{
@@ -86,4 +111,7 @@ cogl_nop_framebuffer_class_init (CoglNopFramebufferClass *klass)
driver_class->finish = cogl_nop_framebuffer_finish;
driver_class->flush = cogl_nop_framebuffer_flush;
driver_class->discard_buffers = cogl_nop_framebuffer_discard_buffers;
+ driver_class->draw_attributes = cogl_nop_framebuffer_draw_attributes;
+ driver_class->draw_indexed_attributes =
+ cogl_nop_framebuffer_draw_indexed_attributes;
}
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]