[cogl/wip/standalone: 11/13] core: Introduce _COGL_ASSERT()
- From: Damien Lespiau <dlespiau src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [cogl/wip/standalone: 11/13] core: Introduce _COGL_ASSERT()
- Date: Mon, 27 Feb 2012 17:46:34 +0000 (UTC)
commit 6eb8137c7416183b3f11d57668a7949a3ddb8364
Author: Damien Lespiau <damien lespiau intel com>
Date: Mon Feb 27 17:30:30 2012 +0000
core: Introduce _COGL_ASSERT()
Instead of using the glib facility for assertions and ending up
depending on a whole lot of files to pull in for the standalone version,
we can just define our own little _COGL_ASSERT().
cogl/cogl-bitmap-pixbuf.c | 10 +++++-----
cogl/cogl-bitmap.c | 14 +++++++-------
cogl/cogl-framebuffer.c | 10 +++++-----
cogl/cogl-journal.c | 2 +-
cogl/cogl-matrix-stack.c | 8 ++++----
cogl/cogl-pipeline-layer-state.c | 16 ++++++++--------
cogl/cogl-pipeline-layer.c | 4 ++--
cogl/cogl-pipeline-opengl.c | 4 ++--
cogl/cogl-pipeline-progend-glsl.c | 2 +-
cogl/cogl-pipeline-state.c | 2 +-
cogl/cogl-pipeline.c | 10 +++++-----
cogl/cogl-quaternion.c | 4 ++--
cogl/cogl-rectangle-map.c | 20 ++++++++++----------
cogl/cogl-texture-2d-sliced.c | 6 +++---
cogl/cogl-texture-rectangle.c | 8 ++++----
cogl/cogl-util.h | 10 ++++++++++
cogl/cogl-xlib-renderer.c | 4 ++--
cogl/cogl-xlib.c | 2 +-
cogl/cogl2-path.c | 6 +++---
cogl/winsys/cogl-winsys-egl-wayland.c | 4 ++--
cogl/winsys/cogl-winsys-egl.c | 2 +-
cogl/winsys/cogl-winsys-glx.c | 2 +-
22 files changed, 80 insertions(+), 70 deletions(-)
---
diff --git a/cogl/cogl-bitmap-pixbuf.c b/cogl/cogl-bitmap-pixbuf.c
index b64af5a..d5e7f3e 100644
--- a/cogl/cogl-bitmap-pixbuf.c
+++ b/cogl/cogl-bitmap-pixbuf.c
@@ -105,8 +105,8 @@ _cogl_bitmap_from_file (const char *filename,
CGColorSpaceRef color_space;
CGContextRef bitmap_context;
- g_assert (filename != NULL);
- g_assert (error == NULL || *error == NULL);
+ _COGL_ASSERT (filename != NULL);
+ _COGL_ASSERT (error == NULL || *error == NULL);
url = CFURLCreateFromFileSystemRepresentation (NULL,
(guchar *) filename,
@@ -242,12 +242,12 @@ _cogl_bitmap_from_file (const char *filename,
/* According to current docs this should be true and so
* the translation to cogl pixel format below valid */
- g_assert (bits_per_sample == 8);
+ _COGL_ASSERT (bits_per_sample == 8);
if (has_alpha)
- g_assert (n_channels == 4);
+ _COGL_ASSERT (n_channels == 4);
else
- g_assert (n_channels == 3);
+ _COGL_ASSERT (n_channels == 3);
/* Translate to cogl pixel format */
switch (color_space)
diff --git a/cogl/cogl-bitmap.c b/cogl/cogl-bitmap.c
index 37a4594..9207064 100644
--- a/cogl/cogl-bitmap.c
+++ b/cogl/cogl-bitmap.c
@@ -64,8 +64,8 @@ COGL_OBJECT_DEFINE (Bitmap, bitmap);
static void
_cogl_bitmap_free (CoglBitmap *bmp)
{
- g_assert (!bmp->mapped);
- g_assert (!bmp->bound);
+ _COGL_ASSERT (!bmp->mapped);
+ _COGL_ASSERT (!bmp->bound);
if (bmp->destroy_fn)
bmp->destroy_fn (bmp->data, bmp->destroy_fn_data);
@@ -208,7 +208,7 @@ _cogl_bitmap_copy_subregion (CoglBitmap *src,
int line;
/* Intended only for fast copies when format is equal! */
- g_assert (src->format == dst->format);
+ _COGL_ASSERT (src->format == dst->format);
bpp = _cogl_pixel_format_get_bytes_per_pixel (src->format);
if ((srcdata = _cogl_bitmap_map (src, COGL_BUFFER_ACCESS_READ, 0)))
@@ -380,7 +380,7 @@ _cogl_bitmap_map (CoglBitmap *bitmap,
if (bitmap->shared_bmp)
return _cogl_bitmap_map (bitmap->shared_bmp, access, hints);
- g_assert (!bitmap->mapped);
+ _COGL_ASSERT (!bitmap->mapped);
if (bitmap->buffer)
{
@@ -419,7 +419,7 @@ _cogl_bitmap_unmap (CoglBitmap *bitmap)
return;
}
- g_assert (bitmap->mapped);
+ _COGL_ASSERT (bitmap->mapped);
bitmap->mapped = FALSE;
if (bitmap->buffer)
@@ -437,7 +437,7 @@ _cogl_bitmap_bind (CoglBitmap *bitmap,
if (bitmap->shared_bmp)
return _cogl_bitmap_bind (bitmap->shared_bmp, access, hints);
- g_assert (!bitmap->bound);
+ _COGL_ASSERT (!bitmap->bound);
/* If the bitmap wasn't created from a buffer then the
implementation of bind is the same as map */
@@ -474,7 +474,7 @@ _cogl_bitmap_unbind (CoglBitmap *bitmap)
return;
}
- g_assert (bitmap->bound);
+ _COGL_ASSERT (bitmap->bound);
bitmap->bound = FALSE;
/* If the bitmap wasn't created from a pixel array then the
diff --git a/cogl/cogl-framebuffer.c b/cogl/cogl-framebuffer.c
index 5a549ab..6b00df7 100644
--- a/cogl/cogl-framebuffer.c
+++ b/cogl/cogl-framebuffer.c
@@ -1213,7 +1213,7 @@ cogl_get_draw_framebuffer (void)
_COGL_GET_CONTEXT (ctx, NULL);
- g_assert (ctx->framebuffer_stack);
+ _COGL_ASSERT (ctx->framebuffer_stack);
entry = ctx->framebuffer_stack->data;
@@ -1227,7 +1227,7 @@ _cogl_get_read_framebuffer (void)
_COGL_GET_CONTEXT (ctx, NULL);
- g_assert (ctx->framebuffer_stack);
+ _COGL_ASSERT (ctx->framebuffer_stack);
entry = ctx->framebuffer_stack->data;
@@ -1287,8 +1287,8 @@ cogl_pop_framebuffer (void)
_COGL_GET_CONTEXT (ctx, NO_RETVAL);
- g_assert (ctx->framebuffer_stack != NULL);
- g_assert (ctx->framebuffer_stack->next != NULL);
+ _COGL_ASSERT (ctx->framebuffer_stack != NULL);
+ _COGL_ASSERT (ctx->framebuffer_stack->next != NULL);
to_pop = ctx->framebuffer_stack->data;
to_restore = ctx->framebuffer_stack->next->data;
@@ -1475,7 +1475,7 @@ _cogl_framebuffer_flush_viewport_state (CoglFramebuffer *framebuffer)
{
float gl_viewport_y;
- g_assert (framebuffer->viewport_width >=0 &&
+ _COGL_ASSERT (framebuffer->viewport_width >=0 &&
framebuffer->viewport_height >=0);
/* Convert the Cogl viewport y offset to an OpenGL viewport y offset
diff --git a/cogl/cogl-journal.c b/cogl/cogl-journal.c
index bec9e6d..7e3c268 100644
--- a/cogl/cogl-journal.c
+++ b/cogl/cogl-journal.c
@@ -1169,7 +1169,7 @@ upload_vertices (CoglJournal *journal,
int entry_num;
int i;
- g_assert (needed_vbo_len);
+ _COGL_ASSERT (needed_vbo_len);
attribute_buffer = create_attribute_buffer (journal, needed_vbo_len * 4);
buffer = COGL_BUFFER (attribute_buffer);
diff --git a/cogl/cogl-matrix-stack.c b/cogl/cogl-matrix-stack.c
index fd1bed0..4c362f9 100644
--- a/cogl/cogl-matrix-stack.c
+++ b/cogl/cogl-matrix-stack.c
@@ -368,8 +368,8 @@ _cogl_matrix_stack_flush_matrix_to_gl_builtin (CoglContext *ctx,
CoglMatrix *matrix,
CoglMatrixMode mode)
{
- g_assert (ctx->driver == COGL_DRIVER_GL ||
- ctx->driver == COGL_DRIVER_GLES1);
+ _COGL_ASSERT (ctx->driver == COGL_DRIVER_GL ||
+ ctx->driver == COGL_DRIVER_GLES1);
#if defined (HAVE_COGL_GL) || defined (HAVE_COGL_GLES)
if (ctx->flushed_matrix_mode != mode)
@@ -408,8 +408,8 @@ _cogl_matrix_stack_flush_to_gl_builtins (CoglContext *ctx,
CoglMatrixMode mode,
gboolean disable_flip)
{
- g_assert (ctx->driver == COGL_DRIVER_GL ||
- ctx->driver == COGL_DRIVER_GLES1);
+ _COGL_ASSERT (ctx->driver == COGL_DRIVER_GL ||
+ ctx->driver == COGL_DRIVER_GLES1);
#if defined (HAVE_COGL_GL) || defined (HAVE_COGL_GLES)
{
diff --git a/cogl/cogl-pipeline-layer-state.c b/cogl/cogl-pipeline-layer-state.c
index 910215a..e439d31 100644
--- a/cogl/cogl-pipeline-layer-state.c
+++ b/cogl/cogl-pipeline-layer-state.c
@@ -185,7 +185,7 @@ _cogl_pipeline_set_layer_texture_type (CoglPipeline *pipeline,
{
layer->differences &= ~change;
- g_assert (layer->owner == pipeline);
+ _COGL_ASSERT (layer->owner == pipeline);
if (layer->differences == 0)
_cogl_pipeline_prune_empty_layer_difference (pipeline,
layer);
@@ -259,7 +259,7 @@ _cogl_pipeline_set_layer_texture_data (CoglPipeline *pipeline,
if (layer->texture != NULL)
cogl_object_unref (layer->texture);
- g_assert (layer->owner == pipeline);
+ _COGL_ASSERT (layer->owner == pipeline);
if (layer->differences == 0)
_cogl_pipeline_prune_empty_layer_difference (pipeline,
layer);
@@ -399,7 +399,7 @@ _cogl_pipeline_set_layer_wrap_modes (CoglPipeline *pipeline,
{
layer->differences &= ~change;
- g_assert (layer->owner == pipeline);
+ _COGL_ASSERT (layer->owner == pipeline);
if (layer->differences == 0)
_cogl_pipeline_prune_empty_layer_difference (pipeline,
layer);
@@ -764,7 +764,7 @@ cogl_pipeline_set_layer_point_sprite_coords_enabled (CoglPipeline *pipeline,
{
layer->differences &= ~change;
- g_assert (layer->owner == pipeline);
+ _COGL_ASSERT (layer->owner == pipeline);
if (layer->differences == 0)
_cogl_pipeline_prune_empty_layer_difference (pipeline,
layer);
@@ -1247,7 +1247,7 @@ cogl_pipeline_set_layer_combine (CoglPipeline *pipeline,
{
layer->differences &= ~state;
- g_assert (layer->owner == pipeline);
+ _COGL_ASSERT (layer->owner == pipeline);
if (layer->differences == 0)
_cogl_pipeline_prune_empty_layer_difference (pipeline,
layer);
@@ -1327,7 +1327,7 @@ cogl_pipeline_set_layer_combine_constant (CoglPipeline *pipeline,
{
layer->differences &= ~state;
- g_assert (layer->owner == pipeline);
+ _COGL_ASSERT (layer->owner == pipeline);
if (layer->differences == 0)
_cogl_pipeline_prune_empty_layer_difference (pipeline,
layer);
@@ -1447,7 +1447,7 @@ cogl_pipeline_set_layer_matrix (CoglPipeline *pipeline,
{
layer->differences &= ~state;
- g_assert (layer->owner == pipeline);
+ _COGL_ASSERT (layer->owner == pipeline);
if (layer->differences == 0)
_cogl_pipeline_prune_empty_layer_difference (pipeline,
layer);
@@ -1630,7 +1630,7 @@ cogl_pipeline_set_layer_filters (CoglPipeline *pipeline,
{
layer->differences &= ~state;
- g_assert (layer->owner == pipeline);
+ _COGL_ASSERT (layer->owner == pipeline);
if (layer->differences == 0)
_cogl_pipeline_prune_empty_layer_difference (pipeline,
layer);
diff --git a/cogl/cogl-pipeline-layer.c b/cogl/cogl-pipeline-layer.c
index 558a8b6..ffab848 100644
--- a/cogl/cogl-pipeline-layer.c
+++ b/cogl/cogl-pipeline-layer.c
@@ -515,7 +515,7 @@ _cogl_pipeline_layer_resolve_authorities (CoglPipelineLayer *layer,
}
while ((authority = _cogl_pipeline_layer_get_parent (authority)));
- g_assert (remaining == 0);
+ _COGL_ASSERT (remaining == 0);
}
gboolean
@@ -716,7 +716,7 @@ _cogl_pipeline_init_default_layers (void)
*/
ctx->default_layer_n = _cogl_pipeline_layer_copy (layer);
new = _cogl_pipeline_set_layer_unit (NULL, ctx->default_layer_n, 1);
- g_assert (new == ctx->default_layer_n);
+ _COGL_ASSERT (new == ctx->default_layer_n);
/* Since we passed a newly allocated layer we don't expect that
* _set_layer_unit() will have to allocate *another* layer. */
diff --git a/cogl/cogl-pipeline-opengl.c b/cogl/cogl-pipeline-opengl.c
index ca16a8c..55419b8 100644
--- a/cogl/cogl-pipeline-opengl.c
+++ b/cogl/cogl-pipeline-opengl.c
@@ -730,8 +730,8 @@ get_max_activateable_texture_units (void)
}
#endif
- g_assert (n_values <= G_N_ELEMENTS (values) &&
- n_values > 0);
+ _COGL_ASSERT (n_values <= G_N_ELEMENTS (values) &&
+ n_values > 0);
/* Use the maximum value */
ctx->max_activateable_texture_units = values[0];
diff --git a/cogl/cogl-pipeline-progend-glsl.c b/cogl/cogl-pipeline-progend-glsl.c
index 5d65d70..9cccf0a 100644
--- a/cogl/cogl-pipeline-progend-glsl.c
+++ b/cogl/cogl-pipeline-progend-glsl.c
@@ -752,7 +752,7 @@ _cogl_pipeline_progend_glsl_end (CoglPipeline *pipeline,
_cogl_shader_compile_real (shader, n_tex_coord_attribs);
- g_assert (shader->language == COGL_SHADER_LANGUAGE_GLSL);
+ _COGL_ASSERT (shader->language == COGL_SHADER_LANGUAGE_GLSL);
GE( ctx, glAttachShader (program_state->program,
shader->gl_handle) );
diff --git a/cogl/cogl-pipeline-state.c b/cogl/cogl-pipeline-state.c
index 313e57f..5fed142 100644
--- a/cogl/cogl-pipeline-state.c
+++ b/cogl/cogl-pipeline-state.c
@@ -1470,7 +1470,7 @@ _cogl_pipeline_override_uniform (CoglPipeline *pipeline,
if (uniforms_state->override_values == NULL)
{
- g_assert (override_index == 0);
+ _COGL_ASSERT (override_index == 0);
uniforms_state->override_values = g_new (CoglBoxedValue, 1);
}
else
diff --git a/cogl/cogl-pipeline.c b/cogl/cogl-pipeline.c
index 7545855..8429c4a 100644
--- a/cogl/cogl-pipeline.c
+++ b/cogl/cogl-pipeline.c
@@ -461,7 +461,7 @@ _cogl_pipeline_free (CoglPipeline *pipeline)
destroy_weak_children_cb,
NULL);
- g_assert (COGL_LIST_EMPTY (&COGL_NODE (pipeline)->children));
+ _COGL_ASSERT (COGL_LIST_EMPTY (&COGL_NODE (pipeline)->children));
_cogl_pipeline_unparent (COGL_NODE (pipeline));
@@ -1756,7 +1756,7 @@ _cogl_pipeline_get_layer_with_flags (CoglPipeline *pipeline,
new = _cogl_pipeline_set_layer_unit (NULL, layer, unit_index);
/* Since we passed a newly allocated layer we wouldn't expect
* _set_layer_unit() to have to allocate *another* layer. */
- g_assert (new == layer);
+ _COGL_ASSERT (new == layer);
}
layer->index = layer_index;
@@ -2122,7 +2122,7 @@ _cogl_pipeline_resolve_authorities (CoglPipeline *pipeline,
}
while ((authority = _cogl_pipeline_get_parent (authority)));
- g_assert (remaining == 0);
+ _COGL_ASSERT (remaining == 0);
}
/* Comparison of two arbitrary pipelines is done by:
@@ -2605,7 +2605,7 @@ _cogl_pipeline_init_layer_state_hash_functions (void)
_cogl_pipeline_layer_hash_fragment_snippets_state;
/* So we get a big error if we forget to update this code! */
- g_assert (COGL_PIPELINE_LAYER_STATE_SPARSE_COUNT == 11);
+ _COGL_ASSERT (COGL_PIPELINE_LAYER_STATE_SPARSE_COUNT == 11);
}
static gboolean
@@ -2712,7 +2712,7 @@ _cogl_pipeline_init_state_hash_functions (void)
_cogl_pipeline_hash_fragment_snippets_state;
/* So we get a big error if we forget to update this code! */
- g_assert (COGL_PIPELINE_STATE_SPARSE_COUNT == 16);
+ _COGL_ASSERT (COGL_PIPELINE_STATE_SPARSE_COUNT == 16);
}
unsigned int
diff --git a/cogl/cogl-quaternion.c b/cogl/cogl-quaternion.c
index 5a68611..83ed41b 100644
--- a/cogl/cogl-quaternion.c
+++ b/cogl/cogl-quaternion.c
@@ -529,7 +529,7 @@ cogl_quaternion_slerp (CoglQuaternion *result,
}
/* If we have two unit quaternions the dot should be <= 1.0 */
- g_assert (cos_difference < 1.1f);
+ _COGL_ASSERT (cos_difference < 1.1f);
/* Determine the interpolation factors for each quaternion, simply using
@@ -616,7 +616,7 @@ cogl_quaternion_nlerp (CoglQuaternion *result,
}
/* If we have two unit quaternions the dot should be <= 1.0 */
- g_assert (cos_difference < 1.1f);
+ _COGL_ASSERT (cos_difference < 1.1f);
fa = 1.0f - t;
fb = t;
diff --git a/cogl/cogl-rectangle-map.c b/cogl/cogl-rectangle-map.c
index a483a56..73c790a 100644
--- a/cogl/cogl-rectangle-map.c
+++ b/cogl/cogl-rectangle-map.c
@@ -280,19 +280,19 @@ _cogl_rectangle_map_verify_recursive (CoglRectangleMapNode *node)
int sum =
_cogl_rectangle_map_verify_recursive (node->d.branch.left) +
_cogl_rectangle_map_verify_recursive (node->d.branch.right);
- g_assert (node->largest_gap ==
- MAX (node->d.branch.left->largest_gap,
- node->d.branch.right->largest_gap));
+ _COGL_ASSERT (node->largest_gap ==
+ MAX (node->d.branch.left->largest_gap,
+ node->d.branch.right->largest_gap));
return sum;
}
case COGL_RECTANGLE_MAP_EMPTY_LEAF:
- g_assert (node->largest_gap ==
- node->rectangle.width * node->rectangle.height);
+ _COGL_ASSERT (node->largest_gap ==
+ node->rectangle.width * node->rectangle.height);
return 0;
case COGL_RECTANGLE_MAP_FILLED_LEAF:
- g_assert (node->largest_gap == 0);
+ _COGL_ASSERT (node->largest_gap == 0);
return 1;
}
@@ -443,7 +443,7 @@ _cogl_rectangle_map_add (CoglRectangleMap *map,
for (node = found_node->parent; node; node = node->parent)
{
/* This node is a parent so it should always be a branch */
- g_assert (node->type == COGL_RECTANGLE_MAP_BRANCH);
+ _COGL_ASSERT (node->type == COGL_RECTANGLE_MAP_BRANCH);
node->largest_gap = MAX (node->d.branch.left->largest_gap,
node->d.branch.right->largest_gap);
@@ -518,7 +518,7 @@ _cogl_rectangle_map_remove (CoglRectangleMap *map,
for (node = node->parent; node; node = node->parent)
{
/* This node is a parent so it should always be a branch */
- g_assert (node->type == COGL_RECTANGLE_MAP_BRANCH);
+ _COGL_ASSERT (node->type == COGL_RECTANGLE_MAP_BRANCH);
if (node->d.branch.left->type == COGL_RECTANGLE_MAP_EMPTY_LEAF &&
node->d.branch.right->type == COGL_RECTANGLE_MAP_EMPTY_LEAF)
@@ -541,7 +541,7 @@ _cogl_rectangle_map_remove (CoglRectangleMap *map,
node->d.branch.right->largest_gap);
/* There is now one less rectangle */
- g_assert (map->n_rectangles > 0);
+ _COGL_ASSERT (map->n_rectangles > 0);
map->n_rectangles--;
/* and more space */
map->space_remaining += rectangle_size;
@@ -643,7 +643,7 @@ _cogl_rectangle_map_internal_foreach (CoglRectangleMap *map,
}
/* The stack should now be empty */
- g_assert (stack->len == 0);
+ _COGL_ASSERT (stack->len == 0);
}
typedef struct _CoglRectangleMapForeachClosure
diff --git a/cogl/cogl-texture-2d-sliced.c b/cogl/cogl-texture-2d-sliced.c
index 1ec9ed4..ece1a42 100644
--- a/cogl/cogl-texture-2d-sliced.c
+++ b/cogl/cogl-texture-2d-sliced.c
@@ -575,7 +575,7 @@ _cogl_pot_slices_for_size (int size_to_fill,
while (span.size - size_to_fill > max_waste)
{
span.size /= 2;
- g_assert (span.size > 0);
+ _COGL_ASSERT (span.size > 0);
}
}
}
@@ -953,7 +953,7 @@ _cogl_texture_2d_sliced_new_from_foreign (GLuint gl_handle,
/* This should only be called when the texture target is 2D. If a
rectangle texture is used then _cogl_texture_new_from_foreign
will create a cogl_texture_rectangle instead */
- g_assert (gl_target == GL_TEXTURE_2D);
+ _COGL_ASSERT (gl_target == GL_TEXTURE_2D);
gl_width = width + x_pot_waste;
gl_height = height + y_pot_waste;
@@ -1087,7 +1087,7 @@ _cogl_texture_2d_sliced_transform_coords_to_gl (CoglTexture *tex,
CoglSpan *y_span;
CoglTexture2D *slice_tex;
- g_assert (!_cogl_texture_2d_sliced_is_sliced (tex));
+ _COGL_ASSERT (!_cogl_texture_2d_sliced_is_sliced (tex));
/* Don't include the waste in the texture coordinates */
x_span = &g_array_index (tex_2ds->slice_x_spans, CoglSpan, 0);
diff --git a/cogl/cogl-texture-rectangle.c b/cogl/cogl-texture-rectangle.c
index 7580fc9..014372e 100644
--- a/cogl/cogl-texture-rectangle.c
+++ b/cogl/cogl-texture-rectangle.c
@@ -82,8 +82,8 @@ _cogl_texture_rectangle_set_wrap_mode_parameters (CoglTexture *tex,
if (tex_rect->wrap_mode_s != wrap_mode_s ||
tex_rect->wrap_mode_t != wrap_mode_t)
{
- g_assert (can_use_wrap_mode (wrap_mode_s));
- g_assert (can_use_wrap_mode (wrap_mode_t));
+ _COGL_ASSERT (can_use_wrap_mode (wrap_mode_s));
+ _COGL_ASSERT (can_use_wrap_mode (wrap_mode_t));
_cogl_bind_gl_texture_transient (GL_TEXTURE_RECTANGLE_ARB,
tex_rect->gl_texture,
@@ -446,7 +446,7 @@ _cogl_texture_rectangle_set_filters (CoglTexture *tex,
return;
/* Rectangle textures don't support mipmapping */
- g_assert (min_filter == GL_LINEAR || min_filter == GL_NEAREST);
+ _COGL_ASSERT (min_filter == GL_LINEAR || min_filter == GL_NEAREST);
/* Store new values */
tex_rect->min_filter = min_filter;
@@ -469,7 +469,7 @@ _cogl_texture_rectangle_pre_paint (CoglTexture *tex,
_COGL_GET_CONTEXT (ctx, NO_RETVAL);
/* Rectangle textures don't support mipmaps */
- g_assert ((flags & COGL_TEXTURE_NEEDS_MIPMAP) == 0);
+ _COGL_ASSERT ((flags & COGL_TEXTURE_NEEDS_MIPMAP) == 0);
}
static void
diff --git a/cogl/cogl-util.h b/cogl/cogl-util.h
index b546762..b385b3d 100644
--- a/cogl/cogl-util.h
+++ b/cogl/cogl-util.h
@@ -169,6 +169,7 @@ _cogl_util_popcountl (unsigned long num)
#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)
+#define _COGL_ASSERT(EXPR) g_assert(EXPR)
#define _COGL_ASSERT_NOT_REACHED (g_assert_not_reached ())
#else
#define _COGL_RETURN_IF_FAIL(EXPR) do { \
@@ -191,6 +192,15 @@ _cogl_util_popcountl (unsigned long num)
return (VAL); \
}; \
} while(0)
+#define _COGL_ASSERT(EXPR) do { \
+ if (!(EXPR)) \
+ { \
+ fprintf (stderr, "file %s: line %d: assertion `%s' failed", \
+ __FILE__, \
+ __LINE__, \
+ #EXPR); \
+ }; \
+ } while(0)
#define _COGL_ASSERT_NOT_REACHED do { \
fprintf (stderr, "file %s: line %d: reached an unexpected code path", \
__FILE__, \
diff --git a/cogl/cogl-xlib-renderer.c b/cogl/cogl-xlib-renderer.c
index 1bbbe14..3cefcd5 100644
--- a/cogl/cogl-xlib-renderer.c
+++ b/cogl/cogl-xlib-renderer.c
@@ -125,7 +125,7 @@ error_handler (Display *xdpy,
renderer = get_renderer_for_xdisplay (xdpy);
xlib_renderer = _cogl_xlib_renderer_get_data (renderer);
- g_assert (xlib_renderer->trap_state);
+ _COGL_ASSERT (xlib_renderer->trap_state);
xlib_renderer->trap_state->trapped_error_code = error->error_code;
@@ -154,7 +154,7 @@ _cogl_xlib_renderer_untrap_errors (CoglRenderer *renderer,
CoglXlibRenderer *xlib_renderer;
xlib_renderer = _cogl_xlib_renderer_get_data (renderer);
- g_assert (state == xlib_renderer->trap_state);
+ _COGL_ASSERT (state == xlib_renderer->trap_state);
XSetErrorHandler (state->old_error_handler);
diff --git a/cogl/cogl-xlib.c b/cogl/cogl-xlib.c
index 6c8ebea..8407aed 100644
--- a/cogl/cogl-xlib.c
+++ b/cogl/cogl-xlib.c
@@ -65,7 +65,7 @@ void
cogl_xlib_set_display (Display *display)
{
/* This can only be called once before the Cogl context is created */
- g_assert (_cogl_xlib_display == NULL);
+ _COGL_ASSERT (_cogl_xlib_display == NULL);
_cogl_xlib_display = display;
}
diff --git a/cogl/cogl2-path.c b/cogl/cogl2-path.c
index c632fe6..b2ac62c 100644
--- a/cogl/cogl2-path.c
+++ b/cogl/cogl2-path.c
@@ -1054,9 +1054,9 @@ static void
_cogl_path_tesselator_begin (GLenum type,
CoglPathTesselator *tess)
{
- g_assert (type == GL_TRIANGLES ||
- type == GL_TRIANGLE_FAN ||
- type == GL_TRIANGLE_STRIP);
+ _COGL_ASSERT (type == GL_TRIANGLES ||
+ type == GL_TRIANGLE_FAN ||
+ type == GL_TRIANGLE_STRIP);
tess->primitive_type = type;
tess->vertex_number = 0;
diff --git a/cogl/winsys/cogl-winsys-egl-wayland.c b/cogl/winsys/cogl-winsys-egl-wayland.c
index fe75e07..6c3ac96 100644
--- a/cogl/winsys/cogl-winsys-egl-wayland.c
+++ b/cogl/winsys/cogl-winsys-egl-wayland.c
@@ -127,8 +127,8 @@ _cogl_winsys_renderer_connect (CoglRenderer *renderer,
* given then a foreign compositor and shell must also have been
* given because wayland doesn't provide a way to
* retrospectively be notified of the these objects. */
- g_assert (renderer->foreign_wayland_compositor);
- g_assert (renderer->foreign_wayland_shell);
+ _COGL_ASSERT (renderer->foreign_wayland_compositor);
+ _COGL_ASSERT (renderer->foreign_wayland_shell);
wayland_renderer->wayland_compositor =
renderer->foreign_wayland_compositor;
wayland_renderer->wayland_shell = renderer->foreign_wayland_shell;
diff --git a/cogl/winsys/cogl-winsys-egl.c b/cogl/winsys/cogl-winsys-egl.c
index e47e642..c97ea55 100644
--- a/cogl/winsys/cogl-winsys-egl.c
+++ b/cogl/winsys/cogl-winsys-egl.c
@@ -214,7 +214,7 @@ egl_attributes_from_framebuffer_config (CoglDisplay *display,
attributes[i++] = EGL_NONE;
- g_assert (i < MAX_EGL_CONFIG_ATTRIBS);
+ _COGL_ASSERT (i < MAX_EGL_CONFIG_ATTRIBS);
}
static gboolean
diff --git a/cogl/winsys/cogl-winsys-glx.c b/cogl/winsys/cogl-winsys-glx.c
index 765191b..bd567e7 100644
--- a/cogl/winsys/cogl-winsys-glx.c
+++ b/cogl/winsys/cogl-winsys-glx.c
@@ -480,7 +480,7 @@ glx_attributes_from_framebuffer_config (CoglDisplay *display,
attributes[i++] = None;
- g_assert (i < MAX_GLX_CONFIG_ATTRIBS);
+ _COGL_ASSERT (i < MAX_GLX_CONFIG_ATTRIBS);
}
/* It seems the GLX spec never defined an invalid GLXFBConfig that
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]