[cairo-commit] cairo-benchmarks .cvsignore, NONE, 1.1 ChangeLog, 1.2, 1.3 Makefile, 1.2, 1.3 remenic-gradient.c, NONE, 1.1

Billy Biggs commit at pdx.freedesktop.org
Mon Aug 29 19:43:05 PDT 2005


Committed by: vektor

Update of /cvs/cairo/cairo-benchmarks
In directory gabe:/tmp/cvs-serv28629

Modified Files:
	ChangeLog Makefile 
Added Files:
	.cvsignore remenic-gradient.c 
Log Message:
	* remenic-gradient.c: (rounded_rectangle), (run_benchmark), (main):
	Add the test case from bug #4263.
	* Makefile: Add it to the makefile as well.

	* .cvsignore: Add a .cvsignore.



--- NEW FILE: .cvsignore ---
add
add-xlib
curves
curves-xlib
downsample-bilinear
downsample-bilinear-xlib
downsample-nearest
downsample-nearest-xlib
gradients-linear
gradients-linear-xlib
lines
lines-xlib
multiple-clip-rectangles
multiple-clip-rectangles-xlib
over
over-clipped
over-clipped-xlib
over-xlib
pdf2png.c
remenic-gradient
textpath
textpath-xlib
texturedtext
texturedtext-xlib
upsample-bilinear
upsample-bilinear-xlib
upsample-nearest
upsample-nearest-xlib
remenic-gradient

Index: ChangeLog
===================================================================
RCS file: /cvs/cairo/cairo-benchmarks/ChangeLog,v
retrieving revision 1.2
retrieving revision 1.3
diff -u -d -r1.2 -r1.3
--- ChangeLog	30 Aug 2005 02:39:24 -0000	1.2
+++ ChangeLog	30 Aug 2005 02:43:03 -0000	1.3
@@ -1,5 +1,13 @@
 2005-08-29  Billy Biggs  <vektor at dumbterm.net>
 
+	* remenic-gradient.c: (rounded_rectangle), (run_benchmark), (main):
+	Add the test case from bug #4263.
+	* Makefile: Add it to the makefile as well.
+
+	* .cvsignore: Add a .cvsignore.
+
+2005-08-29  Billy Biggs  <vektor at dumbterm.net>
+
 	* Makefile: Add the multiple-clip-rectangles test.
 	* multiple-clip-rectangles.c: (test), (main): Make this
 	a real test case.

Index: Makefile
===================================================================
RCS file: /cvs/cairo/cairo-benchmarks/Makefile,v
retrieving revision 1.2
retrieving revision 1.3
diff -u -d -r1.2 -r1.3
--- Makefile	30 Aug 2005 02:39:24 -0000	1.2
+++ Makefile	30 Aug 2005 02:43:03 -0000	1.3
@@ -25,7 +25,8 @@
 	textpath			\
 	textpath-xlib			\
 	texturedtext			\
-	texturedtext-xlib
+	texturedtext-xlib		\
+	remenic-gradient
 
 MYCFLAGS=-Wall `pkg-config --cflags cairo libpng12`
 MYLDFLAGS=`pkg-config --libs cairo libpng12`

--- NEW FILE: remenic-gradient.c ---
#include <sys/time.h>
#include <cairo.h>
#include <stdlib.h>
#include <stdio.h>

#define WIDTH 400
#define HEIGHT 300
#define NUM_RUNS 100
#define M_PI 3.14159265358979323846

static int square = 1;

void
rounded_rectangle (cairo_t *cr,
		   double x, double y, double w, double h,
		   double radius)
{
    cairo_move_to (cr, x+radius, y);
    cairo_arc (cr, x+w-radius, y+radius,   radius, M_PI + M_PI / 2, M_PI * 2        );
    cairo_arc (cr, x+w-radius, y+h-radius, radius, 0,               M_PI / 2        );
    cairo_arc (cr, x+radius,   y+h-radius, radius, M_PI/2,          M_PI            );
    cairo_arc (cr, x+radius,   y+radius,   radius, M_PI,            270 * M_PI / 180);
}

static void
run_benchmark (cairo_surface_t *surface)
{
    struct timeval before;
    struct timeval after;
    int i;

    cairo_t *cr;
    cairo_pattern_t *pattern;

    gettimeofday (&before, NULL);
    for (i=0; i < NUM_RUNS; i++)
    {
	cr = cairo_create (surface);

	if (square)
	    cairo_rectangle (cr, 0, 0, WIDTH, HEIGHT);
	else
	    rounded_rectangle (cr, 0, 0, WIDTH, HEIGHT, 3.0);

	pattern = cairo_pattern_create_linear (0, 0, 0, HEIGHT);
	cairo_pattern_add_color_stop_rgb (pattern, 0, 1, 0, 0);
	cairo_pattern_add_color_stop_rgb (pattern, 1, 0, 0, 0);
	cairo_set_source (cr, pattern);
	cairo_pattern_destroy (pattern);

	cairo_fill (cr);
	cairo_destroy (cr);
    }
    gettimeofday (&after, NULL);

    fprintf (stderr, "%g msec\n",
	     (after.tv_sec - before.tv_sec) * 1000. +
	     (after.tv_usec - before.tv_usec) / 1000.);
}

int
main (int argc, char *argv[])
{
    cairo_surface_t *surface;
  
    if (argc != 2) {
	fprintf (stderr, "Usage: gradient-test [0/1] (0 == rounded, 1 == square)\n");
	exit (1);
    }

    square = atoi (argv[1]);

    surface = cairo_image_surface_create (CAIRO_FORMAT_RGB24, WIDTH, HEIGHT);

    run_benchmark (surface);

    return 0;
}




More information about the cairo-commit mailing list