[cairo] [PATCH 6/6] [gl] Use GLSL for fill_rectangles when available.

Fernando Carrijo fcarrijo at yahoo.com.br
Thu Jan 14 03:42:50 PST 2010


Hi Eric,

On Wed, 13 Jan 2010 16:08:09 -0800, Eric Anholt <eric at anholt.net> wrote:

> +static GLint
> +_cairo_gl_compile_glsl(GLenum type, GLint *shader_out, const char *source)
> +{
> +    GLint ok;
> +    GLint shader;
> +
> +    shader = glCreateShaderObjectARB (type);
> +    glShaderSourceARB (shader, 1, (const GLchar **)&source, NULL);
> +    glCompileShaderARB (shader);
> +    glGetObjectParameterivARB (shader, GL_OBJECT_COMPILE_STATUS_ARB, &ok);
> +    if (!ok) {
> +	GLchar *info;
> +	GLint size;
> +
> +	glGetObjectParameterivARB (shader, GL_OBJECT_INFO_LOG_LENGTH_ARB,
> +				   &size);
> +	info = malloc (size);
> +
> +	glGetInfoLogARB (shader, size, NULL, info);

Shouldn't we check the return value of malloc?

> +cairo_status_t
> +_cairo_gl_load_glsl (GLint *shader_out,
> +		     const char *vs_source, const char *fs_source)
> +{
> +    GLint ok;
> +    GLint shader, vs, fs;
> +    cairo_status_t status;
> +
> +    shader = glCreateProgramObjectARB ();
> +
> +    status = _cairo_gl_compile_glsl (GL_VERTEX_SHADER_ARB, &vs, vs_source);
> +    if (_cairo_status_is_error (status))
> +	goto fail;
> +    status = _cairo_gl_compile_glsl (GL_FRAGMENT_SHADER_ARB, &fs, fs_source);
> +    if (_cairo_status_is_error (status))
> +	goto fail;
> +
> +    glAttachObjectARB (shader, vs);
> +    glAttachObjectARB (shader, fs);
> +    glLinkProgram (shader);
> +    glGetObjectParameterivARB (shader, GL_OBJECT_LINK_STATUS_ARB, &ok);
> +    if (!ok) {
> +	GLchar *info;
> +	GLint size;
> +
> +	glGetObjectParameterivARB (shader, GL_OBJECT_INFO_LOG_LENGTH_ARB,
> +				   &size);
> +	info = malloc (size);
> +
> +	glGetInfoLogARB (shader, size, NULL, info);

Ditto.

Cheers,
Fernando Carrijo.



More information about the cairo mailing list