From patchwork Mon Jul 25 13:56:31 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: 3078 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 D433A23E54 for ; Mon, 25 Jul 2011 13:57:09 +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 9D52AA183B4 for ; Mon, 25 Jul 2011 13:57:09 +0000 (UTC) Received: by mail-qw0-f52.google.com with SMTP id 8so3003702qwb.11 for ; Mon, 25 Jul 2011 06:57:09 -0700 (PDT) Received: by 10.229.1.217 with SMTP id 25mr1000930qcg.38.1311602229323; Mon, 25 Jul 2011 06:57:09 -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 hl14cs77868qcb; Mon, 25 Jul 2011 06:57:09 -0700 (PDT) Received: by 10.14.29.11 with SMTP id h11mr1590056eea.45.1311602227504; Mon, 25 Jul 2011 06:57:07 -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.07 (version=TLSv1/SSLv3 cipher=OTHER); Mon, 25 Jul 2011 06:57:07 -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 fxe6 with SMTP id 6so6802455fxe.17 for ; Mon, 25 Jul 2011 06:57:07 -0700 (PDT) Received: by 10.223.155.141 with SMTP id s13mr5103468faw.109.1311602226893; Mon, 25 Jul 2011 06:57: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 j19sm3806652faa.17.2011.07.25.06.57.05 (version=TLSv1/SSLv3 cipher=OTHER); Mon, 25 Jul 2011 06:57:06 -0700 (PDT) From: alexandros.frantzis@linaro.org To: patches@linaro.org Subject: [PATCH 04/21] gl: Pass more information to the shader emitter functions Date: Mon, 25 Jul 2011 16:56:31 +0300 Message-Id: <1311602208-5973-4-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 This makes the shader emitter functions more versatile. It allows them to use all information provided by the operands and the context to decide what shader to produce. Signed-off-by: Chris Wilson --- src/cairo-gl-composite.c | 8 ++++---- src/cairo-gl-private.h | 4 ++-- src/cairo-gl-shaders.c | 34 +++++++++++++++++----------------- 3 files changed, 23 insertions(+), 23 deletions(-) diff --git a/src/cairo-gl-composite.c b/src/cairo-gl-composite.c index c8f84a9..05982c4 100644 --- a/src/cairo-gl-composite.c +++ b/src/cairo-gl-composite.c @@ -782,8 +782,8 @@ _cairo_gl_composite_begin_component_alpha (cairo_gl_context_t *ctx, if (setup->op == CAIRO_OPERATOR_OVER) { setup->op = CAIRO_OPERATOR_ADD; status = _cairo_gl_get_shader_by_type (ctx, - setup->src.type, - setup->mask.type, + &setup->src, + &setup->mask, CAIRO_GL_SHADER_IN_CA_SOURCE_ALPHA, &pre_shader); if (unlikely (status)) @@ -831,8 +831,8 @@ _cairo_gl_composite_begin (cairo_gl_composite_t *setup, } status = _cairo_gl_get_shader_by_type (ctx, - setup->src.type, - setup->mask.type, + &setup->src, + &setup->mask, component_alpha ? CAIRO_GL_SHADER_IN_CA_SOURCE : CAIRO_GL_SHADER_IN_NORMAL, &shader); diff --git a/src/cairo-gl-private.h b/src/cairo-gl-private.h index 602550f..e4f1cce 100644 --- a/src/cairo-gl-private.h +++ b/src/cairo-gl-private.h @@ -517,8 +517,8 @@ _cairo_gl_context_is_flushed (cairo_gl_context_t *ctx) cairo_private cairo_status_t _cairo_gl_get_shader_by_type (cairo_gl_context_t *ctx, - cairo_gl_operand_type_t source, - cairo_gl_operand_type_t mask, + cairo_gl_operand_t *source, + cairo_gl_operand_t *mask, cairo_gl_shader_in_t in, cairo_gl_shader_t **shader); diff --git a/src/cairo-gl-shaders.c b/src/cairo-gl-shaders.c index 39e4e30..c59f4f7 100644 --- a/src/cairo-gl-shaders.c +++ b/src/cairo-gl-shaders.c @@ -536,14 +536,14 @@ cairo_gl_shader_get_vertex_source (cairo_gl_var_type_t src, static void cairo_gl_shader_emit_color (cairo_output_stream_t *stream, - GLuint tex_target, - cairo_gl_operand_type_t type, + cairo_gl_context_t *ctx, + cairo_gl_operand_t *op, cairo_gl_tex_t name) { const char *namestr = operand_names[name]; - const char *rectstr = (tex_target == GL_TEXTURE_RECTANGLE ? "Rect" : ""); + const char *rectstr = (ctx->tex_target == GL_TEXTURE_RECTANGLE ? "Rect" : ""); - switch (type) { + switch (op->type) { case CAIRO_GL_OPERAND_COUNT: default: ASSERT_NOT_REACHED; @@ -677,11 +677,11 @@ cairo_gl_shader_emit_color (cairo_output_stream_t *stream, } static cairo_status_t -cairo_gl_shader_get_fragment_source (GLuint tex_target, +cairo_gl_shader_get_fragment_source (cairo_gl_context_t *ctx, cairo_gl_shader_in_t in, - cairo_gl_operand_type_t src, - cairo_gl_operand_type_t mask, - cairo_gl_operand_type_t dest, + cairo_gl_operand_t *src, + cairo_gl_operand_t *mask, + cairo_gl_operand_type_t dest_type, char **out) { cairo_output_stream_t *stream = _cairo_memory_stream_create (); @@ -689,8 +689,8 @@ cairo_gl_shader_get_fragment_source (GLuint tex_target, unsigned long length; cairo_status_t status; - cairo_gl_shader_emit_color (stream, tex_target, src, CAIRO_GL_TEX_SOURCE); - cairo_gl_shader_emit_color (stream, tex_target, mask, CAIRO_GL_TEX_MASK); + cairo_gl_shader_emit_color (stream, ctx, src, CAIRO_GL_TEX_SOURCE); + cairo_gl_shader_emit_color (stream, ctx, mask, CAIRO_GL_TEX_MASK); _cairo_output_stream_printf (stream, "void main()\n" @@ -867,8 +867,8 @@ _cairo_gl_set_shader (cairo_gl_context_t *ctx, cairo_status_t _cairo_gl_get_shader_by_type (cairo_gl_context_t *ctx, - cairo_gl_operand_type_t source, - cairo_gl_operand_type_t mask, + cairo_gl_operand_t *source, + cairo_gl_operand_t *mask, cairo_gl_shader_in_t in, cairo_gl_shader_t **shader) { @@ -876,8 +876,8 @@ _cairo_gl_get_shader_by_type (cairo_gl_context_t *ctx, char *fs_source; cairo_status_t status; - lookup.src = source; - lookup.mask = mask; + lookup.src = source->type; + lookup.mask = mask->type; lookup.dest = CAIRO_GL_OPERAND_NONE; lookup.in = in; lookup.base.hash = _cairo_gl_shader_cache_hash (&lookup); @@ -890,7 +890,7 @@ _cairo_gl_get_shader_by_type (cairo_gl_context_t *ctx, return CAIRO_STATUS_SUCCESS; } - status = cairo_gl_shader_get_fragment_source (ctx->tex_target, + status = cairo_gl_shader_get_fragment_source (ctx, in, source, mask, @@ -911,8 +911,8 @@ _cairo_gl_get_shader_by_type (cairo_gl_context_t *ctx, _cairo_gl_shader_init (&entry->shader); status = _cairo_gl_shader_compile (ctx, &entry->shader, - cairo_gl_operand_get_var_type (source), - cairo_gl_operand_get_var_type (mask), + cairo_gl_operand_get_var_type (source->type), + cairo_gl_operand_get_var_type (mask->type), fs_source); free (fs_source);