Commit 9553020b authored by Eric Anholt's avatar Eric Anholt

glamor: Drop a bunch of GLES2 ifdefs.

Now that we're using epoxy, we can write code using both desktop and
ES symbols and decide what to use at runtime.

v2: Fix a spelling mistake (latter), since the lines were moved
    anyway (noticed by Rémi Cardona).  Fix condition invert in
    glamor_set_composite_texture (caught by Michel Dänzer).
Signed-off-by: Eric Anholt's avatarEric Anholt <eric@anholt.net>
Reviewed-by: Keith Packard <keithp@keithp.com> (v1)
Reviewed-by: Adam Jackson <ajax@redhat.com> (v1)
parent c3c8a5f3
......@@ -301,26 +301,29 @@ glamor_init(ScreenPtr screen, unsigned int flags)
goto fail;;
}
if (epoxy_is_desktop_gl())
glamor_priv->gl_flavor = GLAMOR_GL_DESKTOP;
else
glamor_priv->gl_flavor = GLAMOR_GL_ES2;
gl_version = glamor_gl_get_version();
#ifndef GLAMOR_GLES2
if (glamor_priv->gl_flavor == GLAMOR_GL_DESKTOP) {
if (gl_version < GLAMOR_GL_VERSION_ENCODE(1, 3)) {
ErrorF("Require OpenGL version 1.3 or latter.\n");
ErrorF("Require OpenGL version 1.3 or later.\n");
goto fail;
}
#else
} else {
if (gl_version < GLAMOR_GL_VERSION_ENCODE(2, 0)) {
ErrorF("Require Open GLES2.0 or latter.\n");
ErrorF("Require Open GLES2.0 or later.\n");
goto fail;
}
#endif
#ifdef GLAMOR_GLES2
if (!glamor_gl_has_extension("GL_EXT_texture_format_BGRA8888")) {
ErrorF("GL_EXT_texture_format_BGRA8888 required\n");
goto fail;
}
#endif
}
glamor_priv->has_pack_invert =
glamor_gl_has_extension("GL_MESA_pack_invert");
......@@ -333,11 +336,6 @@ glamor_init(ScreenPtr screen, unsigned int flags)
glamor_set_debug_level(&glamor_debug_level);
#ifdef GLAMOR_GLES2
glamor_priv->gl_flavor = GLAMOR_GL_ES2;
#else
glamor_priv->gl_flavor = GLAMOR_GL_DESKTOP;
#endif
/* If we are using egl screen, call egl screen init to
* register correct close screen function. */
if (flags & GLAMOR_USE_EGL_SCREEN) {
......
......@@ -31,7 +31,6 @@
*
* GC CopyArea implementation
*/
#ifndef GLAMOR_GLES2
static Bool
glamor_copy_n_to_n_fbo_blit(DrawablePtr src,
DrawablePtr dst,
......@@ -117,7 +116,6 @@ glamor_copy_n_to_n_fbo_blit(DrawablePtr src,
glamor_priv->state = BLIT_STATE;
return TRUE;
}
#endif
static Bool
glamor_copy_n_to_n_textured(DrawablePtr src,
......@@ -170,10 +168,10 @@ glamor_copy_n_to_n_textured(DrawablePtr src,
glActiveTexture(GL_TEXTURE0);
glBindTexture(GL_TEXTURE_2D, src_pixmap_priv->base.fbo->tex);
#ifndef GLAMOR_GLES2
if (glamor_priv->gl_flavor == GLAMOR_GL_DESKTOP) {
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_CLAMP_TO_BORDER);
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_CLAMP_TO_BORDER);
#endif
}
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_NEAREST);
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_NEAREST);
......@@ -266,15 +264,14 @@ __glamor_copy_n_to_n(DrawablePtr src,
box[0].x1, box[0].y1,
box[0].x2 - box[0].x1, box[0].y2 - box[0].y1,
dx, dy, src_pixmap, dst_pixmap);
#ifndef GLAMOR_GLES2
if (!overlaped &&
if (glamor_priv->gl_flavor == GLAMOR_GL_DESKTOP &&
!overlaped &&
(glamor_priv->state != RENDER_STATE
|| !src_pixmap_priv->base.gl_tex || !dst_pixmap_priv->base.gl_tex)
&& glamor_copy_n_to_n_fbo_blit(src, dst, gc, box, nbox, dx, dy)) {
ret = TRUE;
goto done;
}
#endif
glamor_calculate_boxes_bound(&bound, box, nbox);
/* Overlaped indicate the src and dst are the same pixmap. */
......
......@@ -240,13 +240,15 @@ _glamor_solid_boxes(PixmapPtr pixmap, BoxPtr box, int nbox, float *color)
}
if (box_cnt == 1)
glDrawArrays(GL_TRIANGLE_FAN, 0, box_cnt * 4);
else
#ifndef GLAMOR_GLES2
else {
if (glamor_priv->gl_flavor == GLAMOR_GL_DESKTOP) {
glDrawRangeElements(GL_TRIANGLES, 0, box_cnt * 4, box_cnt * 6,
GL_UNSIGNED_SHORT, NULL);
#else
glDrawElements(GL_TRIANGLES, box_cnt * 6, GL_UNSIGNED_SHORT, NULL);
#endif
} else {
glDrawElements(GL_TRIANGLES, box_cnt * 6, GL_UNSIGNED_SHORT,
NULL);
}
}
nbox -= box_cnt;
box += box_cnt;
}
......
......@@ -535,14 +535,16 @@ glamor_set_composite_texture(glamor_screen_private *glamor_priv, int unit,
repeat_type = picture->repeatType;
switch (picture->repeatType) {
case RepeatNone:
#ifndef GLAMOR_GLES2
if (glamor_priv->gl_flavor != GLAMOR_GL_ES2) {
/* XXX GLES2 doesn't support GL_CLAMP_TO_BORDER. */
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_CLAMP_TO_BORDER);
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_CLAMP_TO_BORDER);
#else
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_S,
GL_CLAMP_TO_BORDER);
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_T,
GL_CLAMP_TO_BORDER);
} else {
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_CLAMP_TO_EDGE);
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_CLAMP_TO_EDGE);
#endif
}
break;
case RepeatNormal:
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_REPEAT);
......@@ -807,14 +809,14 @@ glamor_flush_composite_rects(ScreenPtr screen)
if (!glamor_priv->render_nr_verts)
return;
#ifndef GLAMOR_GLES2
if (glamor_priv->gl_flavor == GLAMOR_GL_DESKTOP) {
glDrawRangeElements(GL_TRIANGLES, 0, glamor_priv->render_nr_verts,
(glamor_priv->render_nr_verts * 3) / 2,
GL_UNSIGNED_SHORT, NULL);
#else
} else {
glDrawElements(GL_TRIANGLES, (glamor_priv->render_nr_verts * 3) / 2,
GL_UNSIGNED_SHORT, NULL);
#endif
}
glamor_put_context(glamor_priv);
}
......
......@@ -1554,16 +1554,16 @@ _glamor_generate_trapezoid_with_shader(ScreenPtr screen, PicturePtr picture,
glamor_priv->vb, GL_DYNAMIC_DRAW);
}
#ifndef GLAMOR_GLES2
if (glamor_priv->gl_flavor == GLAMOR_GL_DESKTOP) {
glDrawRangeElements(GL_TRIANGLES, 0,
glamor_priv->render_nr_verts,
(glamor_priv->render_nr_verts * 3) / 2,
GL_UNSIGNED_SHORT, NULL);
#else
} else {
glDrawElements(GL_TRIANGLES,
(glamor_priv->render_nr_verts * 3) / 2,
GL_UNSIGNED_SHORT, NULL);
#endif
}
}
glBindBuffer(GL_ARRAY_BUFFER, 0);
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment