diff options
author | Timm Bäder <mail@baedert.org> | 2018-04-12 09:47:17 +0200 |
---|---|---|
committer | Timm Bäder <mail@baedert.org> | 2018-04-14 11:47:02 +0200 |
commit | fdfdada362c91a27f01dc048468cba881d2b6b7e (patch) | |
tree | 8b56fe5cd2ba2e584f36bdd2699c06d680338c3f /gsk | |
parent | 3a995b41d787a28d725492751be4d4a74f3dd3d5 (diff) | |
download | gtk+-fdfdada362c91a27f01dc048468cba881d2b6b7e.tar.gz |
gl renderer: Increase GArray size by 2 up front
Since we know we will add two elements anyway.
Diffstat (limited to 'gsk')
-rw-r--r-- | gsk/gl/gskglrenderops.c | 20 |
1 files changed, 12 insertions, 8 deletions
diff --git a/gsk/gl/gskglrenderops.c b/gsk/gl/gskglrenderops.c index d05ec61a0f..21223ee157 100644 --- a/gsk/gl/gskglrenderops.c +++ b/gsk/gl/gskglrenderops.c @@ -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 */ |