mirror of
https://github.com/brl/mutter.git
synced 2024-11-25 17:40:40 -05:00
cogl: Add function cogl_2d_primitives_immediate
For use in batching multiple primitives as a single GL upload. https://gitlab.gnome.org/GNOME/mutter/merge_requests/969
This commit is contained in:
parent
67d9995280
commit
99cc435730
@ -47,6 +47,13 @@ _cogl_rectangle_immediate (CoglFramebuffer *framebuffer,
|
|||||||
float x_2,
|
float x_2,
|
||||||
float y_2);
|
float y_2);
|
||||||
|
|
||||||
|
void
|
||||||
|
cogl_2d_primitives_immediate (CoglFramebuffer *framebuffer,
|
||||||
|
CoglPipeline *pipeline,
|
||||||
|
CoglVerticesMode mode,
|
||||||
|
const CoglVertexP2 *vertices,
|
||||||
|
unsigned int n_vertices);
|
||||||
|
|
||||||
typedef struct _CoglMultiTexturedRect
|
typedef struct _CoglMultiTexturedRect
|
||||||
{
|
{
|
||||||
const float *position; /* x0,y0,x1,y1 */
|
const float *position; /* x0,y0,x1,y1 */
|
||||||
|
@ -708,42 +708,31 @@ _cogl_framebuffer_draw_multitextured_rectangles (
|
|||||||
}
|
}
|
||||||
|
|
||||||
void
|
void
|
||||||
_cogl_rectangle_immediate (CoglFramebuffer *framebuffer,
|
cogl_2d_primitives_immediate (CoglFramebuffer *framebuffer,
|
||||||
CoglPipeline *pipeline,
|
CoglPipeline *pipeline,
|
||||||
float x_1,
|
CoglVerticesMode mode,
|
||||||
float y_1,
|
const CoglVertexP2 *vertices,
|
||||||
float x_2,
|
unsigned int n_vertices)
|
||||||
float y_2)
|
|
||||||
{
|
{
|
||||||
/* Draw a rectangle using the vertex array API to avoid going
|
|
||||||
through the journal. This should only be used in cases where the
|
|
||||||
code might be called while the journal is already being flushed
|
|
||||||
such as when flushing the clip state */
|
|
||||||
CoglContext *ctx = framebuffer->context;
|
CoglContext *ctx = framebuffer->context;
|
||||||
float vertices[8] =
|
|
||||||
{
|
|
||||||
x_1, y_1,
|
|
||||||
x_1, y_2,
|
|
||||||
x_2, y_1,
|
|
||||||
x_2, y_2
|
|
||||||
};
|
|
||||||
CoglAttributeBuffer *attribute_buffer;
|
CoglAttributeBuffer *attribute_buffer;
|
||||||
CoglAttribute *attributes[1];
|
CoglAttribute *attributes[1];
|
||||||
|
size_t vertices_size = sizeof (CoglVertexP2) * n_vertices;
|
||||||
|
|
||||||
attribute_buffer =
|
attribute_buffer =
|
||||||
cogl_attribute_buffer_new (ctx, sizeof (vertices), vertices);
|
cogl_attribute_buffer_new (ctx, vertices_size, vertices);
|
||||||
attributes[0] = cogl_attribute_new (attribute_buffer,
|
attributes[0] = cogl_attribute_new (attribute_buffer,
|
||||||
"cogl_position_in",
|
"cogl_position_in",
|
||||||
sizeof (float) * 2, /* stride */
|
sizeof (CoglVertexP2), /* stride */
|
||||||
0, /* offset */
|
0, /* offset */
|
||||||
2, /* n_components */
|
2, /* n_components */
|
||||||
COGL_ATTRIBUTE_TYPE_FLOAT);
|
COGL_ATTRIBUTE_TYPE_FLOAT);
|
||||||
|
|
||||||
_cogl_framebuffer_draw_attributes (framebuffer,
|
_cogl_framebuffer_draw_attributes (framebuffer,
|
||||||
pipeline,
|
pipeline,
|
||||||
COGL_VERTICES_MODE_TRIANGLE_STRIP,
|
mode,
|
||||||
0, /* first_index */
|
0, /* first_index */
|
||||||
4, /* n_vertices */
|
n_vertices,
|
||||||
attributes,
|
attributes,
|
||||||
1,
|
1,
|
||||||
COGL_DRAW_SKIP_JOURNAL_FLUSH |
|
COGL_DRAW_SKIP_JOURNAL_FLUSH |
|
||||||
@ -754,3 +743,26 @@ _cogl_rectangle_immediate (CoglFramebuffer *framebuffer,
|
|||||||
cogl_object_unref (attributes[0]);
|
cogl_object_unref (attributes[0]);
|
||||||
cogl_object_unref (attribute_buffer);
|
cogl_object_unref (attribute_buffer);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void
|
||||||
|
_cogl_rectangle_immediate (CoglFramebuffer *framebuffer,
|
||||||
|
CoglPipeline *pipeline,
|
||||||
|
float x_1,
|
||||||
|
float y_1,
|
||||||
|
float x_2,
|
||||||
|
float y_2)
|
||||||
|
{
|
||||||
|
CoglVertexP2 vertices[4] =
|
||||||
|
{
|
||||||
|
{x_1, y_1},
|
||||||
|
{x_1, y_2},
|
||||||
|
{x_2, y_1},
|
||||||
|
{x_2, y_2}
|
||||||
|
};
|
||||||
|
|
||||||
|
cogl_2d_primitives_immediate (framebuffer,
|
||||||
|
pipeline,
|
||||||
|
COGL_VERTICES_MODE_TRIANGLE_STRIP,
|
||||||
|
vertices,
|
||||||
|
4);
|
||||||
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user