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

Side by Side Diff: bench/PictureRecordBench.cpp

Issue 618303002: Remove DEPRECATED_beginRecording(). (Closed) Base URL: https://skia.googlesource.com/skia.git@master
Patch Set: fix up benches Created 6 years, 2 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
« no previous file with comments | « no previous file | include/core/SkPicture.h » ('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 "Benchmark.h" 7 #include "Benchmark.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 35 matching lines...) Expand 10 before | Expand all | Expand 10 after
46 * and regions. This bench populates those dictionaries to test the speed of 46 * and regions. This bench populates those dictionaries to test the speed of
47 * reading and writing to those particular dictionary data structures. 47 * reading and writing to those particular dictionary data structures.
48 */ 48 */
49 class DictionaryRecordBench : public PictureRecordBench { 49 class DictionaryRecordBench : public PictureRecordBench {
50 public: 50 public:
51 DictionaryRecordBench() : INHERITED("dictionaries") {} 51 DictionaryRecordBench() : INHERITED("dictionaries") {}
52 52
53 protected: 53 protected:
54 virtual void onDraw(const int loops, SkCanvas*) SK_OVERRIDE { 54 virtual void onDraw(const int loops, SkCanvas*) SK_OVERRIDE {
55 SkPictureRecorder recorder; 55 SkPictureRecorder recorder;
56 SkCanvas* canvas = NULL; 56 SkCanvas* canvas = recorder.beginRecording(PICTURE_WIDTH, PICTURE_HEIGHT );
57 57
58 const SkPoint translateDelta = getTranslateDelta(loops); 58 const SkPoint translateDelta = getTranslateDelta(loops);
59 59
60 for (int i = 0; i < loops; i++) { 60 for (int i = 0; i < loops; i++) {
61 if (0 == i % kMaxLoopsPerCanvas) { 61 if (0 == i % kMaxLoopsPerCanvas) {
62 SkAutoTUnref<SkPicture> picture(recorder.endRecording()); 62 SkAutoTUnref<SkPicture> picture(recorder.endRecording());
63 canvas = recorder.beginRecording(PICTURE_WIDTH, PICTURE_HEIGHT, NULL, 0); 63 canvas = recorder.beginRecording(PICTURE_WIDTH, PICTURE_HEIGHT);
64 } 64 }
65 65
66 SkColor color = SK_ColorYELLOW + (i % 255); 66 SkColor color = SK_ColorYELLOW + (i % 255);
67 SkIRect rect = SkIRect::MakeWH(i % PICTURE_WIDTH, i % PICTURE_HEIGHT ); 67 SkIRect rect = SkIRect::MakeWH(i % PICTURE_WIDTH, i % PICTURE_HEIGHT );
68 68
69 canvas->save(); 69 canvas->save();
70 70
71 // set the clip to the given region 71 // set the clip to the given region
72 SkRegion region; 72 SkRegion region;
73 region.setRect(rect); 73 region.setRect(rect);
(...skipping 17 matching lines...) Expand all
91 // draw a single color into the bitmap 91 // draw a single color into the bitmap
92 SkCanvas bitmapCanvas(bitmap); 92 SkCanvas bitmapCanvas(bitmap);
93 bitmapCanvas.drawColor(SkColorSetA(color, i % 255)); 93 bitmapCanvas.drawColor(SkColorSetA(color, i % 255));
94 94
95 // draw the bitmap onto the canvas 95 // draw the bitmap onto the canvas
96 canvas->drawBitmapMatrix(bitmap, matrix); 96 canvas->drawBitmapMatrix(bitmap, matrix);
97 97
98 canvas->restore(); 98 canvas->restore();
99 canvas->translate(translateDelta.fX, translateDelta.fY); 99 canvas->translate(translateDelta.fX, translateDelta.fY);
100 } 100 }
101 SkAutoTUnref<SkPicture> cleanup(recorder.endRecording());
101 } 102 }
102 103
103 SkPoint getTranslateDelta(int M) { 104 SkPoint getTranslateDelta(int M) {
104 SkIPoint canvasSize = onGetSize(); 105 SkIPoint canvasSize = onGetSize();
105 return SkPoint::Make(SkIntToScalar((PICTURE_WIDTH - canvasSize.fX)/M), 106 return SkPoint::Make(SkIntToScalar((PICTURE_WIDTH - canvasSize.fX)/M),
106 SkIntToScalar((PICTURE_HEIGHT- canvasSize.fY)/M)); 107 SkIntToScalar((PICTURE_HEIGHT- canvasSize.fY)/M));
107 } 108 }
108 private: 109 private:
109 typedef PictureRecordBench INHERITED; 110 typedef PictureRecordBench INHERITED;
110 }; 111 };
111 112
112 /* 113 /*
113 * Populates the SkPaint dictionary with a large number of unique paint 114 * Populates the SkPaint dictionary with a large number of unique paint
114 * objects that differ only by color 115 * objects that differ only by color
115 */ 116 */
116 class UniquePaintDictionaryRecordBench : public PictureRecordBench { 117 class UniquePaintDictionaryRecordBench : public PictureRecordBench {
117 public: 118 public:
118 UniquePaintDictionaryRecordBench() : INHERITED("unique_paint_dictionary") { } 119 UniquePaintDictionaryRecordBench() : INHERITED("unique_paint_dictionary") { }
119 120
120 protected: 121 protected:
121 virtual void onDraw(const int loops, SkCanvas*) SK_OVERRIDE { 122 virtual void onDraw(const int loops, SkCanvas*) SK_OVERRIDE {
122 SkRandom rand; 123 SkRandom rand;
123 SkPaint paint; 124 SkPaint paint;
124 SkPictureRecorder recorder; 125 SkPictureRecorder recorder;
125 SkCanvas* canvas = NULL; 126 SkCanvas* canvas = recorder.beginRecording(PICTURE_WIDTH, PICTURE_HEIGHT );
126 for (int i = 0; i < loops; i++) { 127 for (int i = 0; i < loops; i++) {
127 if (0 == i % kMaxLoopsPerCanvas) { 128 if (0 == i % kMaxLoopsPerCanvas) {
128 SkAutoTUnref<SkPicture> picture(recorder.endRecording()); 129 SkAutoTUnref<SkPicture> picture(recorder.endRecording());
129 canvas = recorder.beginRecording(PICTURE_WIDTH, PICTURE_HEIGHT, NULL, 0); 130 canvas = recorder.beginRecording(PICTURE_WIDTH, PICTURE_HEIGHT);
130 } 131 }
131 paint.setColor(rand.nextU()); 132 paint.setColor(rand.nextU());
132 canvas->drawPaint(paint); 133 canvas->drawPaint(paint);
133 } 134 }
135 SkAutoTUnref<SkPicture> cleanup(recorder.endRecording());
134 } 136 }
135 137
136 private: 138 private:
137 typedef PictureRecordBench INHERITED; 139 typedef PictureRecordBench INHERITED;
138 }; 140 };
139 141
140 /* 142 /*
141 * Populates the SkPaint dictionary with a number of unique paint 143 * Populates the SkPaint dictionary with a number of unique paint
142 * objects that get reused repeatedly. 144 * objects that get reused repeatedly.
143 * 145 *
(...skipping 25 matching lines...) Expand all
169 private: 171 private:
170 SkPaint fPaint [ObjCount]; 172 SkPaint fPaint [ObjCount];
171 typedef PictureRecordBench INHERITED; 173 typedef PictureRecordBench INHERITED;
172 }; 174 };
173 175
174 /////////////////////////////////////////////////////////////////////////////// 176 ///////////////////////////////////////////////////////////////////////////////
175 177
176 DEF_BENCH( return new DictionaryRecordBench(); ) 178 DEF_BENCH( return new DictionaryRecordBench(); )
177 DEF_BENCH( return new UniquePaintDictionaryRecordBench(); ) 179 DEF_BENCH( return new UniquePaintDictionaryRecordBench(); )
178 DEF_BENCH( return new RecurringPaintDictionaryRecordBench(); ) 180 DEF_BENCH( return new RecurringPaintDictionaryRecordBench(); )
OLDNEW
« no previous file with comments | « no previous file | include/core/SkPicture.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698