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(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(); |
(...skipping 38 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
63 bool fDummy; | 63 bool fDummy; |
64 | 64 |
65 typedef SkDeferredCanvas::NotificationClient INHERITED; | 65 typedef SkDeferredCanvas::NotificationClient INHERITED; |
66 }; | 66 }; |
67 | 67 |
68 // Test that records very simple draw operations. | 68 // Test that records very simple draw operations. |
69 // This benchmark aims to capture performance fluctuations in the recording | 69 // This benchmark aims to capture performance fluctuations in the recording |
70 // overhead of SkDeferredCanvas | 70 // overhead of SkDeferredCanvas |
71 class DeferredRecordBench : public DeferredCanvasBench { | 71 class DeferredRecordBench : public DeferredCanvasBench { |
72 public: | 72 public: |
73 DeferredRecordBench(void* param) | 73 DeferredRecordBench() |
74 : INHERITED(param, "record") { | 74 : INHERITED("record") { |
75 } | 75 } |
76 | 76 |
77 protected: | 77 protected: |
78 | 78 |
79 virtual void initDeferredCanvas(SkDeferredCanvas* canvas) SK_OVERRIDE { | 79 virtual void initDeferredCanvas(SkDeferredCanvas* canvas) SK_OVERRIDE { |
80 canvas->setNotificationClient(&fNotificationClient); | 80 canvas->setNotificationClient(&fNotificationClient); |
81 } | 81 } |
82 | 82 |
83 virtual void drawInDeferredCanvas(SkDeferredCanvas* canvas) SK_OVERRIDE { | 83 virtual void drawInDeferredCanvas(SkDeferredCanvas* canvas) SK_OVERRIDE { |
84 SkRect rect; | 84 SkRect rect; |
(...skipping 13 matching lines...) Expand all Loading... |
98 } | 98 } |
99 | 99 |
100 private: | 100 private: |
101 typedef DeferredCanvasBench INHERITED; | 101 typedef DeferredCanvasBench INHERITED; |
102 SimpleNotificationClient fNotificationClient; | 102 SimpleNotificationClient fNotificationClient; |
103 }; | 103 }; |
104 | 104 |
105 | 105 |
106 /////////////////////////////////////////////////////////////////////////////// | 106 /////////////////////////////////////////////////////////////////////////////// |
107 | 107 |
108 static SkBenchmark* Fact0(void* p) { return new DeferredRecordBench(p); } | 108 DEF_BENCH( return new DeferredRecordBench(); ) |
109 | |
110 static BenchRegistry gReg0(Fact0); | |
OLD | NEW |