gl renderer: Increase GArray size by 2 up front

Since we know we will add two elements anyway.
This commit is contained in:
Timm Bäder 2018-04-12 09:47:17 +02:00
parent 3a995b41d7
commit fdfdada362

View File

@ -407,17 +407,21 @@ ops_draw (RenderOpBuilder *builder,
}
else
{
RenderOp op;
const gsize n_ops = builder->render_ops->len;
RenderOp *op;
gsize offset = builder->buffer_size / sizeof (GskQuadVertex);
op.op = OP_CHANGE_VAO;
memcpy (&op.vertex_data, vertex_data, sizeof(GskQuadVertex) * GL_N_VERTICES);
g_array_append_val (builder->render_ops, op);
/* We will add two render ops here. */
g_array_set_size (builder->render_ops, n_ops + 2);
op.op = OP_DRAW;
op.draw.vao_offset = offset;
op.draw.vao_size = GL_N_VERTICES;
g_array_append_val (builder->render_ops, op);
op = &g_array_index (builder->render_ops, RenderOp, n_ops);
op->op = OP_CHANGE_VAO;
memcpy (&op->vertex_data, vertex_data, sizeof(GskQuadVertex) * GL_N_VERTICES);
op = &g_array_index (builder->render_ops, RenderOp, n_ops + 1);
op->op = OP_DRAW;
op->draw.vao_offset = offset;
op->draw.vao_size = GL_N_VERTICES;
}
/* We added new vertex data in both cases so increase the buffer size */