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(const char name[]) { | 14 DeferredCanvasBench(const char name[]) { |
15 fName.printf("deferred_canvas_%s", name); | 15 fName.printf("deferred_canvas_%s", name); |
16 } | 16 } |
17 | 17 |
18 enum { | 18 enum { |
19 CANVAS_WIDTH = 200, | 19 CANVAS_WIDTH = 200, |
20 CANVAS_HEIGHT = 200, | 20 CANVAS_HEIGHT = 200, |
21 }; | 21 }; |
22 protected: | 22 protected: |
23 virtual const char* onGetName() { | 23 virtual const char* onGetName() { |
24 return fName.c_str(); | 24 return fName.c_str(); |
25 } | 25 } |
26 | 26 |
27 virtual void onDraw(const int loops, SkCanvas* canvas) { | 27 virtual void onDraw(const int loops, SkCanvas* canvas) { |
| 28 #if 0 // what specifically are we interested in timing here? |
28 SkBaseDevice *device = canvas->getDevice()->createCompatibleDevice( | 29 SkBaseDevice *device = canvas->getDevice()->createCompatibleDevice( |
29 SkBitmap::kARGB_8888_Config, CANVAS_WIDTH, CANVAS_HEIGHT, false); | 30 SkBitmap::kARGB_8888_Config, CANVAS_WIDTH, CANVAS_HEIGHT, false); |
30 | 31 |
31 SkAutoTUnref<SkDeferredCanvas> deferredCanvas(SkDeferredCanvas::Create(d
evice)); | 32 SkAutoTUnref<SkDeferredCanvas> deferredCanvas(SkDeferredCanvas::Create(d
evice)); |
32 device->unref(); | 33 device->unref(); |
33 | 34 |
34 initDeferredCanvas(deferredCanvas); | 35 initDeferredCanvas(deferredCanvas); |
35 drawInDeferredCanvas(loops, deferredCanvas); | 36 drawInDeferredCanvas(loops, deferredCanvas); |
36 finalizeDeferredCanvas(deferredCanvas); | 37 finalizeDeferredCanvas(deferredCanvas); |
37 deferredCanvas->flush(); | 38 deferredCanvas->flush(); |
| 39 #endif |
38 } | 40 } |
39 | 41 |
40 virtual void initDeferredCanvas(SkDeferredCanvas* canvas) = 0; | 42 virtual void initDeferredCanvas(SkDeferredCanvas* canvas) = 0; |
41 virtual void drawInDeferredCanvas(const int loops, SkDeferredCanvas* canvas)
= 0; | 43 virtual void drawInDeferredCanvas(const int loops, SkDeferredCanvas* canvas)
= 0; |
42 virtual void finalizeDeferredCanvas(SkDeferredCanvas* canvas) = 0; | 44 virtual void finalizeDeferredCanvas(SkDeferredCanvas* canvas) = 0; |
43 | 45 |
44 SkString fName; | 46 SkString fName; |
45 | 47 |
46 private: | 48 private: |
47 typedef SkBenchmark INHERITED; | 49 typedef SkBenchmark INHERITED; |
(...skipping 47 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
95 | 97 |
96 private: | 98 private: |
97 typedef DeferredCanvasBench INHERITED; | 99 typedef DeferredCanvasBench INHERITED; |
98 SimpleNotificationClient fNotificationClient; | 100 SimpleNotificationClient fNotificationClient; |
99 }; | 101 }; |
100 | 102 |
101 | 103 |
102 /////////////////////////////////////////////////////////////////////////////// | 104 /////////////////////////////////////////////////////////////////////////////// |
103 | 105 |
104 DEF_BENCH( return new DeferredRecordBench(); ) | 106 DEF_BENCH( return new DeferredRecordBench(); ) |
OLD | NEW |