third_party/cairo/src/cairo-gl-shaders.c
static cairo_status_t
_cairo_gl_shader_set_samplers (cairo_gl_context_t *ctx,
			       cairo_gl_shader_t *shader)
{
    cairo_gl_dispatch_t *dispatch = &ctx->dispatch;
    GLint location;
    GLint saved_program;

    /* We have to save/restore the current program because we might be
     * asked for a different program while a shader is bound.  This shouldn't
     * be a performance issue, since this is only called once per compile.
     */
    glGetIntegerv (GL_CURRENT_PROGRAM, &saved_program);
    dispatch->UseProgram (shader->program);

    location = dispatch->GetUniformLocation (shader->program, "source_sampler");
    if (location != -1) {
	dispatch->Uniform1i (location, CAIRO_GL_TEX_SOURCE);
    }

    location = dispatch->GetUniformLocation (shader->program, "mask_sampler");
    if (location != -1) {
	dispatch->Uniform1i (location, CAIRO_GL_TEX_MASK);
    }
    if(_cairo_gl_get_error()) return CAIRO_STATUS_DEVICE_ERROR;
    dispatch->UseProgram (saved_program);
    /* Pop and ignore a possible gl-error when restoring the previous program.
     * It may be that being selected in the gl-context was the last reference
     * to the shader.
     */
    _cairo_gl_get_error(); 
    return CAIRO_STATUS_SUCCESS;
}
/* We always bind the source to texture unit 0 if present, and mask to
 * texture unit 1 if present, so we can just initialize these once at
 * compile time.
 */
We always bind the source to texture unit 0 if present, and mask to
texture unit 1 if present, so we can just initialize these once at
compile time.
We always bind the source to texture unit 0 if present and mask to texture unit 1 if present so we can just initialize these once at compile time .
static cairo_status_t
_cairo_gl_shader_set_samplers (cairo_gl_context_t *ctx,
			       cairo_gl_shader_t *shader)
{
    cairo_gl_dispatch_t *dispatch = &ctx->dispatch;
    GLint location;
    GLint saved_program;
    glGetIntegerv (GL_CURRENT_PROGRAM, &saved_program);
    dispatch->UseProgram (shader->program);
    location = dispatch->GetUniformLocation (shader->program, "source_sampler");
    if (location != -1) {
	dispatch->Uniform1i (location, CAIRO_GL_TEX_SOURCE);
    }
    location = dispatch->GetUniformLocation (shader->program, "mask_sampler");
    if (location != -1) {
	dispatch->Uniform1i (location, CAIRO_GL_TEX_MASK);
    }
    if(_cairo_gl_get_error()) return CAIRO_STATUS_DEVICE_ERROR;
    dispatch->UseProgram (saved_program);
    _cairo_gl_get_error(); 
    return CAIRO_STATUS_SUCCESS;
}
static cairo_status_t _cairo_gl_shader_set_samplers ( cairo_gl_context_t * ctx , cairo_gl_shader_t * shader ) { cairo_gl_dispatch_t * dispatch = & ctx -> dispatch ; GLint location ; GLint saved_program ; glGetIntegerv ( GL_CURRENT_PROGRAM , & saved_program ) ; dispatch -> UseProgram ( shader -> program ) ; location = dispatch -> GetUniformLocation ( shader -> program , " " ) ; if ( location != -1 ) { dispatch -> Uniform1i ( location , CAIRO_GL_TEX_SOURCE ) ; } location = dispatch -> GetUniformLocation ( shader -> program , " " ) ; if ( location != -1 ) { dispatch -> Uniform1i ( location , CAIRO_GL_TEX_MASK ) ; } if ( _cairo_gl_get_error ( ) ) return CAIRO_STATUS_DEVICE_ERROR ; dispatch -> UseProgram ( saved_program ) ; _cairo_gl_get_error ( ) ; return CAIRO_STATUS_SUCCESS ; }
We always bind the source to texture unit 0 if present, and mask to
 texture unit 1 if present, so we can just initialize these once at
 compile time.
We always bind the source to texture unit 0 if present and mask to texture unit 1 if present so we can just initialize these once at compile time .
/* We have to save/restore the current program because we might be
     * asked for a different program while a shader is bound.  This shouldn't
     * be a performance issue, since this is only called once per compile.
     */ /* Pop and ignore a possible gl-error when restoring the previous program.
     * It may be that being selected in the gl-context was the last reference
     * to the shader.
     */