mirror of
https://gitlab.freedesktop.org/cairo/cairo.git
synced 2026-01-24 11:00:24 +01:00
gl: Make _shader_by_type() a getter
And refactor code to do the current_shader assigning itself.
This commit is contained in:
parent
2971ca0498
commit
0fc6f08981
3 changed files with 22 additions and 12 deletions
|
|
@ -938,16 +938,19 @@ _cairo_gl_composite_begin_component_alpha (cairo_gl_context_t *ctx,
|
|||
* lets two values come out of the shader and into the blend unit.
|
||||
*/
|
||||
if (setup->op == CAIRO_OPERATOR_OVER) {
|
||||
cairo_gl_shader_t *pre_shader;
|
||||
setup->op = CAIRO_OPERATOR_ADD;
|
||||
status = _cairo_gl_set_shader_by_type (ctx,
|
||||
status = _cairo_gl_get_shader_by_type (ctx,
|
||||
setup->src.type,
|
||||
setup->mask.type,
|
||||
CAIRO_GL_SHADER_IN_CA_SOURCE_ALPHA);
|
||||
CAIRO_GL_SHADER_IN_CA_SOURCE_ALPHA,
|
||||
&pre_shader);
|
||||
if (unlikely (status))
|
||||
return status;
|
||||
|
||||
_cairo_gl_set_shader (ctx, pre_shader);
|
||||
_cairo_gl_composite_bind_to_shader (ctx, setup);
|
||||
ctx->pre_shader = ctx->current_shader;
|
||||
ctx->pre_shader = pre_shader;
|
||||
}
|
||||
|
||||
return CAIRO_STATUS_SUCCESS;
|
||||
|
|
@ -961,6 +964,7 @@ _cairo_gl_composite_begin (cairo_gl_composite_t *setup,
|
|||
cairo_gl_context_t *ctx;
|
||||
cairo_status_t status;
|
||||
cairo_bool_t component_alpha;
|
||||
cairo_gl_shader_t *shader;
|
||||
|
||||
assert (setup->dst);
|
||||
|
||||
|
|
@ -981,11 +985,12 @@ _cairo_gl_composite_begin (cairo_gl_composite_t *setup,
|
|||
goto FAIL;
|
||||
}
|
||||
|
||||
status = _cairo_gl_set_shader_by_type (ctx,
|
||||
status = _cairo_gl_get_shader_by_type (ctx,
|
||||
setup->src.type,
|
||||
setup->mask.type,
|
||||
component_alpha ? CAIRO_GL_SHADER_IN_CA_SOURCE
|
||||
: CAIRO_GL_SHADER_IN_NORMAL);
|
||||
: CAIRO_GL_SHADER_IN_NORMAL,
|
||||
&shader);
|
||||
if (unlikely (status)) {
|
||||
ctx->pre_shader = NULL;
|
||||
goto FAIL;
|
||||
|
|
@ -1004,6 +1009,7 @@ _cairo_gl_composite_begin (cairo_gl_composite_t *setup,
|
|||
setup->op,
|
||||
component_alpha);
|
||||
|
||||
_cairo_gl_set_shader (ctx, shader);
|
||||
_cairo_gl_composite_bind_to_shader (ctx, setup);
|
||||
|
||||
glBindBufferARB (GL_ARRAY_BUFFER_ARB, ctx->vbo);
|
||||
|
|
|
|||
|
|
@ -399,10 +399,11 @@ cairo_private void
|
|||
_cairo_gl_context_fini_shaders (cairo_gl_context_t *ctx);
|
||||
|
||||
cairo_private cairo_status_t
|
||||
_cairo_gl_set_shader_by_type (cairo_gl_context_t *ctx,
|
||||
_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_shader_in_t in);
|
||||
cairo_gl_shader_in_t in,
|
||||
cairo_gl_shader_t **shader);
|
||||
|
||||
cairo_private void
|
||||
_cairo_gl_shader_bind_float (cairo_gl_context_t *ctx,
|
||||
|
|
|
|||
|
|
@ -924,17 +924,20 @@ _cairo_gl_set_shader (cairo_gl_context_t *ctx,
|
|||
}
|
||||
|
||||
cairo_status_t
|
||||
_cairo_gl_set_shader_by_type (cairo_gl_context_t *ctx,
|
||||
_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_shader_in_t in)
|
||||
cairo_gl_shader_in_t in,
|
||||
cairo_gl_shader_t **shader)
|
||||
{
|
||||
cairo_shader_cache_entry_t lookup, *entry;
|
||||
char *fs_source;
|
||||
cairo_status_t status;
|
||||
|
||||
if (ctx->shader_impl == NULL)
|
||||
if (ctx->shader_impl == NULL) {
|
||||
*shader = NULL;
|
||||
return CAIRO_STATUS_SUCCESS;
|
||||
}
|
||||
|
||||
lookup.src = source;
|
||||
lookup.mask = mask;
|
||||
|
|
@ -946,7 +949,7 @@ _cairo_gl_set_shader_by_type (cairo_gl_context_t *ctx,
|
|||
entry = _cairo_cache_lookup (&ctx->shaders, &lookup.base);
|
||||
if (entry) {
|
||||
assert (entry->shader.program);
|
||||
_cairo_gl_set_shader (ctx, &entry->shader);
|
||||
*shader = &entry->shader;
|
||||
return CAIRO_STATUS_SUCCESS;
|
||||
}
|
||||
|
||||
|
|
@ -988,7 +991,7 @@ _cairo_gl_set_shader_by_type (cairo_gl_context_t *ctx,
|
|||
return status;
|
||||
}
|
||||
|
||||
_cairo_gl_set_shader (ctx, &entry->shader);
|
||||
*shader = &entry->shader;
|
||||
|
||||
return CAIRO_STATUS_SUCCESS;
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue