summaryrefslogtreecommitdiff
path: root/glamor
diff options
context:
space:
mode:
authorEric Anholt <eric@anholt.net>2015-02-04 14:38:15 -0800
committerEric Anholt <eric@anholt.net>2015-03-24 12:43:34 -0700
commit9e9fcf578063b4155aab4adab83f8d956bde5d1a (patch)
tree46770cd2ddd44e3eb0794f81a50b9696dc46e37e /glamor
parent909a406aa239b8d231d6f63ce05a3e4a2bc3cb07 (diff)
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>
Diffstat (limited to 'glamor')
-rw-r--r--glamor/glamor_copy.c8
-rw-r--r--glamor/glamor_rects.c9
-rw-r--r--glamor/glamor_spans.c9
-rw-r--r--glamor/glamor_utils.h17
4 files changed, 20 insertions, 23 deletions
diff --git a/glamor/glamor_copy.c b/glamor/glamor_copy.c
index 2ea270c4b..e2d52041f 100644
--- a/glamor/glamor_copy.c
+++ b/glamor/glamor_copy.c
@@ -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);
diff --git a/glamor/glamor_rects.c b/glamor/glamor_rects.c
index c8c92be17..c378e4a30 100644
--- a/glamor/glamor_rects.c
+++ b/glamor/glamor_rects.c
@@ -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);
}
}
}
diff --git a/glamor/glamor_spans.c b/glamor/glamor_spans.c
index 7138db5a0..b358c60bd 100644
--- a/glamor/glamor_spans.c
+++ b/glamor/glamor_spans.c
@@ -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);
}
}
}
diff --git a/glamor/glamor_utils.h b/glamor/glamor_utils.h
index 6a3bd2942..0927ffb06 100644
--- a/glamor/glamor_utils.h
+++ b/glamor/glamor_utils.h
@@ -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