diff options
Diffstat (limited to 'src/cairo-gl-shaders.c')
-rw-r--r-- | src/cairo-gl-shaders.c | 31 |
1 files changed, 23 insertions, 8 deletions
diff --git a/src/cairo-gl-shaders.c b/src/cairo-gl-shaders.c index 41672d62..ae2977c5 100644 --- a/src/cairo-gl-shaders.c +++ b/src/cairo-gl-shaders.c @@ -215,9 +215,9 @@ _cairo_gl_shader_fini (cairo_gl_context_t *ctx, static const char *operand_names[] = { "source", "mask", "dest" }; static cairo_gl_var_type_t -cairo_gl_operand_get_var_type (cairo_gl_operand_type_t type) +cairo_gl_operand_get_var_type (cairo_gl_operand_t *operand) { - switch (type) { + switch (operand->type) { default: case CAIRO_GL_OPERAND_COUNT: ASSERT_NOT_REACHED; @@ -228,8 +228,9 @@ cairo_gl_operand_get_var_type (cairo_gl_operand_type_t type) case CAIRO_GL_OPERAND_RADIAL_GRADIENT_A0: case CAIRO_GL_OPERAND_RADIAL_GRADIENT_NONE: case CAIRO_GL_OPERAND_RADIAL_GRADIENT_EXT: + return operand->gradient.texgen ? CAIRO_GL_VAR_TEXGEN : CAIRO_GL_VAR_TEXCOORDS; case CAIRO_GL_OPERAND_TEXTURE: - return CAIRO_GL_VAR_TEXCOORDS; + return operand->texture.texgen ? CAIRO_GL_VAR_TEXGEN : CAIRO_GL_VAR_TEXCOORDS; } } @@ -245,7 +246,16 @@ cairo_gl_shader_emit_variable (cairo_output_stream_t *stream, break; case CAIRO_GL_VAR_TEXCOORDS: _cairo_output_stream_printf (stream, + "attribute vec4 MultiTexCoord%d;\n" + "varying vec2 %s_texcoords;\n", + name, + operand_names[name]); + break; + case CAIRO_GL_VAR_TEXGEN: + _cairo_output_stream_printf (stream, + "uniform mat3 %s_texgen;\n" "varying vec2 %s_texcoords;\n", + operand_names[name], operand_names[name]); break; } @@ -266,6 +276,12 @@ cairo_gl_shader_emit_vertex (cairo_output_stream_t *stream, " %s_texcoords = MultiTexCoord%d.xy;\n", operand_names[name], name); break; + + case CAIRO_GL_VAR_TEXGEN: + _cairo_output_stream_printf (stream, + " %s_texcoords = (%s_texgen * Vertex.xyw).xy;\n", + operand_names[name], operand_names[name]); + break; } } @@ -301,8 +317,6 @@ cairo_gl_shader_get_vertex_source (cairo_gl_var_type_t src, _cairo_output_stream_printf (stream, "attribute vec4 Vertex;\n" "attribute vec4 Color;\n" - "attribute vec4 MultiTexCoord0;\n" - "attribute vec4 MultiTexCoord1;\n" "uniform mat4 ModelViewProjectionMatrix;\n" "void main()\n" "{\n" @@ -920,7 +934,8 @@ _cairo_gl_shader_bind_vec4 (cairo_gl_context_t *ctx, void _cairo_gl_shader_bind_matrix (cairo_gl_context_t *ctx, - const char *name, cairo_matrix_t* m) + const char *name, + const cairo_matrix_t* m) { cairo_gl_dispatch_t *dispatch = &ctx->dispatch; GLint location = dispatch->GetUniformLocation (ctx->current_shader->program, @@ -1016,8 +1031,8 @@ _cairo_gl_get_shader_by_type (cairo_gl_context_t *ctx, _cairo_gl_shader_init (&entry->shader); status = _cairo_gl_shader_compile_and_link (ctx, &entry->shader, - cairo_gl_operand_get_var_type (source->type), - cairo_gl_operand_get_var_type (mask->type), + cairo_gl_operand_get_var_type (source), + cairo_gl_operand_get_var_type (mask), use_coverage, fs_source); free (fs_source); |