From patchwork Mon Jul 25 14:06:55 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: 3108 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 8D59823E54 for ; Mon, 25 Jul 2011 14:07:08 +0000 (UTC) Received: from mail-qy0-f173.google.com (mail-qy0-f173.google.com [209.85.216.173]) by fiordland.canonical.com (Postfix) with ESMTP id 3AD85A1844E for ; Mon, 25 Jul 2011 14:07:08 +0000 (UTC) Received: by mail-qy0-f173.google.com with SMTP id 10so1064330qyk.11 for ; Mon, 25 Jul 2011 07:07:08 -0700 (PDT) Received: by 10.229.25.212 with SMTP id a20mr3480534qcc.148.1311602827936; Mon, 25 Jul 2011 07:07:07 -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 hl14cs78222qcb; Mon, 25 Jul 2011 07:07:07 -0700 (PDT) Received: by 10.204.8.75 with SMTP id g11mr389481bkg.59.1311602826828; Mon, 25 Jul 2011 07:07:06 -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 l8si7047111fam.151.2011.07.25.07.07.06 (version=TLSv1/SSLv3 cipher=OTHER); Mon, 25 Jul 2011 07:07:06 -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 6so6812833fxe.17 for ; Mon, 25 Jul 2011 07:07:06 -0700 (PDT) Received: by 10.223.64.80 with SMTP id d16mr6840028fai.86.1311602826280; Mon, 25 Jul 2011 07:07:06 -0700 (PDT) Received: from localhost (77.49.93.204.dsl.dyn.forthnet.gr [77.49.93.204]) by mx.google.com with ESMTPS id j19sm3806481faa.41.2011.07.25.07.07.03 (version=TLSv1/SSLv3 cipher=OTHER); Mon, 25 Jul 2011 07:07:04 -0700 (PDT) From: alexandros.frantzis@linaro.org To: patches@linaro.org Subject: [PATCH 3/3] gl: Remove fixed-function related code paths Date: Mon, 25 Jul 2011 17:06:55 +0300 Message-Id: <1311602815-6314-3-git-send-email-alexandros.frantzis@linaro.org> X-Mailer: git-send-email 1.7.5.4 In-Reply-To: <1311602815-6314-1-git-send-email-alexandros.frantzis@linaro.org> References: <1311602815-6314-1-git-send-email-alexandros.frantzis@linaro.org> From: Alexandros Frantzis Fixed-function related code paths are no longer used, as we require shader support for the gl backend. Reviewed-by: Eric Anholt --- src/cairo-gl-composite.c | 106 +-------------------------------------------- src/cairo-gl-device.c | 6 --- src/cairo-gl-private.h | 1 - 3 files changed, 3 insertions(+), 110 deletions(-) diff --git a/src/cairo-gl-composite.c b/src/cairo-gl-composite.c index 5017f55..a32e00d 100644 --- a/src/cairo-gl-composite.c +++ b/src/cairo-gl-composite.c @@ -414,9 +414,6 @@ static void _cairo_gl_composite_bind_to_shader (cairo_gl_context_t *ctx, cairo_gl_composite_t *setup) { - if (ctx->current_shader == NULL) - return; - _cairo_gl_operand_bind_to_shader (ctx, &setup->src, CAIRO_GL_TEX_SOURCE); _cairo_gl_operand_bind_to_shader (ctx, &setup->mask, CAIRO_GL_TEX_MASK); } @@ -472,68 +469,6 @@ _cairo_gl_texture_set_filter (cairo_gl_context_t *ctx, } } -static void -_cairo_gl_operand_setup_fixed (cairo_gl_operand_t *operand, - cairo_gl_tex_t tex_unit) -{ - switch (operand->type) { - case CAIRO_GL_OPERAND_CONSTANT: - glTexEnvfv (GL_TEXTURE_ENV, GL_TEXTURE_ENV_COLOR, operand->constant.color); - glTexEnvi (GL_TEXTURE_ENV, GL_SRC0_RGB, GL_CONSTANT); - glTexEnvi (GL_TEXTURE_ENV, GL_SRC0_ALPHA, GL_CONSTANT); - break; - case CAIRO_GL_OPERAND_TEXTURE: - glTexEnvi (GL_TEXTURE_ENV, GL_SRC0_RGB, GL_TEXTURE0 + tex_unit); - glTexEnvi (GL_TEXTURE_ENV, GL_SRC0_ALPHA, GL_TEXTURE0 + tex_unit); - break; - case CAIRO_GL_OPERAND_SPANS: - glTexEnvi (GL_TEXTURE_ENV, GL_SRC0_RGB, GL_PRIMARY_COLOR); - glTexEnvi (GL_TEXTURE_ENV, GL_SRC0_ALPHA, GL_PRIMARY_COLOR); - break; - case CAIRO_GL_OPERAND_COUNT: - default: - ASSERT_NOT_REACHED; - case CAIRO_GL_OPERAND_LINEAR_GRADIENT: - case CAIRO_GL_OPERAND_RADIAL_GRADIENT_A0: - case CAIRO_GL_OPERAND_RADIAL_GRADIENT_NONE: - case CAIRO_GL_OPERAND_RADIAL_GRADIENT_EXT: - case CAIRO_GL_OPERAND_NONE: - return; - } - - switch (tex_unit) { - case CAIRO_GL_TEX_TEMP: - default: - ASSERT_NOT_REACHED; - break; - case CAIRO_GL_TEX_SOURCE: - glTexEnvi (GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, GL_COMBINE); - glTexEnvi (GL_TEXTURE_ENV, GL_COMBINE_RGB, GL_REPLACE); - glTexEnvi (GL_TEXTURE_ENV, GL_COMBINE_ALPHA, GL_REPLACE); - glTexEnvi (GL_TEXTURE_ENV, GL_OPERAND0_RGB, GL_SRC_COLOR); - glTexEnvi (GL_TEXTURE_ENV, GL_OPERAND0_ALPHA, GL_SRC_ALPHA); - break; - - case CAIRO_GL_TEX_MASK: - glTexEnvi (GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, GL_COMBINE); - glTexEnvi (GL_TEXTURE_ENV, GL_COMBINE_RGB, GL_MODULATE); - glTexEnvi (GL_TEXTURE_ENV, GL_COMBINE_ALPHA, GL_MODULATE); - - glTexEnvi (GL_TEXTURE_ENV, GL_SRC1_RGB, GL_PREVIOUS); - glTexEnvi (GL_TEXTURE_ENV, GL_SRC1_ALPHA, GL_PREVIOUS); - glTexEnvi (GL_TEXTURE_ENV, GL_OPERAND1_RGB, GL_SRC_COLOR); - glTexEnvi (GL_TEXTURE_ENV, GL_OPERAND1_ALPHA, GL_SRC_ALPHA); - - if (operand->type == CAIRO_GL_OPERAND_TEXTURE && - operand->texture.attributes.has_component_alpha) - glTexEnvi (GL_TEXTURE_ENV, GL_OPERAND0_RGB, GL_SRC_COLOR); - else - glTexEnvi (GL_TEXTURE_ENV, GL_OPERAND0_RGB, GL_SRC_ALPHA); - glTexEnvi (GL_TEXTURE_ENV, GL_OPERAND0_ALPHA, GL_SRC_ALPHA); - break; - } -} - static cairo_bool_t _cairo_gl_operand_needs_setup (cairo_gl_operand_t *dest, cairo_gl_operand_t *source, @@ -577,8 +512,7 @@ _cairo_gl_context_setup_operand (cairo_gl_context_t *ctx, cairo_gl_tex_t tex_unit, cairo_gl_operand_t *operand, unsigned int vertex_size, - unsigned int vertex_offset, - cairo_bool_t use_shaders) + unsigned int vertex_offset) { cairo_bool_t needs_setup; @@ -612,17 +546,10 @@ _cairo_gl_context_setup_operand (cairo_gl_context_t *ctx, glEnableClientState (GL_COLOR_ARRAY); /* fall through */ case CAIRO_GL_OPERAND_CONSTANT: - if (! use_shaders) { - glActiveTexture (GL_TEXTURE0 + tex_unit); - /* Have to have a dummy texture bound in order to use the combiner unit. */ - glBindTexture (ctx->tex_target, ctx->dummy_tex); - glEnable (ctx->tex_target); - } break; case CAIRO_GL_OPERAND_TEXTURE: glActiveTexture (GL_TEXTURE0 + tex_unit); glBindTexture (ctx->tex_target, operand->texture.tex); - glEnable (ctx->tex_target); _cairo_gl_texture_set_extend (ctx, ctx->tex_target, operand->texture.attributes.extend); _cairo_gl_texture_set_filter (ctx, ctx->tex_target, @@ -642,7 +569,6 @@ _cairo_gl_context_setup_operand (cairo_gl_context_t *ctx, 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); - glEnable (GL_TEXTURE_1D); glClientActiveTexture (GL_TEXTURE0 + tex_unit); glTexCoordPointer (2, GL_FLOAT, vertex_size, @@ -650,9 +576,6 @@ _cairo_gl_context_setup_operand (cairo_gl_context_t *ctx, glEnableClientState (GL_TEXTURE_COORD_ARRAY); break; } - - if (! use_shaders) - _cairo_gl_operand_setup_fixed (operand, tex_unit); } void @@ -671,14 +594,9 @@ _cairo_gl_context_destroy_operand (cairo_gl_context_t *ctx, glDisableClientState (GL_COLOR_ARRAY); /* fall through */ case CAIRO_GL_OPERAND_CONSTANT: - if (ctx->current_shader == NULL) { - glActiveTexture (GL_TEXTURE0 + tex_unit); - glDisable (ctx->tex_target); - } break; case CAIRO_GL_OPERAND_TEXTURE: glActiveTexture (GL_TEXTURE0 + tex_unit); - glDisable (ctx->tex_target); glClientActiveTexture (GL_TEXTURE0 + tex_unit); glDisableClientState (GL_TEXTURE_COORD_ARRAY); break; @@ -688,7 +606,6 @@ _cairo_gl_context_destroy_operand (cairo_gl_context_t *ctx, case CAIRO_GL_OPERAND_RADIAL_GRADIENT_EXT: _cairo_gl_gradient_destroy (ctx->operands[tex_unit].gradient.gradient); glActiveTexture (GL_TEXTURE0 + tex_unit); - glDisable (GL_TEXTURE_1D); glClientActiveTexture (GL_TEXTURE0 + tex_unit); glDisableClientState (GL_TEXTURE_COORD_ARRAY); break; @@ -697,21 +614,6 @@ _cairo_gl_context_destroy_operand (cairo_gl_context_t *ctx, memset (&ctx->operands[tex_unit], 0, sizeof (cairo_gl_operand_t)); } -/* Swizzles the source for creating the "source alpha" value - * (src.aaaa * mask.argb) required by component alpha rendering. - */ -static void -_cairo_gl_set_src_alpha (cairo_gl_context_t *ctx, - cairo_bool_t activate) -{ - if (ctx->current_shader) - return; - - glActiveTexture (GL_TEXTURE0); - - glTexEnvi (GL_TEXTURE_ENV, GL_OPERAND0_RGB, activate ? GL_SRC_ALPHA : GL_SRC_COLOR); -} - static void _cairo_gl_set_operator (cairo_gl_context_t *ctx, cairo_operator_t op, @@ -962,8 +864,8 @@ _cairo_gl_composite_begin (cairo_gl_composite_t *setup, glEnableClientState (GL_VERTEX_ARRAY); } - _cairo_gl_context_setup_operand (ctx, CAIRO_GL_TEX_SOURCE, &setup->src, vertex_size, dst_size, shader != NULL); - _cairo_gl_context_setup_operand (ctx, CAIRO_GL_TEX_MASK, &setup->mask, vertex_size, dst_size + src_size, shader != NULL); + _cairo_gl_context_setup_operand (ctx, CAIRO_GL_TEX_SOURCE, &setup->src, vertex_size, dst_size); + _cairo_gl_context_setup_operand (ctx, CAIRO_GL_TEX_MASK, &setup->mask, vertex_size, dst_size + src_size); _cairo_gl_set_operator (ctx, setup->op, @@ -1010,9 +912,7 @@ _cairo_gl_composite_draw (cairo_gl_context_t *ctx, _cairo_gl_set_shader (ctx, ctx->pre_shader); _cairo_gl_set_operator (ctx, CAIRO_OPERATOR_DEST_OUT, TRUE); - _cairo_gl_set_src_alpha (ctx, TRUE); glDrawArrays (GL_TRIANGLES, 0, count); - _cairo_gl_set_src_alpha (ctx, FALSE); _cairo_gl_set_shader (ctx, prev_shader); _cairo_gl_set_operator (ctx, CAIRO_OPERATOR_ADD, TRUE); diff --git a/src/cairo-gl-device.c b/src/cairo-gl-device.c index 048d48b..25423e0 100644 --- a/src/cairo-gl-device.c +++ b/src/cairo-gl-device.c @@ -196,12 +196,6 @@ _cairo_gl_context_init (cairo_gl_context_t *ctx) if (unlikely (status)) return status; - /* Set up the dummy texture for tex_env_combine with constant color. */ - glGenTextures (1, &ctx->dummy_tex); - glBindTexture (ctx->tex_target, ctx->dummy_tex); - glTexImage2D (ctx->tex_target, 0, GL_RGBA, 1, 1, 0, - GL_RGBA, GL_UNSIGNED_BYTE, NULL); - /* PBO for any sort of texture upload */ dispatch->GenBuffers (1, &ctx->texture_load_pbo); dispatch->GenBuffers (1, &ctx->vbo); diff --git a/src/cairo-gl-private.h b/src/cairo-gl-private.h index ace4032..6cea8c0 100644 --- a/src/cairo-gl-private.h +++ b/src/cairo-gl-private.h @@ -225,7 +225,6 @@ typedef struct _cairo_gl_dispatch { struct _cairo_gl_context { cairo_device_t base; - GLuint dummy_tex; GLuint texture_load_pbo; GLuint vbo; GLint max_framebuffer_size;