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

Side by Side Diff: bench/PictureRecordBench.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/PicturePlaybackBench.cpp ('k') | bench/PremulAndUnpremulAlphaOpsBench.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 #include "SkBenchmark.h" 7 #include "SkBenchmark.h"
8 #include "SkCanvas.h" 8 #include "SkCanvas.h"
9 #include "SkColor.h" 9 #include "SkColor.h"
10 #include "SkPaint.h" 10 #include "SkPaint.h"
(...skipping 32 matching lines...) Expand 10 before | Expand all | Expand 10 after
43 /* 43 /*
44 * An SkPicture has internal dictionaries to store bitmaps, matrices, paints, 44 * An SkPicture has internal dictionaries to store bitmaps, matrices, paints,
45 * and regions. This bench populates those dictionaries to test the speed of 45 * and regions. This bench populates those dictionaries to test the speed of
46 * reading and writing to those particular dictionary data structures. 46 * reading and writing to those particular dictionary data structures.
47 */ 47 */
48 class DictionaryRecordBench : public PictureRecordBench { 48 class DictionaryRecordBench : public PictureRecordBench {
49 public: 49 public:
50 DictionaryRecordBench() : INHERITED("dictionaries") {} 50 DictionaryRecordBench() : INHERITED("dictionaries") {}
51 51
52 protected: 52 protected:
53 virtual void onDraw(SkCanvas*) SK_OVERRIDE { 53 virtual void onDraw(const int loops, SkCanvas*) SK_OVERRIDE {
54 SkAutoTDelete<SkPicture> picture; 54 SkAutoTDelete<SkPicture> picture;
55 SkCanvas* canvas = NULL; 55 SkCanvas* canvas = NULL;
56 56
57 const SkPoint translateDelta = getTranslateDelta(this->getLoops()); 57 const SkPoint translateDelta = getTranslateDelta(loops);
58 58
59 for (int i = 0; i < this->getLoops(); i++) { 59 for (int i = 0; i < loops; i++) {
60 if (0 == i % kMaxLoopsPerCanvas) { 60 if (0 == i % kMaxLoopsPerCanvas) {
61 picture.reset(SkNEW(SkPicture)); 61 picture.reset(SkNEW(SkPicture));
62 canvas = picture->beginRecording(PICTURE_WIDTH, PICTURE_HEIGHT); 62 canvas = picture->beginRecording(PICTURE_WIDTH, PICTURE_HEIGHT);
63 } 63 }
64 64
65 SkColor color = SK_ColorYELLOW + (i % 255); 65 SkColor color = SK_ColorYELLOW + (i % 255);
66 SkIRect rect = SkIRect::MakeWH(i % PICTURE_WIDTH, i % PICTURE_HEIGHT ); 66 SkIRect rect = SkIRect::MakeWH(i % PICTURE_WIDTH, i % PICTURE_HEIGHT );
67 67
68 canvas->save(); 68 canvas->save();
69 69
(...skipping 40 matching lines...) Expand 10 before | Expand all | Expand 10 after
110 110
111 /* 111 /*
112 * Populates the SkPaint dictionary with a large number of unique paint 112 * Populates the SkPaint dictionary with a large number of unique paint
113 * objects that differ only by color 113 * objects that differ only by color
114 */ 114 */
115 class UniquePaintDictionaryRecordBench : public PictureRecordBench { 115 class UniquePaintDictionaryRecordBench : public PictureRecordBench {
116 public: 116 public:
117 UniquePaintDictionaryRecordBench() : INHERITED("unique_paint_dictionary") { } 117 UniquePaintDictionaryRecordBench() : INHERITED("unique_paint_dictionary") { }
118 118
119 protected: 119 protected:
120 virtual void onDraw(SkCanvas*) SK_OVERRIDE { 120 virtual void onDraw(const int loops, SkCanvas*) SK_OVERRIDE {
121 SkRandom rand; 121 SkRandom rand;
122 SkPaint paint; 122 SkPaint paint;
123 SkAutoTDelete<SkPicture> picture; 123 SkAutoTDelete<SkPicture> picture;
124 SkCanvas* canvas = NULL; 124 SkCanvas* canvas = NULL;
125 for (int i = 0; i < this->getLoops(); i++) { 125 for (int i = 0; i < loops; i++) {
126 if (0 == i % kMaxLoopsPerCanvas) { 126 if (0 == i % kMaxLoopsPerCanvas) {
127 picture.reset(SkNEW(SkPicture)); 127 picture.reset(SkNEW(SkPicture));
128 canvas = picture->beginRecording(PICTURE_WIDTH, PICTURE_HEIGHT); 128 canvas = picture->beginRecording(PICTURE_WIDTH, PICTURE_HEIGHT);
129 } 129 }
130 paint.setColor(rand.nextU()); 130 paint.setColor(rand.nextU());
131 canvas->drawPaint(paint); 131 canvas->drawPaint(paint);
132 } 132 }
133 } 133 }
134 134
135 private: 135 private:
(...skipping 14 matching lines...) Expand all
150 SkRandom rand; 150 SkRandom rand;
151 for (int i = 0; i < ObjCount; i++) { 151 for (int i = 0; i < ObjCount; i++) {
152 fPaint[i].setColor(rand.nextU()); 152 fPaint[i].setColor(rand.nextU());
153 } 153 }
154 } 154 }
155 155
156 enum { 156 enum {
157 ObjCount = 100, // number of unique paint objects 157 ObjCount = 100, // number of unique paint objects
158 }; 158 };
159 protected: 159 protected:
160 virtual void onDraw(SkCanvas*) SK_OVERRIDE { 160 virtual void onDraw(const int loops, SkCanvas*) SK_OVERRIDE {
161 SkPicture picture; 161 SkPicture picture;
162 SkCanvas* canvas = picture.beginRecording(PICTURE_WIDTH, PICTURE_HEIGHT) ; 162 SkCanvas* canvas = picture.beginRecording(PICTURE_WIDTH, PICTURE_HEIGHT) ;
163 for (int i = 0; i < this->getLoops(); i++) { 163 for (int i = 0; i < loops; i++) {
164 canvas->drawPaint(fPaint[i % ObjCount]); 164 canvas->drawPaint(fPaint[i % ObjCount]);
165 } 165 }
166 } 166 }
167 167
168 private: 168 private:
169 SkPaint fPaint [ObjCount]; 169 SkPaint fPaint [ObjCount];
170 typedef PictureRecordBench INHERITED; 170 typedef PictureRecordBench INHERITED;
171 }; 171 };
172 172
173 /////////////////////////////////////////////////////////////////////////////// 173 ///////////////////////////////////////////////////////////////////////////////
174 174
175 DEF_BENCH( return new DictionaryRecordBench(); ) 175 DEF_BENCH( return new DictionaryRecordBench(); )
176 DEF_BENCH( return new UniquePaintDictionaryRecordBench(); ) 176 DEF_BENCH( return new UniquePaintDictionaryRecordBench(); )
177 DEF_BENCH( return new RecurringPaintDictionaryRecordBench(); ) 177 DEF_BENCH( return new RecurringPaintDictionaryRecordBench(); )
OLDNEW
« no previous file with comments | « bench/PicturePlaybackBench.cpp ('k') | bench/PremulAndUnpremulAlphaOpsBench.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698