From patchwork Mon Jul 25 13:56:34 2011 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: alexandros.frantzis@linaro.org X-Patchwork-Id: 3081 Return-Path: X-Original-To: patchwork@peony.canonical.com Delivered-To: patchwork@peony.canonical.com Received: from fiordland.canonical.com (fiordland.canonical.com [91.189.94.145]) by peony.canonical.com (Postfix) with ESMTP id 2DE8D23E54 for ; Mon, 25 Jul 2011 13:57:19 +0000 (UTC) Received: from mail-qw0-f52.google.com (mail-qw0-f52.google.com [209.85.216.52]) by fiordland.canonical.com (Postfix) with ESMTP id EACDCA183B4 for ; Mon, 25 Jul 2011 13:57:18 +0000 (UTC) Received: by mail-qw0-f52.google.com with SMTP id 8so3003702qwb.11 for ; Mon, 25 Jul 2011 06:57:18 -0700 (PDT) Received: by 10.229.1.217 with SMTP id 25mr1001106qcg.38.1311602238674; Mon, 25 Jul 2011 06:57:18 -0700 (PDT) X-Forwarded-To: linaro-patchwork@canonical.com X-Forwarded-For: patch@linaro.org linaro-patchwork@canonical.com Delivered-To: patches@linaro.org Received: by 10.229.217.78 with SMTP id hl14cs77875qcb; Mon, 25 Jul 2011 06:57:18 -0700 (PDT) Received: by 10.213.34.1 with SMTP id j1mr210068ebd.17.1311602237570; Mon, 25 Jul 2011 06:57:17 -0700 (PDT) Received: from mail-fx0-f44.google.com (mail-fx0-f44.google.com [209.85.161.44]) by mx.google.com with ESMTPS id 18si7042659fat.105.2011.07.25.06.57.17 (version=TLSv1/SSLv3 cipher=OTHER); Mon, 25 Jul 2011 06:57:17 -0700 (PDT) Received-SPF: neutral (google.com: 209.85.161.44 is neither permitted nor denied by best guess record for domain of alexandros.frantzis@linaro.org) client-ip=209.85.161.44; Authentication-Results: mx.google.com; spf=neutral (google.com: 209.85.161.44 is neither permitted nor denied by best guess record for domain of alexandros.frantzis@linaro.org) smtp.mail=alexandros.frantzis@linaro.org Received: by mail-fx0-f44.google.com with SMTP id 6so6802455fxe.17 for ; Mon, 25 Jul 2011 06:57:17 -0700 (PDT) Received: by 10.223.57.85 with SMTP id b21mr4754222fah.110.1311602237123; Mon, 25 Jul 2011 06:57:17 -0700 (PDT) Received: from localhost (77.49.93.204.dsl.dyn.forthnet.gr [77.49.93.204]) by mx.google.com with ESMTPS id h9sm3807334faa.15.2011.07.25.06.57.15 (version=TLSv1/SSLv3 cipher=OTHER); Mon, 25 Jul 2011 06:57:16 -0700 (PDT) From: alexandros.frantzis@linaro.org To: patches@linaro.org Subject: [PATCH 07/21] gl: Store gradients in 2D textures of height 1 instead of 1D textures Date: Mon, 25 Jul 2011 16:56:34 +0300 Message-Id: <1311602208-5973-7-git-send-email-alexandros.frantzis@linaro.org> X-Mailer: git-send-email 1.7.5.4 In-Reply-To: <1311602208-5973-1-git-send-email-alexandros.frantzis@linaro.org> References: <1311602208-5973-1-git-send-email-alexandros.frantzis@linaro.org> From: Alexandros Frantzis 1D textures are not available in GLES2. We use 2D textures with height 1 instead, which are equivalent to 1D textures and exist across all GL flavors. Signed-off-by: Chris Wilson --- src/cairo-gl-composite.c | 6 +++--- src/cairo-gl-gradient.c | 6 +++--- src/cairo-gl-shaders.c | 44 ++++++++++++++++++++++---------------------- 3 files changed, 28 insertions(+), 28 deletions(-) diff --git a/src/cairo-gl-composite.c b/src/cairo-gl-composite.c index 4b0ead8..575719b 100644 --- a/src/cairo-gl-composite.c +++ b/src/cairo-gl-composite.c @@ -652,9 +652,9 @@ _cairo_gl_context_setup_operand (cairo_gl_context_t *ctx, case CAIRO_GL_OPERAND_RADIAL_GRADIENT_EXT: _cairo_gl_gradient_reference (operand->gradient.gradient); glActiveTexture (GL_TEXTURE0 + tex_unit); - glBindTexture (GL_TEXTURE_1D, operand->gradient.gradient->tex); - _cairo_gl_texture_set_extend (ctx, GL_TEXTURE_1D, operand->gradient.extend); - _cairo_gl_texture_set_filter (ctx, GL_TEXTURE_1D, CAIRO_FILTER_BILINEAR); + glBindTexture (ctx->tex_target, operand->gradient.gradient->tex); + _cairo_gl_texture_set_extend (ctx, ctx->tex_target, operand->gradient.extend); + _cairo_gl_texture_set_filter (ctx, ctx->tex_target, CAIRO_FILTER_BILINEAR); dispatch->VertexAttribPointer (CAIRO_GL_TEXCOORD0_ATTRIB_INDEX + tex_unit, 2, GL_FLOAT, GL_FALSE, vertex_size, diff --git a/src/cairo-gl-gradient.c b/src/cairo-gl-gradient.c index a48e156..ef7fd53 100644 --- a/src/cairo-gl-gradient.c +++ b/src/cairo-gl-gradient.c @@ -239,9 +239,9 @@ _cairo_gl_gradient_create (cairo_gl_context_t *ctx, glGenTextures (1, &gradient->tex); _cairo_gl_context_activate (ctx, CAIRO_GL_TEX_TEMP); - glBindTexture (GL_TEXTURE_1D, gradient->tex); - glTexImage1D (GL_TEXTURE_1D, 0, GL_RGBA8, tex_width, 0, - GL_BGRA, GL_UNSIGNED_INT_8_8_8_8_REV, 0); + glBindTexture (ctx->tex_target, gradient->tex); + glTexImage2D (ctx->tex_target, 0, GL_RGBA8, tex_width, 1, 0, + GL_BGRA, GL_UNSIGNED_INT_8_8_8_8_REV, 0); dispatch->BindBuffer (GL_PIXEL_UNPACK_BUFFER, 0); diff --git a/src/cairo-gl-shaders.c b/src/cairo-gl-shaders.c index e35c256..77a28aa 100644 --- a/src/cairo-gl-shaders.c +++ b/src/cairo-gl-shaders.c @@ -638,34 +638,34 @@ cairo_gl_shader_emit_color (cairo_output_stream_t *stream, _cairo_output_stream_printf (stream, "varying vec2 %s_texcoords;\n" "uniform vec2 %s_texdims;\n" - "uniform sampler1D %s_sampler;\n" + "uniform sampler2D%s %s_sampler;\n" "\n" "vec4 get_%s()\n" "{\n", - namestr, namestr, namestr, namestr); + namestr, namestr, rectstr, namestr, namestr); if (ctx->gl_flavor == CAIRO_GL_FLAVOR_ES && _cairo_gl_shader_needs_border_fade (op)) { _cairo_output_stream_printf (stream, " float border_fade = %s_border_fade (%s_texcoords.x, %s_texdims.x);\n" - " vec4 texel = texture1D (%s_sampler, %s_texcoords.x);\n" + " vec4 texel = texture2D%s (%s_sampler, vec2 (%s_texcoords.x, 0.5));\n" " return texel * border_fade;\n" "}\n", - namestr, namestr, namestr, namestr, namestr); + namestr, namestr, namestr, rectstr, namestr, namestr); } else { _cairo_output_stream_printf (stream, - " return texture1D (%s_sampler, %s_texcoords.x);\n" + " return texture2D%s (%s_sampler, vec2 (%s_texcoords.x, 0.5));\n" "}\n", - namestr, namestr); + rectstr, namestr, namestr); } break; case CAIRO_GL_OPERAND_RADIAL_GRADIENT_A0: _cairo_output_stream_printf (stream, "varying vec2 %s_texcoords;\n" "uniform vec2 %s_texdims;\n" - "uniform sampler1D %s_sampler;\n" + "uniform sampler2D%s %s_sampler;\n" "uniform vec3 %s_circle_d;\n" "uniform float %s_radius_0;\n" "\n" @@ -678,31 +678,31 @@ cairo_gl_shader_emit_color (cairo_output_stream_t *stream, " \n" " float t = 0.5 * C / B;\n" " float is_valid = step (-%s_radius_0, t * %s_circle_d.z);\n", - namestr, namestr, namestr, namestr, namestr, namestr, + namestr, namestr, rectstr, namestr, namestr, namestr, namestr, namestr, namestr, namestr, namestr, namestr); if (ctx->gl_flavor == CAIRO_GL_FLAVOR_ES && _cairo_gl_shader_needs_border_fade (op)) { _cairo_output_stream_printf (stream, " float border_fade = %s_border_fade (t, %s_texdims.x);\n" - " vec4 texel = texture1D (%s_sampler, t);\n" + " vec4 texel = texture2D%s (%s_sampler, vec2 (t, 0.5));\n" " return mix (vec4 (0.0), texel * border_fade, is_valid);\n" "}\n", - namestr, namestr, namestr); + namestr, namestr, rectstr, namestr); } else { _cairo_output_stream_printf (stream, - " return mix (vec4 (0.0), texture1D (%s_sampler, t), is_valid);\n" + " return mix (vec4 (0.0), texture2D%s (%s_sampler, vec2(t, 0.5)), is_valid);\n" "}\n", - namestr); + rectstr, namestr); } break; case CAIRO_GL_OPERAND_RADIAL_GRADIENT_NONE: _cairo_output_stream_printf (stream, "varying vec2 %s_texcoords;\n" "uniform vec2 %s_texdims;\n" - "uniform sampler1D %s_sampler;\n" + "uniform sampler2D%s %s_sampler;\n" "uniform vec3 %s_circle_d;\n" "uniform float %s_a;\n" "uniform float %s_radius_0;\n" @@ -722,30 +722,30 @@ cairo_gl_shader_emit_color (cairo_output_stream_t *stream, " float has_color = step (0., det) * max (is_valid.x, is_valid.y);\n" " \n" " float upper_t = mix (t.y, t.x, is_valid.x);\n", - namestr, namestr, namestr, namestr, namestr, namestr, + namestr, namestr, rectstr, namestr, namestr, namestr, namestr, namestr, namestr, namestr, namestr, namestr, namestr); if (ctx->gl_flavor == CAIRO_GL_FLAVOR_ES && _cairo_gl_shader_needs_border_fade (op)) { _cairo_output_stream_printf (stream, " float border_fade = %s_border_fade (upper_t, %s_texdims.x);\n" - " vec4 texel = texture1D (%s_sampler, upper_t);\n" + " vec4 texel = texture2D%s (%s_sampler, vec2 (upper_t, 0.5));\n" " return mix (vec4 (0.0), texel * border_fade, has_color);\n" "}\n", - namestr, namestr, namestr); + namestr, namestr, rectstr, namestr); } else { _cairo_output_stream_printf (stream, - " return mix (vec4 (0.0), texture1D (%s_sampler, upper_t), has_color);\n" + " return mix (vec4 (0.0), texture2D%s (%s_sampler, vec2 (upper_t, 0.5)), has_color);\n" "}\n", - namestr); + rectstr, namestr); } break; case CAIRO_GL_OPERAND_RADIAL_GRADIENT_EXT: _cairo_output_stream_printf (stream, "varying vec2 %s_texcoords;\n" - "uniform sampler1D %s_sampler;\n" + "uniform sampler2D%s %s_sampler;\n" "uniform vec3 %s_circle_d;\n" "uniform float %s_a;\n" "uniform float %s_radius_0;\n" @@ -765,11 +765,11 @@ cairo_gl_shader_emit_color (cairo_output_stream_t *stream, " float has_color = step (0., det) * max (is_valid.x, is_valid.y);\n" " \n" " float upper_t = mix (t.y, t.x, is_valid.x);\n" - " return mix (vec4 (0.0), texture1D (%s_sampler, upper_t), has_color);\n" + " return mix (vec4 (0.0), texture2D%s (%s_sampler, vec2 (upper_t, 0.5)), has_color);\n" "}\n", + namestr, rectstr, namestr, namestr, namestr, namestr, namestr, namestr, namestr, namestr, namestr, - namestr, namestr, namestr, namestr, namestr, - namestr, namestr, namestr, namestr); + namestr, namestr, namestr, rectstr, namestr); break; case CAIRO_GL_OPERAND_SPANS: _cairo_output_stream_printf (stream,