summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorBryce Harrington <b.harrington@samsung.com>2014-04-16 17:37:18 -0700
committerBryce Harrington <b.harrington@samsung.com>2014-04-18 10:09:10 -0700
commitcd11a4ff0421fd293279b202be800550890574bb (patch)
treead7ecaf85527daa7e47d98a4ed2bb167bfa69e6a
parent3e22a8580a8045e450a2f2e47c8ac36abf8882ae (diff)
perf: Refactor some common macros to cairo-perf.h
These macros are standard in src's cairoint.h and test's cairo-test.h internal header files, so for consistency do the same thing with perf's cairo-perf.h. Reviewed-by: Uli Schlachter <psychon@znc.in>
-rw-r--r--perf/cairo-perf-chart.c2
-rw-r--r--perf/cairo-perf-compare-backends.c1
-rw-r--r--perf/cairo-perf-trace.c5
-rw-r--r--perf/cairo-perf.h12
-rw-r--r--perf/micro/cairo-perf-cover.c5
-rw-r--r--perf/micro/dragon.c8
-rw-r--r--perf/micro/zrusin.c4
7 files changed, 17 insertions, 20 deletions
diff --git a/perf/cairo-perf-chart.c b/perf/cairo-perf-chart.c
index 1faa964f2..738fe5c7b 100644
--- a/perf/cairo-perf-chart.c
+++ b/perf/cairo-perf-chart.c
@@ -57,8 +57,6 @@ struct color {
#define FONT_SIZE 12
#define PAD (4)
-#define MAX(a,b) ((a) > (b) ? (a) : (b))
-
static double
to_factor (double x)
{
diff --git a/perf/cairo-perf-compare-backends.c b/perf/cairo-perf-compare-backends.c
index 2cbb24c5d..ff7359e1a 100644
--- a/perf/cairo-perf-compare-backends.c
+++ b/perf/cairo-perf-compare-backends.c
@@ -149,7 +149,6 @@ test_diff_print (test_diff_t *diff,
printf("\n");
}
-#define MAX(a,b) ((a) > (b) ? (a) : (b))
static void
cairo_perf_reports_compare (cairo_perf_report_t *reports,
int num_reports,
diff --git a/perf/cairo-perf-trace.c b/perf/cairo-perf-trace.c
index f27f8e44d..02e0e29f9 100644
--- a/perf/cairo-perf-trace.c
+++ b/perf/cairo-perf-trace.c
@@ -199,7 +199,6 @@ scache_equal (const void *A,
return a->entry.hash == b->entry.hash;
}
-#define ARRAY_SIZE(A) (sizeof(A)/sizeof(A[0]))
static void
scache_mark_active (cairo_surface_t *surface)
{
@@ -210,7 +209,7 @@ scache_mark_active (cairo_surface_t *surface)
return;
t0 = cairo_surface_reference (surface);
- for (n = 0; n < ARRAY_SIZE (surface_holdovers); n++) {
+ for (n = 0; n < ARRAY_LENGTH (surface_holdovers); n++) {
if (surface_holdovers[n] == surface) {
surface_holdovers[n] = t0;
t0 = surface;
@@ -232,7 +231,7 @@ scache_clear (void)
if (surface_cache == NULL)
return;
- for (n = 0; n < ARRAY_SIZE (surface_holdovers); n++) {
+ for (n = 0; n < ARRAY_LENGTH (surface_holdovers); n++) {
cairo_surface_destroy (surface_holdovers[n]);
surface_holdovers[n] = NULL;
}
diff --git a/perf/cairo-perf.h b/perf/cairo-perf.h
index 4e898acd7..b32b0e0ff 100644
--- a/perf/cairo-perf.h
+++ b/perf/cairo-perf.h
@@ -195,6 +195,18 @@ test_report_cmp_name (const void *a,
#define CAIRO_PERF_DECL(func) CAIRO_PERF_RUN_DECL(func); CAIRO_PERF_ENABLED_DECL(func)
+#ifndef MIN
+#define MIN(a, b) ((a) < (b) ? (a) : (b))
+#endif
+
+#ifndef MAX
+#define MAX(a, b) ((a) > (b) ? (a) : (b))
+#endif
+
+#ifndef ARRAY_LENGTH
+#define ARRAY_LENGTH(__array) ((int) (sizeof (__array) / sizeof (__array[0])))
+#endif
+
CAIRO_PERF_DECL (fill);
CAIRO_PERF_DECL (paint);
CAIRO_PERF_DECL (paint_with_alpha);
diff --git a/perf/micro/cairo-perf-cover.c b/perf/micro/cairo-perf-cover.c
index 151a2e679..c2499021f 100644
--- a/perf/micro/cairo-perf-cover.c
+++ b/perf/micro/cairo-perf-cover.c
@@ -290,7 +290,6 @@ set_source_radial_rgba (cairo_t *cr,
}
typedef void (*set_source_func_t) (cairo_t *cr, int width, int height);
-#define ARRAY_SIZE(arr) (sizeof(arr)/sizeof((arr)[0]))
void
cairo_perf_cover_sources_and_operators (cairo_perf_t *perf,
@@ -325,10 +324,10 @@ cairo_perf_cover_sources_and_operators (cairo_perf_t *perf,
{ CAIRO_OPERATOR_SOURCE, "source" }
};
- for (i = 0; i < ARRAY_SIZE (sources); i++) {
+ for (i = 0; i < ARRAY_LENGTH (sources); i++) {
(sources[i].set_source) (perf->cr, perf->size, perf->size);
- for (j = 0; j < ARRAY_SIZE (operators); j++) {
+ for (j = 0; j < ARRAY_LENGTH (operators); j++) {
cairo_set_operator (perf->cr, operators[j].op);
xasprintf (&expanded_name, "%s_%s_%s",
diff --git a/perf/micro/dragon.c b/perf/micro/dragon.c
index e215eaccc..aa5daf534 100644
--- a/perf/micro/dragon.c
+++ b/perf/micro/dragon.c
@@ -28,14 +28,6 @@
#include "cairo-perf.h"
-#ifndef MIN
-#define MIN(a,b) (((a) < (b)) ? (a) : (b))
-#endif
-
-#ifndef MAX
-#define MAX(a,b) (((a) > (b)) ? (a) : (b))
-#endif
-
static inline int
next_pot (int v)
{
diff --git a/perf/micro/zrusin.c b/perf/micro/zrusin.c
index 7d8b004bf..3dee74d23 100644
--- a/perf/micro/zrusin.c
+++ b/perf/micro/zrusin.c
@@ -33,14 +33,12 @@ typedef struct {
#include "zrusin-another.h"
-#define ARRAY_SIZE(arr) sizeof(arr)/sizeof(arr[0])
-
static void
zrusin_another_path (cairo_t *cr)
{
unsigned int i;
- for (i=0; i < ARRAY_SIZE (zrusin_another); i++)
+ for (i=0; i < ARRAY_LENGTH (zrusin_another); i++)
cairo_line_to (cr, zrusin_another[i].x, zrusin_another[i].y);
}