1
0
Fork 0

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, CoglFramebuffer *read_buffer,
CoglFramebufferState state); 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 gboolean
(* framebuffer_read_pixels_into_bitmap) (CoglFramebuffer *framebuffer, (* framebuffer_read_pixels_into_bitmap) (CoglFramebuffer *framebuffer,
int x, 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); 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 static void
cogl_framebuffer_driver_get_property (GObject *object, cogl_framebuffer_driver_get_property (GObject *object,
guint prop_id, guint prop_id,

View file

@ -28,6 +28,7 @@
#ifndef COGL_FRAMEBUFFER_DRIVER_H #ifndef COGL_FRAMEBUFFER_DRIVER_H
#define COGL_FRAMEBUFFER_DRIVER_H #define COGL_FRAMEBUFFER_DRIVER_H
#include "cogl-attribute-private.h"
#include "cogl-framebuffer.h" #include "cogl-framebuffer.h"
typedef struct _CoglFramebufferBits CoglFramebufferBits; typedef struct _CoglFramebufferBits CoglFramebufferBits;
@ -58,6 +59,25 @@ struct _CoglFramebufferDriverClass
void (* discard_buffers) (CoglFramebufferDriver *driver, void (* discard_buffers) (CoglFramebufferDriver *driver,
unsigned long buffers); 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 * CoglFramebuffer *
@ -85,4 +105,25 @@ void
cogl_framebuffer_driver_discard_buffers (CoglFramebufferDriver *driver, cogl_framebuffer_driver_discard_buffers (CoglFramebufferDriver *driver,
unsigned long buffers); 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 */ #endif /* COGL_FRAMEBUFFER_DRIVER_H */

View file

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

View file

@ -55,27 +55,6 @@ void
cogl_gl_framebuffer_bind (CoglGlFramebuffer *gl_framebuffer, cogl_gl_framebuffer_bind (CoglGlFramebuffer *gl_framebuffer,
GLenum target); 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 gboolean
_cogl_framebuffer_gl_read_pixels_into_bitmap (CoglFramebuffer *framebuffer, _cogl_framebuffer_gl_read_pixels_into_bitmap (CoglFramebuffer *framebuffer,
int x, int x,

View file

@ -328,8 +328,8 @@ cogl_gl_framebuffer_flush (CoglFramebufferDriver *driver)
GE (ctx, glFlush ()); GE (ctx, glFlush ());
} }
void static void
_cogl_framebuffer_gl_draw_attributes (CoglFramebuffer *framebuffer, cogl_gl_framebuffer_draw_attributes (CoglFramebufferDriver *driver,
CoglPipeline *pipeline, CoglPipeline *pipeline,
CoglVerticesMode mode, CoglVerticesMode mode,
int first_vertex, int first_vertex,
@ -338,6 +338,9 @@ _cogl_framebuffer_gl_draw_attributes (CoglFramebuffer *framebuffer,
int n_attributes, int n_attributes,
CoglDrawFlags flags) CoglDrawFlags flags)
{ {
CoglFramebuffer *framebuffer =
cogl_framebuffer_driver_get_framebuffer (driver);
_cogl_flush_attributes_state (framebuffer, pipeline, flags, _cogl_flush_attributes_state (framebuffer, pipeline, flags,
attributes, n_attributes); attributes, n_attributes);
@ -360,8 +363,8 @@ sizeof_index_type (CoglIndicesType type)
g_return_val_if_reached (0); g_return_val_if_reached (0);
} }
void static void
_cogl_framebuffer_gl_draw_indexed_attributes (CoglFramebuffer *framebuffer, cogl_gl_framebuffer_draw_indexed_attributes (CoglFramebufferDriver *driver,
CoglPipeline *pipeline, CoglPipeline *pipeline,
CoglVerticesMode mode, CoglVerticesMode mode,
int first_vertex, int first_vertex,
@ -371,6 +374,8 @@ _cogl_framebuffer_gl_draw_indexed_attributes (CoglFramebuffer *framebuffer,
int n_attributes, int n_attributes,
CoglDrawFlags flags) CoglDrawFlags flags)
{ {
CoglFramebuffer *framebuffer =
cogl_framebuffer_driver_get_framebuffer (driver);
CoglBuffer *buffer; CoglBuffer *buffer;
uint8_t *base; uint8_t *base;
size_t buffer_offset; size_t buffer_offset;
@ -685,4 +690,7 @@ cogl_gl_framebuffer_class_init (CoglGlFramebufferClass *klass)
driver_class->clear = cogl_gl_framebuffer_clear; driver_class->clear = cogl_gl_framebuffer_clear;
driver_class->finish = cogl_gl_framebuffer_finish; driver_class->finish = cogl_gl_framebuffer_finish;
driver_class->flush = cogl_gl_framebuffer_flush; 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_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_draw_attributes,
_cogl_framebuffer_gl_draw_indexed_attributes,
_cogl_framebuffer_gl_read_pixels_into_bitmap, _cogl_framebuffer_gl_read_pixels_into_bitmap,
_cogl_texture_2d_gl_free, _cogl_texture_2d_gl_free,
_cogl_texture_2d_gl_can_create, _cogl_texture_2d_gl_can_create,

View file

@ -459,8 +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_draw_attributes,
_cogl_framebuffer_gl_draw_indexed_attributes,
_cogl_framebuffer_gl_read_pixels_into_bitmap, _cogl_framebuffer_gl_read_pixels_into_bitmap,
_cogl_texture_2d_gl_free, _cogl_texture_2d_gl_free,
_cogl_texture_2d_gl_can_create, _cogl_texture_2d_gl_can_create,

View file

@ -99,8 +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_draw_attributes,
_cogl_framebuffer_nop_draw_indexed_attributes,
_cogl_framebuffer_nop_read_pixels_into_bitmap, _cogl_framebuffer_nop_read_pixels_into_bitmap,
_cogl_texture_2d_nop_free, _cogl_texture_2d_nop_free,
_cogl_texture_2d_nop_can_create, _cogl_texture_2d_nop_can_create,

View file

@ -37,27 +37,6 @@
#include "cogl-types.h" #include "cogl-types.h"
#include "cogl-context-private.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 gboolean
_cogl_framebuffer_nop_read_pixels_into_bitmap (CoglFramebuffer *framebuffer, _cogl_framebuffer_nop_read_pixels_into_bitmap (CoglFramebuffer *framebuffer,
int x, int x,

View file

@ -35,31 +35,6 @@
#include <glib.h> #include <glib.h>
#include <string.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 gboolean
_cogl_framebuffer_nop_read_pixels_into_bitmap (CoglFramebuffer *framebuffer, _cogl_framebuffer_nop_read_pixels_into_bitmap (CoglFramebuffer *framebuffer,
int x, 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 static void
cogl_nop_framebuffer_init (CoglNopFramebuffer *nop_framebuffer) 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->finish = cogl_nop_framebuffer_finish;
driver_class->flush = cogl_nop_framebuffer_flush; driver_class->flush = cogl_nop_framebuffer_flush;
driver_class->discard_buffers = cogl_nop_framebuffer_discard_buffers; 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;
} }