summaryrefslogtreecommitdiff
path: root/perf
diff options
context:
space:
mode:
authorChris Wilson <chris@chris-wilson.co.uk>2011-09-12 13:18:29 +0100
committerChris Wilson <chris@chris-wilson.co.uk>2011-09-12 15:44:46 +0100
commit0f26f75eda317efc9e448c875110b846b224d463 (patch)
tree80fd31a552f2527888fbb0166442a1e7c6525ff5 /perf
parent7b6586a7385a529d7bfaa463541715f74f4a904d (diff)
perf/micro: Add measurement of setting the pixel directly using pixman
Signed-off-by: Chris Wilson <chris@chris-wilson.co.uk>
Diffstat (limited to 'perf')
-rw-r--r--perf/micro/pixel.c38
1 files changed, 38 insertions, 0 deletions
diff --git a/perf/micro/pixel.c b/perf/micro/pixel.c
index 12b8f47b..dd3ba526 100644
--- a/perf/micro/pixel.c
+++ b/perf/micro/pixel.c
@@ -28,6 +28,43 @@
#include "cairo-perf.h"
+#include <pixman.h>
+
+static cairo_time_t
+pixel_direct (cairo_t *cr, int width, int height, int loops)
+{
+ cairo_surface_t *surface, *image;
+ uint32_t *data;
+ int stride, bpp;
+
+ surface = cairo_get_target (cr);
+ image = cairo_surface_map_to_image (surface, NULL);
+ data = (uint32_t *) cairo_image_surface_get_data (image);
+ stride = cairo_image_surface_get_stride (image) / sizeof (uint32_t);
+
+ switch (cairo_image_surface_get_format (image)) {
+ default:
+ case CAIRO_FORMAT_INVALID:
+ case CAIRO_FORMAT_A1: bpp = 0; break;
+ case CAIRO_FORMAT_A8: bpp = 8; break;
+ case CAIRO_FORMAT_RGB16_565: bpp = 16; break;
+ case CAIRO_FORMAT_RGB24:
+ case CAIRO_FORMAT_RGB30:
+ case CAIRO_FORMAT_ARGB32: bpp = 32; break;
+ }
+
+ cairo_perf_timer_start ();
+
+ while (loops--)
+ pixman_fill (data, stride, bpp, 0, 0, 1, 1, -1);
+
+ cairo_perf_timer_stop ();
+
+ cairo_surface_unmap_image (surface, image);
+
+ return cairo_perf_timer_elapsed ();
+}
+
static cairo_time_t
pixel_paint (cairo_t *cr, int width, int height, int loops)
{
@@ -167,6 +204,7 @@ pixel (cairo_perf_t *perf, cairo_t *cr, int width, int height)
{
cairo_set_source_rgb (cr, 1., 1., 1.);
+ cairo_perf_run (perf, "pixel-direct", pixel_direct, NULL);
cairo_perf_run (perf, "pixel-paint", pixel_paint, NULL);
cairo_perf_run (perf, "pixel-mask", pixel_mask, NULL);
cairo_perf_run (perf, "pixel-rectangle", pixel_rectangle, NULL);