Evas GL common: Enable vertex arrays only when requested

This should fix Dave's crash with the GL engine.

Indeed the pointer to the color array is passed directly
to the driver, without memcpy. Then, during glDrawArrays, the
driver will try to address it... but it could as well be NULL or
invalid. So, crashes would occur.

Also mark use_vertex as always true. We keep this field only for the
alloc() function.
This commit is contained in:
Jean-Philippe Andre 2015-04-13 15:28:16 +09:00
parent 258dc999ee
commit 0c7857024b
2 changed files with 13 additions and 4 deletions

View File

@ -511,7 +511,7 @@ struct _Evas_Engine_GL_Context
GLfloat *texsam;
GLfloat *mask;
Eina_Bool line: 1;
Eina_Bool use_vertex : 1;
Eina_Bool use_vertex : 1; // always true
Eina_Bool use_color : 1;
Eina_Bool use_texuv : 1;
Eina_Bool use_texuv2 : 1;

View File

@ -1742,7 +1742,7 @@ evas_gl_common_context_line_push(Evas_Engine_GL_Context *gc,
shader_array_flush(gc);
gc->pipe[pn].array.line = 0;
gc->pipe[pn].array.anti_alias = 0;
gc->pipe[pn].array.use_vertex = 0;
//gc->pipe[pn].array.use_vertex = 0;
gc->pipe[pn].array.use_color = 0;
gc->pipe[pn].array.use_texuv = 0;
gc->pipe[pn].array.use_texuv2 = 0;
@ -3077,8 +3077,17 @@ shader_array_flush(Evas_Engine_GL_Context *gc)
texsam_ptr = (unsigned char *)gc->pipe[i].array.texsam;
mask_ptr = (unsigned char *)gc->pipe[i].array.mask;
}
// use_vertex is always true
glVertexAttribPointer(SHAD_VERTEX, VERTEX_CNT, GL_SHORT, GL_FALSE, 0, vertex_ptr);
glVertexAttribPointer(SHAD_COLOR, COLOR_CNT, GL_UNSIGNED_BYTE, GL_TRUE, 0, color_ptr);
if (gc->pipe[i].array.use_color)
{
glEnableVertexAttribArray(SHAD_COLOR);
glVertexAttribPointer(SHAD_COLOR, COLOR_CNT, GL_UNSIGNED_BYTE, GL_TRUE, 0, color_ptr);
}
else
glDisableVertexAttribArray(SHAD_COLOR);
if (gc->pipe[i].array.line)
{
@ -3338,7 +3347,7 @@ shader_array_flush(Evas_Engine_GL_Context *gc)
if (gc->pipe[i].array.mask) free(gc->pipe[i].array.mask);
gc->pipe[i].array.line = 0;
gc->pipe[i].array.use_vertex = 0;
//gc->pipe[i].array.use_vertex = 0;
gc->pipe[i].array.use_color = 0;
gc->pipe[i].array.use_texuv = 0;
gc->pipe[i].array.use_texuv2 = 0;