+/*
+ * Copyright (C) 2000 Red Hat, Inc
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License as published by the Free Software Foundation; either
+ * version 2 of the License, or (at your option) any later version.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library; if not, write to the
+ * Free Software Foundation, Inc., 59 Temple Place - Suite 330,
+ * Boston, MA 02111-1307, USA.
+ */
+#include "config.h"
#include <glib.h>
#include <string.h>
#include <stdlib.h>
static GTimeVal start_time;
-void start_timing (void)
+static void
+start_timing (void)
{
g_get_current_time (&start_time);
}
-double
+static double
stop_timing (const char *test, int iterations, int bytes)
{
GTimeVal stop_time;
return ((double)bytes * iterations) / (1000*msecs);
}
-void
+static void
init_array (double times[3][3][4])
{
int i, j, k;
times[i][j][k] = -1;
}
-void
+static void
dump_array (double times[3][3][4])
{
int i, j;
switch (j)
{
- case GDK_INTERP_NEAREST:
+ case PIXOPS_INTERP_NEAREST:
printf (" NEAREST\n");
break;
- case GDK_INTERP_TILES:
+ case PIXOPS_INTERP_TILES:
printf (" TILES\n");
break;
- case GDK_INTERP_BILINEAR:
+ case PIXOPS_INTERP_BILINEAR:
printf (" BILINEAR\n");
break;
- case GDK_INTERP_HYPER:
+ case PIXOPS_INTERP_HYPER:
printf (" HYPER\n");
break;
}
int main (int argc, char **argv)
{
int src_width, src_height, dest_width, dest_height;
- char *src_buf, *dest_buf;
+ unsigned char *src_buf, *dest_buf;
int src_index, dest_index;
int i;
double scale_times[3][3][4];
int filter_level;
- src_buf = malloc(src_rowstride * src_height);
+ src_buf = g_malloc(src_rowstride * src_height);
memset (src_buf, 0x80, src_rowstride * src_height);
- dest_buf = malloc(dest_rowstride * dest_height);
+ dest_buf = g_malloc(dest_rowstride * dest_height);
memset (dest_buf, 0x80, dest_rowstride * dest_height);
- for (filter_level = GDK_INTERP_NEAREST ; filter_level <= GDK_INTERP_HYPER; filter_level++)
+ for (filter_level = PIXOPS_INTERP_NEAREST ; filter_level <= PIXOPS_INTERP_HYPER; filter_level++)
{
printf ("src_channels = %d (%s); dest_channels = %d (%s); filter_level=",
src_channels, src_has_alpha ? "alpha" : "no alpha",
dest_channels, dest_has_alpha ? "alpha" : "no alpha");
switch (filter_level)
{
- case GDK_INTERP_NEAREST:
- printf ("GDK_INTERP_NEAREST\n");
+ case PIXOPS_INTERP_NEAREST:
+ printf ("PIXOPS_INTERP_NEAREST\n");
break;
- case GDK_INTERP_TILES:
- printf ("GDK_INTERP_TILES\n");
+ case PIXOPS_INTERP_TILES:
+ printf ("PIXOPS_INTERP_TILES\n");
break;
- case GDK_INTERP_BILINEAR:
- printf ("GDK_INTERP_BILINEAR\n");
+ case PIXOPS_INTERP_BILINEAR:
+ printf ("PIXOPS_INTERP_BILINEAR\n");
break;
- case GDK_INTERP_HYPER:
- printf ("GDK_INTERP_HYPER\n");
+ case PIXOPS_INTERP_HYPER:
+ printf ("PIXOPS_INTERP_HYPER\n");
break;
}
start_timing ();
for (i = 0; i < ITERS; i++)
{
- pixops_scale (dest_buf, 0, 0, dest_width, dest_height, dest_rowstride, dest_channels, dest_has_alpha,
- src_buf, src_width, src_height, src_rowstride, src_channels, src_has_alpha,
- (double)dest_width / src_width, (double)dest_height / src_height,
- filter_level);
+ _pixops_scale (dest_buf, dest_width, dest_height,
+ dest_rowstride, dest_channels,
+ dest_has_alpha, src_buf, src_width,
+ src_height, src_rowstride, src_channels,
+ src_has_alpha, 0, 0, 0, 0, 0, 0,
+ (double)dest_width / src_width,
+ (double)dest_height / src_height,
+ filter_level);
}
scale_times[src_index][dest_index][filter_level] =
stop_timing (" scale\t\t", ITERS, dest_height * dest_width);
start_timing ();
for (i = 0; i < ITERS; i++)
{
- pixops_composite (dest_buf, 0, 0, dest_width, dest_height, dest_rowstride, dest_channels, dest_has_alpha,
- src_buf, src_width, src_height, src_rowstride, src_channels, src_has_alpha,
- (double)dest_width / src_width, (double)dest_height / src_height,
- filter_level, 255);
+ _pixops_composite (dest_buf, dest_width, dest_height,
+ dest_rowstride, dest_channels,
+ dest_has_alpha, src_buf, src_width,
+ src_height, src_rowstride, src_channels,
+ src_has_alpha, 0, 0, 0, 0, 0, 0,
+ (double)dest_width / src_width,
+ (double)dest_height / src_height,
+ filter_level, 255);
}
composite_times[src_index][dest_index][filter_level] =
- stop_timing (" composite\t\t", ITERS, dest_height * dest_width);
+ stop_timing (" composite\t\t", ITERS,
+ dest_height * dest_width);
start_timing ();
for (i = 0; i < ITERS; i++)
{
- pixops_composite_color (dest_buf, 0, 0, dest_width, dest_height, dest_rowstride, dest_channels, dest_has_alpha,
- src_buf, src_width, src_height, src_rowstride, src_channels, src_has_alpha,
- (double)dest_width / src_width, (double)dest_height / src_height,
- filter_level, 255, 0, 0, 16, 0xaaaaaa, 0x555555);
+ _pixops_composite_color (dest_buf, dest_width, dest_height,
+ dest_rowstride, dest_channels,
+ dest_has_alpha, src_buf, src_width,
+ src_height, src_rowstride,
+ src_channels, src_has_alpha, 0, 0,
+ 0, 0, 0, 0,
+ (double)dest_width / src_width,
+ (double)dest_height / src_height,
+ filter_level, 255, 0, 0, 16,
+ 0xaaaaaa, 0x555555);
}
composite_color_times[src_index][dest_index][filter_level] =
stop_timing (" composite color\t", ITERS, dest_height * dest_width);
}
printf ("\n");
- free (src_buf);
- free (dest_buf);
+ g_free (src_buf);
+ g_free (dest_buf);
}
printf ("SCALE\n=====\n\n");