Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(7)

Side by Side Diff: bench/TableBench.cpp

Issue 99893003: Simplify benchmark internal API. (Closed) Base URL: https://skia.googlecode.com/svn/trunk
Patch Set: rebase Created 7 years ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
« no previous file with comments | « bench/StrokeBench.cpp ('k') | bench/TextBench.cpp » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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 "SkBenchmark.h"
9 #include "SkCanvas.h" 9 #include "SkCanvas.h"
10 #include "SkRect.h" 10 #include "SkRect.h"
(...skipping 15 matching lines...) Expand all
26 class TableBench : public SkBenchmark { 26 class TableBench : public SkBenchmark {
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(SkCanvas* canvas) { 36 virtual void onDraw(const int loops, SkCanvas* canvas) {
37 SkPaint cellPaint; 37 SkPaint cellPaint;
38 cellPaint.setColor(0xFFFFFFF); 38 cellPaint.setColor(0xFFFFFFF);
39 39
40 SkPaint borderPaint; 40 SkPaint borderPaint;
41 borderPaint.setColor(0xFFCCCCCC); 41 borderPaint.setColor(0xFFCCCCCC);
42 42
43 for (int i = 0; i < this->getLoops(); ++i) { 43 for (int i = 0; i < loops; ++i) {
44 for (int row = 0; row < kNumRows; ++row) { 44 for (int row = 0; row < kNumRows; ++row) {
45 for (int col = 0; col < kNumCols; ++col) { 45 for (int col = 0; col < kNumCols; ++col) {
46 SkRect cell = SkRect::MakeLTRB(col * kCellWidth, 46 SkRect cell = SkRect::MakeLTRB(col * kCellWidth,
47 row * kCellHeight, 47 row * kCellHeight,
48 (col+1) * kCellWidth, 48 (col+1) * kCellWidth,
49 (row+1) * kCellHeight); 49 (row+1) * kCellHeight);
50 canvas->drawRect(cell, cellPaint); 50 canvas->drawRect(cell, cellPaint);
51 51
52 SkRect bottom = SkRect::MakeLTRB(col * kCellWidth, 52 SkRect bottom = SkRect::MakeLTRB(col * kCellWidth,
53 row * kCellHeight + (kCellH eight-SK_Scalar1), 53 row * kCellHeight + (kCellH eight-SK_Scalar1),
54 (col+1) * kCellWidth, 54 (col+1) * kCellWidth,
55 (row+1) * kCellHeight); 55 (row+1) * kCellHeight);
56 canvas->drawRect(bottom, borderPaint); 56 canvas->drawRect(bottom, borderPaint);
57 57
58 SkRect right = SkRect::MakeLTRB(col * kCellWidth + (kCellWid th-SK_Scalar1), 58 SkRect right = SkRect::MakeLTRB(col * kCellWidth + (kCellWid th-SK_Scalar1),
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 SkBenchmark INHERITED;
70 }; 70 };
71 71
72 DEF_BENCH( return new TableBench(); ) 72 DEF_BENCH( return new TableBench(); )
OLDNEW
« no previous file with comments | « bench/StrokeBench.cpp ('k') | bench/TextBench.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698