OLD | NEW |
1 /* | 1 /* |
2 * Copyright 2012 Google Inc. | 2 * Copyright 2012 Google Inc. |
3 * | 3 * |
4 * Use of this source code is governed by a BSD-style license that can be | 4 * Use of this source code is governed by a BSD-style license that can be |
5 * found in the LICENSE file. | 5 * found in the LICENSE file. |
6 */ | 6 */ |
7 #include "SkBenchmark.h" | 7 #include "SkBenchmark.h" |
8 #include "SkDeferredCanvas.h" | 8 #include "SkDeferredCanvas.h" |
9 #include "SkDevice.h" | 9 #include "SkDevice.h" |
10 #include "SkString.h" | 10 #include "SkString.h" |
11 | 11 |
12 class DeferredCanvasBench : public SkBenchmark { | 12 class DeferredCanvasBench : public SkBenchmark { |
13 public: | 13 public: |
14 DeferredCanvasBench(void* param, const char name[]) : INHERITED(param) { | 14 DeferredCanvasBench(void* param, const char name[]) : INHERITED(param) { |
15 fName.printf("deferred_canvas_%s", name); | 15 fName.printf("deferred_canvas_%s", name); |
16 } | 16 } |
17 | 17 |
18 enum { | 18 enum { |
19 N = SkBENCHLOOP(25), // number of times to create the picture | 19 N = SkBENCHLOOP(25), // number of times to create the picture |
20 CANVAS_WIDTH = 200, | 20 CANVAS_WIDTH = 200, |
21 CANVAS_HEIGHT = 200, | 21 CANVAS_HEIGHT = 200, |
22 }; | 22 }; |
23 protected: | 23 protected: |
24 virtual const char* onGetName() { | 24 virtual const char* onGetName() { |
25 return fName.c_str(); | 25 return fName.c_str(); |
26 } | 26 } |
27 | 27 |
28 virtual void onDraw(SkCanvas* canvas) { | 28 virtual void onDraw(SkCanvas* canvas) { |
29 SkDevice *device = canvas->getDevice()->createCompatibleDevice( | 29 SkBaseDevice *device = canvas->getDevice()->createCompatibleDevice( |
30 SkBitmap::kARGB_8888_Config, CANVAS_WIDTH, CANVAS_HEIGHT, false); | 30 SkBitmap::kARGB_8888_Config, CANVAS_WIDTH, CANVAS_HEIGHT, false); |
31 | 31 |
32 SkAutoTUnref<SkDeferredCanvas> deferredCanvas(SkDeferredCanvas::Create(d
evice)); | 32 SkAutoTUnref<SkDeferredCanvas> deferredCanvas(SkDeferredCanvas::Create(d
evice)); |
33 device->unref(); | 33 device->unref(); |
34 | 34 |
35 initDeferredCanvas(deferredCanvas); | 35 initDeferredCanvas(deferredCanvas); |
36 | 36 |
37 for (int i = 0; i < N; i++) { | 37 for (int i = 0; i < N; i++) { |
38 drawInDeferredCanvas(deferredCanvas); | 38 drawInDeferredCanvas(deferredCanvas); |
39 } | 39 } |
(...skipping 65 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
105 typedef DeferredCanvasBench INHERITED; | 105 typedef DeferredCanvasBench INHERITED; |
106 SimpleNotificationClient fNotificationClient; | 106 SimpleNotificationClient fNotificationClient; |
107 }; | 107 }; |
108 | 108 |
109 | 109 |
110 /////////////////////////////////////////////////////////////////////////////// | 110 /////////////////////////////////////////////////////////////////////////////// |
111 | 111 |
112 static SkBenchmark* Fact0(void* p) { return new DeferredRecordBench(p); } | 112 static SkBenchmark* Fact0(void* p) { return new DeferredRecordBench(p); } |
113 | 113 |
114 static BenchRegistry gReg0(Fact0); | 114 static BenchRegistry gReg0(Fact0); |
OLD | NEW |