summaryrefslogtreecommitdiffstatsci
path: root/src/skia-tests/rectangles.cpp
diff options
context:
space:
mode:
authorBryce Harrington <b.harrington@samsung.com>2014-03-05 17:13:19 -0800
committerBryce Harrington <b.harrington@samsung.com>2014-03-05 17:16:43 -0800
commitf6a3a24d62db8aa844f785fd38c8e1d21de8794c (patch)
tree65ef4f605c1f2849129d615d2749d3d799835896 /src/skia-tests/rectangles.cpp
parent83303324b218f7ee97c8ce65f71c04d35f250e97 (diff)
rectangles: Make skia and cairo test cases consistent
Both tests now produce identical output, so this is now providing a solid apples-to-apples comparison. This shows cairo trumping skia's performance by about 300% on the image backend. Note that I disabled antialiasing in the cairo case in order to make the rectangle lines draw as sharply as they do in skia. It looks like skia may have antialiasing off by default; to be certain I've forced it off.
Diffstat (limited to 'src/skia-tests/rectangles.cpp')
-rw-r--r--src/skia-tests/rectangles.cpp24
1 files changed, 17 insertions, 7 deletions
diff --git a/src/skia-tests/rectangles.cpp b/src/skia-tests/rectangles.cpp
index 81130fd..8b5cc18 100644
--- a/src/skia-tests/rectangles.cpp
+++ b/src/skia-tests/rectangles.cpp
@@ -1,3 +1,4 @@
+#include <math.h>
#include <SkCanvas.h>
#include <SkPaint.h>
#include <SkRect.h>
@@ -8,7 +9,10 @@
int
sk_setup_rectangles(caskbench_context_t *ctx)
{
- ctx->skia_paint->setARGB(255, 255, 255, 255);
+ ctx->skia_canvas->drawARGB(255, 0, 0, 0);
+ ctx->skia_paint->setAntiAlias(false);
+ ctx->skia_paint->setStrokeWidth(1);
+ ctx->skia_paint->setStyle(SkPaint::kStroke_Style);
return 1;
}
@@ -20,17 +24,23 @@ sk_teardown_rectangles(void)
int
sk_test_rectangles(caskbench_context_t *ctx)
{
+ unsigned char red, green, blue, alpha;
int i, x, y, w, h;
SkRect rect;
for (i=0; i<ctx->size; i++) {
- ctx->skia_paint->setColor(rand());
- w = (0.5*(double)ctx->canvas_width*rand())/RAND_MAX + 1;
- h = (0.5*(double)ctx->canvas_height*rand())/RAND_MAX + 1;
- x = (0.5*(double)ctx->canvas_width*rand())/RAND_MAX;
- y = (0.5*(double)ctx->canvas_height*rand())/RAND_MAX;
+ red = int( 255 * (double)rand()/RAND_MAX );
+ green = int( 255 * (double)rand()/RAND_MAX );
+ blue = int( 255 * (double)rand()/RAND_MAX );
+ alpha = int( 255 * (double)rand()/RAND_MAX );
+ ctx->skia_paint->setARGB(alpha, red, green, blue);
+
+ w = trunc( (0.5*(double)ctx->canvas_width*rand())/RAND_MAX ) + 1;
+ h = trunc( (0.5*(double)ctx->canvas_height*rand())/RAND_MAX ) + 1;
+ x = trunc( (0.5*(double)ctx->canvas_width*rand())/RAND_MAX );
+ y = trunc( (0.5*(double)ctx->canvas_height*rand())/RAND_MAX );
rect.set(x, y, x+w, y+h);
- ctx->skia_paint->setStrokeWidth(1);
+
ctx->skia_canvas->drawRect(rect, *(ctx->skia_paint));
}