diff --git a/cogl/cogl-atlas-texture.c b/cogl/cogl-atlas-texture.c index 5b6b2ff6d..bb10c9896 100644 --- a/cogl/cogl-atlas-texture.c +++ b/cogl/cogl-atlas-texture.c @@ -734,7 +734,7 @@ _cogl_atlas_texture_new_from_bitmap (CoglBitmap *bmp, _COGL_GET_CONTEXT (ctx, COGL_INVALID_HANDLE); - g_return_val_if_fail (cogl_is_bitmap (bmp), COGL_INVALID_HANDLE); + _COGL_RETURN_VAL_IF_FAIL (cogl_is_bitmap (bmp), COGL_INVALID_HANDLE); bmp_width = _cogl_bitmap_get_width (bmp); bmp_height = _cogl_bitmap_get_height (bmp); diff --git a/cogl/cogl-attribute.c b/cogl/cogl-attribute.c index 700d05cfd..348071da6 100644 --- a/cogl/cogl-attribute.c +++ b/cogl/cogl-attribute.c @@ -29,6 +29,7 @@ #include "config.h" #endif +#include "cogl-util.h" #include "cogl-context-private.h" #include "cogl-object-private.h" #include "cogl-journal-private.h" @@ -284,7 +285,7 @@ cogl_attribute_new (CoglAttributeBuffer *attribute_buffer, gboolean cogl_attribute_get_normalized (CoglAttribute *attribute) { - g_return_val_if_fail (cogl_is_attribute (attribute), FALSE); + _COGL_RETURN_VAL_IF_FAIL (cogl_is_attribute (attribute), FALSE); return attribute->normalized; } @@ -305,7 +306,7 @@ void cogl_attribute_set_normalized (CoglAttribute *attribute, gboolean normalized) { - g_return_if_fail (cogl_is_attribute (attribute)); + _COGL_RETURN_IF_FAIL (cogl_is_attribute (attribute)); if (G_UNLIKELY (attribute->immutable_ref)) warn_about_midscene_changes (); @@ -316,7 +317,7 @@ cogl_attribute_set_normalized (CoglAttribute *attribute, CoglAttributeBuffer * cogl_attribute_get_buffer (CoglAttribute *attribute) { - g_return_val_if_fail (cogl_is_attribute (attribute), NULL); + _COGL_RETURN_VAL_IF_FAIL (cogl_is_attribute (attribute), NULL); return attribute->attribute_buffer; } @@ -325,7 +326,7 @@ void cogl_attribute_set_buffer (CoglAttribute *attribute, CoglAttributeBuffer *attribute_buffer) { - g_return_if_fail (cogl_is_attribute (attribute)); + _COGL_RETURN_IF_FAIL (cogl_is_attribute (attribute)); if (G_UNLIKELY (attribute->immutable_ref)) warn_about_midscene_changes (); @@ -339,7 +340,7 @@ cogl_attribute_set_buffer (CoglAttribute *attribute, CoglAttribute * _cogl_attribute_immutable_ref (CoglAttribute *attribute) { - g_return_val_if_fail (cogl_is_attribute (attribute), NULL); + _COGL_RETURN_VAL_IF_FAIL (cogl_is_attribute (attribute), NULL); attribute->immutable_ref++; _cogl_buffer_immutable_ref (COGL_BUFFER (attribute->attribute_buffer)); @@ -349,8 +350,8 @@ _cogl_attribute_immutable_ref (CoglAttribute *attribute) void _cogl_attribute_immutable_unref (CoglAttribute *attribute) { - g_return_if_fail (cogl_is_attribute (attribute)); - g_return_if_fail (attribute->immutable_ref > 0); + _COGL_RETURN_IF_FAIL (cogl_is_attribute (attribute)); + _COGL_RETURN_IF_FAIL (attribute->immutable_ref > 0); attribute->immutable_ref--; _cogl_buffer_immutable_unref (COGL_BUFFER (attribute->attribute_buffer)); diff --git a/cogl/cogl-bitmap-pixbuf.c b/cogl/cogl-bitmap-pixbuf.c index 1a99f4bce..5923f7e39 100644 --- a/cogl/cogl-bitmap-pixbuf.c +++ b/cogl/cogl-bitmap-pixbuf.c @@ -26,6 +26,7 @@ #endif #include "cogl.h" +#include "cogl-util.h" #include "cogl-internal.h" #include "cogl-bitmap-private.h" @@ -195,7 +196,7 @@ _cogl_bitmap_get_size_from_file (const char *filename, int *width, int *height) { - g_return_val_if_fail (filename != NULL, FALSE); + _COGL_RETURN_VAL_IF_FAIL (filename != NULL, FALSE); if (gdk_pixbuf_get_file_info (filename, width, height) != NULL) return TRUE; @@ -224,7 +225,7 @@ _cogl_bitmap_from_file (const char *filename, int bits_per_sample; int n_channels; - g_return_val_if_fail (error == NULL || *error == NULL, FALSE); + _COGL_RETURN_VAL_IF_FAIL (error == NULL || *error == NULL, FALSE); /* Load from file using GdkPixbuf */ pixbuf = gdk_pixbuf_new_from_file (filename, error); @@ -307,7 +308,7 @@ _cogl_bitmap_from_file (const char *filename, int height; guint8 *pixels; - g_return_val_if_fail (error == NULL || *error == NULL, FALSE); + _COGL_RETURN_VAL_IF_FAIL (error == NULL || *error == NULL, FALSE); /* Load from file using stb */ pixels = stbi_load (filename, diff --git a/cogl/cogl-bitmap.c b/cogl/cogl-bitmap.c index 781e6f8d1..a109d03b9 100644 --- a/cogl/cogl-bitmap.c +++ b/cogl/cogl-bitmap.c @@ -26,6 +26,7 @@ #endif #include "cogl.h" +#include "cogl-util.h" #include "cogl-debug.h" #include "cogl-internal.h" #include "cogl-bitmap-private.h" @@ -310,7 +311,7 @@ cogl_bitmap_new_from_file (const char *filename, { CoglBitmap *bmp; - g_return_val_if_fail (error == NULL || *error == NULL, COGL_INVALID_HANDLE); + _COGL_RETURN_VAL_IF_FAIL (error == NULL || *error == NULL, COGL_INVALID_HANDLE); if ((bmp = _cogl_bitmap_from_file (filename, error)) == NULL) { @@ -336,7 +337,7 @@ cogl_bitmap_new_from_buffer (CoglBuffer *buffer, { CoglBitmap *bmp; - g_return_val_if_fail (cogl_is_buffer (buffer), NULL); + _COGL_RETURN_VAL_IF_FAIL (cogl_is_buffer (buffer), NULL); bmp = _cogl_bitmap_new_from_data (NULL, /* data */ format, diff --git a/cogl/cogl-blit.c b/cogl/cogl-blit.c index eff8f7140..e65a5b0b4 100644 --- a/cogl/cogl-blit.c +++ b/cogl/cogl-blit.c @@ -31,6 +31,7 @@ #include #include "cogl.h" +#include "cogl-util.h" #include "cogl-blit.h" #include "cogl-context-private.h" #include "cogl-framebuffer-private.h" @@ -369,7 +370,7 @@ _cogl_blit_begin (CoglBlitData *data, _cogl_blit_modes[i].name); /* The last blit mode can't fail so this should never happen */ - g_return_if_fail (i < G_N_ELEMENTS (_cogl_blit_modes)); + _COGL_RETURN_IF_FAIL (i < G_N_ELEMENTS (_cogl_blit_modes)); } data->blit_mode = _cogl_blit_default_mode; diff --git a/cogl/cogl-buffer.c b/cogl/cogl-buffer.c index 9fff90a55..cb7d0a044 100644 --- a/cogl/cogl-buffer.c +++ b/cogl/cogl-buffer.c @@ -296,8 +296,8 @@ _cogl_buffer_fini (CoglBuffer *buffer) { _COGL_GET_CONTEXT (ctx, NO_RETVAL); - g_return_if_fail (!(buffer->flags & COGL_BUFFER_FLAG_MAPPED)); - g_return_if_fail (buffer->immutable_ref == 0); + _COGL_RETURN_IF_FAIL (!(buffer->flags & COGL_BUFFER_FLAG_MAPPED)); + _COGL_RETURN_IF_FAIL (buffer->immutable_ref == 0); if (buffer->flags & COGL_BUFFER_FLAG_BUFFER_OBJECT) GE( ctx, glDeleteBuffers (1, &buffer->gl_handle) ); @@ -341,14 +341,14 @@ _cogl_buffer_bind (CoglBuffer *buffer, CoglBufferBindTarget target) { _COGL_GET_CONTEXT (ctx, NULL); - g_return_val_if_fail (buffer != NULL, NULL); + _COGL_RETURN_VAL_IF_FAIL (buffer != NULL, NULL); /* Don't allow binding the buffer to multiple targets at the same time */ - g_return_val_if_fail (ctx->current_buffer[buffer->last_target] != buffer, - NULL); + _COGL_RETURN_VAL_IF_FAIL (ctx->current_buffer[buffer->last_target] != buffer, + NULL); /* Don't allow nesting binds to the same target */ - g_return_val_if_fail (ctx->current_buffer[target] == NULL, NULL); + _COGL_RETURN_VAL_IF_FAIL (ctx->current_buffer[target] == NULL, NULL); buffer->last_target = target; ctx->current_buffer[target] = buffer; @@ -368,10 +368,10 @@ _cogl_buffer_unbind (CoglBuffer *buffer) { _COGL_GET_CONTEXT (ctx, NO_RETVAL); - g_return_if_fail (buffer != NULL); + _COGL_RETURN_IF_FAIL (buffer != NULL); /* the unbind should pair up with a previous bind */ - g_return_if_fail (ctx->current_buffer[buffer->last_target] == buffer); + _COGL_RETURN_IF_FAIL (ctx->current_buffer[buffer->last_target] == buffer); if (buffer->flags & COGL_BUFFER_FLAG_BUFFER_OBJECT) { @@ -430,7 +430,7 @@ cogl_buffer_map (CoglBuffer *buffer, CoglBufferAccess access, CoglBufferMapHint hints) { - g_return_val_if_fail (cogl_is_buffer (buffer), NULL); + _COGL_RETURN_VAL_IF_FAIL (cogl_is_buffer (buffer), NULL); if (G_UNLIKELY (buffer->immutable_ref)) warn_about_midscene_changes (); @@ -461,7 +461,7 @@ _cogl_buffer_map_for_fill_or_fallback (CoglBuffer *buffer) _COGL_GET_CONTEXT (ctx, NULL); - g_return_val_if_fail (!ctx->buffer_map_fallback_in_use, NULL); + _COGL_RETURN_VAL_IF_FAIL (!ctx->buffer_map_fallback_in_use, NULL); ctx->buffer_map_fallback_in_use = TRUE; @@ -490,7 +490,7 @@ _cogl_buffer_unmap_for_fill_or_fallback (CoglBuffer *buffer) { _COGL_GET_CONTEXT (ctx, NO_RETVAL); - g_return_if_fail (ctx->buffer_map_fallback_in_use); + _COGL_RETURN_IF_FAIL (ctx->buffer_map_fallback_in_use); ctx->buffer_map_fallback_in_use = FALSE; @@ -511,8 +511,8 @@ cogl_buffer_set_data (CoglBuffer *buffer, const void *data, gsize size) { - g_return_val_if_fail (cogl_is_buffer (buffer), FALSE); - g_return_val_if_fail ((offset + size) <= buffer->size, FALSE); + _COGL_RETURN_VAL_IF_FAIL (cogl_is_buffer (buffer), FALSE); + _COGL_RETURN_VAL_IF_FAIL ((offset + size) <= buffer->size, FALSE); if (G_UNLIKELY (buffer->immutable_ref)) warn_about_midscene_changes (); @@ -523,7 +523,7 @@ cogl_buffer_set_data (CoglBuffer *buffer, CoglBuffer * _cogl_buffer_immutable_ref (CoglBuffer *buffer) { - g_return_val_if_fail (cogl_is_buffer (buffer), NULL); + _COGL_RETURN_VAL_IF_FAIL (cogl_is_buffer (buffer), NULL); buffer->immutable_ref++; return buffer; @@ -532,8 +532,8 @@ _cogl_buffer_immutable_ref (CoglBuffer *buffer) void _cogl_buffer_immutable_unref (CoglBuffer *buffer) { - g_return_if_fail (cogl_is_buffer (buffer)); - g_return_if_fail (buffer->immutable_ref > 0); + _COGL_RETURN_IF_FAIL (cogl_is_buffer (buffer)); + _COGL_RETURN_IF_FAIL (buffer->immutable_ref > 0); buffer->immutable_ref--; } diff --git a/cogl/cogl-clip-stack.c b/cogl/cogl-clip-stack.c index 1c44a27f3..e3e8340bc 100644 --- a/cogl/cogl-clip-stack.c +++ b/cogl/cogl-clip-stack.c @@ -751,7 +751,7 @@ _cogl_clip_stack_pop (CoglClipStack *stack) { CoglClipStack *new_top; - g_return_val_if_fail (stack != NULL, NULL); + _COGL_RETURN_VAL_IF_FAIL (stack != NULL, NULL); /* To pop we are moving the top of the stack to the old top's parent node. The stack always needs to have a reference to the top entry diff --git a/cogl/cogl-clip-state.c b/cogl/cogl-clip-state.c index 1f234718a..9de2a8f4c 100644 --- a/cogl/cogl-clip-state.c +++ b/cogl/cogl-clip-state.c @@ -222,7 +222,7 @@ _cogl_clip_stack_restore_real (CoglClipState *clip_state) { CoglHandle stack; - g_return_if_fail (clip_state->stacks != NULL); + _COGL_RETURN_IF_FAIL (clip_state->stacks != NULL); stack = clip_state->stacks->data; diff --git a/cogl/cogl-clutter.c b/cogl/cogl-clutter.c index fca6e82fd..f9f6321d1 100644 --- a/cogl/cogl-clutter.c +++ b/cogl/cogl-clutter.c @@ -31,6 +31,7 @@ #include #include "cogl.h" +#include "cogl-util.h" #include "cogl-types.h" #include "cogl-private.h" #include "cogl-context-private.h" @@ -77,7 +78,7 @@ cogl_clutter_winsys_xlib_get_visual_info (void) winsys = _cogl_context_get_winsys (ctx); /* This should only be called for xlib contexts */ - g_return_val_if_fail (winsys->xlib_get_visual_info != NULL, NULL); + _COGL_RETURN_VAL_IF_FAIL (winsys->xlib_get_visual_info != NULL, NULL); return winsys->xlib_get_visual_info (); } diff --git a/cogl/cogl-color.c b/cogl/cogl-color.c index b9556b072..9292d84b9 100644 --- a/cogl/cogl-color.c +++ b/cogl/cogl-color.c @@ -28,6 +28,7 @@ #include #include "cogl.h" +#include "cogl-util.h" #include "cogl-color.h" #include "cogl-fixed.h" @@ -60,7 +61,7 @@ cogl_color_init_from_4ub (CoglColor *color, guint8 blue, guint8 alpha) { - g_return_if_fail (color != NULL); + _COGL_RETURN_IF_FAIL (color != NULL); color->red = red; color->green = green; @@ -86,7 +87,7 @@ cogl_color_init_from_4f (CoglColor *color, float blue, float alpha) { - g_return_if_fail (color != NULL); + _COGL_RETURN_IF_FAIL (color != NULL); color->red = (red * 255); color->green = (green * 255); @@ -109,7 +110,7 @@ void cogl_color_init_from_4fv (CoglColor *color, float *color_array) { - g_return_if_fail (color != NULL); + _COGL_RETURN_IF_FAIL (color != NULL); color->red = (color_array[0] * 255); color->green = (color_array[1] * 255); @@ -297,8 +298,8 @@ cogl_color_equal (gconstpointer v1, gconstpointer v2) { const guint32 *c1 = v1, *c2 = v2; - g_return_val_if_fail (v1 != NULL, FALSE); - g_return_val_if_fail (v2 != NULL, FALSE); + _COGL_RETURN_VAL_IF_FAIL (v1 != NULL, FALSE); + _COGL_RETURN_VAL_IF_FAIL (v2 != NULL, FALSE); /* XXX: We don't compare the padding */ return *c1 == *c2 ? TRUE : FALSE; diff --git a/cogl/cogl-context.c b/cogl/cogl-context.c index 953e4b97f..bd3eca410 100644 --- a/cogl/cogl-context.c +++ b/cogl/cogl-context.c @@ -525,7 +525,7 @@ cogl_egl_context_get_egl_display (CoglContext *context) const CoglWinsysVtable *winsys = _cogl_context_get_winsys (context); /* This should only be called for EGL contexts */ - g_return_val_if_fail (winsys->context_egl_get_egl_display != NULL, NULL); + _COGL_RETURN_VAL_IF_FAIL (winsys->context_egl_get_egl_display != NULL, NULL); return winsys->context_egl_get_egl_display (context); } diff --git a/cogl/cogl-depth-state.c b/cogl/cogl-depth-state.c index 076d1b2ec..10eb3548f 100644 --- a/cogl/cogl-depth-state.c +++ b/cogl/cogl-depth-state.c @@ -28,6 +28,7 @@ #endif #include +#include "cogl-util.h" #include "cogl-depth-state-private.h" void @@ -46,14 +47,14 @@ void cogl_depth_state_set_test_enabled (CoglDepthState *state, gboolean enabled) { - g_return_if_fail (state->magic == COGL_DEPTH_STATE_MAGIC); + _COGL_RETURN_IF_FAIL (state->magic == COGL_DEPTH_STATE_MAGIC); state->test_enabled = enabled; } gboolean cogl_depth_state_get_test_enabled (CoglDepthState *state) { - g_return_val_if_fail (state->magic == COGL_DEPTH_STATE_MAGIC, FALSE); + _COGL_RETURN_VAL_IF_FAIL (state->magic == COGL_DEPTH_STATE_MAGIC, FALSE); return state->test_enabled; } @@ -61,14 +62,14 @@ void cogl_depth_state_set_write_enabled (CoglDepthState *state, gboolean enabled) { - g_return_if_fail (state->magic == COGL_DEPTH_STATE_MAGIC); + _COGL_RETURN_IF_FAIL (state->magic == COGL_DEPTH_STATE_MAGIC); state->write_enabled = enabled; } gboolean cogl_depth_state_get_write_enabled (CoglDepthState *state) { - g_return_val_if_fail (state->magic == COGL_DEPTH_STATE_MAGIC, FALSE); + _COGL_RETURN_VAL_IF_FAIL (state->magic == COGL_DEPTH_STATE_MAGIC, FALSE); return state->write_enabled; } @@ -76,14 +77,14 @@ void cogl_depth_state_set_test_function (CoglDepthState *state, CoglDepthTestFunction function) { - g_return_if_fail (state->magic == COGL_DEPTH_STATE_MAGIC); + _COGL_RETURN_IF_FAIL (state->magic == COGL_DEPTH_STATE_MAGIC); state->test_function = function; } CoglDepthTestFunction cogl_depth_state_get_test_function (CoglDepthState *state) { - g_return_val_if_fail (state->magic == COGL_DEPTH_STATE_MAGIC, FALSE); + _COGL_RETURN_VAL_IF_FAIL (state->magic == COGL_DEPTH_STATE_MAGIC, FALSE); return state->test_function; } @@ -92,7 +93,7 @@ cogl_depth_state_set_range (CoglDepthState *state, float near, float far) { - g_return_if_fail (state->magic == COGL_DEPTH_STATE_MAGIC); + _COGL_RETURN_IF_FAIL (state->magic == COGL_DEPTH_STATE_MAGIC); state->range_near = near; state->range_far = far; } @@ -102,7 +103,7 @@ cogl_depth_state_get_range (CoglDepthState *state, float *near_out, float *far_out) { - g_return_if_fail (state->magic == COGL_DEPTH_STATE_MAGIC); + _COGL_RETURN_IF_FAIL (state->magic == COGL_DEPTH_STATE_MAGIC); *near_out = state->range_near; *far_out = state->range_far; } diff --git a/cogl/cogl-display.c b/cogl/cogl-display.c index 0eefee82b..5c7f588c3 100644 --- a/cogl/cogl-display.c +++ b/cogl/cogl-display.c @@ -150,7 +150,7 @@ void cogl_gdl_display_set_plane (CoglDisplay *display, gdl_plane_id_t plane) { - g_return_if_fail (display->setup == FALSE); + _COGL_RETURN_IF_FAIL (display->setup == FALSE); display->gdl_plane = plane; } @@ -161,7 +161,7 @@ void cogl_wayland_display_set_compositor_display (CoglDisplay *display, struct wl_display *wayland_display) { - g_return_if_fail (display->setup == FALSE); + _COGL_RETURN_IF_FAIL (display->setup == FALSE); display->wayland_compositor_display = wayland_display; } diff --git a/cogl/cogl-euler.c b/cogl/cogl-euler.c index afe24bedd..4718e354a 100644 --- a/cogl/cogl-euler.c +++ b/cogl/cogl-euler.c @@ -25,6 +25,7 @@ */ #include +#include #include #include @@ -151,8 +152,8 @@ cogl_euler_equal (gconstpointer v1, gconstpointer v2) const CoglEuler *a = v1; const CoglEuler *b = v2; - g_return_val_if_fail (v1 != NULL, FALSE); - g_return_val_if_fail (v2 != NULL, FALSE); + _COGL_RETURN_VAL_IF_FAIL (v1 != NULL, FALSE); + _COGL_RETURN_VAL_IF_FAIL (v2 != NULL, FALSE); if (v1 == v2) return TRUE; diff --git a/cogl/cogl-framebuffer.c b/cogl/cogl-framebuffer.c index 968c3f8f5..5116f109e 100644 --- a/cogl/cogl-framebuffer.c +++ b/cogl/cogl-framebuffer.c @@ -505,7 +505,7 @@ cogl_framebuffer_set_viewport (CoglFramebuffer *framebuffer, float width, float height) { - g_return_if_fail (width > 0 && height > 0); + _COGL_RETURN_IF_FAIL (width > 0 && height > 0); if (framebuffer->viewport_x == x && framebuffer->viewport_y == y && @@ -1146,8 +1146,8 @@ _cogl_set_framebuffers_real (CoglFramebuffer *draw_buffer, _COGL_GET_CONTEXT (ctx, NO_RETVAL); - g_return_if_fail (ctx != NULL); - g_return_if_fail (draw_buffer && read_buffer ? + _COGL_RETURN_IF_FAIL (ctx != NULL); + _COGL_RETURN_IF_FAIL (draw_buffer && read_buffer ? draw_buffer->context == read_buffer->context : TRUE); entry = ctx->framebuffer_stack->data; @@ -1178,8 +1178,8 @@ _cogl_set_framebuffers (CoglFramebuffer *draw_buffer, CoglFramebuffer *current_draw_buffer; CoglFramebuffer *current_read_buffer; - g_return_if_fail (_cogl_is_framebuffer (draw_buffer)); - g_return_if_fail (_cogl_is_framebuffer (read_buffer)); + _COGL_RETURN_IF_FAIL (_cogl_is_framebuffer (draw_buffer)); + _COGL_RETURN_IF_FAIL (_cogl_is_framebuffer (read_buffer)); current_draw_buffer = cogl_get_draw_framebuffer (); current_read_buffer = _cogl_get_read_framebuffer (); @@ -1257,14 +1257,14 @@ _cogl_push_framebuffers (CoglFramebuffer *draw_buffer, CoglContext *ctx; CoglFramebuffer *old_draw_buffer, *old_read_buffer; - g_return_if_fail (_cogl_is_framebuffer (draw_buffer)); - g_return_if_fail (_cogl_is_framebuffer (read_buffer)); + _COGL_RETURN_IF_FAIL (_cogl_is_framebuffer (draw_buffer)); + _COGL_RETURN_IF_FAIL (_cogl_is_framebuffer (read_buffer)); ctx = draw_buffer->context; - g_return_if_fail (ctx != NULL); - g_return_if_fail (draw_buffer->context == read_buffer->context); + _COGL_RETURN_IF_FAIL (ctx != NULL); + _COGL_RETURN_IF_FAIL (draw_buffer->context == read_buffer->context); - g_return_if_fail (ctx->framebuffer_stack != NULL); + _COGL_RETURN_IF_FAIL (ctx->framebuffer_stack != NULL); /* Copy the top of the stack so that when we call cogl_set_framebuffer it will still know what the old framebuffer was */ @@ -1380,10 +1380,10 @@ _cogl_framebuffer_flush_state (CoglFramebuffer *draw_buffer, /* NB: Currently we only take advantage of binding separate * read/write buffers for offscreen framebuffer blit * purposes. */ - g_return_if_fail (ctx->private_feature_flags & - COGL_PRIVATE_FEATURE_OFFSCREEN_BLIT); - g_return_if_fail (draw_buffer->type == COGL_FRAMEBUFFER_TYPE_OFFSCREEN); - g_return_if_fail (read_buffer->type == COGL_FRAMEBUFFER_TYPE_OFFSCREEN); + _COGL_RETURN_IF_FAIL (ctx->private_feature_flags & + COGL_PRIVATE_FEATURE_OFFSCREEN_BLIT); + _COGL_RETURN_IF_FAIL (draw_buffer->type == COGL_FRAMEBUFFER_TYPE_OFFSCREEN); + _COGL_RETURN_IF_FAIL (read_buffer->type == COGL_FRAMEBUFFER_TYPE_OFFSCREEN); bind_gl_framebuffer (ctx, GL_DRAW_FRAMEBUFFER, draw_buffer); bind_gl_framebuffer (ctx, GL_READ_FRAMEBUFFER, read_buffer); @@ -1530,7 +1530,7 @@ void cogl_framebuffer_set_samples_per_pixel (CoglFramebuffer *framebuffer, int samples_per_pixel) { - g_return_if_fail (!framebuffer->allocated); + _COGL_RETURN_IF_FAIL (!framebuffer->allocated); framebuffer->config.samples_per_pixel = samples_per_pixel; } @@ -1584,7 +1584,7 @@ cogl_framebuffer_resolve_samples_region (CoglFramebuffer *framebuffer, CoglContext * cogl_framebuffer_get_context (CoglFramebuffer *framebuffer) { - g_return_val_if_fail (framebuffer != NULL, NULL); + _COGL_RETURN_VAL_IF_FAIL (framebuffer != NULL, NULL); return framebuffer->context; } @@ -1670,16 +1670,16 @@ _cogl_blit_framebuffer (unsigned int src_x, read_buffer = _cogl_get_read_framebuffer (); ctx = draw_buffer->context; - g_return_if_fail (ctx->private_feature_flags & + _COGL_RETURN_IF_FAIL (ctx->private_feature_flags & COGL_PRIVATE_FEATURE_OFFSCREEN_BLIT); /* We can only support blitting between offscreen buffers because otherwise we would need to mirror the image and GLES2.0 doesn't support this */ - g_return_if_fail (cogl_is_offscreen (draw_buffer)); - g_return_if_fail (cogl_is_offscreen (read_buffer)); + _COGL_RETURN_IF_FAIL (cogl_is_offscreen (draw_buffer)); + _COGL_RETURN_IF_FAIL (cogl_is_offscreen (read_buffer)); /* The buffers must be the same format */ - g_return_if_fail (draw_buffer->format == read_buffer->format); + _COGL_RETURN_IF_FAIL (draw_buffer->format == read_buffer->format); /* Make sure the current framebuffers are bound. We explicitly avoid flushing the clip state so we can bind our own empty state */ @@ -1741,7 +1741,7 @@ void cogl_framebuffer_discard_buffers (CoglFramebuffer *framebuffer, unsigned long buffers) { - g_return_if_fail (buffers & COGL_BUFFER_BIT_COLOR); + _COGL_RETURN_IF_FAIL (buffers & COGL_BUFFER_BIT_COLOR); _cogl_framebuffer_discard_buffers_real (framebuffer, buffers); } diff --git a/cogl/cogl-indices.c b/cogl/cogl-indices.c index 2ca93b9c8..686ef8ac2 100644 --- a/cogl/cogl-indices.c +++ b/cogl/cogl-indices.c @@ -30,6 +30,7 @@ #include "config.h" #endif +#include "cogl-util.h" #include "cogl-object-private.h" #include "cogl-context-private.h" #include "cogl-indices.h" @@ -104,15 +105,15 @@ cogl_indices_get_buffer (CoglIndices *indices) CoglIndicesType cogl_indices_get_type (CoglIndices *indices) { - g_return_val_if_fail (cogl_is_indices (indices), - COGL_INDICES_TYPE_UNSIGNED_BYTE); + _COGL_RETURN_VAL_IF_FAIL (cogl_is_indices (indices), + COGL_INDICES_TYPE_UNSIGNED_BYTE); return indices->type; } gsize cogl_indices_get_offset (CoglIndices *indices) { - g_return_val_if_fail (cogl_is_indices (indices), 0); + _COGL_RETURN_VAL_IF_FAIL (cogl_is_indices (indices), 0); return indices->offset; } @@ -133,7 +134,7 @@ void cogl_indices_set_offset (CoglIndices *indices, gsize offset) { - g_return_if_fail (cogl_is_indices (indices)); + _COGL_RETURN_IF_FAIL (cogl_is_indices (indices)); if (G_UNLIKELY (indices->immutable_ref)) warn_about_midscene_changes (); @@ -151,7 +152,7 @@ _cogl_indices_free (CoglIndices *indices) CoglIndices * _cogl_indices_immutable_ref (CoglIndices *indices) { - g_return_val_if_fail (cogl_is_indices (indices), NULL); + _COGL_RETURN_VAL_IF_FAIL (cogl_is_indices (indices), NULL); indices->immutable_ref++; _cogl_buffer_immutable_ref (COGL_BUFFER (indices->buffer)); @@ -161,8 +162,8 @@ _cogl_indices_immutable_ref (CoglIndices *indices) void _cogl_indices_immutable_unref (CoglIndices *indices) { - g_return_if_fail (cogl_is_indices (indices)); - g_return_if_fail (indices->immutable_ref > 0); + _COGL_RETURN_IF_FAIL (cogl_is_indices (indices)); + _COGL_RETURN_IF_FAIL (indices->immutable_ref > 0); indices->immutable_ref--; _cogl_buffer_immutable_unref (COGL_BUFFER (indices->buffer)); diff --git a/cogl/cogl-matrix.c b/cogl/cogl-matrix.c index 19e6589cb..abb0a9267 100644 --- a/cogl/cogl-matrix.c +++ b/cogl/cogl-matrix.c @@ -66,6 +66,7 @@ #endif #include +#include #include #include #include @@ -375,7 +376,7 @@ _cogl_matrix_print (const CoglMatrix *matrix) { if (!(matrix->flags & MAT_DIRTY_TYPE)) { - g_return_if_fail (matrix->type < COGL_MATRIX_N_TYPES); + _COGL_RETURN_IF_FAIL (matrix->type < COGL_MATRIX_N_TYPES); g_print ("Matrix type: %s, flags: %x\n", types[matrix->type], (int)matrix->flags); } @@ -1777,8 +1778,8 @@ cogl_matrix_equal (gconstpointer v1, gconstpointer v2) const CoglMatrix *a = v1; const CoglMatrix *b = v2; - g_return_val_if_fail (v1 != NULL, FALSE); - g_return_val_if_fail (v2 != NULL, FALSE); + _COGL_RETURN_VAL_IF_FAIL (v1 != NULL, FALSE); + _COGL_RETURN_VAL_IF_FAIL (v2 != NULL, FALSE); /* We want to avoid having a fuzzy _equal() function (e.g. that uses * an arbitrary epsilon value) since this function noteably conforms @@ -2002,7 +2003,7 @@ cogl_matrix_transform_points (const CoglMatrix *matrix, int n_points) { /* The results of transforming always have three components... */ - g_return_if_fail (stride_out >= sizeof (Point3f)); + _COGL_RETURN_IF_FAIL (stride_out >= sizeof (Point3f)); if (n_components == 2) _cogl_matrix_transform_points_f2 (matrix, @@ -2011,7 +2012,7 @@ cogl_matrix_transform_points (const CoglMatrix *matrix, n_points); else { - g_return_if_fail (n_components == 3); + _COGL_RETURN_IF_FAIL (n_components == 3); _cogl_matrix_transform_points_f3 (matrix, stride_in, points_in, @@ -2041,7 +2042,7 @@ cogl_matrix_project_points (const CoglMatrix *matrix, n_points); else { - g_return_if_fail (n_components == 4); + _COGL_RETURN_IF_FAIL (n_components == 4); _cogl_matrix_project_points_f4 (matrix, stride_in, points_in, diff --git a/cogl/cogl-node.c b/cogl/cogl-node.c index 46112f389..3d7909e71 100644 --- a/cogl/cogl-node.c +++ b/cogl/cogl-node.c @@ -29,6 +29,7 @@ #include "config.h" #endif +#include "cogl-util.h" #include "cogl-node-private.h" void @@ -79,7 +80,7 @@ _cogl_pipeline_node_unparent_real (CoglNode *node) if (parent == NULL) return; - g_return_if_fail (!COGL_LIST_EMPTY (&parent->children)); + _COGL_RETURN_IF_FAIL (!COGL_LIST_EMPTY (&parent->children)); COGL_LIST_REMOVE (node, list_node); diff --git a/cogl/cogl-object.c b/cogl/cogl-object.c index 418005690..7f06d8d29 100644 --- a/cogl/cogl-object.c +++ b/cogl/cogl-object.c @@ -30,6 +30,7 @@ #include #include +#include "cogl-util.h" #include "cogl-types.h" #include "cogl-object-private.h" @@ -38,7 +39,7 @@ cogl_object_ref (void *object) { CoglObject *obj = object; - g_return_val_if_fail (object != NULL, NULL); + _COGL_RETURN_VAL_IF_FAIL (object != NULL, NULL); obj->ref_count++; return object; @@ -55,8 +56,8 @@ cogl_object_unref (void *object) { CoglObject *obj = object; - g_return_if_fail (object != NULL); - g_return_if_fail (obj->ref_count > 0); + _COGL_RETURN_IF_FAIL (object != NULL); + _COGL_RETURN_IF_FAIL (obj->ref_count > 0); if (--obj->ref_count < 1) { diff --git a/cogl/cogl-onscreen.c b/cogl/cogl-onscreen.c index 52ee784ab..f95f96c71 100644 --- a/cogl/cogl-onscreen.c +++ b/cogl/cogl-onscreen.c @@ -25,6 +25,7 @@ #include "config.h" #endif +#include "cogl-util.h" #include "cogl-onscreen-private.h" #include "cogl-framebuffer-private.h" #include "cogl-onscreen-template-private.h" @@ -112,7 +113,7 @@ _cogl_onscreen_free (CoglOnscreen *onscreen) const CoglWinsysVtable *winsys = _cogl_framebuffer_get_winsys (framebuffer); winsys->onscreen_deinit (onscreen); - g_return_if_fail (onscreen->winsys == NULL); + _COGL_RETURN_IF_FAIL (onscreen->winsys == NULL); /* Chain up to parent */ _cogl_framebuffer_free (framebuffer); @@ -125,7 +126,7 @@ cogl_framebuffer_swap_buffers (CoglFramebuffer *framebuffer) { const CoglWinsysVtable *winsys; - g_return_if_fail (framebuffer->type == COGL_FRAMEBUFFER_TYPE_ONSCREEN); + _COGL_RETURN_IF_FAIL (framebuffer->type == COGL_FRAMEBUFFER_TYPE_ONSCREEN); /* FIXME: we shouldn't need to flush *all* journals here! */ cogl_flush (); @@ -144,7 +145,7 @@ cogl_framebuffer_swap_region (CoglFramebuffer *framebuffer, { const CoglWinsysVtable *winsys; - g_return_if_fail (framebuffer->type == COGL_FRAMEBUFFER_TYPE_ONSCREEN); + _COGL_RETURN_IF_FAIL (framebuffer->type == COGL_FRAMEBUFFER_TYPE_ONSCREEN); /* FIXME: we shouldn't need to flush *all* journals here! */ cogl_flush (); @@ -153,7 +154,7 @@ cogl_framebuffer_swap_region (CoglFramebuffer *framebuffer, /* This should only be called if the winsys advertises COGL_WINSYS_FEATURE_SWAP_REGION */ - g_return_if_fail (winsys->onscreen_swap_region != NULL); + _COGL_RETURN_IF_FAIL (winsys->onscreen_swap_region != NULL); winsys->onscreen_swap_region (COGL_ONSCREEN (framebuffer), rectangles, @@ -174,7 +175,7 @@ cogl_x11_onscreen_set_foreign_window_xid (CoglOnscreen *onscreen, { /* We don't wan't applications to get away with being lazy here and not * passing an update callback... */ - g_return_if_fail (update); + _COGL_RETURN_IF_FAIL (update); onscreen->foreign_xid = xid; onscreen->foreign_update_mask_callback = update; @@ -193,7 +194,7 @@ cogl_x11_onscreen_get_window_xid (CoglOnscreen *onscreen) const CoglWinsysVtable *winsys = _cogl_framebuffer_get_winsys (framebuffer); /* This should only be called for x11 onscreens */ - g_return_val_if_fail (winsys->onscreen_x11_get_window_xid != NULL, 0); + _COGL_RETURN_VAL_IF_FAIL (winsys->onscreen_x11_get_window_xid != NULL, 0); return winsys->onscreen_x11_get_window_xid (onscreen); } @@ -208,7 +209,7 @@ cogl_x11_onscreen_get_visual_xid (CoglOnscreen *onscreen) guint32 id; /* This should only be called for xlib based onscreens */ - g_return_val_if_fail (winsys->xlib_get_visual_info != NULL, 0); + _COGL_RETURN_VAL_IF_FAIL (winsys->xlib_get_visual_info != NULL, 0); visinfo = winsys->xlib_get_visual_info (); id = (guint32)visinfo->visualid; @@ -239,7 +240,7 @@ cogl_win32_onscreen_get_window (CoglOnscreen *onscreen) _cogl_framebuffer_get_winsys (framebuffer); /* This should only be called for win32 onscreens */ - g_return_val_if_fail (winsys->onscreen_win32_get_window != NULL, 0); + _COGL_RETURN_VAL_IF_FAIL (winsys->onscreen_win32_get_window != NULL, 0); return winsys->onscreen_win32_get_window (onscreen); } @@ -256,11 +257,11 @@ cogl_framebuffer_add_swap_buffers_callback (CoglFramebuffer *framebuffer, const CoglWinsysVtable *winsys = _cogl_framebuffer_get_winsys (framebuffer); /* Should this just be cogl_onscreen API instead? */ - g_return_val_if_fail (framebuffer->type == COGL_FRAMEBUFFER_TYPE_ONSCREEN, 0); + _COGL_RETURN_VAL_IF_FAIL (framebuffer->type == COGL_FRAMEBUFFER_TYPE_ONSCREEN, 0); /* This should only be called when COGL_WINSYS_FEATURE_SWAP_BUFFERS_EVENT is advertised */ - g_return_val_if_fail (winsys->onscreen_add_swap_buffers_callback != NULL, 0); + _COGL_RETURN_VAL_IF_FAIL (winsys->onscreen_add_swap_buffers_callback != NULL, 0); return winsys->onscreen_add_swap_buffers_callback (onscreen, callback, @@ -276,7 +277,7 @@ cogl_framebuffer_remove_swap_buffers_callback (CoglFramebuffer *framebuffer, /* This should only be called when COGL_WINSYS_FEATURE_SWAP_BUFFERS_EVENT is advertised */ - g_return_if_fail (winsys->onscreen_remove_swap_buffers_callback != NULL); + _COGL_RETURN_IF_FAIL (winsys->onscreen_remove_swap_buffers_callback != NULL); winsys->onscreen_remove_swap_buffers_callback (onscreen, id); } diff --git a/cogl/cogl-path.c b/cogl/cogl-path.c index 116bd50bc..f6d262a77 100644 --- a/cogl/cogl-path.c +++ b/cogl/cogl-path.c @@ -28,6 +28,7 @@ #endif #include "cogl.h" +#include "cogl-util.h" #include "cogl-internal.h" #include "cogl-context-private.h" #include "cogl2-path.h" @@ -292,7 +293,7 @@ cogl_set_path (CoglPath *path) { _COGL_GET_CONTEXT (ctx, NO_RETVAL); - g_return_if_fail (cogl_is_path (path)); + _COGL_RETURN_IF_FAIL (cogl_is_path (path)); /* Reference the new object first in case it is the same as the old object */ diff --git a/cogl/cogl-pipeline-layer-state.c b/cogl/cogl-pipeline-layer-state.c index d87772fef..d06576395 100644 --- a/cogl/cogl-pipeline-layer-state.c +++ b/cogl/cogl-pipeline-layer-state.c @@ -288,7 +288,7 @@ get_texture_target (CoglTexture *texture) GLuint ignore_handle; GLenum gl_target; - g_return_val_if_fail (texture, 0); + _COGL_RETURN_VAL_IF_FAIL (texture, 0); cogl_texture_get_gl_texture (texture, &ignore_handle, &gl_target); @@ -395,7 +395,7 @@ public_to_internal_wrap_mode (CoglPipelineWrapMode mode) static CoglPipelineWrapMode internal_to_public_wrap_mode (CoglPipelineWrapModeInternal internal_mode) { - g_return_val_if_fail (internal_mode != + _COGL_RETURN_VAL_IF_FAIL (internal_mode != COGL_PIPELINE_WRAP_MODE_INTERNAL_CLAMP_TO_BORDER, COGL_PIPELINE_WRAP_MODE_AUTOMATIC); return (CoglPipelineWrapMode)internal_mode; @@ -412,7 +412,7 @@ cogl_pipeline_set_layer_wrap_mode_s (CoglPipeline *pipeline, CoglPipelineWrapModeInternal internal_mode = public_to_internal_wrap_mode (mode); - g_return_if_fail (cogl_is_pipeline (pipeline)); + _COGL_RETURN_IF_FAIL (cogl_is_pipeline (pipeline)); /* Note: this will ensure that the layer exists, creating one if it * doesn't already. @@ -443,7 +443,7 @@ cogl_pipeline_set_layer_wrap_mode_t (CoglPipeline *pipeline, CoglPipelineWrapModeInternal internal_mode = public_to_internal_wrap_mode (mode); - g_return_if_fail (cogl_is_pipeline (pipeline)); + _COGL_RETURN_IF_FAIL (cogl_is_pipeline (pipeline)); /* Note: this will ensure that the layer exists, creating one if it * doesn't already. @@ -486,7 +486,7 @@ cogl_pipeline_set_layer_wrap_mode_p (CoglPipeline *pipeline, CoglPipelineWrapModeInternal internal_mode = public_to_internal_wrap_mode (mode); - g_return_if_fail (cogl_is_pipeline (pipeline)); + _COGL_RETURN_IF_FAIL (cogl_is_pipeline (pipeline)); /* Note: this will ensure that the layer exists, creating one if it * doesn't already. @@ -517,7 +517,7 @@ cogl_pipeline_set_layer_wrap_mode (CoglPipeline *pipeline, CoglPipelineWrapModeInternal internal_mode = public_to_internal_wrap_mode (mode); - g_return_if_fail (cogl_is_pipeline (pipeline)); + _COGL_RETURN_IF_FAIL (cogl_is_pipeline (pipeline)); /* Note: this will ensure that the layer exists, creating one if it * doesn't already. @@ -546,7 +546,7 @@ _cogl_pipeline_layer_get_wrap_mode_s (CoglPipelineLayer *layer) CoglPipelineLayerState change = COGL_PIPELINE_LAYER_STATE_WRAP_MODES; CoglPipelineLayer *authority; - g_return_val_if_fail (_cogl_is_pipeline_layer (layer), FALSE); + _COGL_RETURN_VAL_IF_FAIL (_cogl_is_pipeline_layer (layer), FALSE); /* Now find the ancestor of the layer that is the authority for the * state we want to change */ @@ -560,7 +560,7 @@ cogl_pipeline_get_layer_wrap_mode_s (CoglPipeline *pipeline, int layer_index) { CoglPipelineLayer *layer; - g_return_val_if_fail (cogl_is_pipeline (pipeline), FALSE); + _COGL_RETURN_VAL_IF_FAIL (cogl_is_pipeline (pipeline), FALSE); /* Note: this will ensure that the layer exists, creating one if it * doesn't already. @@ -581,7 +581,7 @@ _cogl_pipeline_layer_get_wrap_mode_t (CoglPipelineLayer *layer) CoglPipelineLayerState change = COGL_PIPELINE_LAYER_STATE_WRAP_MODES; CoglPipelineLayer *authority; - g_return_val_if_fail (_cogl_is_pipeline_layer (layer), FALSE); + _COGL_RETURN_VAL_IF_FAIL (_cogl_is_pipeline_layer (layer), FALSE); /* Now find the ancestor of the layer that is the authority for the * state we want to change */ @@ -595,7 +595,7 @@ cogl_pipeline_get_layer_wrap_mode_t (CoglPipeline *pipeline, int layer_index) { CoglPipelineLayer *layer; - g_return_val_if_fail (cogl_is_pipeline (pipeline), FALSE); + _COGL_RETURN_VAL_IF_FAIL (cogl_is_pipeline (pipeline), FALSE); /* Note: this will ensure that the layer exists, creating one if it * doesn't already. @@ -624,7 +624,7 @@ cogl_pipeline_get_layer_wrap_mode_p (CoglPipeline *pipeline, int layer_index) { CoglPipelineLayer *layer; - g_return_val_if_fail (cogl_is_pipeline (pipeline), FALSE); + _COGL_RETURN_VAL_IF_FAIL (cogl_is_pipeline (pipeline), FALSE); /* Note: this will ensure that the layer exists, creating one if it * doesn't already. @@ -666,7 +666,7 @@ cogl_pipeline_set_layer_point_sprite_coords_enabled (CoglPipeline *pipeline, _COGL_GET_CONTEXT (ctx, FALSE); - g_return_val_if_fail (cogl_is_pipeline (pipeline), FALSE); + _COGL_RETURN_VAL_IF_FAIL (cogl_is_pipeline (pipeline), FALSE); /* Don't allow point sprite coordinates to be enabled if the driver doesn't support it */ @@ -758,7 +758,7 @@ cogl_pipeline_get_layer_point_sprite_coords_enabled (CoglPipeline *pipeline, CoglPipelineLayer *layer; CoglPipelineLayer *authority; - g_return_val_if_fail (cogl_is_pipeline (pipeline), FALSE); + _COGL_RETURN_VAL_IF_FAIL (cogl_is_pipeline (pipeline), FALSE); /* Note: this will ensure that the layer exists, creating one if it * doesn't already. @@ -1009,7 +1009,7 @@ cogl_pipeline_set_layer_combine (CoglPipeline *pipeline, GError *internal_error = NULL; int count; - g_return_val_if_fail (cogl_is_pipeline (pipeline), FALSE); + _COGL_RETURN_VAL_IF_FAIL (cogl_is_pipeline (pipeline), FALSE); /* Note: this will ensure that the layer exists, creating one if it * doesn't already. @@ -1119,7 +1119,7 @@ cogl_pipeline_set_layer_combine_constant (CoglPipeline *pipeline, CoglPipelineLayer *new; float color_as_floats[4]; - g_return_if_fail (cogl_is_pipeline (pipeline)); + _COGL_RETURN_IF_FAIL (cogl_is_pipeline (pipeline)); /* Note: this will ensure that the layer exists, creating one if it * doesn't already. @@ -1202,7 +1202,7 @@ _cogl_pipeline_get_layer_combine_constant (CoglPipeline *pipeline, CoglPipelineLayer *layer; CoglPipelineLayer *authority; - g_return_if_fail (cogl_is_pipeline (pipeline)); + _COGL_RETURN_IF_FAIL (cogl_is_pipeline (pipeline)); /* Note: this will ensure that the layer exists, creating one if it * doesn't already. @@ -1229,7 +1229,7 @@ _cogl_pipeline_get_layer_matrix (CoglPipeline *pipeline, int layer_index) CoglPipelineLayer *layer; CoglPipelineLayer *authority; - g_return_val_if_fail (cogl_is_pipeline (pipeline), NULL); + _COGL_RETURN_VAL_IF_FAIL (cogl_is_pipeline (pipeline), NULL); layer = _cogl_pipeline_get_layer (pipeline, layer_index); @@ -1247,7 +1247,7 @@ cogl_pipeline_set_layer_matrix (CoglPipeline *pipeline, CoglPipelineLayer *authority; CoglPipelineLayer *new; - g_return_if_fail (cogl_is_pipeline (pipeline)); + _COGL_RETURN_IF_FAIL (cogl_is_pipeline (pipeline)); /* Note: this will ensure that the layer exists, creating one if it * doesn't already. @@ -1311,7 +1311,7 @@ cogl_pipeline_set_layer_matrix (CoglPipeline *pipeline, CoglTexture * _cogl_pipeline_layer_get_texture (CoglPipelineLayer *layer) { - g_return_val_if_fail (_cogl_is_pipeline_layer (layer), NULL); + _COGL_RETURN_VAL_IF_FAIL (_cogl_is_pipeline_layer (layer), NULL); return _cogl_pipeline_layer_get_texture_real (layer); } @@ -1355,7 +1355,7 @@ _cogl_pipeline_get_layer_filters (CoglPipeline *pipeline, CoglPipelineLayer *layer; CoglPipelineLayer *authority; - g_return_if_fail (cogl_is_pipeline (pipeline)); + _COGL_RETURN_IF_FAIL (cogl_is_pipeline (pipeline)); layer = _cogl_pipeline_get_layer (pipeline, layer_index); @@ -1396,7 +1396,7 @@ _cogl_pipeline_layer_get_min_filter (CoglPipelineLayer *layer) { CoglPipelineLayer *authority; - g_return_val_if_fail (_cogl_is_pipeline_layer (layer), 0); + _COGL_RETURN_VAL_IF_FAIL (_cogl_is_pipeline_layer (layer), 0); authority = _cogl_pipeline_layer_get_authority (layer, @@ -1410,7 +1410,7 @@ _cogl_pipeline_layer_get_mag_filter (CoglPipelineLayer *layer) { CoglPipelineLayer *authority; - g_return_val_if_fail (_cogl_is_pipeline_layer (layer), 0); + _COGL_RETURN_VAL_IF_FAIL (_cogl_is_pipeline_layer (layer), 0); authority = _cogl_pipeline_layer_get_authority (layer, @@ -1430,7 +1430,7 @@ cogl_pipeline_set_layer_filters (CoglPipeline *pipeline, CoglPipelineLayer *authority; CoglPipelineLayer *new; - g_return_if_fail (cogl_is_pipeline (pipeline)); + _COGL_RETURN_IF_FAIL (cogl_is_pipeline (pipeline)); /* Note: this will ensure that the layer exists, creating one if it * doesn't already. diff --git a/cogl/cogl-pipeline-layer.c b/cogl/cogl-pipeline-layer.c index 1e71a0652..0b5693fe1 100644 --- a/cogl/cogl-pipeline-layer.c +++ b/cogl/cogl-pipeline-layer.c @@ -29,6 +29,7 @@ #include "config.h" #endif +#include "cogl-util.h" #include "cogl-context-private.h" #include "cogl-texture-private.h" @@ -235,7 +236,7 @@ _cogl_pipeline_layer_pre_change_notify (CoglPipeline *required_owner, goto init_layer_state; /* We only allow a NULL required_owner for new layers */ - g_return_val_if_fail (required_owner != NULL, layer); + _COGL_RETURN_VAL_IF_FAIL (required_owner != NULL, layer); /* Chain up: * A modification of a layer is indirectly also a modification of diff --git a/cogl/cogl-pipeline-progend-glsl.c b/cogl/cogl-pipeline-progend-glsl.c index 15273f997..c82bc76fa 100644 --- a/cogl/cogl-pipeline-progend-glsl.c +++ b/cogl/cogl-pipeline-progend-glsl.c @@ -29,6 +29,7 @@ #include "config.h" #endif +#include "cogl-util.h" #include "cogl-context-private.h" #include "cogl-pipeline-private.h" #include "cogl-pipeline-opengl-private.h" @@ -168,8 +169,8 @@ _cogl_pipeline_progend_glsl_get_position_attribute (CoglPipeline *pipeline) _COGL_GET_CONTEXT (ctx, -1); - g_return_val_if_fail (program_state != NULL, -1); - g_return_val_if_fail (program_state->program != 0, -1); + _COGL_RETURN_VAL_IF_FAIL (program_state != NULL, -1); + _COGL_RETURN_VAL_IF_FAIL (program_state->program != 0, -1); if (program_state->position_attribute_location == ATTRIBUTE_LOCATION_UNKNOWN) GE_RET( program_state->position_attribute_location, @@ -186,8 +187,8 @@ _cogl_pipeline_progend_glsl_get_color_attribute (CoglPipeline *pipeline) _COGL_GET_CONTEXT (ctx, -1); - g_return_val_if_fail (program_state != NULL, -1); - g_return_val_if_fail (program_state->program != 0, -1); + _COGL_RETURN_VAL_IF_FAIL (program_state != NULL, -1); + _COGL_RETURN_VAL_IF_FAIL (program_state->program != 0, -1); if (program_state->color_attribute_location == ATTRIBUTE_LOCATION_UNKNOWN) GE_RET( program_state->color_attribute_location, @@ -204,8 +205,8 @@ _cogl_pipeline_progend_glsl_get_normal_attribute (CoglPipeline *pipeline) _COGL_GET_CONTEXT (ctx, -1); - g_return_val_if_fail (program_state != NULL, -1); - g_return_val_if_fail (program_state->program != 0, -1); + _COGL_RETURN_VAL_IF_FAIL (program_state != NULL, -1); + _COGL_RETURN_VAL_IF_FAIL (program_state->program != 0, -1); if (program_state->normal_attribute_location == ATTRIBUTE_LOCATION_UNKNOWN) GE_RET( program_state->normal_attribute_location, @@ -223,8 +224,8 @@ _cogl_pipeline_progend_glsl_get_tex_coord_attribute (CoglPipeline *pipeline, _COGL_GET_CONTEXT (ctx, -1); - g_return_val_if_fail (program_state != NULL, -1); - g_return_val_if_fail (program_state->program != 0, -1); + _COGL_RETURN_VAL_IF_FAIL (program_state != NULL, -1); + _COGL_RETURN_VAL_IF_FAIL (program_state->program != 0, -1); if (unit == 0) { @@ -921,7 +922,7 @@ _cogl_pipeline_progend_glsl_pre_paint (CoglPipeline *pipeline) /* We only need to update the matrices if we're using the the GLSL vertend, but this is a requirement on GLES2 anyway */ - g_return_if_fail (pipeline->vertend == COGL_PIPELINE_VERTEND_GLSL); + _COGL_RETURN_IF_FAIL (pipeline->vertend == COGL_PIPELINE_VERTEND_GLSL); program_state = get_program_state (pipeline); diff --git a/cogl/cogl-pipeline-state.c b/cogl/cogl-pipeline-state.c index 45beb7581..78102d866 100644 --- a/cogl/cogl-pipeline-state.c +++ b/cogl/cogl-pipeline-state.c @@ -47,7 +47,7 @@ _cogl_pipeline_get_user_program (CoglPipeline *pipeline) { CoglPipeline *authority; - g_return_val_if_fail (cogl_is_pipeline (pipeline), NULL); + _COGL_RETURN_VAL_IF_FAIL (cogl_is_pipeline (pipeline), NULL); authority = _cogl_pipeline_get_authority (pipeline, COGL_PIPELINE_STATE_USER_SHADER); @@ -244,7 +244,7 @@ cogl_pipeline_get_color (CoglPipeline *pipeline, { CoglPipeline *authority; - g_return_if_fail (cogl_is_pipeline (pipeline)); + _COGL_RETURN_IF_FAIL (cogl_is_pipeline (pipeline)); authority = _cogl_pipeline_get_authority (pipeline, COGL_PIPELINE_STATE_COLOR); @@ -270,7 +270,7 @@ cogl_pipeline_set_color (CoglPipeline *pipeline, CoglPipelineState state = COGL_PIPELINE_STATE_COLOR; CoglPipeline *authority; - g_return_if_fail (cogl_is_pipeline (pipeline)); + _COGL_RETURN_IF_FAIL (cogl_is_pipeline (pipeline)); authority = _cogl_pipeline_get_authority (pipeline, state); @@ -321,7 +321,7 @@ _cogl_pipeline_get_blend_enabled (CoglPipeline *pipeline) { CoglPipeline *authority; - g_return_val_if_fail (cogl_is_pipeline (pipeline), FALSE); + _COGL_RETURN_VAL_IF_FAIL (cogl_is_pipeline (pipeline), FALSE); authority = _cogl_pipeline_get_authority (pipeline, COGL_PIPELINE_STATE_BLEND_ENABLE); @@ -342,9 +342,9 @@ _cogl_pipeline_set_blend_enabled (CoglPipeline *pipeline, CoglPipelineState state = COGL_PIPELINE_STATE_BLEND_ENABLE; CoglPipeline *authority; - g_return_if_fail (cogl_is_pipeline (pipeline)); - g_return_if_fail (enable > 1 && - "don't pass TRUE or FALSE to _set_blend_enabled!"); + _COGL_RETURN_IF_FAIL (cogl_is_pipeline (pipeline)); + _COGL_RETURN_IF_FAIL (enable > 1 && + "don't pass TRUE or FALSE to _set_blend_enabled!"); authority = _cogl_pipeline_get_authority (pipeline, state); @@ -372,7 +372,7 @@ cogl_pipeline_get_ambient (CoglPipeline *pipeline, { CoglPipeline *authority; - g_return_if_fail (cogl_is_pipeline (pipeline)); + _COGL_RETURN_IF_FAIL (cogl_is_pipeline (pipeline)); authority = _cogl_pipeline_get_authority (pipeline, COGL_PIPELINE_STATE_LIGHTING); @@ -389,7 +389,7 @@ cogl_pipeline_set_ambient (CoglPipeline *pipeline, CoglPipeline *authority; CoglPipelineLightingState *lighting_state; - g_return_if_fail (cogl_is_pipeline (pipeline)); + _COGL_RETURN_IF_FAIL (cogl_is_pipeline (pipeline)); authority = _cogl_pipeline_get_authority (pipeline, state); @@ -422,7 +422,7 @@ cogl_pipeline_get_diffuse (CoglPipeline *pipeline, { CoglPipeline *authority; - g_return_if_fail (cogl_is_pipeline (pipeline)); + _COGL_RETURN_IF_FAIL (cogl_is_pipeline (pipeline)); authority = _cogl_pipeline_get_authority (pipeline, COGL_PIPELINE_STATE_LIGHTING); @@ -439,7 +439,7 @@ cogl_pipeline_set_diffuse (CoglPipeline *pipeline, CoglPipeline *authority; CoglPipelineLightingState *lighting_state; - g_return_if_fail (cogl_is_pipeline (pipeline)); + _COGL_RETURN_IF_FAIL (cogl_is_pipeline (pipeline)); authority = _cogl_pipeline_get_authority (pipeline, state); @@ -481,7 +481,7 @@ cogl_pipeline_get_specular (CoglPipeline *pipeline, { CoglPipeline *authority; - g_return_if_fail (cogl_is_pipeline (pipeline)); + _COGL_RETURN_IF_FAIL (cogl_is_pipeline (pipeline)); authority = _cogl_pipeline_get_authority (pipeline, COGL_PIPELINE_STATE_LIGHTING); @@ -497,7 +497,7 @@ cogl_pipeline_set_specular (CoglPipeline *pipeline, const CoglColor *specular) CoglPipelineState state = COGL_PIPELINE_STATE_LIGHTING; CoglPipelineLightingState *lighting_state; - g_return_if_fail (cogl_is_pipeline (pipeline)); + _COGL_RETURN_IF_FAIL (cogl_is_pipeline (pipeline)); authority = _cogl_pipeline_get_authority (pipeline, state); @@ -529,7 +529,7 @@ cogl_pipeline_get_shininess (CoglPipeline *pipeline) { CoglPipeline *authority; - g_return_val_if_fail (cogl_is_pipeline (pipeline), 0); + _COGL_RETURN_VAL_IF_FAIL (cogl_is_pipeline (pipeline), 0); authority = _cogl_pipeline_get_authority (pipeline, COGL_PIPELINE_STATE_LIGHTING); @@ -545,7 +545,7 @@ cogl_pipeline_set_shininess (CoglPipeline *pipeline, CoglPipelineState state = COGL_PIPELINE_STATE_LIGHTING; CoglPipelineLightingState *lighting_state; - g_return_if_fail (cogl_is_pipeline (pipeline)); + _COGL_RETURN_IF_FAIL (cogl_is_pipeline (pipeline)); if (shininess < 0.0) { @@ -581,7 +581,7 @@ cogl_pipeline_get_emission (CoglPipeline *pipeline, { CoglPipeline *authority; - g_return_if_fail (cogl_is_pipeline (pipeline)); + _COGL_RETURN_IF_FAIL (cogl_is_pipeline (pipeline)); authority = _cogl_pipeline_get_authority (pipeline, COGL_PIPELINE_STATE_LIGHTING); @@ -597,7 +597,7 @@ cogl_pipeline_set_emission (CoglPipeline *pipeline, const CoglColor *emission) CoglPipelineState state = COGL_PIPELINE_STATE_LIGHTING; CoglPipelineLightingState *lighting_state; - g_return_if_fail (cogl_is_pipeline (pipeline)); + _COGL_RETURN_IF_FAIL (cogl_is_pipeline (pipeline)); authority = _cogl_pipeline_get_authority (pipeline, state); @@ -632,7 +632,7 @@ _cogl_pipeline_set_alpha_test_function (CoglPipeline *pipeline, CoglPipeline *authority; CoglPipelineAlphaFuncState *alpha_state; - g_return_if_fail (cogl_is_pipeline (pipeline)); + _COGL_RETURN_IF_FAIL (cogl_is_pipeline (pipeline)); authority = _cogl_pipeline_get_authority (pipeline, state); @@ -662,7 +662,7 @@ _cogl_pipeline_set_alpha_test_function_reference (CoglPipeline *pipeline, CoglPipeline *authority; CoglPipelineAlphaFuncState *alpha_state; - g_return_if_fail (cogl_is_pipeline (pipeline)); + _COGL_RETURN_IF_FAIL (cogl_is_pipeline (pipeline)); authority = _cogl_pipeline_get_authority (pipeline, state); @@ -699,7 +699,7 @@ cogl_pipeline_get_alpha_test_function (CoglPipeline *pipeline) { CoglPipeline *authority; - g_return_val_if_fail (cogl_is_pipeline (pipeline), 0); + _COGL_RETURN_VAL_IF_FAIL (cogl_is_pipeline (pipeline), 0); authority = _cogl_pipeline_get_authority (pipeline, COGL_PIPELINE_STATE_ALPHA_FUNC); @@ -712,7 +712,7 @@ cogl_pipeline_get_alpha_test_reference (CoglPipeline *pipeline) { CoglPipeline *authority; - g_return_val_if_fail (cogl_is_pipeline (pipeline), 0.0f); + _COGL_RETURN_VAL_IF_FAIL (cogl_is_pipeline (pipeline), 0.0f); authority = _cogl_pipeline_get_authority (pipeline, @@ -828,7 +828,7 @@ cogl_pipeline_set_blend (CoglPipeline *pipeline, _COGL_GET_CONTEXT (ctx, FALSE); - g_return_val_if_fail (cogl_is_pipeline (pipeline), FALSE); + _COGL_RETURN_VAL_IF_FAIL (cogl_is_pipeline (pipeline), FALSE); count = _cogl_blend_string_compile (blend_description, @@ -922,7 +922,7 @@ cogl_pipeline_set_blend_constant (CoglPipeline *pipeline, { _COGL_GET_CONTEXT (ctx, NO_RETVAL); - g_return_if_fail (cogl_is_pipeline (pipeline)); + _COGL_RETURN_IF_FAIL (cogl_is_pipeline (pipeline)); if (ctx->driver == COGL_DRIVER_GLES1) return; @@ -962,7 +962,7 @@ cogl_pipeline_get_user_program (CoglPipeline *pipeline) { CoglPipeline *authority; - g_return_val_if_fail (cogl_is_pipeline (pipeline), COGL_INVALID_HANDLE); + _COGL_RETURN_VAL_IF_FAIL (cogl_is_pipeline (pipeline), COGL_INVALID_HANDLE); authority = _cogl_pipeline_get_authority (pipeline, COGL_PIPELINE_STATE_USER_SHADER); @@ -983,7 +983,7 @@ cogl_pipeline_set_user_program (CoglPipeline *pipeline, CoglPipelineState state = COGL_PIPELINE_STATE_USER_SHADER; CoglPipeline *authority; - g_return_if_fail (cogl_is_pipeline (pipeline)); + _COGL_RETURN_IF_FAIL (cogl_is_pipeline (pipeline)); authority = _cogl_pipeline_get_authority (pipeline, state); @@ -1046,8 +1046,8 @@ cogl_pipeline_set_depth_state (CoglPipeline *pipeline, _COGL_GET_CONTEXT (ctx, FALSE); - g_return_val_if_fail (cogl_is_pipeline (pipeline), FALSE); - g_return_val_if_fail (depth_state->magic == COGL_DEPTH_STATE_MAGIC, FALSE); + _COGL_RETURN_VAL_IF_FAIL (cogl_is_pipeline (pipeline), FALSE); + _COGL_RETURN_VAL_IF_FAIL (depth_state->magic == COGL_DEPTH_STATE_MAGIC, FALSE); authority = _cogl_pipeline_get_authority (pipeline, state); @@ -1091,7 +1091,7 @@ cogl_pipeline_get_depth_state (CoglPipeline *pipeline, { CoglPipeline *authority; - g_return_if_fail (cogl_is_pipeline (pipeline)); + _COGL_RETURN_IF_FAIL (cogl_is_pipeline (pipeline)); authority = _cogl_pipeline_get_authority (pipeline, COGL_PIPELINE_STATE_DEPTH); @@ -1103,7 +1103,7 @@ cogl_pipeline_get_color_mask (CoglPipeline *pipeline) { CoglPipeline *authority; - g_return_val_if_fail (cogl_is_pipeline (pipeline), 0); + _COGL_RETURN_VAL_IF_FAIL (cogl_is_pipeline (pipeline), 0); authority = _cogl_pipeline_get_authority (pipeline, COGL_PIPELINE_STATE_LOGIC_OPS); @@ -1119,7 +1119,7 @@ cogl_pipeline_set_color_mask (CoglPipeline *pipeline, CoglPipeline *authority; CoglPipelineLogicOpsState *logic_ops_state; - g_return_if_fail (cogl_is_pipeline (pipeline)); + _COGL_RETURN_IF_FAIL (cogl_is_pipeline (pipeline)); authority = _cogl_pipeline_get_authority (pipeline, state); @@ -1149,7 +1149,7 @@ _cogl_pipeline_set_fog_state (CoglPipeline *pipeline, CoglPipeline *authority; CoglPipelineFogState *current_fog_state; - g_return_if_fail (cogl_is_pipeline (pipeline)); + _COGL_RETURN_IF_FAIL (cogl_is_pipeline (pipeline)); authority = _cogl_pipeline_get_authority (pipeline, state); @@ -1185,7 +1185,7 @@ _cogl_pipeline_set_cull_face_state (CoglPipeline *pipeline, CoglPipeline *authority; CoglPipelineCullFaceState *current_cull_face_state; - g_return_if_fail (cogl_is_pipeline (pipeline)); + _COGL_RETURN_IF_FAIL (cogl_is_pipeline (pipeline)); authority = _cogl_pipeline_get_authority (pipeline, state); @@ -1214,8 +1214,8 @@ _cogl_pipeline_get_cull_face_mode (CoglPipeline *pipeline) CoglPipelineState state = COGL_PIPELINE_STATE_CULL_FACE; CoglPipeline *authority; - g_return_val_if_fail (cogl_is_pipeline (pipeline), - COGL_PIPELINE_CULL_FACE_MODE_NONE); + _COGL_RETURN_VAL_IF_FAIL (cogl_is_pipeline (pipeline), + COGL_PIPELINE_CULL_FACE_MODE_NONE); authority = _cogl_pipeline_get_authority (pipeline, state); @@ -1227,7 +1227,7 @@ cogl_pipeline_get_point_size (CoglPipeline *pipeline) { CoglPipeline *authority; - g_return_val_if_fail (cogl_is_pipeline (pipeline), FALSE); + _COGL_RETURN_VAL_IF_FAIL (cogl_is_pipeline (pipeline), FALSE); authority = _cogl_pipeline_get_authority (pipeline, COGL_PIPELINE_STATE_POINT_SIZE); @@ -1242,7 +1242,7 @@ cogl_pipeline_set_point_size (CoglPipeline *pipeline, CoglPipelineState state = COGL_PIPELINE_STATE_POINT_SIZE; CoglPipeline *authority; - g_return_if_fail (cogl_is_pipeline (pipeline)); + _COGL_RETURN_IF_FAIL (cogl_is_pipeline (pipeline)); authority = _cogl_pipeline_get_authority (pipeline, state); diff --git a/cogl/cogl-pipeline.c b/cogl/cogl-pipeline.c index 0af701417..60e96eb22 100644 --- a/cogl/cogl-pipeline.c +++ b/cogl/cogl-pipeline.c @@ -297,7 +297,7 @@ _cogl_pipeline_promote_weak_ancestors (CoglPipeline *strong) { CoglNode *n; - g_return_if_fail (!strong->is_weak); + _COGL_RETURN_IF_FAIL (!strong->is_weak); /* If the parent of strong is weak, then we want to promote it by taking a reference on strong's grandparent. We don't need to take @@ -319,7 +319,7 @@ _cogl_pipeline_revert_weak_ancestors (CoglPipeline *strong) { CoglNode *n; - g_return_if_fail (!strong->is_weak); + _COGL_RETURN_IF_FAIL (!strong->is_weak); /* This reverts the effect of calling _cogl_pipeline_promote_weak_ancestors */ @@ -478,7 +478,7 @@ _cogl_pipeline_free (CoglPipeline *pipeline) gboolean _cogl_pipeline_get_real_blend_enabled (CoglPipeline *pipeline) { - g_return_val_if_fail (cogl_is_pipeline (pipeline), FALSE); + _COGL_RETURN_VAL_IF_FAIL (cogl_is_pipeline (pipeline), FALSE); return pipeline->real_blend_enable; } @@ -583,7 +583,7 @@ _cogl_pipeline_foreach_layer_internal (CoglPipeline *pipeline, for (i = 0, cont = TRUE; i < n_layers && cont == TRUE; i++) { - g_return_if_fail (authority->layers_cache_dirty == FALSE); + _COGL_RETURN_IF_FAIL (authority->layers_cache_dirty == FALSE); cont = callback (authority->layers_cache[i], user_data); } } @@ -945,7 +945,7 @@ _cogl_pipeline_init_multi_property_sparse_state (CoglPipeline *pipeline, { CoglPipeline *authority; - g_return_if_fail (change & COGL_PIPELINE_STATE_ALL_SPARSE); + _COGL_RETURN_IF_FAIL (change & COGL_PIPELINE_STATE_ALL_SPARSE); if (!(change & COGL_PIPELINE_STATE_MULTI_PROPERTY)) return; @@ -1285,7 +1285,7 @@ _cogl_pipeline_add_layer_difference (CoglPipeline *pipeline, CoglPipelineLayer *layer, gboolean inc_n_layers) { - g_return_if_fail (layer->owner == NULL); + _COGL_RETURN_IF_FAIL (layer->owner == NULL); layer->owner = pipeline; cogl_object_ref (layer); @@ -1319,7 +1319,7 @@ _cogl_pipeline_remove_layer_difference (CoglPipeline *pipeline, CoglPipelineLayer *layer, gboolean dec_n_layers) { - g_return_if_fail (layer->owner == pipeline); + _COGL_RETURN_IF_FAIL (layer->owner == pipeline); /* - Flush journal primitives referencing the current state. * - Make sure the pipeline has no dependants so it may be modified. @@ -1692,7 +1692,7 @@ _cogl_pipeline_prune_empty_layer_difference (CoglPipeline *layers_authority, CoglPipelineLayerInfo layer_info; CoglPipeline *old_layers_authority; - g_return_if_fail (link != NULL); + _COGL_RETURN_IF_FAIL (link != NULL); /* If the layer's parent doesn't have an owner then we can simply * take ownership ourselves and drop our reference on the empty @@ -2289,7 +2289,7 @@ _cogl_pipeline_get_fog_enabled (CoglPipeline *pipeline) { CoglPipeline *authority; - g_return_val_if_fail (cogl_is_pipeline (pipeline), FALSE); + _COGL_RETURN_VAL_IF_FAIL (cogl_is_pipeline (pipeline), FALSE); authority = _cogl_pipeline_get_authority (pipeline, COGL_PIPELINE_STATE_FOG); @@ -2299,7 +2299,7 @@ _cogl_pipeline_get_fog_enabled (CoglPipeline *pipeline) unsigned long _cogl_pipeline_get_age (CoglPipeline *pipeline) { - g_return_val_if_fail (cogl_is_pipeline (pipeline), 0); + _COGL_RETURN_VAL_IF_FAIL (cogl_is_pipeline (pipeline), 0); return pipeline->age; } @@ -2311,7 +2311,7 @@ cogl_pipeline_remove_layer (CoglPipeline *pipeline, int layer_index) CoglPipelineLayerInfo layer_info; int i; - g_return_if_fail (cogl_is_pipeline (pipeline)); + _COGL_RETURN_IF_FAIL (cogl_is_pipeline (pipeline)); authority = _cogl_pipeline_get_authority (pipeline, COGL_PIPELINE_STATE_LAYERS); @@ -2374,7 +2374,7 @@ prepend_layer_to_list_cb (CoglPipelineLayer *layer, const GList * _cogl_pipeline_get_layers (CoglPipeline *pipeline) { - g_return_val_if_fail (cogl_is_pipeline (pipeline), NULL); + _COGL_RETURN_VAL_IF_FAIL (cogl_is_pipeline (pipeline), NULL); if (!pipeline->deprecated_get_layers_list_dirty) g_list_free (pipeline->deprecated_get_layers_list); @@ -2397,7 +2397,7 @@ cogl_pipeline_get_n_layers (CoglPipeline *pipeline) { CoglPipeline *authority; - g_return_val_if_fail (cogl_is_pipeline (pipeline), 0); + _COGL_RETURN_VAL_IF_FAIL (cogl_is_pipeline (pipeline), 0); authority = _cogl_pipeline_get_authority (pipeline, COGL_PIPELINE_STATE_LAYERS); diff --git a/cogl/cogl-primitive.c b/cogl/cogl-primitive.c index cba40ff57..b2232de25 100644 --- a/cogl/cogl-primitive.c +++ b/cogl/cogl-primitive.c @@ -29,6 +29,7 @@ #include "config.h" #endif +#include "cogl-util.h" #include "cogl-object-private.h" #include "cogl-primitive.h" #include "cogl-primitive-private.h" @@ -66,7 +67,7 @@ cogl_primitive_new_with_attributes (CoglVerticesMode mode, CoglAttribute *attribute = attributes[i]; cogl_object_ref (attribute); - g_return_val_if_fail (cogl_is_attribute (attribute), NULL); + _COGL_RETURN_VAL_IF_FAIL (cogl_is_attribute (attribute), NULL); primitive->attributes[i] = attribute; } @@ -393,7 +394,7 @@ cogl_primitive_set_attributes (CoglPrimitive *primitive, { int i; - g_return_if_fail (cogl_is_primitive (primitive)); + _COGL_RETURN_IF_FAIL (cogl_is_primitive (primitive)); if (G_UNLIKELY (primitive->immutable_ref)) { @@ -406,7 +407,7 @@ cogl_primitive_set_attributes (CoglPrimitive *primitive, * attribute thats actually in the new list too. */ for (i = 0; i < n_attributes; i++) { - g_return_if_fail (cogl_is_attribute (attributes[i])); + _COGL_RETURN_IF_FAIL (cogl_is_attribute (attributes[i])); cogl_object_ref (attributes[i]); } @@ -442,7 +443,7 @@ cogl_primitive_set_attributes (CoglPrimitive *primitive, int cogl_primitive_get_first_vertex (CoglPrimitive *primitive) { - g_return_val_if_fail (cogl_is_primitive (primitive), 0); + _COGL_RETURN_VAL_IF_FAIL (cogl_is_primitive (primitive), 0); return primitive->first_vertex; } @@ -451,7 +452,7 @@ void cogl_primitive_set_first_vertex (CoglPrimitive *primitive, int first_vertex) { - g_return_if_fail (cogl_is_primitive (primitive)); + _COGL_RETURN_IF_FAIL (cogl_is_primitive (primitive)); if (G_UNLIKELY (primitive->immutable_ref)) { @@ -465,7 +466,7 @@ cogl_primitive_set_first_vertex (CoglPrimitive *primitive, int cogl_primitive_get_n_vertices (CoglPrimitive *primitive) { - g_return_val_if_fail (cogl_is_primitive (primitive), 0); + _COGL_RETURN_VAL_IF_FAIL (cogl_is_primitive (primitive), 0); return primitive->n_vertices; } @@ -474,7 +475,7 @@ void cogl_primitive_set_n_vertices (CoglPrimitive *primitive, int n_vertices) { - g_return_if_fail (cogl_is_primitive (primitive)); + _COGL_RETURN_IF_FAIL (cogl_is_primitive (primitive)); primitive->n_vertices = n_vertices; } @@ -482,7 +483,7 @@ cogl_primitive_set_n_vertices (CoglPrimitive *primitive, CoglVerticesMode cogl_primitive_get_mode (CoglPrimitive *primitive) { - g_return_val_if_fail (cogl_is_primitive (primitive), 0); + _COGL_RETURN_VAL_IF_FAIL (cogl_is_primitive (primitive), 0); return primitive->mode; } @@ -491,7 +492,7 @@ void cogl_primitive_set_mode (CoglPrimitive *primitive, CoglVerticesMode mode) { - g_return_if_fail (cogl_is_primitive (primitive)); + _COGL_RETURN_IF_FAIL (cogl_is_primitive (primitive)); if (G_UNLIKELY (primitive->immutable_ref)) { @@ -506,7 +507,7 @@ void cogl_primitive_set_indices (CoglPrimitive *primitive, CoglIndices *indices) { - g_return_if_fail (cogl_is_primitive (primitive)); + _COGL_RETURN_IF_FAIL (cogl_is_primitive (primitive)); if (G_UNLIKELY (primitive->immutable_ref)) { @@ -526,7 +527,7 @@ _cogl_primitive_immutable_ref (CoglPrimitive *primitive) { int i; - g_return_val_if_fail (cogl_is_primitive (primitive), NULL); + _COGL_RETURN_VAL_IF_FAIL (cogl_is_primitive (primitive), NULL); primitive->immutable_ref++; @@ -541,8 +542,8 @@ _cogl_primitive_immutable_unref (CoglPrimitive *primitive) { int i; - g_return_if_fail (cogl_is_primitive (primitive)); - g_return_if_fail (primitive->immutable_ref > 0); + _COGL_RETURN_IF_FAIL (cogl_is_primitive (primitive)); + _COGL_RETURN_IF_FAIL (primitive->immutable_ref > 0); primitive->immutable_ref--; diff --git a/cogl/cogl-program.c b/cogl/cogl-program.c index 044c284c3..51d5baa3e 100644 --- a/cogl/cogl-program.c +++ b/cogl/cogl-program.c @@ -27,6 +27,7 @@ #include "cogl.h" +#include "cogl-util.h" #include "cogl-internal.h" #include "cogl-context-private.h" #include "cogl-handle.h" @@ -107,9 +108,9 @@ cogl_program_attach_shader (CoglHandle program_handle, /* Only one shader is allowed if the type is ARBfp */ if (shader->language == COGL_SHADER_LANGUAGE_ARBFP) - g_return_if_fail (program->attached_shaders == NULL); + _COGL_RETURN_IF_FAIL (program->attached_shaders == NULL); else if (shader->language == COGL_SHADER_LANGUAGE_GLSL) - g_return_if_fail (_cogl_program_get_language (program) == + _COGL_RETURN_IF_FAIL (_cogl_program_get_language (program) == COGL_SHADER_LANGUAGE_GLSL); program->attached_shaders @@ -132,7 +133,7 @@ cogl_program_use (CoglHandle handle) { _COGL_GET_CONTEXT (ctx, NO_RETVAL); - g_return_if_fail (handle == COGL_INVALID_HANDLE || + _COGL_RETURN_IF_FAIL (handle == COGL_INVALID_HANDLE || cogl_is_program (handle)); if (ctx->current_program == 0 && handle != 0) @@ -202,8 +203,8 @@ cogl_program_uniform_x (CoglHandle handle, _COGL_GET_CONTEXT (ctx, NO_RETVAL); - g_return_if_fail (cogl_is_program (handle)); - g_return_if_fail (program != NULL); + _COGL_RETURN_IF_FAIL (cogl_is_program (handle)); + _COGL_RETURN_IF_FAIL (program != NULL); if (uniform_no >= 0 && uniform_no < program->custom_uniforms->len && size >= 1 && size <= 4 && count >= 1) @@ -342,7 +343,7 @@ cogl_program_set_uniform_matrix (CoglHandle handle, gboolean transpose, const float *value) { - g_return_if_fail (cogl_is_program (handle)); + _COGL_RETURN_IF_FAIL (cogl_is_program (handle)); cogl_program_uniform_x (handle, uniform_location, dimensions, count, @@ -383,13 +384,13 @@ get_local_param_index (const char *uniform_name) *p++ = input[i]; input[i] = '\0'; - g_return_val_if_fail (strncmp ("program.local[", input, 14) == 0, -1); + _COGL_RETURN_VAL_IF_FAIL (strncmp ("program.local[", input, 14) == 0, -1); _index = g_ascii_strtoull (input + 14, &endptr, 10); - g_return_val_if_fail (endptr != input + 14, -1); - g_return_val_if_fail (*endptr == ']', -1); + _COGL_RETURN_VAL_IF_FAIL (endptr != input + 14, -1); + _COGL_RETURN_VAL_IF_FAIL (*endptr == ']', -1); - g_return_val_if_fail (_index >= 0, -1); + _COGL_RETURN_VAL_IF_FAIL (_index >= 0, -1); g_free (input); @@ -484,9 +485,9 @@ _cogl_program_flush_uniform_arbfp (GLint location, if (value->type != COGL_BOXED_NONE) { - g_return_if_fail (value->type == COGL_BOXED_FLOAT); - g_return_if_fail (value->size == 4); - g_return_if_fail (value->count == 1); + _COGL_RETURN_IF_FAIL (value->type == COGL_BOXED_FLOAT); + _COGL_RETURN_IF_FAIL (value->size == 4); + _COGL_RETURN_IF_FAIL (value->count == 1); GE( ctx, glProgramLocalParameter4fv (GL_FRAGMENT_PROGRAM_ARB, location, value->v.float_value) ); @@ -505,7 +506,7 @@ _cogl_program_flush_uniforms (CoglProgram *program, _COGL_GET_CONTEXT (ctx, NO_RETVAL); - g_return_if_fail (ctx->driver != COGL_DRIVER_GLES1); + _COGL_RETURN_IF_FAIL (ctx->driver != COGL_DRIVER_GLES1); for (i = 0; i < program->custom_uniforms->len; i++) { diff --git a/cogl/cogl-quaternion.c b/cogl/cogl-quaternion.c index 9403fc7ca..602c27642 100644 --- a/cogl/cogl-quaternion.c +++ b/cogl/cogl-quaternion.c @@ -35,6 +35,7 @@ */ #include +#include #include #include #include @@ -319,8 +320,8 @@ cogl_quaternion_equal (gconstpointer v1, gconstpointer v2) const CoglQuaternion *a = v1; const CoglQuaternion *b = v2; - g_return_val_if_fail (v1 != NULL, FALSE); - g_return_val_if_fail (v2 != NULL, FALSE); + _COGL_RETURN_VAL_IF_FAIL (v1 != NULL, FALSE); + _COGL_RETURN_VAL_IF_FAIL (v2 != NULL, FALSE); if (v1 == v2) return TRUE; @@ -486,7 +487,7 @@ cogl_quaternion_slerp (CoglQuaternion *result, float fa; float fb; - g_return_if_fail (t >=0 && t <= 1.0f); + _COGL_RETURN_IF_FAIL (t >=0 && t <= 1.0f); if (t == 0) { @@ -573,7 +574,7 @@ cogl_quaternion_nlerp (CoglQuaternion *result, float fa; float fb; - g_return_if_fail (t >=0 && t <= 1.0f); + _COGL_RETURN_IF_FAIL (t >=0 && t <= 1.0f); if (t == 0) { diff --git a/cogl/cogl-rectangle-map.c b/cogl/cogl-rectangle-map.c index 60b6e79d6..a483a56df 100644 --- a/cogl/cogl-rectangle-map.c +++ b/cogl/cogl-rectangle-map.c @@ -30,6 +30,7 @@ #include +#include "cogl-util.h" #include "cogl-rectangle-map.h" #include "cogl-debug.h" @@ -354,7 +355,7 @@ _cogl_rectangle_map_add (CoglRectangleMap *map, /* Zero-sized rectangles break the algorithm for removing rectangles so we'll disallow them */ - g_return_val_if_fail (width > 0 && height > 0, FALSE); + _COGL_RETURN_VAL_IF_FAIL (width > 0 && height > 0, FALSE); /* Start with the root node */ g_array_set_size (stack, 0); diff --git a/cogl/cogl-renderer.c b/cogl/cogl-renderer.c index 0ca3edd2e..5cc6ed993 100644 --- a/cogl/cogl-renderer.c +++ b/cogl/cogl-renderer.c @@ -32,6 +32,7 @@ #include #include "cogl.h" +#include "cogl-util.h" #include "cogl-internal.h" #include "cogl-private.h" #include "cogl-object.h" @@ -133,10 +134,10 @@ void cogl_xlib_renderer_set_foreign_display (CoglRenderer *renderer, Display *xdisplay) { - g_return_if_fail (cogl_is_renderer (renderer)); + _COGL_RETURN_IF_FAIL (cogl_is_renderer (renderer)); /* NB: Renderers are considered immutable once connected */ - g_return_if_fail (!renderer->connected); + _COGL_RETURN_IF_FAIL (!renderer->connected); renderer->foreign_xdpy = xdisplay; } @@ -144,7 +145,7 @@ cogl_xlib_renderer_set_foreign_display (CoglRenderer *renderer, Display * cogl_xlib_renderer_get_foreign_display (CoglRenderer *renderer) { - g_return_val_if_fail (cogl_is_renderer (renderer), NULL); + _COGL_RETURN_VAL_IF_FAIL (cogl_is_renderer (renderer), NULL); return renderer->foreign_xdpy; } @@ -374,7 +375,7 @@ void cogl_renderer_set_winsys_id (CoglRenderer *renderer, CoglWinsysID winsys_id) { - g_return_if_fail (!renderer->connected); + _COGL_RETURN_IF_FAIL (!renderer->connected); renderer->winsys_id_override = winsys_id; } @@ -382,7 +383,7 @@ cogl_renderer_set_winsys_id (CoglRenderer *renderer, CoglWinsysID cogl_renderer_get_winsys_id (CoglRenderer *renderer) { - g_return_val_if_fail (renderer->connected, 0); + _COGL_RETURN_VAL_IF_FAIL (renderer->connected, 0); return renderer->winsys_vtable->id; } diff --git a/cogl/cogl-spans.c b/cogl/cogl-spans.c index 3935e9768..618440b52 100644 --- a/cogl/cogl-spans.c +++ b/cogl/cogl-spans.c @@ -28,6 +28,7 @@ #include "math.h" #include "cogl.h" +#include "cogl-util.h" #include "cogl-internal.h" #include "cogl-spans.h" @@ -77,8 +78,8 @@ _cogl_span_iter_begin (CoglSpanIter *iter, /* XXX: If CLAMP_TO_EDGE needs to be emulated then it needs to be * done at a higher level than here... */ - g_return_if_fail (wrap_mode == COGL_PIPELINE_WRAP_MODE_REPEAT || - wrap_mode == COGL_PIPELINE_WRAP_MODE_MIRRORED_REPEAT); + _COGL_RETURN_IF_FAIL (wrap_mode == COGL_PIPELINE_WRAP_MODE_REPEAT || + wrap_mode == COGL_PIPELINE_WRAP_MODE_MIRRORED_REPEAT); iter->span = NULL; diff --git a/cogl/cogl-sub-texture.c b/cogl/cogl-sub-texture.c index 44a8543bc..4776e3556 100644 --- a/cogl/cogl-sub-texture.c +++ b/cogl/cogl-sub-texture.c @@ -219,10 +219,13 @@ _cogl_sub_texture_new (CoglHandle next_texture, next_height = cogl_texture_get_height (next_texture); /* The region must specify a non-zero subset of the full texture */ - g_return_val_if_fail (sub_x >= 0 && sub_y >= 0, COGL_INVALID_HANDLE); - g_return_val_if_fail (sub_width > 0 && sub_height > 0, COGL_INVALID_HANDLE); - g_return_val_if_fail (sub_x + sub_width <= next_width, COGL_INVALID_HANDLE); - g_return_val_if_fail (sub_y + sub_height <= next_height, COGL_INVALID_HANDLE); + _COGL_RETURN_VAL_IF_FAIL (sub_x >= 0 && sub_y >= 0, COGL_INVALID_HANDLE); + _COGL_RETURN_VAL_IF_FAIL (sub_width > 0 && sub_height > 0, + COGL_INVALID_HANDLE); + _COGL_RETURN_VAL_IF_FAIL (sub_x + sub_width <= next_width, + COGL_INVALID_HANDLE); + _COGL_RETURN_VAL_IF_FAIL (sub_y + sub_height <= next_height, + COGL_INVALID_HANDLE); sub_tex = g_new (CoglSubTexture, 1); diff --git a/cogl/cogl-texture-2d-sliced.c b/cogl/cogl-texture-2d-sliced.c index ec8db2fbd..03d3299cb 100644 --- a/cogl/cogl-texture-2d-sliced.c +++ b/cogl/cogl-texture-2d-sliced.c @@ -883,7 +883,7 @@ _cogl_texture_2d_sliced_new_from_bitmap (CoglBitmap *bmp, _COGL_GET_CONTEXT (ctx, NULL); - g_return_val_if_fail (cogl_is_bitmap (bmp), NULL); + _COGL_RETURN_VAL_IF_FAIL (cogl_is_bitmap (bmp), NULL); width = _cogl_bitmap_get_width (bmp); height = _cogl_bitmap_get_height (bmp); diff --git a/cogl/cogl-texture-2d.c b/cogl/cogl-texture-2d.c index c64b14e43..61847d4ba 100644 --- a/cogl/cogl-texture-2d.c +++ b/cogl/cogl-texture-2d.c @@ -224,7 +224,7 @@ _cogl_texture_2d_new_from_bitmap (CoglBitmap *bmp, _COGL_GET_CONTEXT (ctx, COGL_INVALID_HANDLE); - g_return_val_if_fail (bmp != NULL, COGL_INVALID_HANDLE); + _COGL_RETURN_VAL_IF_FAIL (bmp != NULL, COGL_INVALID_HANDLE); internal_format = _cogl_texture_determine_internal_format (_cogl_bitmap_get_format (bmp), @@ -303,8 +303,8 @@ cogl_texture_2d_new_from_data (CoglContext *ctx, CoglBitmap *bmp; CoglHandle tex; - g_return_val_if_fail (format != COGL_PIXEL_FORMAT_ANY, NULL); - g_return_val_if_fail (data != NULL, NULL); + _COGL_RETURN_VAL_IF_FAIL (format != COGL_PIXEL_FORMAT_ANY, NULL); + _COGL_RETURN_VAL_IF_FAIL (data != NULL, NULL); /* Rowstride from width if not given */ if (rowstride == 0) @@ -458,11 +458,11 @@ _cogl_egl_texture_2d_new_from_image (CoglContext *ctx, CoglTexture2D *tex_2d; GLenum gl_error; - g_return_val_if_fail (_cogl_context_get_winsys (ctx) == + _COGL_RETURN_VAL_IF_FAIL (_cogl_context_get_winsys (ctx) == _cogl_winsys_egl_get_vtable (), NULL); - g_return_val_if_fail (ctx->private_feature_flags & + _COGL_RETURN_VAL_IF_FAIL (ctx->private_feature_flags & COGL_PRIVATE_FEATURE_TEXTURE_2D_FROM_EGL_IMAGE, NULL); @@ -538,7 +538,7 @@ cogl_wayland_texture_2d_new_from_buffer (CoglContext *ctx, { EGLImageKHR image; - g_return_val_if_fail (_cogl_context_get_winsys (ctx) == + _COGL_RETURN_VAL_IF_FAIL (_cogl_context_get_winsys (ctx) == _cogl_winsys_egl_get_vtable (), NULL); image = _cogl_egl_create_image (ctx, @@ -577,7 +577,7 @@ _cogl_texture_2d_copy_from_framebuffer (CoglHandle handle, _COGL_GET_CONTEXT (ctx, NO_RETVAL); - g_return_if_fail (cogl_is_texture_2d (handle)); + _COGL_RETURN_IF_FAIL (cogl_is_texture_2d (handle)); tex_2d = COGL_TEXTURE_2D (handle); diff --git a/cogl/cogl-texture-3d.c b/cogl/cogl-texture-3d.c index 584bbbd2a..d6e36dd4c 100644 --- a/cogl/cogl-texture-3d.c +++ b/cogl/cogl-texture-3d.c @@ -330,7 +330,7 @@ cogl_texture_3d_new_from_data (unsigned int width, CoglHandle ret; /* These are considered a programmer errors so we won't set a - GError. It would be nice if this was a g_return_if_fail but the + GError. It would be nice if this was a _COGL_RETURN_IF_FAIL but the rest of Cogl isn't using that */ if (format == COGL_PIXEL_FORMAT_ANY) return COGL_INVALID_HANDLE; diff --git a/cogl/cogl-texture-rectangle.c b/cogl/cogl-texture-rectangle.c index a2011536b..9ea93921e 100644 --- a/cogl/cogl-texture-rectangle.c +++ b/cogl/cogl-texture-rectangle.c @@ -216,7 +216,7 @@ _cogl_texture_rectangle_new_from_bitmap (CoglBitmap *bmp, _COGL_GET_CONTEXT (ctx, COGL_INVALID_HANDLE); - g_return_val_if_fail (cogl_is_bitmap (bmp), COGL_INVALID_HANDLE); + _COGL_RETURN_VAL_IF_FAIL (cogl_is_bitmap (bmp), COGL_INVALID_HANDLE); internal_format = _cogl_texture_determine_internal_format (_cogl_bitmap_get_format (bmp), diff --git a/cogl/cogl-texture.c b/cogl/cogl-texture.c index fa3857dc0..f8e2d5c5b 100644 --- a/cogl/cogl-texture.c +++ b/cogl/cogl-texture.c @@ -397,7 +397,7 @@ cogl_texture_new_from_file (const char *filename, CoglTexture *texture = NULL; CoglPixelFormat src_format; - g_return_val_if_fail (error == NULL || *error == NULL, NULL); + _COGL_RETURN_VAL_IF_FAIL (error == NULL || *error == NULL, NULL); bmp = cogl_bitmap_new_from_file (filename, error); if (bmp == NULL) @@ -515,7 +515,7 @@ cogl_texture_new_from_buffer_EXP (CoglPixelBuffer *buffer, CoglPixelBuffer *pixel_buffer; CoglBitmap *bmp; - g_return_val_if_fail (cogl_is_buffer (buffer), NULL); + _COGL_RETURN_VAL_IF_FAIL (cogl_is_buffer (buffer), NULL); if (format == COGL_PIXEL_FORMAT_ANY) return NULL; diff --git a/cogl/cogl-util.c b/cogl/cogl-util.c index ddee76a5d..f41a2ad1a 100644 --- a/cogl/cogl-util.c +++ b/cogl/cogl-util.c @@ -236,5 +236,4 @@ _cogl_util_ffs (int num) return i; } - #endif /* HAVE_FFS */ diff --git a/cogl/cogl-util.h b/cogl/cogl-util.h index e32fcd68e..44bb5015c 100644 --- a/cogl/cogl-util.h +++ b/cogl/cogl-util.h @@ -27,6 +27,10 @@ #include #include +#ifndef COGL_HAS_GLIB_SUPPORT +#include +#endif + int _cogl_util_next_p2 (int a); @@ -103,4 +107,30 @@ int _cogl_util_ffs (int num); #endif +#ifdef COGL_HAS_GLIB_SUPPORT +#define _COGL_RETURN_IF_FAIL(EXPR) g_return_if_fail(EXPR) +#define _COGL_RETURN_VAL_IF_FAIL(EXPR, VAL) g_return_val_if_fail(EXPR, VAL) +#else +#define _COGL_RETURN_IF_FAIL(EXPR) do { \ + if (!(EXPR)) \ + { \ + fprintf (stderr, "file %s: line %d: assertion `%s' failed", \ + __FILE__, \ + __LINE__, \ + #EXPR); \ + return; \ + }; \ + } while(0) +#define _COGL_RETURN_VAL_IF_FAIL(EXPR, VAL) do { \ + if (!(EXPR)) \ + { \ + fprintf (stderr, "file %s: line %d: assertion `%s' failed", \ + __FILE__, \ + __LINE__, \ + #EXPR); \ + return (VAL); \ + }; \ + } while(0) +#endif /* COGL_HAS_GLIB_SUPPORT */ + #endif /* __COGL_UTIL_H */ diff --git a/cogl/cogl-vector.c b/cogl/cogl-vector.c index 7436053ca..b22086c2f 100644 --- a/cogl/cogl-vector.c +++ b/cogl/cogl-vector.c @@ -25,6 +25,7 @@ */ #include +#include #include #include @@ -51,8 +52,8 @@ cogl_vector3_equal (gconstpointer v1, gconstpointer v2) CoglVector3 *vector0 = (CoglVector3 *)v1; CoglVector3 *vector1 = (CoglVector3 *)v2; - g_return_val_if_fail (v1 != NULL, FALSE); - g_return_val_if_fail (v2 != NULL, FALSE); + _COGL_RETURN_VAL_IF_FAIL (v1 != NULL, FALSE); + _COGL_RETURN_VAL_IF_FAIL (v2 != NULL, FALSE); /* There's no point picking an arbitrary epsilon that's appropriate * for comparing the components so we just use == that will at least @@ -68,8 +69,8 @@ cogl_vector3_equal_with_epsilon (const CoglVector3 *vector0, const CoglVector3 *vector1, float epsilon) { - g_return_val_if_fail (vector0 != NULL, FALSE); - g_return_val_if_fail (vector1 != NULL, FALSE); + _COGL_RETURN_VAL_IF_FAIL (vector0 != NULL, FALSE); + _COGL_RETURN_VAL_IF_FAIL (vector1 != NULL, FALSE); if (fabsf (vector0->x - vector1->x) < epsilon && fabsf (vector0->y - vector1->y) < epsilon && @@ -219,8 +220,8 @@ cogl_vector4_init_from_vector4 (CoglVector4 *vector, CoglVector4 *src) gboolean cogl_vector4_equal (gconstpointer *v0, gconstpointer *v1) { - g_return_val_if_fail (v1 != NULL, FALSE); - g_return_val_if_fail (v2 != NULL, FALSE); + _COGL_RETURN_VAL_IF_FAIL (v1 != NULL, FALSE); + _COGL_RETURN_VAL_IF_FAIL (v2 != NULL, FALSE); return memcmp (v1, v2, sizeof (float) * 4) == 0 ? TRUE : FALSE; } diff --git a/cogl/cogl-vertex-buffer.c b/cogl/cogl-vertex-buffer.c index 4d0343e45..1654dc7d8 100644 --- a/cogl/cogl-vertex-buffer.c +++ b/cogl/cogl-vertex-buffer.c @@ -1163,7 +1163,7 @@ update_primitive_attributes (CoglVertexBuffer *buffer) ; } - g_return_if_fail (n_attributes > 0); + _COGL_RETURN_IF_FAIL (n_attributes > 0); attributes = g_alloca (sizeof (CoglAttribute *) * n_attributes); diff --git a/cogl/cogl-xlib-renderer.c b/cogl/cogl-xlib-renderer.c index 92fe5ff5c..40d596ab8 100644 --- a/cogl/cogl-xlib-renderer.c +++ b/cogl/cogl-xlib-renderer.c @@ -29,6 +29,7 @@ #endif #include "cogl.h" +#include "cogl-util.h" #include "cogl-internal.h" #include "cogl-object.h" @@ -197,7 +198,7 @@ cogl_xlib_renderer_get_display (CoglRenderer *renderer) { CoglXlibRenderer *xlib_renderer; - g_return_val_if_fail (cogl_is_renderer (renderer), NULL); + _COGL_RETURN_VAL_IF_FAIL (cogl_is_renderer (renderer), NULL); xlib_renderer = renderer->winsys; diff --git a/cogl/cogl.c b/cogl/cogl.c index bee8170d5..e5a10a2ff 100644 --- a/cogl/cogl.c +++ b/cogl/cogl.c @@ -149,7 +149,7 @@ toggle_client_flag (CoglContext *ctx, unsigned long flag, GLenum gl_flag) { - g_return_val_if_fail (ctx->driver != COGL_DRIVER_GLES2, FALSE); + _COGL_RETURN_VAL_IF_FAIL (ctx->driver != COGL_DRIVER_GLES2, FALSE); /* Toggles and caches a single client-side enable flag * on or off by comparing to current state @@ -453,7 +453,7 @@ _cogl_read_pixels_with_rowstride (int x, _COGL_GET_CONTEXT (ctx, NO_RETVAL); - g_return_if_fail (source == COGL_READ_PIXELS_COLOR_BUFFER); + _COGL_RETURN_IF_FAIL (source == COGL_READ_PIXELS_COLOR_BUFFER); if (width == 1 && height == 1 && !framebuffer->clear_clip_dirty) { @@ -924,7 +924,7 @@ cogl_push_source (void *material_or_pipeline) { CoglPipeline *pipeline = COGL_PIPELINE (material_or_pipeline); - g_return_if_fail (cogl_is_pipeline (pipeline)); + _COGL_RETURN_IF_FAIL (cogl_is_pipeline (pipeline)); _cogl_push_source (pipeline, TRUE); } @@ -939,7 +939,7 @@ _cogl_push_source (CoglPipeline *pipeline, gboolean enable_legacy) _COGL_GET_CONTEXT (ctx, NO_RETVAL); - g_return_if_fail (cogl_is_pipeline (pipeline)); + _COGL_RETURN_IF_FAIL (cogl_is_pipeline (pipeline)); if (ctx->source_stack) { @@ -964,7 +964,7 @@ cogl_pop_source (void) _COGL_GET_CONTEXT (ctx, NO_RETVAL); - g_return_if_fail (ctx->source_stack); + _COGL_RETURN_IF_FAIL (ctx->source_stack); top = ctx->source_stack->data; top->push_count--; @@ -985,7 +985,7 @@ cogl_get_source (void) _COGL_GET_CONTEXT (ctx, NULL); - g_return_val_if_fail (ctx->source_stack, NULL); + _COGL_RETURN_VAL_IF_FAIL (ctx->source_stack, NULL); top = ctx->source_stack->data; return top->pipeline; @@ -998,7 +998,7 @@ _cogl_get_enable_legacy_state (void) _COGL_GET_CONTEXT (ctx, FALSE); - g_return_val_if_fail (ctx->source_stack, FALSE); + _COGL_RETURN_VAL_IF_FAIL (ctx->source_stack, FALSE); top = ctx->source_stack->data; return top->enable_legacy; @@ -1012,8 +1012,8 @@ cogl_set_source (void *material_or_pipeline) _COGL_GET_CONTEXT (ctx, NO_RETVAL); - g_return_if_fail (cogl_is_pipeline (pipeline)); - g_return_if_fail (ctx->source_stack); + _COGL_RETURN_IF_FAIL (cogl_is_pipeline (pipeline)); + _COGL_RETURN_IF_FAIL (ctx->source_stack); top = ctx->source_stack->data; if (top->pipeline == pipeline && top->enable_legacy) @@ -1040,7 +1040,7 @@ cogl_set_source_texture (CoglTexture *texture) { _COGL_GET_CONTEXT (ctx, NO_RETVAL); - g_return_if_fail (texture != NULL); + _COGL_RETURN_IF_FAIL (texture != NULL); cogl_pipeline_set_layer_texture (ctx->texture_pipeline, 0, texture); cogl_set_source (ctx->texture_pipeline); diff --git a/cogl/cogl2-path.c b/cogl/cogl2-path.c index b3d3f05b4..8dd21ebcf 100644 --- a/cogl/cogl2-path.c +++ b/cogl/cogl2-path.c @@ -31,6 +31,7 @@ #endif #include "cogl.h" +#include "cogl-util.h" #include "cogl-object.h" #include "cogl-internal.h" #include "cogl-context-private.h" @@ -133,7 +134,7 @@ void cogl2_path_set_fill_rule (CoglPath *path, CoglPathFillRule fill_rule) { - g_return_if_fail (cogl_is_path (path)); + _COGL_RETURN_IF_FAIL (cogl_is_path (path)); if (path->data->fill_rule != fill_rule) { @@ -146,7 +147,7 @@ cogl2_path_set_fill_rule (CoglPath *path, CoglPathFillRule cogl2_path_get_fill_rule (CoglPath *path) { - g_return_val_if_fail (cogl_is_path (path), COGL_PATH_FILL_RULE_NON_ZERO); + _COGL_RETURN_VAL_IF_FAIL (cogl_is_path (path), COGL_PATH_FILL_RULE_NON_ZERO); return path->data->fill_rule; } @@ -341,7 +342,7 @@ _cogl_path_fill_nodes (CoglPath *path, CoglDrawFlags flags) void cogl2_path_fill (CoglPath *path) { - g_return_if_fail (cogl_is_path (path)); + _COGL_RETURN_IF_FAIL (cogl_is_path (path)); if (path->data->path_nodes->len == 0) return; @@ -364,7 +365,7 @@ cogl2_path_fill (CoglPath *path) void cogl2_path_stroke (CoglPath *path) { - g_return_if_fail (cogl_is_path (path)); + _COGL_RETURN_IF_FAIL (cogl_is_path (path)); if (path->data->path_nodes->len == 0) return; @@ -379,7 +380,7 @@ cogl2_path_move_to (CoglPath *path, { CoglPathData *data; - g_return_if_fail (cogl_is_path (path)); + _COGL_RETURN_IF_FAIL (cogl_is_path (path)); _cogl_path_add_node (path, TRUE, x, y); @@ -398,7 +399,7 @@ cogl2_path_rel_move_to (CoglPath *path, { CoglPathData *data; - g_return_if_fail (cogl_is_path (path)); + _COGL_RETURN_IF_FAIL (cogl_is_path (path)); data = path->data; @@ -414,7 +415,7 @@ cogl2_path_line_to (CoglPath *path, { CoglPathData *data; - g_return_if_fail (cogl_is_path (path)); + _COGL_RETURN_IF_FAIL (cogl_is_path (path)); _cogl_path_add_node (path, FALSE, x, y); @@ -431,7 +432,7 @@ cogl2_path_rel_line_to (CoglPath *path, { CoglPathData *data; - g_return_if_fail (cogl_is_path (path)); + _COGL_RETURN_IF_FAIL (cogl_is_path (path)); data = path->data; @@ -443,7 +444,7 @@ cogl2_path_rel_line_to (CoglPath *path, void cogl2_path_close (CoglPath *path) { - g_return_if_fail (cogl_is_path (path)); + _COGL_RETURN_IF_FAIL (cogl_is_path (path)); _cogl_path_add_node (path, FALSE, path->data->path_start.x, path->data->path_start.y); @@ -469,7 +470,7 @@ cogl2_path_polyline (CoglPath *path, { int c = 0; - g_return_if_fail (cogl_is_path (path)); + _COGL_RETURN_IF_FAIL (cogl_is_path (path)); cogl2_path_move_to (path, coords[0], coords[1]); @@ -594,7 +595,7 @@ cogl2_path_arc (CoglPath *path, { float angle_step = 10; - g_return_if_fail (cogl_is_path (path)); + _COGL_RETURN_IF_FAIL (cogl_is_path (path)); /* it is documented that a move to is needed to create a freestanding * arc @@ -638,7 +639,7 @@ cogl2_path_ellipse (CoglPath *path, { float angle_step = 10; - g_return_if_fail (cogl_is_path (path)); + _COGL_RETURN_IF_FAIL (cogl_is_path (path)); /* FIXME: if shows to be slow might be optimized * by mirroring just a quarter of it */ @@ -664,7 +665,7 @@ cogl2_path_round_rectangle (CoglPath *path, float inner_width = x_2 - x_1 - radius * 2; float inner_height = y_2 - y_1 - radius * 2; - g_return_if_fail (cogl_is_path (path)); + _COGL_RETURN_IF_FAIL (cogl_is_path (path)); cogl2_path_move_to (path, x_1, y_1 + radius); _cogl_path_rel_arc (path, @@ -815,7 +816,7 @@ cogl2_path_curve_to (CoglPath *path, { CoglBezCubic cubic; - g_return_if_fail (cogl_is_path (path)); + _COGL_RETURN_IF_FAIL (cogl_is_path (path)); /* Prepare cubic curve */ cubic.p1 = path->data->path_pen; @@ -845,7 +846,7 @@ cogl2_path_rel_curve_to (CoglPath *path, { CoglPathData *data; - g_return_if_fail (cogl_is_path (path)); + _COGL_RETURN_IF_FAIL (cogl_is_path (path)); data = path->data; @@ -883,7 +884,7 @@ cogl_path_copy (CoglPath *old_path) { CoglPath *new_path; - g_return_val_if_fail (cogl_is_path (old_path), NULL); + _COGL_RETURN_VAL_IF_FAIL (cogl_is_path (old_path), NULL); new_path = g_slice_new (CoglPath); new_path->data = old_path->data; @@ -1004,7 +1005,7 @@ cogl_rel_curve2_to (CoglPath *path, { CoglPathData *data; - g_return_if_fail (cogl_is_path (path)); + _COGL_RETURN_IF_FAIL (cogl_is_path (path)); data = path->data; diff --git a/cogl/winsys/cogl-winsys-egl.c b/cogl/winsys/cogl-winsys-egl.c index e2e74bde3..0c7c4c80a 100644 --- a/cogl/winsys/cogl-winsys-egl.c +++ b/cogl/winsys/cogl-winsys-egl.c @@ -30,6 +30,7 @@ #include "cogl.h" +#include "cogl-util.h" #include "cogl-winsys-egl-private.h" #include "cogl-winsys-private.h" #include "cogl-feature-private.h" @@ -522,7 +523,7 @@ update_winsys_features (CoglContext *context, GError **error) CoglDisplayEGL *egl_display = context->display->winsys; CoglRendererEGL *egl_renderer = context->display->renderer->winsys; - g_return_val_if_fail (egl_display->egl_context, FALSE); + _COGL_RETURN_VAL_IF_FAIL (egl_display->egl_context, FALSE); memset (context->winsys_features, 0, sizeof (context->winsys_features)); @@ -691,7 +692,7 @@ try_create_context (CoglDisplay *display, with_stencil_buffer, cfg_attribs); - g_return_val_if_fail (egl_display->egl_context == NULL, TRUE); + _COGL_RETURN_VAL_IF_FAIL (egl_display->egl_context == NULL, TRUE); edpy = egl_renderer->edpy; @@ -1045,7 +1046,7 @@ _cogl_winsys_display_destroy (CoglDisplay *display) { CoglDisplayEGL *egl_display = display->winsys; - g_return_if_fail (egl_display != NULL); + _COGL_RETURN_IF_FAIL (egl_display != NULL); cleanup_context (display); @@ -1148,7 +1149,7 @@ _cogl_winsys_display_setup (CoglDisplay *display, CoglRendererEGL *egl_renderer = display->renderer->winsys; #endif - g_return_val_if_fail (display->winsys == NULL, FALSE); + _COGL_RETURN_VAL_IF_FAIL (display->winsys == NULL, FALSE); egl_display = g_slice_new0 (CoglDisplayEGL); display->winsys = egl_display; @@ -1231,7 +1232,7 @@ _cogl_winsys_onscreen_init (CoglOnscreen *onscreen, gboolean need_stencil = egl_display->stencil_disabled ? FALSE : framebuffer->config.need_stencil; - g_return_val_if_fail (egl_display->egl_context, FALSE); + _COGL_RETURN_VAL_IF_FAIL (egl_display->egl_context, FALSE); egl_attributes_from_framebuffer_config (display, &framebuffer->config, @@ -1642,7 +1643,7 @@ _cogl_winsys_xlib_get_visual_info (void) _COGL_GET_CONTEXT (ctx, NULL); - g_return_val_if_fail (ctx->display->winsys, FALSE); + _COGL_RETURN_VAL_IF_FAIL (ctx->display->winsys, FALSE); egl_display = ctx->display->winsys; @@ -1833,10 +1834,10 @@ void cogl_wayland_renderer_set_foreign_display (CoglRenderer *renderer, struct wl_display *display) { - g_return_if_fail (cogl_is_renderer (renderer)); + _COGL_RETURN_IF_FAIL (cogl_is_renderer (renderer)); /* NB: Renderers are considered immutable once connected */ - g_return_if_fail (!renderer->connected); + _COGL_RETURN_IF_FAIL (!renderer->connected); renderer->foreign_wayland_display = display; } @@ -1844,7 +1845,7 @@ cogl_wayland_renderer_set_foreign_display (CoglRenderer *renderer, struct wl_display * cogl_wayland_renderer_get_display (CoglRenderer *renderer) { - g_return_val_if_fail (cogl_is_renderer (renderer), NULL); + _COGL_RETURN_VAL_IF_FAIL (cogl_is_renderer (renderer), NULL); if (renderer->foreign_wayland_display) return renderer->foreign_wayland_display; @@ -1861,10 +1862,10 @@ void cogl_wayland_renderer_set_foreign_compositor (CoglRenderer *renderer, struct wl_compositor *compositor) { - g_return_if_fail (cogl_is_renderer (renderer)); + _COGL_RETURN_IF_FAIL (cogl_is_renderer (renderer)); /* NB: Renderers are considered immutable once connected */ - g_return_if_fail (!renderer->connected); + _COGL_RETURN_IF_FAIL (!renderer->connected); renderer->foreign_wayland_compositor = compositor; } @@ -1872,7 +1873,7 @@ cogl_wayland_renderer_set_foreign_compositor (CoglRenderer *renderer, struct wl_compositor * cogl_wayland_renderer_get_compositor (CoglRenderer *renderer) { - g_return_val_if_fail (cogl_is_renderer (renderer), NULL); + _COGL_RETURN_VAL_IF_FAIL (cogl_is_renderer (renderer), NULL); if (renderer->foreign_wayland_compositor) return renderer->foreign_wayland_compositor; @@ -1913,7 +1914,7 @@ _cogl_egl_create_image (CoglContext *ctx, CoglRendererEGL *egl_renderer = ctx->display->renderer->winsys; EGLContext egl_ctx; - g_return_val_if_fail (egl_renderer->pf_eglCreateImage, EGL_NO_IMAGE_KHR); + _COGL_RETURN_VAL_IF_FAIL (egl_renderer->pf_eglCreateImage, EGL_NO_IMAGE_KHR); /* The EGL_KHR_image_pixmap spec explicitly states that EGL_NO_CONTEXT must * always be used in conjunction with the EGL_NATIVE_PIXMAP_KHR target */ @@ -1937,7 +1938,7 @@ _cogl_egl_destroy_image (CoglContext *ctx, { CoglRendererEGL *egl_renderer = ctx->display->renderer->winsys; - g_return_if_fail (egl_renderer->pf_eglDestroyImage); + _COGL_RETURN_IF_FAIL (egl_renderer->pf_eglDestroyImage); egl_renderer->pf_eglDestroyImage (egl_renderer->edpy, image); } diff --git a/cogl/winsys/cogl-winsys-glx.c b/cogl/winsys/cogl-winsys-glx.c index 10422e791..61af5fd78 100644 --- a/cogl/winsys/cogl-winsys-glx.c +++ b/cogl/winsys/cogl-winsys-glx.c @@ -30,6 +30,7 @@ #include "cogl.h" +#include "cogl-util.h" #include "cogl-winsys-private.h" #include "cogl-feature-private.h" #include "cogl-context-private.h" @@ -381,7 +382,7 @@ update_winsys_features (CoglContext *context, GError **error) int default_screen; int i; - g_return_val_if_fail (glx_display->glx_context, FALSE); + _COGL_RETURN_VAL_IF_FAIL (glx_display->glx_context, FALSE); if (!_cogl_context_update_features (context, error)) return FALSE; @@ -592,7 +593,7 @@ create_context (CoglDisplay *display, GError **error) GLXDrawable dummy_drawable; CoglXlibTrapState old_state; - g_return_val_if_fail (glx_display->glx_context == NULL, TRUE); + _COGL_RETURN_VAL_IF_FAIL (glx_display->glx_context == NULL, TRUE); glx_display->found_fbconfig = find_fbconfig (display, &display->onscreen_template->config, &config, @@ -714,7 +715,7 @@ _cogl_winsys_display_destroy (CoglDisplay *display) CoglXlibRenderer *xlib_renderer = display->renderer->winsys; CoglGLXRenderer *glx_renderer = display->renderer->winsys; - g_return_if_fail (glx_display != NULL); + _COGL_RETURN_IF_FAIL (glx_display != NULL); if (glx_display->glx_context) { @@ -749,7 +750,7 @@ _cogl_winsys_display_setup (CoglDisplay *display, CoglGLXDisplay *glx_display; int i; - g_return_val_if_fail (display->winsys == NULL, FALSE); + _COGL_RETURN_VAL_IF_FAIL (display->winsys == NULL, FALSE); glx_display = g_slice_new0 (CoglGLXDisplay); display->winsys = glx_display; @@ -803,7 +804,7 @@ _cogl_winsys_onscreen_init (CoglOnscreen *onscreen, GLXFBConfig fbconfig; GError *fbconfig_error = NULL; - g_return_val_if_fail (glx_display->glx_context, FALSE); + _COGL_RETURN_VAL_IF_FAIL (glx_display->glx_context, FALSE); if (!find_fbconfig (display, &framebuffer->config, &fbconfig, @@ -1483,7 +1484,7 @@ _cogl_winsys_xlib_get_visual_info (void) _COGL_GET_CONTEXT (ctx, NULL); - g_return_val_if_fail (ctx->display->winsys, FALSE); + _COGL_RETURN_VAL_IF_FAIL (ctx->display->winsys, FALSE); glx_display = ctx->display->winsys; xlib_renderer = ctx->display->renderer->winsys; diff --git a/cogl/winsys/cogl-winsys-wgl.c b/cogl/winsys/cogl-winsys-wgl.c index 9e120024e..fbe35908c 100644 --- a/cogl/winsys/cogl-winsys-wgl.c +++ b/cogl/winsys/cogl-winsys-wgl.c @@ -32,6 +32,7 @@ #include "cogl.h" +#include "cogl-util.h" #include "cogl-winsys-private.h" #include "cogl-context-private.h" #include "cogl-framebuffer.h" @@ -420,7 +421,7 @@ create_context (CoglDisplay *display, GError **error) { CoglDisplayWgl *wgl_display = display->winsys; - g_return_val_if_fail (wgl_display->wgl_context == NULL, FALSE); + _COGL_RETURN_VAL_IF_FAIL (wgl_display->wgl_context == NULL, FALSE); /* Cogl assumes that there is always a GL context selected; in order * to make sure that a WGL context exists and is made current, we @@ -496,7 +497,7 @@ _cogl_winsys_display_destroy (CoglDisplay *display) { CoglDisplayWgl *wgl_display = display->winsys; - g_return_if_fail (wgl_display != NULL); + _COGL_RETURN_IF_FAIL (wgl_display != NULL); if (wgl_display->wgl_context) { @@ -524,7 +525,7 @@ _cogl_winsys_display_setup (CoglDisplay *display, { CoglDisplayWgl *wgl_display; - g_return_val_if_fail (display->winsys == NULL, FALSE); + _COGL_RETURN_VAL_IF_FAIL (display->winsys == NULL, FALSE); wgl_display = g_slice_new0 (CoglDisplayWgl); display->winsys = wgl_display; @@ -585,7 +586,7 @@ update_winsys_features (CoglContext *context, GError **error) const char *wgl_extensions; int i; - g_return_val_if_fail (wgl_display->wgl_context, FALSE); + _COGL_RETURN_VAL_IF_FAIL (wgl_display->wgl_context, FALSE); if (!_cogl_context_update_features (context, error)) return FALSE; @@ -660,7 +661,7 @@ _cogl_winsys_onscreen_bind (CoglOnscreen *onscreen) NULL, but this isn't really going to work because before checking whether onscreen == NULL it reads the pointer to get the context */ - g_return_if_fail (onscreen != NULL); + _COGL_RETURN_IF_FAIL (onscreen != NULL); context = COGL_FRAMEBUFFER (onscreen)->context; wgl_context = context->winsys; @@ -734,7 +735,7 @@ _cogl_winsys_onscreen_init (CoglOnscreen *onscreen, int pf; HWND hwnd; - g_return_val_if_fail (wgl_display->wgl_context, FALSE); + _COGL_RETURN_VAL_IF_FAIL (wgl_display->wgl_context, FALSE); /* XXX: Note we ignore the user's original width/height when given a * foreign window. */ diff --git a/configure.ac b/configure.ac index f43681520..e1f760f07 100644 --- a/configure.ac +++ b/configure.ac @@ -394,6 +394,27 @@ AC_ARG_ENABLE( ) AM_CONDITIONAL([INSTALL_EXAMPLES], [test "x$enable_examples_install" = "xyes"]) +dnl ============================================================ +dnl Should glib be used? +dnl ============================================================ +AC_ARG_ENABLE( + [glib], + [AC_HELP_STRING([--enable-glib=@<:@no/yes@:>@], [Enable glib support @<:@default=yes@:>@])], + [], + enable_glib=yes +) +AM_CONDITIONAL([USE_GLIB], [test "x$enable_glib" = "xyes"]) + +AS_IF([test "x$enable_glib" = "xyes"], + [ + COGL_DEFINES_SYMBOLS="$COGL_DEFINES_SYMBOLS COGL_HAS_GLIB_SUPPORT" + ], + [ + EXPERIMENTAL_CONFIG=yes + EXPERIMENTAL_OPTIONS="$EXPERIMENTAL_OPTIONS --disable-glib," + ] +) + dnl ============================================================ dnl Determine which drivers and window systems we can support dnl ============================================================