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 | 7 |
8 #include "SkBenchmark.h" | 8 #include "Benchmark.h" |
9 #include "SkCanvas.h" | 9 #include "SkCanvas.h" |
10 #include "SkRect.h" | 10 #include "SkRect.h" |
11 | 11 |
12 static const SkScalar kCellWidth = SkIntToScalar(20); | 12 static const SkScalar kCellWidth = SkIntToScalar(20); |
13 static const SkScalar kCellHeight = SkIntToScalar(10); | 13 static const SkScalar kCellHeight = SkIntToScalar(10); |
14 | 14 |
15 // This bench draws a table in the manner of Google spreadsheet and sahadan.com. | 15 // This bench draws a table in the manner of Google spreadsheet and sahadan.com. |
16 // ____________ ___ | 16 // ____________ ___ |
17 // | 1 | 2 | | 17 // | 1 | 2 | |
18 // |____________|___| | 18 // |____________|___| |
19 // | 3 | 4 | | 19 // | 3 | 4 | |
20 // |____________|___| | 20 // |____________|___| |
21 // | 21 // |
22 // Areas 1-4 are first all draw white. Areas 3&4 are then drawn grey. Areas | 22 // Areas 1-4 are first all draw white. Areas 3&4 are then drawn grey. Areas |
23 // 2&4 are then drawn grey. Areas 2&3 are thus double drawn while area 4 is | 23 // 2&4 are then drawn grey. Areas 2&3 are thus double drawn while area 4 is |
24 // triple drawn. | 24 // triple drawn. |
25 // This trio of drawRects is then repeat for the next cell. | 25 // This trio of drawRects is then repeat for the next cell. |
26 class TableBench : public SkBenchmark { | 26 class TableBench : public Benchmark { |
27 public: | 27 public: |
28 static const int kNumRows = 48; | 28 static const int kNumRows = 48; |
29 static const int kNumCols = 32; | 29 static const int kNumCols = 32; |
30 | 30 |
31 protected: | 31 protected: |
32 virtual const char* onGetName() { | 32 virtual const char* onGetName() { |
33 return "tablebench"; | 33 return "tablebench"; |
34 } | 34 } |
35 | 35 |
36 virtual void onDraw(const int loops, SkCanvas* canvas) { | 36 virtual void onDraw(const int loops, SkCanvas* canvas) { |
(...skipping 22 matching lines...) Expand all Loading... |
59 row * kCellHeight, | 59 row * kCellHeight, |
60 (col+1) * kCellWidth, | 60 (col+1) * kCellWidth, |
61 (row+1) * kCellHeight); | 61 (row+1) * kCellHeight); |
62 canvas->drawRect(right, borderPaint); | 62 canvas->drawRect(right, borderPaint); |
63 } | 63 } |
64 } | 64 } |
65 } | 65 } |
66 } | 66 } |
67 | 67 |
68 private: | 68 private: |
69 typedef SkBenchmark INHERITED; | 69 typedef Benchmark INHERITED; |
70 }; | 70 }; |
71 | 71 |
72 DEF_BENCH( return new TableBench(); ) | 72 DEF_BENCH( return new TableBench(); ) |
OLD | NEW |