diff options
author | Billy Biggs <vektor@freedesktop.org> | 2005-08-30 02:43:03 +0000 |
---|---|---|
committer | Billy Biggs <vektor@freedesktop.org> | 2005-08-30 02:43:03 +0000 |
commit | b70311250baa8e26b1d218679468ee6763c3a137 (patch) | |
tree | 34ed83e5245bcccbfafbccb0e31320faabbeab02 | |
parent | ed08e10596f8d94aa7c687126b68fe213c285902 (diff) |
* 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.
-rw-r--r-- | .cvsignore | 29 | ||||
-rw-r--r-- | ChangeLog | 8 | ||||
-rw-r--r-- | Makefile | 3 | ||||
-rw-r--r-- | remenic-gradient.c | 79 |
4 files changed, 118 insertions, 1 deletions
diff --git a/.cvsignore b/.cvsignore new file mode 100644 index 0000000..369d560 --- /dev/null +++ b/.cvsignore @@ -0,0 +1,29 @@ +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 @@ -1,5 +1,13 @@ 2005-08-29 Billy Biggs <vektor@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@dumbterm.net> + * Makefile: Add the multiple-clip-rectangles test. * multiple-clip-rectangles.c: (test), (main): Make this a real test case. @@ -25,7 +25,8 @@ BENCHMARKS= \ textpath \ textpath-xlib \ texturedtext \ - texturedtext-xlib + texturedtext-xlib \ + remenic-gradient MYCFLAGS=-Wall `pkg-config --cflags cairo libpng12` MYLDFLAGS=`pkg-config --libs cairo libpng12` diff --git a/remenic-gradient.c b/remenic-gradient.c new file mode 100644 index 0000000..d68c903 --- /dev/null +++ b/remenic-gradient.c @@ -0,0 +1,79 @@ +#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; +} + |