renderer-gl: Allocate buffer on the stack

This avoids an extra heap allocation for each view.
dev
Link Mauve 5 years ago committed by Emmanuel Gil Peyrot
parent 04918f3b0b
commit 48cd15ed44
  1. 9
      libweston/renderer-gl/gl-renderer.c

@ -732,9 +732,10 @@ triangle_fan_debug(struct gl_renderer *gr,
int first, int count) int first, int count)
{ {
int i; int i;
GLushort *buffer; /* There can be at most eight vertices for a given view. */
GLushort buffer[(8 - 1 + 8 - 2) * 2];
GLushort *index; GLushort *index;
int nelems; GLsizei nelems;
static int color_idx = 0; static int color_idx = 0;
struct gl_shader_config alt; struct gl_shader_config alt;
const GLfloat *col; const GLfloat *col;
@ -766,8 +767,8 @@ triangle_fan_debug(struct gl_renderer *gr,
gl_renderer_use_program(gr, &alt); gl_renderer_use_program(gr, &alt);
nelems = (count - 1 + count - 2) * 2; nelems = (count - 1 + count - 2) * 2;
assert((unsigned long)nelems <= ARRAY_LENGTH(buffer));
buffer = malloc(sizeof(GLushort) * nelems);
index = buffer; index = buffer;
for (i = 1; i < count; i++) { for (i = 1; i < count; i++) {
@ -782,8 +783,6 @@ triangle_fan_debug(struct gl_renderer *gr,
glDrawElements(GL_LINES, nelems, GL_UNSIGNED_SHORT, buffer); glDrawElements(GL_LINES, nelems, GL_UNSIGNED_SHORT, buffer);
free(buffer);
gl_renderer_use_program(gr, sconf); gl_renderer_use_program(gr, sconf);
} }

Loading…
Cancel
Save