diff options
author | Chris Wilson <chris@chris-wilson.co.uk> | 2011-09-11 19:06:36 +0100 |
---|---|---|
committer | Chris Wilson <chris@chris-wilson.co.uk> | 2011-09-11 19:06:36 +0100 |
commit | a27e9b65eefad5083461042c4c6c3a14ee5708e7 (patch) | |
tree | f1d0365ef63592f78b2ddb5f796706a971be9044 | |
parent | 483e9d62e4b04f72e541fe562e34c7afb420c93e (diff) |
tiger: switchable antialiasing quality
-rw-r--r-- | demo.c | 31 | ||||
-rw-r--r-- | demo.h | 1 | ||||
-rw-r--r-- | spinner-demo.c | 4 | ||||
-rw-r--r-- | spiral-demo.c | 3 | ||||
-rw-r--r-- | tiger-demo.c | 14 |
5 files changed, 47 insertions, 6 deletions
@@ -47,6 +47,37 @@ int device_get_benchmark(int argc, char **argv) return count; } +static cairo_antialias_t str_to_antialias(const char *str) +{ + if (strcmp (str, "none") == 0) + return CAIRO_ANTIALIAS_NONE; + else if (strcmp (str, "fast") == 0) + return CAIRO_ANTIALIAS_FAST; + else if (strcmp (str, "good") == 0) + return CAIRO_ANTIALIAS_GOOD; + else if (strcmp (str, "best") == 0) + return CAIRO_ANTIALIAS_BEST; + else + return CAIRO_ANTIALIAS_DEFAULT; +} + +cairo_antialias_t device_get_antialias(int argc, char **argv) +{ + int n; + + for (n = 1; n < argc; n++) { + if (strncmp (argv[n], "--antialias=", 12) == 0) { + return str_to_antialias(argv[n]+12); + } else if (strcmp (argv[n], "--antialias") == 0) { + if (n + 1 < argc) + return str_to_antialias(argv[++n]); + else + return CAIRO_ANTIALIAS_DEFAULT; + } + } + + return CAIRO_ANTIALIAS_DEFAULT; +} struct device *device_open(int argc, char **argv) { @@ -29,6 +29,7 @@ struct slide { struct device *device_open(int argc, char **argv); int device_get_size(int argc, char **argv, int *width, int *height); +cairo_antialias_t device_get_antialias(int argc, char **argv); int device_get_benchmark(int argc, char **argv); #if HAVE_GLX diff --git a/spinner-demo.c b/spinner-demo.c index 0ddf549..fa72ec0 100644 --- a/spinner-demo.c +++ b/spinner-demo.c @@ -244,8 +244,8 @@ int main(int argc, char **argv) load_sources("/usr/share/backgrounds", device, device->get_framebuffer(device)->surface); - printf("Loaded %d images, %d/%d pixels in total\n", - num_sources, out_pixels, in_pixels); + printf("Loaded %d images, %ld/%ld pixels in total\n", + num_sources, (long)out_pixels, (long)in_pixels); if (num_sources == 0) return 0; diff --git a/spiral-demo.c b/spiral-demo.c index e3787d7..f5545fb 100644 --- a/spiral-demo.c +++ b/spiral-demo.c @@ -218,7 +218,8 @@ int main(int argc, char **argv) } load_sources(path, device->get_framebuffer(device)->surface); - printf("Loaded %d images, %d/%d pixels in total from %s\n", num_sources, out_pixels, in_pixels, path); + printf("Loaded %d images, %ld/%ld pixels in total from %s\n", + num_sources, (long)out_pixels, (long)in_pixels, path); gettimeofday(&start, 0); now = last_tty = last_fps = start; frames = 0; diff --git a/tiger-demo.c b/tiger-demo.c index 7f4388f..dd35452 100644 --- a/tiger-demo.c +++ b/tiger-demo.c @@ -21,14 +21,19 @@ #include "tiger.inc" -static void tiger(struct device *device, struct framebuffer *fb, - double scale, double rotation) +static void tiger(struct device *device, + struct framebuffer *fb, + cairo_antialias_t antialias, + double scale, + double rotation) { cairo_t *cr; int i; cr = cairo_create (fb->surface); + cairo_set_antialias (cr, antialias); + cairo_set_operator (cr, CAIRO_OPERATOR_SOURCE); cairo_set_source_rgba (cr, 0.1, 0.2, 0.3, 1.0); cairo_paint (cr); @@ -117,6 +122,8 @@ int main (int argc, char **argv) struct device *device; struct timeval start, last_tty, last_fps, now; + cairo_antialias_t antialias; + double scale = 0.1; double factor = 1.05; double rotation = 0.0; @@ -127,6 +134,7 @@ int main (int argc, char **argv) int benchmark; device = device_open(argc, argv); + antialias = device_get_antialias(argc, argv); benchmark = device_get_benchmark(argc, argv); if (benchmark == 0) benchmark = 20; @@ -135,7 +143,7 @@ int main (int argc, char **argv) do { struct framebuffer *fb = device->get_framebuffer (device); - tiger (device, fb, scale, rotation); + tiger (device, fb, antialias, scale, rotation); gettimeofday(&now, NULL); if (benchmark < 0 && last_fps.tv_sec) |