glamor: Add a helper function for the common GL_QUADS fallback pattern.

We should do better than this with an index buffer, but for now at
least make it so that we don't have to copy the same code to new
places.

Signed-off-by: Eric Anholt <eric@anholt.net>
Reviewed-by: Keith Packard <keithp@keithp.com>
This commit is contained in:
Eric Anholt 2015-02-04 14:38:15 -08:00
parent 909a406aa2
commit 9e9fcf5780
4 changed files with 20 additions and 23 deletions

View File

@ -387,13 +387,7 @@ glamor_copy_fbo_fbo_draw(DrawablePtr src,
src_box->x2 - src_box->x1,
src_box->y2 - src_box->y1);
if (glamor_priv->gl_flavor == GLAMOR_GL_DESKTOP)
glDrawArrays(GL_QUADS, 0, nbox * 4);
else {
int i;
for (i = 0; i < nbox; i++)
glDrawArrays(GL_TRIANGLE_FAN, i*4, 4);
}
glamor_glDrawArrays_GL_QUADS(glamor_priv, nbox);
}
}
glDisable(GL_SCISSOR_TEST);

View File

@ -126,14 +126,7 @@ glamor_poly_fill_rect_gl(DrawablePtr drawable,
if (glamor_priv->glsl_version >= 130)
glDrawArraysInstanced(GL_TRIANGLE_STRIP, 0, 4, nrect);
else {
if (glamor_priv->gl_flavor == GLAMOR_GL_DESKTOP) {
glDrawArrays(GL_QUADS, 0, nrect * 4);
} else {
int i;
for (i = 0; i < nrect; i++) {
glDrawArrays(GL_TRIANGLE_FAN, i * 4, 4);
}
}
glamor_glDrawArrays_GL_QUADS(glamor_priv, nrect);
}
}
}

View File

@ -134,14 +134,7 @@ glamor_fill_spans_gl(DrawablePtr drawable,
if (glamor_priv->glsl_version >= 130)
glDrawArraysInstanced(GL_TRIANGLE_STRIP, 0, 4, n);
else {
if (glamor_priv->gl_flavor == GLAMOR_GL_DESKTOP) {
glDrawArrays(GL_QUADS, 0, 4 * n);
} else {
int i;
for (i = 0; i < n; i++) {
glDrawArrays(GL_TRIANGLE_FAN, i * 4, 4);
}
}
glamor_glDrawArrays_GL_QUADS(glamor_priv, nbox);
}
}
}

View File

@ -1393,4 +1393,21 @@ glamor_make_current(glamor_screen_private *glamor_priv)
}
}
/**
* Helper function for implementing draws with GL_QUADS on GLES2,
* where we don't have them.
*/
static inline void
glamor_glDrawArrays_GL_QUADS(glamor_screen_private *glamor_priv, unsigned count)
{
if (glamor_priv->gl_flavor == GLAMOR_GL_DESKTOP) {
glDrawArrays(GL_QUADS, 0, count * 4);
} else {
unsigned i;
for (i = 0; i < count; i++)
glDrawArrays(GL_TRIANGLE_FAN, i * 4, 4);
}
}
#endif