From 2276c56411611a12bfdfc36bcc1cba9c3c65c6c9 Mon Sep 17 00:00:00 2001 From: Bryce Harrington Date: Tue, 26 Nov 2013 19:22:34 -0800 Subject: 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. --- src/caskbench.cpp | 29 +++++++++++++++-------------- 1 file changed, 15 insertions(+), 14 deletions(-) (limited to 'src/caskbench.cpp') 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; - - 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()); - - cairo_surface_write_to_png (skia_surface, fname); - cairo_surface_destroy(skia_surface); + SkBaseDevice *device = context->skia_device; + assert (device); + + 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 (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; -- cgit v1.3.1-4-g156e