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

Side by Side Diff: bench/BitmapBench.cpp

Issue 19825002: stop using bitmap-filter flags outside of paint itself, as a step towards really changing them into… (Closed) Base URL: https://skia.googlecode.com/svn/trunk
Patch Set: Created 7 years, 5 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
« no previous file with comments | « no previous file | bench/BitmapScaleBench.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 /* 2 /*
3 * Copyright 2011 Google Inc. 3 * Copyright 2011 Google Inc.
4 * 4 *
5 * Use of this source code is governed by a BSD-style license that can be 5 * Use of this source code is governed by a BSD-style license that can be
6 * found in the LICENSE file. 6 * found in the LICENSE file.
7 */ 7 */
8 #include "SkBenchmark.h" 8 #include "SkBenchmark.h"
9 #include "SkBitmap.h" 9 #include "SkBitmap.h"
10 #include "SkPaint.h" 10 #include "SkPaint.h"
(...skipping 131 matching lines...) Expand 10 before | Expand all | Expand 10 after
142 SkPaint paint(fPaint); 142 SkPaint paint(fPaint);
143 this->setupPaint(&paint); 143 this->setupPaint(&paint);
144 144
145 const SkBitmap& bitmap = fBitmap; 145 const SkBitmap& bitmap = fBitmap;
146 const SkScalar x0 = SkIntToScalar(-bitmap.width() / 2); 146 const SkScalar x0 = SkIntToScalar(-bitmap.width() / 2);
147 const SkScalar y0 = SkIntToScalar(-bitmap.height() / 2); 147 const SkScalar y0 = SkIntToScalar(-bitmap.height() / 2);
148 148
149 int count = N; 149 int count = N;
150 #ifdef SK_RELEASE 150 #ifdef SK_RELEASE
151 // in DEBUG, N is always 1 151 // in DEBUG, N is always 1
152 if (paint.getFlags() & SkPaint::kHighQualityFilterBitmap_Flag) { 152 if (SkPaint::kHigh_FilterLevel == paint.getFilterLevel()) {
153 count /= BICUBIC_DUR_SCALE; 153 count /= BICUBIC_DUR_SCALE;
154 } 154 }
155 #endif 155 #endif
156 for (int i = 0; i < count; i++) { 156 for (int i = 0; i < count; i++) {
157 SkScalar x = x0 + rand.nextUScalar1() * dim.fX; 157 SkScalar x = x0 + rand.nextUScalar1() * dim.fX;
158 SkScalar y = y0 + rand.nextUScalar1() * dim.fY; 158 SkScalar y = y0 + rand.nextUScalar1() * dim.fY;
159 159
160 if (fForceUpdate) 160 if (fForceUpdate)
161 bitmap.notifyPixelsChanged(); 161 bitmap.notifyPixelsChanged();
162 162
163 canvas->drawBitmap(bitmap, x, y, &paint); 163 canvas->drawBitmap(bitmap, x, y, &paint);
164 } 164 }
165 } 165 }
166 166
167 virtual float onGetDurationScale() SK_OVERRIDE { 167 virtual float onGetDurationScale() SK_OVERRIDE {
168 SkPaint paint; 168 SkPaint paint;
169 this->setupPaint(&paint); 169 this->setupPaint(&paint);
170 #ifdef SK_DEBUG 170 #ifdef SK_DEBUG
171 return 1; 171 return 1;
172 #else 172 #else
173 return (paint.getFlags() & SkPaint::kHighQualityFilterBitmap_Flag) ? 173 return SkPaint::kHigh_FilterLevel == paint.getFilterLevel() ?
174 (float)BICUBIC_DUR_SCALE : 1; 174 (float)BICUBIC_DUR_SCALE : 1;
175 #endif 175 #endif
176 } 176 }
177 177
178 virtual void onDrawIntoBitmap(const SkBitmap& bm) { 178 virtual void onDrawIntoBitmap(const SkBitmap& bm) {
179 const int w = bm.width(); 179 const int w = bm.width();
180 const int h = bm.height(); 180 const int h = bm.height();
181 181
182 SkCanvas canvas(bm); 182 SkCanvas canvas(bm);
183 SkPaint p; 183 SkPaint p;
(...skipping 73 matching lines...) Expand 10 before | Expand all | Expand 10 after
257 canvas->translate(-x, -y); 257 canvas->translate(-x, -y);
258 } 258 }
259 if (fFlags & kRotate_Flag) { 259 if (fFlags & kRotate_Flag) {
260 const SkScalar x = SkIntToScalar(dim.fWidth) / 2; 260 const SkScalar x = SkIntToScalar(dim.fWidth) / 2;
261 const SkScalar y = SkIntToScalar(dim.fHeight) / 2; 261 const SkScalar y = SkIntToScalar(dim.fHeight) / 2;
262 262
263 canvas->translate(x, y); 263 canvas->translate(x, y);
264 canvas->rotate(SkIntToScalar(35)); 264 canvas->rotate(SkIntToScalar(35));
265 canvas->translate(-x, -y); 265 canvas->translate(-x, -y);
266 } 266 }
267
268 uint32_t orMask = 0;
269 uint32_t clearMask = SkPaint::kFilterBitmap_Flag | SkPaint::kHighQuality FilterBitmap_Flag;
270 if (fFlags & kBilerp_Flag) {
271 orMask |= SkPaint::kFilterBitmap_Flag;
272 }
273 if (fFlags & kBicubic_Flag) {
274 orMask |= SkPaint::kHighQualityFilterBitmap_Flag;
275 }
276 this->setPaintMasks(orMask, clearMask);
277
278 INHERITED::onDraw(canvas); 267 INHERITED::onDraw(canvas);
279 } 268 }
280 269
270 virtual void setupPaint(SkPaint* paint) SK_OVERRIDE {
271 this->INHERITED::setupPaint(paint);
272
273 int index = 0;
274 if (fFlags & kBilerp_Flag) {
275 index |= 1;
276 }
277 if (fFlags & kBicubic_Flag) {
278 index |= 2;
279 }
280 static const SkPaint::FilterLevel gLevels[] = {
281 SkPaint::kNone_FilterLevel,
282 SkPaint::kLow_FilterLevel,
283 SkPaint::kMedium_FilterLevel,
284 SkPaint::kHigh_FilterLevel
285 };
286 paint->setFilterLevel(gLevels[index]);
287 }
288
281 private: 289 private:
282 typedef BitmapBench INHERITED; 290 typedef BitmapBench INHERITED;
283 }; 291 };
284 292
285 /** Verify optimizations that test source alpha values. */ 293 /** Verify optimizations that test source alpha values. */
286 294
287 class SourceAlphaBitmapBench : public BitmapBench { 295 class SourceAlphaBitmapBench : public BitmapBench {
288 public: 296 public:
289 enum SourceAlpha { kOpaque_SourceAlpha, kTransparent_SourceAlpha, 297 enum SourceAlpha { kOpaque_SourceAlpha, kTransparent_SourceAlpha,
290 kTwoStripes_SourceAlpha, kThreeStripes_SourceAlpha}; 298 kTwoStripes_SourceAlpha, kThreeStripes_SourceAlpha};
(...skipping 101 matching lines...) Expand 10 before | Expand all | Expand 10 after
392 DEF_BENCH( return new FilterBitmapBench(p, true, SkBitmap::kARGB_8888_Config, tr ue, false, kScale_Flag | kRotate_Flag | kBilerp_Flag); ) 400 DEF_BENCH( return new FilterBitmapBench(p, true, SkBitmap::kARGB_8888_Config, tr ue, false, kScale_Flag | kRotate_Flag | kBilerp_Flag); )
393 401
394 DEF_BENCH( return new FilterBitmapBench(p, false, SkBitmap::kARGB_8888_Config, f alse, false, kScale_Flag | kBilerp_Flag | kBicubic_Flag); ) 402 DEF_BENCH( return new FilterBitmapBench(p, false, SkBitmap::kARGB_8888_Config, f alse, false, kScale_Flag | kBilerp_Flag | kBicubic_Flag); )
395 DEF_BENCH( return new FilterBitmapBench(p, false, SkBitmap::kARGB_8888_Config, f alse, false, kScale_Flag | kRotate_Flag | kBilerp_Flag | kBicubic_Flag); ) 403 DEF_BENCH( return new FilterBitmapBench(p, false, SkBitmap::kARGB_8888_Config, f alse, false, kScale_Flag | kRotate_Flag | kBilerp_Flag | kBicubic_Flag); )
396 404
397 // source alpha tests -> S32A_Opaque_BlitRow32_{arm,neon} 405 // source alpha tests -> S32A_Opaque_BlitRow32_{arm,neon}
398 DEF_BENCH( return new SourceAlphaBitmapBench(p, SourceAlphaBitmapBench::kOpaque_ SourceAlpha, SkBitmap::kARGB_8888_Config); ) 406 DEF_BENCH( return new SourceAlphaBitmapBench(p, SourceAlphaBitmapBench::kOpaque_ SourceAlpha, SkBitmap::kARGB_8888_Config); )
399 DEF_BENCH( return new SourceAlphaBitmapBench(p, SourceAlphaBitmapBench::kTranspa rent_SourceAlpha, SkBitmap::kARGB_8888_Config); ) 407 DEF_BENCH( return new SourceAlphaBitmapBench(p, SourceAlphaBitmapBench::kTranspa rent_SourceAlpha, SkBitmap::kARGB_8888_Config); )
400 DEF_BENCH( return new SourceAlphaBitmapBench(p, SourceAlphaBitmapBench::kTwoStri pes_SourceAlpha, SkBitmap::kARGB_8888_Config); ) 408 DEF_BENCH( return new SourceAlphaBitmapBench(p, SourceAlphaBitmapBench::kTwoStri pes_SourceAlpha, SkBitmap::kARGB_8888_Config); )
401 DEF_BENCH( return new SourceAlphaBitmapBench(p, SourceAlphaBitmapBench::kThreeSt ripes_SourceAlpha, SkBitmap::kARGB_8888_Config); ) 409 DEF_BENCH( return new SourceAlphaBitmapBench(p, SourceAlphaBitmapBench::kThreeSt ripes_SourceAlpha, SkBitmap::kARGB_8888_Config); )
OLDNEW
« no previous file with comments | « no previous file | bench/BitmapScaleBench.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698