[cairo-commit] 3 commits - src/cairo-gl-composite.c src/cairo-gl-device.c src/cairo-gl-private.h src/cairo-gl-shaders.c
Eric Anholt
anholt at kemper.freedesktop.org
Mon Jan 31 16:08:48 PST 2011
src/cairo-gl-composite.c | 106 +----------------------------------------------
src/cairo-gl-device.c | 6 --
src/cairo-gl-private.h | 1
src/cairo-gl-shaders.c | 35 ++++++---------
4 files changed, 17 insertions(+), 131 deletions(-)
New commits:
commit 7f15319621a71fb01ea41c4efc34bf1f54505ef5
Author: Alexandros Frantzis <alexandros.frantzis at linaro.org>
Date: Fri Jan 28 15:02:54 2011 +0200
gl: Remove fixed-function related code paths
Fixed-function related code paths are no longer used, as we require shader
support for the gl backend.
Reviewed-by: Eric Anholt <eric at anholt.net>
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;
commit f6ca11694b7935408446b36a17bfee024237dbbf
Author: Alexandros Frantzis <alexandros.frantzis at linaro.org>
Date: Fri Jan 28 15:02:53 2011 +0200
gl: Remove unnecessary checks for NULL shader implementation
Due to the fact that we fail if the system doesn't support shaders, we
now always have a valid shader implementation.
Reviewed-by: Eric Anholt <eric at anholt.net>
diff --git a/src/cairo-gl-shaders.c b/src/cairo-gl-shaders.c
index 6a42fd1..a39883d 100644
--- a/src/cairo-gl-shaders.c
+++ b/src/cairo-gl-shaders.c
@@ -379,16 +379,14 @@ _cairo_gl_context_init_shaders (cairo_gl_context_t *ctx)
if (unlikely (status))
return status;
- if (ctx->shader_impl != NULL) {
- _cairo_gl_shader_init (&ctx->fill_rectangles_shader);
- status = _cairo_gl_shader_compile (ctx,
- &ctx->fill_rectangles_shader,
- CAIRO_GL_VAR_NONE,
- CAIRO_GL_VAR_NONE,
- fill_fs_source);
- if (unlikely (status))
- return status;
- }
+ _cairo_gl_shader_init (&ctx->fill_rectangles_shader);
+ status = _cairo_gl_shader_compile (ctx,
+ &ctx->fill_rectangles_shader,
+ CAIRO_GL_VAR_NONE,
+ CAIRO_GL_VAR_NONE,
+ fill_fs_source);
+ if (unlikely (status))
+ return status;
return CAIRO_STATUS_SUCCESS;
}
@@ -719,9 +717,6 @@ _cairo_gl_shader_compile (cairo_gl_context_t *ctx,
unsigned int vertex_shader;
cairo_status_t status;
- if (ctx->shader_impl == NULL)
- return CAIRO_STATUS_SUCCESS;
-
assert (shader->program == 0);
vertex_shader = cairo_gl_var_type_hash (src, mask, CAIRO_GL_VAR_NONE);
@@ -813,9 +808,6 @@ void
_cairo_gl_set_shader (cairo_gl_context_t *ctx,
cairo_gl_shader_t *shader)
{
- if (ctx->shader_impl == NULL)
- return;
-
if (ctx->current_shader == shader)
return;
@@ -835,11 +827,6 @@ _cairo_gl_get_shader_by_type (cairo_gl_context_t *ctx,
char *fs_source;
cairo_status_t status;
- if (ctx->shader_impl == NULL) {
- *shader = NULL;
- return CAIRO_STATUS_SUCCESS;
- }
-
lookup.src = source;
lookup.mask = mask;
lookup.dest = CAIRO_GL_OPERAND_NONE;
commit 037c9ba7e27bdd33a4fefa43dad68ce0d25e35ad
Author: Alexandros Frantzis <alexandros.frantzis at linaro.org>
Date: Fri Jan 28 15:02:52 2011 +0200
gl: Fail if GL implementation doesn't support shaders
The non-shaders implementation was never tuned for fixed-function GL
implementation, the maintainers are not interested in supporting it,
and the hardware is rather rare at this point. This lets us focus on
the implementation for modern hardware, which needs plenty of work
still.
Reviewed-by: Eric Anholt <eric at anholt.net>
diff --git a/src/cairo-gl-shaders.c b/src/cairo-gl-shaders.c
index 2b31bfc..6a42fd1 100644
--- a/src/cairo-gl-shaders.c
+++ b/src/cairo-gl-shaders.c
@@ -359,9 +359,15 @@ _cairo_gl_context_init_shaders (cairo_gl_context_t *ctx)
(_cairo_gl_has_extension ("GL_ARB_shader_objects") &&
_cairo_gl_has_extension ("GL_ARB_fragment_shader") &&
_cairo_gl_has_extension ("GL_ARB_vertex_shader")))
+ {
ctx->shader_impl = &shader_impl_core_2_0;
+ }
else
+ {
ctx->shader_impl = NULL;
+ fprintf (stderr, "Error: The cairo gl backend requires shader support!\n");
+ return CAIRO_STATUS_DEVICE_ERROR;
+ }
memset (ctx->vertex_shaders, 0, sizeof (ctx->vertex_shaders));
More information about the cairo-commit
mailing list