diff options
| author | Bryce Harrington <bryce@canonical.com> | 2013-11-26 19:22:34 -0800 |
|---|---|---|
| committer | Bryce Harrington <bryce@canonical.com> | 2013-11-26 19:22:34 -0800 |
| commit | 2276c56411611a12bfdfc36bcc1cba9c3c65c6c9 (patch) | |
| tree | 2cf53bc561d54397dcfc3834c5494e07ce04c775 /src/caskbench.cpp | |
| parent | d01f172ca15592e2507ce8920621180ed4bb389a (diff) | |
Make context track the skia device rather than the bitmap
We can access the bitmap from the device later when we want to write the
file. Tracking the device instead will allow us to generalize to work
with skia EGL devices too.
Diffstat (limited to 'src/caskbench.cpp')
| -rw-r--r-- | src/caskbench.cpp | 25 |
1 files changed, 13 insertions, 12 deletions
diff --git a/src/caskbench.cpp b/src/caskbench.cpp index 1ba3132..a80f95c 100644 --- a/src/caskbench.cpp +++ b/src/caskbench.cpp @@ -59,17 +59,18 @@ write_image_file_cairo (const char *fname, caskbench_context_t *context) void write_image_file_skia (const char *fname, caskbench_context_t *context) { - SkBitmap *bitmap = context->skia_bitmap; + SkBaseDevice *device = context->skia_device; + assert (device); - assert (bitmap); - SkAutoLockPixels image_lock(*bitmap); - cairo_surface_t* skia_surface = cairo_image_surface_create_for_data((unsigned char*)bitmap->getPixels(), - CAIRO_FORMAT_ARGB32, - bitmap->width(), bitmap->height(), - bitmap->rowBytes()); + const SkBitmap &bitmap = device->accessBitmap(false); + SkAutoLockPixels image_lock(bitmap); + cairo_surface_t* surface = cairo_image_surface_create_for_data((unsigned char*)bitmap.getPixels(), + CAIRO_FORMAT_ARGB32, + bitmap.width(), bitmap.height(), + bitmap.rowBytes()); - cairo_surface_write_to_png (skia_surface, fname); - cairo_surface_destroy(skia_surface); + cairo_surface_write_to_png (surface, fname); + cairo_surface_destroy(surface); } @@ -252,8 +253,8 @@ main (int argc, char *argv[]) skia_bitmap.setConfig(SkBitmap::kARGB_8888_Config, context.canvas_width, context.canvas_height); skia_bitmap.allocPixels(); - SkBitmapDevice device(skia_bitmap); - SkCanvas skia_canvas(&device); + SkBitmapDevice skia_device(skia_bitmap); + SkCanvas skia_canvas(&skia_device); // If dry run, just list the test cases if (opt.dry_run) { @@ -266,7 +267,7 @@ main (int argc, char *argv[]) context.paint = &skia_paint; context.canvas = &skia_canvas; context.cairo_surface = cairo_surface; - context.skia_bitmap = &skia_bitmap; + context.skia_device = &skia_device; result.test_case_name = perf_tests[c].name; result.size = 0; |