summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorBenjamin Otte <otte@redhat.com>2010-05-05 19:36:46 +0200
committerBenjamin Otte <otte@redhat.com>2010-05-08 18:03:05 +0200
commit4571055c46e82cbb6d3ab47860d63e400b338238 (patch)
tree570ac04de58cb8c86a4fb569c046d670315d512d
parent59b31aeed9b3ec2a1ac6da188ef5e86d20626662 (diff)
gl: Print GL errors when releasing the device
Don't scatter calls to error printing around everywhere, instead do it in the one place where it matters. Also, convert the functions to macros, so we can use __FILE__ and __LINE__ when printing a warning
-rw-r--r--src/cairo-gl-private.h15
-rw-r--r--src/cairo-gl-surface.c22
2 files changed, 11 insertions, 26 deletions
diff --git a/src/cairo-gl-private.h b/src/cairo-gl-private.h
index b3085988..c9b99c04 100644
--- a/src/cairo-gl-private.h
+++ b/src/cairo-gl-private.h
@@ -194,6 +194,12 @@ typedef struct _cairo_gl_composite_setup {
cairo_private extern const cairo_surface_backend_t _cairo_gl_surface_backend;
+#define _cairo_gl_check_error() do { \
+ GLenum err; \
+ while ((err = glGetError ())) \
+ fprintf (stderr, "%s:%d: GL error 0x%08x\n", __FILE__,__LINE__, (int) err); \
+} while (0)
+
static inline cairo_device_t *
_cairo_gl_context_create_in_error (cairo_status_t status)
{
@@ -251,11 +257,10 @@ _cairo_gl_context_acquire (cairo_device_t *device,
return CAIRO_STATUS_SUCCESS;
}
-static cairo_always_inline void
-_cairo_gl_context_release (cairo_gl_context_t *ctx)
-{
- cairo_device_release (&ctx->base);
-}
+#define _cairo_gl_context_release(ctx) do {\
+ _cairo_gl_check_error (); \
+ cairo_device_release (&(ctx)->base); \
+} while (0)
cairo_private void
_cairo_gl_set_destination (cairo_gl_context_t *ctx, cairo_gl_surface_t *surface);
diff --git a/src/cairo-gl-surface.c b/src/cairo-gl-surface.c
index 5e71b2fd..a2d09e56 100644
--- a/src/cairo-gl-surface.c
+++ b/src/cairo-gl-surface.c
@@ -319,7 +319,7 @@ _cairo_gl_surface_create_scratch (cairo_gl_context_t *ctx,
int height)
{
cairo_gl_surface_t *surface;
- GLenum err, format;
+ GLenum format;
cairo_status_t status;
assert (width <= ctx->max_framebuffer_size && height <= ctx->max_framebuffer_size);
@@ -379,10 +379,6 @@ _cairo_gl_surface_create_scratch (cairo_gl_context_t *ctx,
0);
ctx->current_target = NULL;
- while ((err = glGetError ())) {
- fprintf (stderr, "GL error in surface create: 0x%08x\n", err);
- }
-
status = glCheckFramebufferStatusEXT (GL_FRAMEBUFFER_EXT);
if (status != GL_FRAMEBUFFER_COMPLETE_EXT)
fprintf (stderr, "destination is framebuffer incomplete\n");
@@ -740,7 +736,6 @@ _cairo_gl_surface_get_image (cairo_gl_surface_t *surface,
{
cairo_image_surface_t *image;
cairo_gl_context_t *ctx;
- GLenum err;
GLenum format, type;
cairo_format_t cairo_format;
unsigned int cpp;
@@ -792,9 +787,6 @@ _cairo_gl_surface_get_image (cairo_gl_surface_t *surface,
if (surface->fb == 0 && GLEW_MESA_pack_invert)
glPixelStorei (GL_PACK_INVERT_MESA, 0);
- while ((err = glGetError ()))
- fprintf (stderr, "GL error 0x%08x\n", (int) err);
-
_cairo_gl_context_release (ctx);
*image_out = image;
@@ -1813,7 +1805,6 @@ _cairo_gl_surface_composite_component_alpha (cairo_operator_t op,
struct gl_point *texcoord_mask = texcoord_mask_stack;
cairo_status_t status;
int num_vertices, i;
- GLenum err;
cairo_gl_composite_setup_t setup;
cairo_gl_shader_program_t *ca_source_program = NULL;
cairo_gl_shader_program_t *ca_source_alpha_program = NULL;
@@ -1984,9 +1975,6 @@ _cairo_gl_surface_composite_component_alpha (cairo_operator_t op,
glDisable (GL_TEXTURE_1D);
glDisable (ctx->tex_target);
- while ((err = glGetError ()))
- fprintf (stderr, "GL error 0x%08x\n", (int) err);
-
CLEANUP:
_cairo_gl_operand_destroy (&setup.src);
if (mask != NULL)
@@ -2026,7 +2014,6 @@ _cairo_gl_surface_composite (cairo_operator_t op,
struct gl_point *texcoord_mask = texcoord_mask_stack;
cairo_status_t status;
int num_vertices, i;
- GLenum err;
cairo_gl_composite_setup_t setup;
if (! _cairo_gl_operator_is_supported (op))
@@ -2235,9 +2222,6 @@ _cairo_gl_surface_composite (cairo_operator_t op,
glDisable (GL_TEXTURE_1D);
glDisable (ctx->tex_target);
- while ((err = glGetError ()))
- fprintf (stderr, "GL error 0x%08x\n", (int) err);
-
if (vertices != vertices_stack)
free (vertices);
@@ -2797,7 +2781,6 @@ _cairo_gl_surface_create_span_renderer (cairo_operator_t op,
cairo_status_t status;
cairo_surface_attributes_t *src_attributes;
const cairo_rectangle_int_t *extents;
- GLenum err;
renderer = calloc (1, sizeof (*renderer));
if (unlikely (renderer == NULL))
@@ -2877,9 +2860,6 @@ _cairo_gl_surface_create_span_renderer (cairo_operator_t op,
glTexEnvi (GL_TEXTURE_ENV, GL_OPERAND1_ALPHA, GL_SRC_ALPHA);
}
- while ((err = glGetError ()))
- fprintf (stderr, "GL error 0x%08x\n", (int) err);
-
return &renderer->base;
}