mirror of
https://github.com/brl/mutter.git
synced 2024-11-23 08:30:42 -05:00
[pango-display-list] Use indexed vertices on GLES
Now that CoglVertexBuffers support indices we can use them with GLES to avoid duplicating vertices. Regular GL still uses GL_QUADS because it is shown to still have a performance benefit over indices with the Intel drivers.
This commit is contained in:
parent
67544f38d4
commit
97921a7d13
@ -41,13 +41,6 @@ typedef enum
|
||||
typedef struct _CoglPangoDisplayListNode CoglPangoDisplayListNode;
|
||||
typedef struct _CoglPangoDisplayListVertex CoglPangoDisplayListVertex;
|
||||
|
||||
#ifdef HAVE_CLUTTER_GLX
|
||||
#define COGL_PANGO_DISPLAY_LIST_DRAW_MODE GL_QUADS
|
||||
#else
|
||||
/* GLES doesn't support GL_QUADS so we use GL_TRIANGLES instead */
|
||||
#define COGL_PANGO_DISPLAY_LIST_DRAW_MODE GL_TRIANGLES
|
||||
#endif
|
||||
|
||||
struct _CoglPangoDisplayList
|
||||
{
|
||||
CoglColor color;
|
||||
@ -184,24 +177,6 @@ _cogl_pango_display_list_add_texture (CoglPangoDisplayList *dl,
|
||||
verts->y = y_1;
|
||||
verts->t_x = tx_2;
|
||||
verts->t_y = ty_1;
|
||||
|
||||
#ifndef HAVE_CLUTTER_GLX
|
||||
|
||||
/* GLES doesn't support GL_QUADS so we use GL_TRIANGLES instead with
|
||||
two extra vertices per quad. FIXME: It might be better to use
|
||||
indexed elements here but cogl vertex buffers don't currently
|
||||
support storing the indices */
|
||||
|
||||
g_array_set_size (node->d.texture.verts,
|
||||
node->d.texture.verts->len + 2);
|
||||
verts = &g_array_index (node->d.texture.verts,
|
||||
CoglPangoDisplayListVertex,
|
||||
node->d.texture.verts->len - 6);
|
||||
|
||||
verts[4] = verts[0];
|
||||
verts[5] = verts[2];
|
||||
|
||||
#endif /* HAVE_CLUTTER_GLX */
|
||||
}
|
||||
|
||||
void
|
||||
@ -270,9 +245,29 @@ _cogl_pango_display_list_render_texture (CoglHandle material,
|
||||
node->d.texture.vertex_buffer = vb;
|
||||
}
|
||||
|
||||
|
||||
#ifdef CLUTTER_COGL_HAS_GL
|
||||
|
||||
cogl_vertex_buffer_draw (node->d.texture.vertex_buffer,
|
||||
COGL_PANGO_DISPLAY_LIST_DRAW_MODE,
|
||||
GL_QUADS,
|
||||
0, node->d.texture.verts->len);
|
||||
|
||||
#else /* CLUTTER_COGL_HAS_GL */
|
||||
{
|
||||
/* GLES doesn't support GL_QUADS so instead we use a VBO with
|
||||
indexed vertices to generate GL_TRIANGLES from the quads */
|
||||
|
||||
int n_indices = node->d.texture.verts->len / 4 * 6;
|
||||
CoglHandle indices_vbo
|
||||
= cogl_vertex_buffer_indices_get_for_quads (n_indices);
|
||||
|
||||
cogl_vertex_buffer_draw_elements (node->d.texture.vertex_buffer,
|
||||
COGL_VERTICES_MODE_TRIANGLES,
|
||||
indices_vbo,
|
||||
0, node->d.texture.verts->len - 1,
|
||||
0, n_indices);
|
||||
}
|
||||
#endif /* CLUTTER_COGL_HAS_GL */
|
||||
}
|
||||
|
||||
void
|
||||
|
Loading…
Reference in New Issue
Block a user