OLD | NEW |
1 // Copyright (c) 2013 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2013 The Chromium Authors. All rights reserved. |
2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
4 | 4 |
5 #include "base/containers/hash_tables.h" | 5 #include "base/containers/hash_tables.h" |
6 #include "base/logging.h" | 6 #include "base/logging.h" |
7 #include "base/time/time.h" | 7 #include "base/time/time.h" |
8 #include "skia/ext/benchmarking_canvas.h" | 8 #include "skia/ext/benchmarking_canvas.h" |
9 #include "third_party/skia/include/utils/SkProxyCanvas.h" | 9 #include "third_party/skia/include/utils/SkProxyCanvas.h" |
10 | 10 |
(...skipping 22 matching lines...) Expand all Loading... |
33 } | 33 } |
34 | 34 |
35 double GetTime(size_t index) { | 35 double GetTime(size_t index) { |
36 TimingsMap::const_iterator timing_info = timings_map_.find(index); | 36 TimingsMap::const_iterator timing_info = timings_map_.find(index); |
37 return timing_info != timings_map_.end() | 37 return timing_info != timings_map_.end() |
38 ? timing_info->second.InMillisecondsF() | 38 ? timing_info->second.InMillisecondsF() |
39 : 0.0; | 39 : 0.0; |
40 } | 40 } |
41 | 41 |
42 // SkCanvas overrides. | 42 // SkCanvas overrides. |
43 virtual void willSave() OVERRIDE { | 43 virtual void willSave() override { |
44 AutoStamper stamper(this); | 44 AutoStamper stamper(this); |
45 SkProxyCanvas::willSave(); | 45 SkProxyCanvas::willSave(); |
46 } | 46 } |
47 | 47 |
48 virtual SaveLayerStrategy willSaveLayer(const SkRect* bounds, | 48 virtual SaveLayerStrategy willSaveLayer(const SkRect* bounds, |
49 const SkPaint* paint, | 49 const SkPaint* paint, |
50 SaveFlags flags) OVERRIDE { | 50 SaveFlags flags) override { |
51 AutoStamper stamper(this); | 51 AutoStamper stamper(this); |
52 return SkProxyCanvas::willSaveLayer(bounds, paint, flags); | 52 return SkProxyCanvas::willSaveLayer(bounds, paint, flags); |
53 } | 53 } |
54 | 54 |
55 virtual void willRestore() OVERRIDE { | 55 virtual void willRestore() override { |
56 AutoStamper stamper(this); | 56 AutoStamper stamper(this); |
57 SkProxyCanvas::willRestore(); | 57 SkProxyCanvas::willRestore(); |
58 } | 58 } |
59 | 59 |
60 virtual void drawPaint(const SkPaint& paint) OVERRIDE { | 60 virtual void drawPaint(const SkPaint& paint) override { |
61 AutoStamper stamper(this); | 61 AutoStamper stamper(this); |
62 SkProxyCanvas::drawPaint(paint); | 62 SkProxyCanvas::drawPaint(paint); |
63 } | 63 } |
64 | 64 |
65 virtual void drawPoints(PointMode mode, size_t count, const SkPoint pts[], | 65 virtual void drawPoints(PointMode mode, size_t count, const SkPoint pts[], |
66 const SkPaint& paint) OVERRIDE { | 66 const SkPaint& paint) override { |
67 AutoStamper stamper(this); | 67 AutoStamper stamper(this); |
68 SkProxyCanvas::drawPoints(mode, count, pts, paint); | 68 SkProxyCanvas::drawPoints(mode, count, pts, paint); |
69 } | 69 } |
70 | 70 |
71 virtual void drawOval(const SkRect& rect, const SkPaint& paint) OVERRIDE { | 71 virtual void drawOval(const SkRect& rect, const SkPaint& paint) override { |
72 AutoStamper stamper(this); | 72 AutoStamper stamper(this); |
73 SkProxyCanvas::drawOval(rect, paint); | 73 SkProxyCanvas::drawOval(rect, paint); |
74 } | 74 } |
75 | 75 |
76 virtual void drawRect(const SkRect& rect, const SkPaint& paint) OVERRIDE { | 76 virtual void drawRect(const SkRect& rect, const SkPaint& paint) override { |
77 AutoStamper stamper(this); | 77 AutoStamper stamper(this); |
78 SkProxyCanvas::drawRect(rect, paint); | 78 SkProxyCanvas::drawRect(rect, paint); |
79 } | 79 } |
80 | 80 |
81 virtual void drawRRect(const SkRRect& rrect, const SkPaint& paint) OVERRIDE { | 81 virtual void drawRRect(const SkRRect& rrect, const SkPaint& paint) override { |
82 AutoStamper stamper(this); | 82 AutoStamper stamper(this); |
83 SkProxyCanvas::drawRRect(rrect, paint); | 83 SkProxyCanvas::drawRRect(rrect, paint); |
84 } | 84 } |
85 | 85 |
86 virtual void drawPath(const SkPath& path, const SkPaint& paint) OVERRIDE { | 86 virtual void drawPath(const SkPath& path, const SkPaint& paint) override { |
87 AutoStamper stamper(this); | 87 AutoStamper stamper(this); |
88 SkProxyCanvas::drawPath(path, paint); | 88 SkProxyCanvas::drawPath(path, paint); |
89 } | 89 } |
90 | 90 |
91 virtual void drawBitmap(const SkBitmap& bitmap, SkScalar left, SkScalar top, | 91 virtual void drawBitmap(const SkBitmap& bitmap, SkScalar left, SkScalar top, |
92 const SkPaint* paint = NULL) OVERRIDE { | 92 const SkPaint* paint = NULL) override { |
93 AutoStamper stamper(this); | 93 AutoStamper stamper(this); |
94 SkProxyCanvas::drawBitmap(bitmap, left, top, paint); | 94 SkProxyCanvas::drawBitmap(bitmap, left, top, paint); |
95 } | 95 } |
96 | 96 |
97 virtual void drawBitmapRectToRect(const SkBitmap& bitmap, const SkRect* src, | 97 virtual void drawBitmapRectToRect(const SkBitmap& bitmap, const SkRect* src, |
98 const SkRect& dst, | 98 const SkRect& dst, |
99 const SkPaint* paint, | 99 const SkPaint* paint, |
100 DrawBitmapRectFlags flags) OVERRIDE { | 100 DrawBitmapRectFlags flags) override { |
101 AutoStamper stamper(this); | 101 AutoStamper stamper(this); |
102 SkProxyCanvas::drawBitmapRectToRect(bitmap, src, dst, paint, flags); | 102 SkProxyCanvas::drawBitmapRectToRect(bitmap, src, dst, paint, flags); |
103 } | 103 } |
104 | 104 |
105 virtual void drawBitmapMatrix(const SkBitmap& bitmap, const SkMatrix& m, | 105 virtual void drawBitmapMatrix(const SkBitmap& bitmap, const SkMatrix& m, |
106 const SkPaint* paint = NULL) OVERRIDE { | 106 const SkPaint* paint = NULL) override { |
107 AutoStamper stamper(this); | 107 AutoStamper stamper(this); |
108 SkProxyCanvas::drawBitmapMatrix(bitmap, m, paint); | 108 SkProxyCanvas::drawBitmapMatrix(bitmap, m, paint); |
109 } | 109 } |
110 | 110 |
111 virtual void drawSprite(const SkBitmap& bitmap, int left, int top, | 111 virtual void drawSprite(const SkBitmap& bitmap, int left, int top, |
112 const SkPaint* paint = NULL) OVERRIDE { | 112 const SkPaint* paint = NULL) override { |
113 AutoStamper stamper(this); | 113 AutoStamper stamper(this); |
114 SkProxyCanvas::drawSprite(bitmap, left, top, paint); | 114 SkProxyCanvas::drawSprite(bitmap, left, top, paint); |
115 } | 115 } |
116 | 116 |
117 virtual void drawVertices(VertexMode vmode, int vertexCount, | 117 virtual void drawVertices(VertexMode vmode, int vertexCount, |
118 const SkPoint vertices[], const SkPoint texs[], | 118 const SkPoint vertices[], const SkPoint texs[], |
119 const SkColor colors[], SkXfermode* xmode, | 119 const SkColor colors[], SkXfermode* xmode, |
120 const uint16_t indices[], int indexCount, | 120 const uint16_t indices[], int indexCount, |
121 const SkPaint& paint) OVERRIDE { | 121 const SkPaint& paint) override { |
122 AutoStamper stamper(this); | 122 AutoStamper stamper(this); |
123 SkProxyCanvas::drawVertices(vmode, vertexCount, vertices, texs, colors, | 123 SkProxyCanvas::drawVertices(vmode, vertexCount, vertices, texs, colors, |
124 xmode, indices, indexCount, paint); | 124 xmode, indices, indexCount, paint); |
125 } | 125 } |
126 | 126 |
127 virtual void drawData(const void* data, size_t length) OVERRIDE { | 127 virtual void drawData(const void* data, size_t length) override { |
128 AutoStamper stamper(this); | 128 AutoStamper stamper(this); |
129 SkProxyCanvas::drawData(data, length); | 129 SkProxyCanvas::drawData(data, length); |
130 } | 130 } |
131 | 131 |
132 protected: | 132 protected: |
133 virtual void onDrawText(const void* text, size_t byteLength, SkScalar x, | 133 virtual void onDrawText(const void* text, size_t byteLength, SkScalar x, |
134 SkScalar y, const SkPaint& paint) OVERRIDE { | 134 SkScalar y, const SkPaint& paint) override { |
135 AutoStamper stamper(this); | 135 AutoStamper stamper(this); |
136 SkProxyCanvas::onDrawText(text, byteLength, x, y, paint); | 136 SkProxyCanvas::onDrawText(text, byteLength, x, y, paint); |
137 } | 137 } |
138 | 138 |
139 virtual void onDrawPosText(const void* text, size_t byteLength, | 139 virtual void onDrawPosText(const void* text, size_t byteLength, |
140 const SkPoint pos[], | 140 const SkPoint pos[], |
141 const SkPaint& paint) OVERRIDE { | 141 const SkPaint& paint) override { |
142 AutoStamper stamper(this); | 142 AutoStamper stamper(this); |
143 SkProxyCanvas::onDrawPosText(text, byteLength, pos, paint); | 143 SkProxyCanvas::onDrawPosText(text, byteLength, pos, paint); |
144 } | 144 } |
145 | 145 |
146 virtual void onDrawPosTextH(const void* text, size_t byteLength, | 146 virtual void onDrawPosTextH(const void* text, size_t byteLength, |
147 const SkScalar xpos[], SkScalar constY, | 147 const SkScalar xpos[], SkScalar constY, |
148 const SkPaint& paint) OVERRIDE { | 148 const SkPaint& paint) override { |
149 AutoStamper stamper(this); | 149 AutoStamper stamper(this); |
150 SkProxyCanvas::onDrawPosTextH(text, byteLength, xpos, constY, paint); | 150 SkProxyCanvas::onDrawPosTextH(text, byteLength, xpos, constY, paint); |
151 } | 151 } |
152 | 152 |
153 virtual void onDrawTextOnPath(const void* text, size_t byteLength, | 153 virtual void onDrawTextOnPath(const void* text, size_t byteLength, |
154 const SkPath& path, const SkMatrix* matrix, | 154 const SkPath& path, const SkMatrix* matrix, |
155 const SkPaint& paint) OVERRIDE { | 155 const SkPaint& paint) override { |
156 AutoStamper stamper(this); | 156 AutoStamper stamper(this); |
157 SkProxyCanvas::onDrawTextOnPath(text, byteLength, path, matrix, paint); | 157 SkProxyCanvas::onDrawTextOnPath(text, byteLength, path, matrix, paint); |
158 } | 158 } |
159 | 159 |
160 virtual void onClipRect(const SkRect& rect, SkRegion::Op op, | 160 virtual void onClipRect(const SkRect& rect, SkRegion::Op op, |
161 ClipEdgeStyle edge_style) OVERRIDE { | 161 ClipEdgeStyle edge_style) override { |
162 AutoStamper stamper(this); | 162 AutoStamper stamper(this); |
163 SkProxyCanvas::onClipRect(rect, op, edge_style); | 163 SkProxyCanvas::onClipRect(rect, op, edge_style); |
164 } | 164 } |
165 | 165 |
166 virtual void onClipRRect(const SkRRect& rrect, SkRegion::Op op, | 166 virtual void onClipRRect(const SkRRect& rrect, SkRegion::Op op, |
167 ClipEdgeStyle edge_style) OVERRIDE { | 167 ClipEdgeStyle edge_style) override { |
168 AutoStamper stamper(this); | 168 AutoStamper stamper(this); |
169 SkProxyCanvas::onClipRRect(rrect, op, edge_style); | 169 SkProxyCanvas::onClipRRect(rrect, op, edge_style); |
170 } | 170 } |
171 | 171 |
172 virtual void onClipPath(const SkPath& path, SkRegion::Op op, | 172 virtual void onClipPath(const SkPath& path, SkRegion::Op op, |
173 ClipEdgeStyle edge_style) OVERRIDE { | 173 ClipEdgeStyle edge_style) override { |
174 AutoStamper stamper(this); | 174 AutoStamper stamper(this); |
175 SkProxyCanvas::onClipPath(path, op, edge_style); | 175 SkProxyCanvas::onClipPath(path, op, edge_style); |
176 } | 176 } |
177 | 177 |
178 virtual void onClipRegion(const SkRegion& region, | 178 virtual void onClipRegion(const SkRegion& region, |
179 SkRegion::Op op) OVERRIDE { | 179 SkRegion::Op op) override { |
180 AutoStamper stamper(this); | 180 AutoStamper stamper(this); |
181 SkProxyCanvas::onClipRegion(region, op); | 181 SkProxyCanvas::onClipRegion(region, op); |
182 } | 182 } |
183 | 183 |
184 virtual void onDrawPicture(const SkPicture* picture, const SkMatrix* matrix, | 184 virtual void onDrawPicture(const SkPicture* picture, const SkMatrix* matrix, |
185 const SkPaint* paint) OVERRIDE { | 185 const SkPaint* paint) override { |
186 AutoStamper stamper(this); | 186 AutoStamper stamper(this); |
187 SkProxyCanvas::onDrawPicture(picture, matrix, paint); | 187 SkProxyCanvas::onDrawPicture(picture, matrix, paint); |
188 } | 188 } |
189 | 189 |
190 private: | 190 private: |
191 typedef base::hash_map<size_t, base::TimeDelta> TimingsMap; | 191 typedef base::hash_map<size_t, base::TimeDelta> TimingsMap; |
192 TimingsMap timings_map_; | 192 TimingsMap timings_map_; |
193 | 193 |
194 skia::RefPtr<SkCanvas> canvas_; | 194 skia::RefPtr<SkCanvas> canvas_; |
195 | 195 |
(...skipping 34 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
230 DCHECK_LT(index, static_cast<size_t>(debug_canvas_->getSize())); | 230 DCHECK_LT(index, static_cast<size_t>(debug_canvas_->getSize())); |
231 return debug_canvas_->getDrawCommandAt(index); | 231 return debug_canvas_->getDrawCommandAt(index); |
232 } | 232 } |
233 | 233 |
234 double BenchmarkingCanvas::GetTime(size_t index) { | 234 double BenchmarkingCanvas::GetTime(size_t index) { |
235 DCHECK_LT(index, static_cast<size_t>(debug_canvas_->getSize())); | 235 DCHECK_LT(index, static_cast<size_t>(debug_canvas_->getSize())); |
236 return timing_canvas_->GetTime(index); | 236 return timing_canvas_->GetTime(index); |
237 } | 237 } |
238 | 238 |
239 } // namespace skia | 239 } // namespace skia |
OLD | NEW |