OLD | NEW |
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 "Benchmark.h" | 8 #include "Benchmark.h" |
9 #include "SkBitmap.h" | 9 #include "SkBitmap.h" |
10 #include "SkCanvas.h" | 10 #include "SkCanvas.h" |
(...skipping 230 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
241 | 241 |
242 virtual ~GradientBench() { | 242 virtual ~GradientBench() { |
243 fShader->unref(); | 243 fShader->unref(); |
244 } | 244 } |
245 | 245 |
246 protected: | 246 protected: |
247 virtual const char* onGetName() { | 247 virtual const char* onGetName() { |
248 return fName.c_str(); | 248 return fName.c_str(); |
249 } | 249 } |
250 | 250 |
251 virtual void onDraw(const int loops, SkCanvas* canvas) { | 251 virtual void onDraw(int loops, SkCanvas* canvas) { |
252 SkPaint paint; | 252 SkPaint paint; |
253 this->setupPaint(&paint); | 253 this->setupPaint(&paint); |
254 | 254 |
255 paint.setShader(fShader); | 255 paint.setShader(fShader); |
256 if (fDither) { | 256 if (fDither) { |
257 paint.setDither(true); | 257 paint.setDither(true); |
258 } | 258 } |
259 | 259 |
260 SkRect r = { 0, 0, SkIntToScalar(W), SkIntToScalar(H) }; | 260 SkRect r = { 0, 0, SkIntToScalar(W), SkIntToScalar(H) }; |
261 for (int i = 0; i < loops; i++) { | 261 for (int i = 0; i < loops; i++) { |
(...skipping 68 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
330 Gradient2Bench(bool hasAlpha) { | 330 Gradient2Bench(bool hasAlpha) { |
331 fName.printf("gradient_create_%s", hasAlpha ? "alpha" : "opaque"); | 331 fName.printf("gradient_create_%s", hasAlpha ? "alpha" : "opaque"); |
332 fHasAlpha = hasAlpha; | 332 fHasAlpha = hasAlpha; |
333 } | 333 } |
334 | 334 |
335 protected: | 335 protected: |
336 virtual const char* onGetName() { | 336 virtual const char* onGetName() { |
337 return fName.c_str(); | 337 return fName.c_str(); |
338 } | 338 } |
339 | 339 |
340 virtual void onDraw(const int loops, SkCanvas* canvas) { | 340 virtual void onDraw(int loops, SkCanvas* canvas) { |
341 SkPaint paint; | 341 SkPaint paint; |
342 this->setupPaint(&paint); | 342 this->setupPaint(&paint); |
343 | 343 |
344 const SkRect r = { 0, 0, SkIntToScalar(4), SkIntToScalar(4) }; | 344 const SkRect r = { 0, 0, SkIntToScalar(4), SkIntToScalar(4) }; |
345 const SkPoint pts[] = { | 345 const SkPoint pts[] = { |
346 { 0, 0 }, | 346 { 0, 0 }, |
347 { SkIntToScalar(100), SkIntToScalar(100) }, | 347 { SkIntToScalar(100), SkIntToScalar(100) }, |
348 }; | 348 }; |
349 | 349 |
350 for (int i = 0; i < loops; i++) { | 350 for (int i = 0; i < loops; i++) { |
(...skipping 10 matching lines...) Expand all Loading... |
361 canvas->drawRect(r, paint); | 361 canvas->drawRect(r, paint); |
362 } | 362 } |
363 } | 363 } |
364 | 364 |
365 private: | 365 private: |
366 typedef Benchmark INHERITED; | 366 typedef Benchmark INHERITED; |
367 }; | 367 }; |
368 | 368 |
369 DEF_BENCH( return new Gradient2Bench(false); ) | 369 DEF_BENCH( return new Gradient2Bench(false); ) |
370 DEF_BENCH( return new Gradient2Bench(true); ) | 370 DEF_BENCH( return new Gradient2Bench(true); ) |
OLD | NEW |