diff options
| author | Bryce Harrington <b.harrington@samsung.com> | 2013-11-12 19:52:58 -0800 |
|---|---|---|
| committer | Bryce Harrington <b.harrington@samsung.com> | 2013-11-13 13:19:18 -0800 |
| commit | 04cdffeed4d3c58c81f79e1c3869e3cb58f81cb7 (patch) | |
| tree | d1454541c5a14cd13fdd9f4cbdf530dd2737345e /src/skia-tests/rectangles.cpp | |
| parent | 8d30cc5e32d4c098c1382594e0799de44a44f1bf (diff) | |
Add a rectangles test case
Derived from Cairo's rectangles micro benchmark
Diffstat (limited to 'src/skia-tests/rectangles.cpp')
| -rw-r--r-- | src/skia-tests/rectangles.cpp | 39 |
1 files changed, 39 insertions, 0 deletions
diff --git a/src/skia-tests/rectangles.cpp b/src/skia-tests/rectangles.cpp new file mode 100644 index 0000000..f6fc2bc --- /dev/null +++ b/src/skia-tests/rectangles.cpp @@ -0,0 +1,39 @@ +#include "SkBitmap.h" +#include "SkBitmapDevice.h" +#include "SkPaint.h" +#include "SkRect.h" +#include <cairo.h> + +#include "caskbench.h" + +int +sk_setup_rectangles(caskbench_context_t *ctx) +{ + ctx->paint->setARGB(255, 255, 255, 255); + return 1; +} + +int +sk_test_rectangles(caskbench_context_t *ctx) +{ + int i, x, y, w, h; + SkRect rect; + + for (i=0; i<ctx->size; i++) { + ctx->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; + rect.set(x, y, x+w, y+h); + ctx->paint->setStrokeWidth(1); + ctx->canvas->drawRect(rect, *(ctx->paint)); + } + + return 1; +} + +void +sk_teardown_rectangles(void) +{ +} |