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

Side by Side Diff: bench/PictureRecordBench.cpp

Issue 214953003: split SkPictureRecorder out of SkPicture (Closed) Base URL: http://skia.googlecode.com/svn/trunk/
Patch Set: update to ToT (again) Created 6 years, 8 months 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
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 33 matching lines...) Expand 10 before | Expand all | Expand 10 after
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(const int loops, SkCanvas*) SK_OVERRIDE { 53 virtual void onDraw(const int loops, SkCanvas*) SK_OVERRIDE {
54 SkAutoTDelete<SkPicture> picture; 54 SkPictureRecorder recorder;
55 SkCanvas* canvas = NULL; 55 SkCanvas* canvas = NULL;
56 56
57 const SkPoint translateDelta = getTranslateDelta(loops); 57 const SkPoint translateDelta = getTranslateDelta(loops);
58 58
59 for (int i = 0; i < loops; 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 SkAutoTUnref<SkPicture> picture(recorder.endRecording());
62 canvas = picture->beginRecording(PICTURE_WIDTH, PICTURE_HEIGHT); 62 canvas = recorder.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
70 // set the clip to the given region 70 // set the clip to the given region
71 SkRegion region; 71 SkRegion region;
72 region.setRect(rect); 72 region.setRect(rect);
(...skipping 40 matching lines...) Expand 10 before | Expand all | Expand 10 after
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(const int loops, 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 SkPictureRecorder recorder;
124 SkCanvas* canvas = NULL; 124 SkCanvas* canvas = NULL;
125 for (int i = 0; i < loops; 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 SkAutoTUnref<SkPicture> picture(recorder.endRecording());
128 canvas = picture->beginRecording(PICTURE_WIDTH, PICTURE_HEIGHT); 128 canvas = recorder.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:
136 typedef PictureRecordBench INHERITED; 136 typedef PictureRecordBench INHERITED;
137 }; 137 };
138 138
(...skipping 12 matching lines...) Expand all
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(const int loops, SkCanvas*) SK_OVERRIDE { 160 virtual void onDraw(const int loops, SkCanvas*) SK_OVERRIDE {
161 SkPicture picture; 161 SkPictureRecorder recorder;
162 SkCanvas* canvas = picture.beginRecording(PICTURE_WIDTH, PICTURE_HEIGHT) ; 162 SkCanvas* canvas = recorder.beginRecording(PICTURE_WIDTH, PICTURE_HEIGHT );
163 for (int i = 0; i < loops; 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/benchmain.cpp » ('j') | samplecode/SampleTiling.cpp » ('J')

Powered by Google App Engine
This is Rietveld 408576698