*/
#undef DEBUG
-#define DEBUG 0
-#if DEBUG
+/* Turn on debugging depending on what type of release this is
+ */
+#if (((PIXMAN_VERSION_MICRO % 2) == 0) && ((PIXMAN_VERSION_MINOR % 2) == 1))
+
+/* Debugging gets turned on for development releases because these
+ * are the things that end up in bleeding edge distributions such
+ * as Rawhide etc.
+ *
+ * For performance reasons we don't turn it on for stable releases or
+ * random git checkouts. (Random git checkouts are often used for
+ * performance work).
+ */
+
+# define DEBUG
+
+#endif
+
+#ifdef DEBUG
+
+void
+_pixman_log_error (const char *function, const char *message);
#define return_if_fail(expr) \
do \
{ \
- if (!(expr)) \
- { \
- fprintf (stderr, "In %s: %s failed\n", FUNC, # expr); \
- return; \
- } \
+ if (!(expr)) \
+ { \
+ _pixman_log_error (FUNC, "The expression " # expr " was false"); \
+ return; \
+ } \
} \
while (0)
do \
{ \
if (!(expr)) \
- { \
- fprintf (stderr, "In %s: %s failed\n", FUNC, # expr); \
- return (retval); \
- } \
+ { \
+ _pixman_log_error (FUNC, "The expression " # expr " was false"); \
+ return (retval); \
+ } \
} \
while (0)
+#define critical_if_fail(expr) \
+ do \
+ { \
+ if (!(expr)) \
+ _pixman_log_error (FUNC, "The expression " # expr " was false"); \
+ } \
+ while (0)
+
+
#else
-#define return_if_fail(expr) \
+#define _pixman_log_error(f,m) do { } while (0) \
+
+#define return_if_fail(expr) \
do \
{ \
if (!(expr)) \
} \
while (0)
+#define critical_if_fail(expr) \
+ do \
+ { \
+ } \
+ while (0)
#endif
/*
#define GOOD_RECT(rect) ((rect)->x1 < (rect)->x2 && (rect)->y1 < (rect)->y2)
#define BAD_RECT(rect) ((rect)->x1 > (rect)->x2 || (rect)->y1 > (rect)->y2)
-/* Turn on debugging depending on what type of release this is
- */
-#if (((PIXMAN_VERSION_MICRO % 2) == 0) && ((PIXMAN_VERSION_MINOR % 2) == 1))
-/* This is a development snapshot, so we want self-checking in order to
- * catch as many bugs as possible. However, we don't turn on the asserts
- * because that just leads to the X server crashing which leads to
- * people not running the snapshots.
- */
-# define noFATAL_BUGS
-# define SELF_CHECKS
-#else
-/* This is either a stable release or a random git checkout. We don't
- * want self checks in either case for performance reasons. (Random
- * git checkouts are often used for performance work
- */
-# define noFATAL_BUGS
-# define noSELF_CHECKS
-#endif
-
-#ifndef FATAL_BUGS
-# undef assert
-# undef abort
-# define assert(expr)
-# define abort()
-#endif
-
-#ifdef SELF_CHECKS
-
-static void
-log_region_error (const char *function, const char *message)
-{
- static int n_messages = 0;
-
- if (n_messages < 5)
- {
- fprintf (stderr,
- "*** BUG ***\n"
- "%s: %s\n"
- "Set a breakpoint on 'log_region_error' to debug\n\n",
- function, message);
-
- abort (); /* This is #defined away unless FATAL_BUGS is defined */
-
- n_messages++;
- }
-}
+#ifdef DEBUG
#define GOOD(reg) \
do \
{ \
if (!PREFIX (_selfcheck (reg))) \
- log_region_error (FUNC, "Malformed region " # reg); \
+ _pixman_log_error (FUNC, "Malformed region " # reg); \
} while (0)
#else
-#define log_region_error(function, name)
#define GOOD(reg)
#endif
} \
ADDRECT (next_rect, nx1, ny1, nx2, ny2); \
region->data->numRects++; \
- assert (region->data->numRects <= region->data->size); \
+ critical_if_fail (region->data->numRects <= region->data->size); \
} while (0)
#define DOWNSIZE(reg, numRects) \
if (!GOOD_RECT (®ion->extents))
{
if (BAD_RECT (®ion->extents))
- log_region_error (FUNC, "Invalid rectangle passed");
+ _pixman_log_error (FUNC, "Invalid rectangle passed");
PREFIX (_init) (region);
return;
}
if (!GOOD_RECT (extents))
{
if (BAD_RECT (extents))
- log_region_error (FUNC, "Invalid rectangle passed");
+ _pixman_log_error (FUNC, "Invalid rectangle passed");
PREFIX (_init) (region);
return;
}
* Figure out how many rectangles are in the band.
*/
numRects = cur_start - prev_start;
- assert (numRects == region->data->numRects - cur_start);
+ critical_if_fail (numRects == region->data->numRects - cur_start);
if (!numRects) return cur_start;
new_rects = r_end - r;
- assert (y1 < y2);
- assert (new_rects != 0);
+ critical_if_fail (y1 < y2);
+ critical_if_fail (new_rects != 0);
/* Make sure we have enough space for all rectangles to be added */
RECTALLOC (region, new_rects);
do
{
- assert (r->x1 < r->x2);
+ critical_if_fail (r->x1 < r->x2);
ADDRECT (next_rect, r->x1, y1, r->x2, y2);
r++;
}
r2 = PIXREGION_RECTS (reg2);
r2_end = r2 + numRects;
- assert (r1 != r1_end);
- assert (r2 != r2_end);
+ critical_if_fail (r1 != r1_end);
+ critical_if_fail (r2 != r2_end);
old_data = (region_data_type_t *)NULL;
* rectangle after the last one in the current band for their
* respective regions.
*/
- assert (r1 != r1_end);
- assert (r2 != r2_end);
+ critical_if_fail (r1 != r1_end);
+ critical_if_fail (r2 != r2_end);
FIND_BAND (r1, r1_band_end, r1_end, r1y1);
FIND_BAND (r2, r2_band_end, r2_end, r2y1);
region->extents.x2 = box_end->x2;
region->extents.y2 = box_end->y2;
- assert (region->extents.y1 < region->extents.y2);
+ critical_if_fail (region->extents.y1 < region->extents.y2);
while (box <= box_end)
{
box++;
}
- assert (region->extents.x1 < region->extents.x2);
+ critical_if_fail (region->extents.x1 < region->extents.x2);
}
/*======================================================================
next_rect = PIXREGION_TOP (region);
- assert (y1 < y2);
- assert (r1 != r1_end && r2 != r2_end);
+ critical_if_fail (y1 < y2);
+ critical_if_fail (r1 != r1_end && r2 != r2_end);
do
{
int x1; /* left and right side of current union */
int x2;
- assert (y1 < y2);
- assert (r1 != r1_end && r2 != r2_end);
+ critical_if_fail (y1 < y2);
+ critical_if_fail (r1 != r1_end && r2 != r2_end);
next_rect = PIXREGION_TOP (region);
if (!GOOD_RECT (®ion.extents))
{
if (BAD_RECT (®ion.extents))
- log_region_error (FUNC, "Invalid rectangle passed");
+ _pixman_log_error (FUNC, "Invalid rectangle passed");
return PREFIX (_copy) (dest, source);
}
-
+
region.data = NULL;
return PREFIX (_union) (dest, source, ®ion);
x1 = r1->x1;
- assert (y1 < y2);
- assert (r1 != r1_end && r2 != r2_end);
+ critical_if_fail (y1 < y2);
+ critical_if_fail (r1 != r1_end && r2 != r2_end);
next_rect = PIXREGION_TOP (region);
* Left part of subtrahend covers part of minuend: add uncovered
* part of minuend to region and skip to next subtrahend.
*/
- assert (x1 < r2->x1);
+ critical_if_fail (x1 < r2->x1);
NEWRECT (region, next_rect, x1, y1, r2->x1, y2);
x1 = r2->x2;
*/
while (r1 != r1_end)
{
- assert (x1 < r1->x2);
+ critical_if_fail (x1 < r1->x2);
NEWRECT (region, next_rect, x1, y1, r1->x2, y2);
{
GOOD (region);
- assert (GOOD_RECT (box));
+ critical_if_fail (GOOD_RECT (box));
region->extents = *box;