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>
This commit is contained in:
Bryce Harrington 2014-04-16 17:37:18 -07:00
parent 3e22a8580a
commit cd11a4ff04
7 changed files with 17 additions and 20 deletions

View file

@ -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)
{

View file

@ -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,

View file

@ -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;
}

View file

@ -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);

View file

@ -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",

View file

@ -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)
{

View file

@ -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);
}