Commit 4aab814c authored by Daniel van Vugt's avatar Daniel van Vugt

cogl: Upload clipping rectangles in parallel

That is as a single array in a single GL operation. Instead of doing
each one as a separate upload.

Closes: GNOME/mutter#971

GNOME/mutter!969
parent a48206e8
......@@ -124,6 +124,7 @@ add_stencil_clip_region (CoglFramebuffer *framebuffer,
CoglMatrix matrix;
int num_rectangles = cairo_region_num_rectangles (region);
int i;
CoglVertexP2 *vertices;
/* NB: This can be called while flushing the journal so we need
* to be very conservative with what state we change.
......@@ -167,11 +168,14 @@ add_stencil_clip_region (CoglFramebuffer *framebuffer,
GE( ctx, glStencilOp (GL_KEEP, GL_KEEP, GL_REPLACE) );
}
vertices = g_alloca (sizeof (CoglVertexP2) * num_rectangles * 6);
for (i = 0; i < num_rectangles; i++)
{
cairo_rectangle_int_t rect;
float x1, y1, z1, w1;
float x2, y2, z2, w2;
CoglVertexP2 *v = vertices + i * 6;
cairo_region_get_rectangle (region, i, &rect);
......@@ -188,11 +192,26 @@ add_stencil_clip_region (CoglFramebuffer *framebuffer,
cogl_matrix_transform_point (&matrix, &x1, &y1, &z1, &w1);
cogl_matrix_transform_point (&matrix, &x2, &y2, &z2, &w2);
_cogl_rectangle_immediate (framebuffer,
ctx->stencil_pipeline,
x1, y1, x2, y2);
v[0].x = x1;
v[0].y = y1;
v[1].x = x1;
v[1].y = y2;
v[2].x = x2;
v[2].y = y1;
v[3].x = x1;
v[3].y = y2;
v[4].x = x2;
v[4].y = y2;
v[5].x = x2;
v[5].y = y1;
}
cogl_2d_primitives_immediate (framebuffer,
ctx->stencil_pipeline,
COGL_VERTICES_MODE_TRIANGLES,
vertices,
6 * num_rectangles);
if (merge)
{
/* Subtract one from all pixels in the stencil buffer so that
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment