cogl/framebuffer: Move attribute drawing to driver class

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/1514>
This commit is contained in:
Jonas Ådahl 2020-10-20 10:55:56 +02:00 committed by Robert Mader
parent 392ffaeeb4
commit 1e5f105836
12 changed files with 158 additions and 134 deletions

View File

@ -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,

View File

@ -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,

View File

@ -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 */

View File

@ -2478,9 +2478,7 @@ _cogl_framebuffer_draw_attributes (CoglFramebuffer *framebuffer,
else
#endif
{
CoglContext *ctx = priv->context;
ctx->driver_vtable->framebuffer_draw_attributes (framebuffer,
cogl_framebuffer_driver_draw_attributes (priv->driver,
pipeline,
mode,
first_vertex,
@ -2519,9 +2517,7 @@ _cogl_framebuffer_draw_indexed_attributes (CoglFramebuffer *framebuffer,
else
#endif
{
CoglContext *ctx = priv->context;
ctx->driver_vtable->framebuffer_draw_indexed_attributes (framebuffer,
cogl_framebuffer_driver_draw_indexed_attributes (priv->driver,
pipeline,
mode,
first_vertex,

View File

@ -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,

View File

@ -328,8 +328,8 @@ cogl_gl_framebuffer_flush (CoglFramebufferDriver *driver)
GE (ctx, glFlush ());
}
void
_cogl_framebuffer_gl_draw_attributes (CoglFramebuffer *framebuffer,
static void
cogl_gl_framebuffer_draw_attributes (CoglFramebufferDriver *driver,
CoglPipeline *pipeline,
CoglVerticesMode mode,
int first_vertex,
@ -338,6 +338,9 @@ _cogl_framebuffer_gl_draw_attributes (CoglFramebuffer *framebuffer,
int n_attributes,
CoglDrawFlags flags)
{
CoglFramebuffer *framebuffer =
cogl_framebuffer_driver_get_framebuffer (driver);
_cogl_flush_attributes_state (framebuffer, pipeline, flags,
attributes, n_attributes);
@ -360,8 +363,8 @@ sizeof_index_type (CoglIndicesType type)
g_return_val_if_reached (0);
}
void
_cogl_framebuffer_gl_draw_indexed_attributes (CoglFramebuffer *framebuffer,
static void
cogl_gl_framebuffer_draw_indexed_attributes (CoglFramebufferDriver *driver,
CoglPipeline *pipeline,
CoglVerticesMode mode,
int first_vertex,
@ -371,6 +374,8 @@ _cogl_framebuffer_gl_draw_indexed_attributes (CoglFramebuffer *framebuffer,
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;
}

View File

@ -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,

View File

@ -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,

View File

@ -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,

View File

@ -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,

View File

@ -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,

View File

@ -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;
}