mirror of
https://gitlab.freedesktop.org/cairo/cairo.git
synced 2026-05-05 05:18:01 +02:00
gl: Refactor status handling in _cairo_gl_context_release()
Previously, the code returned a status and required the caller to mangle this status with his own status. Now, the function takes the previous status ass an argument and does the mangling itself. Also contains fixes for all the callers to actually check the return value - which is now rather trivial as it just requires passing through the status variable.
This commit is contained in:
parent
fc3d521c12
commit
64f90322f7
6 changed files with 43 additions and 43 deletions
|
|
@ -57,9 +57,7 @@ _cairo_gl_create_gradient_texture (cairo_gl_surface_t *dst,
|
|||
|
||||
status = _cairo_gl_gradient_create (ctx, pattern->n_stops, pattern->stops, gradient);
|
||||
|
||||
_cairo_gl_context_release (ctx);
|
||||
|
||||
return status;
|
||||
return _cairo_gl_context_release (ctx, status);
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
@ -994,7 +992,7 @@ _cairo_gl_composite_begin (cairo_gl_composite_t *setup,
|
|||
|
||||
FAIL:
|
||||
if (unlikely (status))
|
||||
_cairo_gl_context_release (ctx);
|
||||
status = _cairo_gl_context_release (ctx, status);
|
||||
|
||||
return status;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -92,7 +92,7 @@ _gl_flush (void *device)
|
|||
glDisable (GL_SCISSOR_TEST);
|
||||
glDisable (GL_BLEND);
|
||||
|
||||
return _cairo_gl_context_release (ctx);
|
||||
return _cairo_gl_context_release (ctx, status);
|
||||
}
|
||||
|
||||
static void
|
||||
|
|
|
|||
|
|
@ -229,7 +229,7 @@ _render_glyphs (cairo_gl_surface_t *dst,
|
|||
cairo_gl_glyph_cache_t *cache = NULL;
|
||||
cairo_gl_context_t *ctx;
|
||||
cairo_gl_composite_t setup;
|
||||
cairo_status_t status, status_maybe_ignored;
|
||||
cairo_status_t status;
|
||||
int i = 0;
|
||||
|
||||
*has_component_alpha = FALSE;
|
||||
|
|
@ -306,14 +306,12 @@ _render_glyphs (cairo_gl_surface_t *dst,
|
|||
|
||||
*has_component_alpha |= cache->pattern.base.has_component_alpha;
|
||||
|
||||
status = _cairo_gl_composite_begin (&setup, &ctx);
|
||||
if (unlikely (status))
|
||||
goto FINISH;
|
||||
|
||||
/* XXX: _cairo_gl_composite_begin() acquires the context a
|
||||
* second time. Need to refactor this loop so this doesn't happen.
|
||||
*/
|
||||
status = _cairo_gl_context_release (ctx);
|
||||
status = _cairo_gl_composite_begin (&setup, &ctx);
|
||||
|
||||
status = _cairo_gl_context_release (ctx, status);
|
||||
if (unlikely (status))
|
||||
goto FINISH;
|
||||
}
|
||||
|
|
@ -351,9 +349,7 @@ _render_glyphs (cairo_gl_surface_t *dst,
|
|||
FINISH:
|
||||
_cairo_scaled_font_thaw_cache (scaled_font);
|
||||
|
||||
status_maybe_ignored = _cairo_gl_context_release (ctx);
|
||||
if (status == CAIRO_STATUS_SUCCESS)
|
||||
status = status_maybe_ignored;
|
||||
status = _cairo_gl_context_release (ctx, status);
|
||||
|
||||
_cairo_gl_composite_fini (&setup);
|
||||
|
||||
|
|
|
|||
|
|
@ -258,6 +258,7 @@ void
|
|||
_cairo_gl_gradient_destroy (cairo_gl_gradient_t *gradient)
|
||||
{
|
||||
cairo_gl_context_t *ctx;
|
||||
cairo_status_t ignore;
|
||||
|
||||
assert (CAIRO_REFERENCE_COUNT_HAS_REFERENCE (&gradient->ref_count));
|
||||
|
||||
|
|
@ -266,7 +267,7 @@ _cairo_gl_gradient_destroy (cairo_gl_gradient_t *gradient)
|
|||
|
||||
if (_cairo_gl_context_acquire (gradient->device, &ctx) == CAIRO_STATUS_SUCCESS) {
|
||||
glDeleteTextures (1, &gradient->tex);
|
||||
_cairo_gl_context_release (ctx);
|
||||
ignore = _cairo_gl_context_release (ctx, CAIRO_STATUS_SUCCESS);
|
||||
}
|
||||
|
||||
free (gradient);
|
||||
|
|
|
|||
|
|
@ -292,16 +292,18 @@ _cairo_gl_context_acquire (cairo_device_t *device,
|
|||
}
|
||||
|
||||
static cairo_always_inline cairo_warn cairo_status_t
|
||||
_cairo_gl_context_release (cairo_gl_context_t *ctx)
|
||||
_cairo_gl_context_release (cairo_gl_context_t *ctx, cairo_status_t status)
|
||||
{
|
||||
cairo_status_t status;
|
||||
GLenum err;
|
||||
|
||||
err = _cairo_gl_get_error ();
|
||||
if (unlikely (err))
|
||||
status = _cairo_error (CAIRO_STATUS_DEVICE_ERROR);
|
||||
else
|
||||
status = CAIRO_STATUS_SUCCESS;
|
||||
|
||||
if (unlikely (err)) {
|
||||
cairo_status_t new_status;
|
||||
new_status = _cairo_error (CAIRO_STATUS_DEVICE_ERROR);
|
||||
if (status == CAIRO_STATUS_SUCCESS)
|
||||
status = new_status;
|
||||
}
|
||||
|
||||
cairo_device_release (&(ctx)->base);
|
||||
|
||||
|
|
|
|||
|
|
@ -304,7 +304,7 @@ _cairo_gl_surface_clear (cairo_gl_surface_t *surface,
|
|||
glClearColor (r, g, b, a);
|
||||
glClear (GL_COLOR_BUFFER_BIT);
|
||||
|
||||
return _cairo_gl_context_release (ctx);
|
||||
return _cairo_gl_context_release (ctx, status);
|
||||
}
|
||||
|
||||
cairo_surface_t *
|
||||
|
|
@ -338,21 +338,16 @@ cairo_gl_surface_create (cairo_device_t *abstract_device,
|
|||
surface = (cairo_gl_surface_t *)
|
||||
_cairo_gl_surface_create_scratch (ctx, content, width, height);
|
||||
if (unlikely (surface->base.status)) {
|
||||
_cairo_gl_context_release (ctx);
|
||||
status = _cairo_gl_context_release (ctx, surface->base.status);
|
||||
return &surface->base;
|
||||
}
|
||||
|
||||
/* Cairo surfaces start out initialized to transparent (black) */
|
||||
status = _cairo_gl_surface_clear (surface, CAIRO_COLOR_TRANSPARENT);
|
||||
|
||||
status = _cairo_gl_context_release (ctx, status);
|
||||
if (unlikely (status)) {
|
||||
cairo_surface_destroy (&surface->base);
|
||||
_cairo_gl_context_release (ctx);
|
||||
return _cairo_surface_create_in_error (status);
|
||||
}
|
||||
|
||||
status = _cairo_gl_context_release (ctx);
|
||||
if (unlikely (status)) {
|
||||
_cairo_gl_context_release (ctx);
|
||||
return _cairo_surface_create_in_error (status);
|
||||
}
|
||||
|
||||
|
|
@ -421,15 +416,19 @@ cairo_gl_surface_swapbuffers (cairo_surface_t *abstract_surface)
|
|||
|
||||
if (! _cairo_gl_surface_is_texture (surface)) {
|
||||
cairo_gl_context_t *ctx;
|
||||
cairo_status_t status;
|
||||
|
||||
if (_cairo_gl_context_acquire (surface->base.device, &ctx))
|
||||
status = _cairo_gl_context_acquire (surface->base.device, &ctx);
|
||||
if (unlikely (status))
|
||||
return;
|
||||
|
||||
cairo_surface_flush (abstract_surface);
|
||||
|
||||
ctx->swap_buffers (ctx, surface);
|
||||
|
||||
_cairo_gl_context_release (ctx);
|
||||
status = _cairo_gl_context_release (ctx, status);
|
||||
if (status)
|
||||
status = _cairo_surface_set_error (abstract_surface, status);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
@ -461,7 +460,11 @@ _cairo_gl_surface_create_similar (void *abstract_surface,
|
|||
surface = _cairo_gl_surface_create_scratch (ctx, content, width, height);
|
||||
|
||||
RELEASE:
|
||||
_cairo_gl_context_release (ctx);
|
||||
status = _cairo_gl_context_release (ctx, status);
|
||||
if (unlikely (status)) {
|
||||
cairo_surface_destroy (surface);
|
||||
return _cairo_surface_create_in_error (status);
|
||||
}
|
||||
|
||||
return surface;
|
||||
}
|
||||
|
|
@ -582,7 +585,7 @@ _cairo_gl_surface_draw_image (cairo_gl_surface_t *dst,
|
|||
FAIL:
|
||||
glPixelStorei (GL_UNPACK_ROW_LENGTH, 0);
|
||||
|
||||
_cairo_gl_context_release (ctx);
|
||||
status = _cairo_gl_context_release (ctx, status);
|
||||
|
||||
if (clone)
|
||||
cairo_surface_destroy (&clone->base);
|
||||
|
|
@ -651,7 +654,7 @@ _cairo_gl_surface_get_image (cairo_gl_surface_t *surface,
|
|||
if (! _cairo_gl_surface_is_texture (surface) && GLEW_MESA_pack_invert)
|
||||
glPixelStorei (GL_PACK_INVERT_MESA, 0);
|
||||
|
||||
status = _cairo_gl_context_release (ctx);
|
||||
status = _cairo_gl_context_release (ctx, status);
|
||||
if (unlikely (status)) {
|
||||
cairo_surface_destroy (&image->base);
|
||||
return status;
|
||||
|
|
@ -690,7 +693,7 @@ _cairo_gl_surface_finish (void *abstract_surface)
|
|||
glDeleteFramebuffersEXT (1, &surface->fb);
|
||||
glDeleteTextures (1, &surface->tex);
|
||||
|
||||
return _cairo_gl_context_release (ctx);
|
||||
return _cairo_gl_context_release (ctx, status);
|
||||
}
|
||||
|
||||
static cairo_status_t
|
||||
|
|
@ -945,7 +948,7 @@ _cairo_gl_surface_composite (cairo_operator_t op,
|
|||
0);
|
||||
}
|
||||
|
||||
status = _cairo_gl_context_release (ctx);
|
||||
status = _cairo_gl_context_release (ctx, status);
|
||||
|
||||
CLEANUP:
|
||||
_cairo_gl_composite_fini (&setup);
|
||||
|
|
@ -1042,7 +1045,7 @@ _cairo_gl_surface_fill_rectangles (void *abstract_dst,
|
|||
0);
|
||||
}
|
||||
|
||||
status = _cairo_gl_context_release (ctx);
|
||||
status = _cairo_gl_context_release (ctx, status);
|
||||
|
||||
CLEANUP:
|
||||
_cairo_gl_composite_fini (&setup);
|
||||
|
|
@ -1146,13 +1149,15 @@ _cairo_gl_finish_unbounded_spans (void *abstract_renderer)
|
|||
0);
|
||||
}
|
||||
|
||||
return CAIRO_STATUS_SUCCESS;
|
||||
return _cairo_gl_context_release (renderer->ctx, CAIRO_STATUS_SUCCESS);
|
||||
}
|
||||
|
||||
static cairo_status_t
|
||||
_cairo_gl_finish_bounded_spans (void *abstract_renderer)
|
||||
{
|
||||
return CAIRO_STATUS_SUCCESS;
|
||||
cairo_gl_surface_span_renderer_t *renderer = abstract_renderer;
|
||||
|
||||
return _cairo_gl_context_release (renderer->ctx, CAIRO_STATUS_SUCCESS);
|
||||
}
|
||||
|
||||
static void
|
||||
|
|
@ -1163,8 +1168,6 @@ _cairo_gl_surface_span_renderer_destroy (void *abstract_renderer)
|
|||
if (!renderer)
|
||||
return;
|
||||
|
||||
_cairo_gl_context_release (renderer->ctx);
|
||||
|
||||
_cairo_gl_composite_fini (&renderer->setup);
|
||||
|
||||
free (renderer);
|
||||
|
|
@ -1287,7 +1290,7 @@ _cairo_gl_surface_flush (void *abstract_surface)
|
|||
(ctx->current_target == surface))
|
||||
_cairo_gl_composite_flush (ctx);
|
||||
|
||||
return _cairo_gl_context_release (ctx);
|
||||
return _cairo_gl_context_release (ctx, status);
|
||||
}
|
||||
|
||||
static cairo_int_status_t
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue