| 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 "SkBenchmark.h" | 8 #include "SkBenchmark.h" |
| 9 #include "SkBitmap.h" | 9 #include "SkBitmap.h" |
| 10 #include "SkPaint.h" | 10 #include "SkPaint.h" |
| (...skipping 29 matching lines...) Expand all Loading... |
| 40 | 40 |
| 41 class BitmapRectBench : public SkBenchmark { | 41 class BitmapRectBench : public SkBenchmark { |
| 42 SkBitmap fBitmap; | 42 SkBitmap fBitmap; |
| 43 bool fDoFilter; | 43 bool fDoFilter; |
| 44 bool fSlightMatrix; | 44 bool fSlightMatrix; |
| 45 uint8_t fAlpha; | 45 uint8_t fAlpha; |
| 46 SkString fName; | 46 SkString fName; |
| 47 SkRect fSrcR, fDstR; | 47 SkRect fSrcR, fDstR; |
| 48 static const int kWidth = 128; | 48 static const int kWidth = 128; |
| 49 static const int kHeight = 128; | 49 static const int kHeight = 128; |
| 50 enum { N = SkBENCHLOOP(300) }; | |
| 51 public: | 50 public: |
| 52 BitmapRectBench(void* param, U8CPU alpha, bool doFilter, bool slightMatrix)
: INHERITED(param) { | 51 BitmapRectBench(void* param, U8CPU alpha, bool doFilter, bool slightMatrix)
: INHERITED(param) { |
| 53 fAlpha = SkToU8(alpha); | 52 fAlpha = SkToU8(alpha); |
| 54 fDoFilter = doFilter; | 53 fDoFilter = doFilter; |
| 55 fSlightMatrix = slightMatrix; | 54 fSlightMatrix = slightMatrix; |
| 56 | 55 |
| 57 fBitmap.setConfig(SkBitmap::kARGB_8888_Config, kWidth, kHeight); | 56 fBitmap.setConfig(SkBitmap::kARGB_8888_Config, kWidth, kHeight); |
| 58 } | 57 } |
| 59 | 58 |
| 60 protected: | 59 protected: |
| (...skipping 25 matching lines...) Expand all Loading... |
| 86 | 85 |
| 87 | 86 |
| 88 virtual void onDraw(SkCanvas* canvas) SK_OVERRIDE { | 87 virtual void onDraw(SkCanvas* canvas) SK_OVERRIDE { |
| 89 SkRandom rand; | 88 SkRandom rand; |
| 90 | 89 |
| 91 SkPaint paint; | 90 SkPaint paint; |
| 92 this->setupPaint(&paint); | 91 this->setupPaint(&paint); |
| 93 paint.setFilterBitmap(fDoFilter); | 92 paint.setFilterBitmap(fDoFilter); |
| 94 paint.setAlpha(fAlpha); | 93 paint.setAlpha(fAlpha); |
| 95 | 94 |
| 96 for (int i = 0; i < N; i++) { | 95 for (int i = 0; i < this->getLoops(); i++) { |
| 97 canvas->drawBitmapRectToRect(fBitmap, &fSrcR, fDstR, &paint); | 96 canvas->drawBitmapRectToRect(fBitmap, &fSrcR, fDstR, &paint); |
| 98 } | 97 } |
| 99 } | 98 } |
| 100 | 99 |
| 101 private: | 100 private: |
| 102 typedef SkBenchmark INHERITED; | 101 typedef SkBenchmark INHERITED; |
| 103 }; | 102 }; |
| 104 | 103 |
| 105 DEF_BENCH(return new BitmapRectBench(p, 0xFF, false, false)) | 104 DEF_BENCH(return new BitmapRectBench(p, 0xFF, false, false)) |
| 106 DEF_BENCH(return new BitmapRectBench(p, 0x80, false, false)) | 105 DEF_BENCH(return new BitmapRectBench(p, 0x80, false, false)) |
| 107 DEF_BENCH(return new BitmapRectBench(p, 0xFF, true, false)) | 106 DEF_BENCH(return new BitmapRectBench(p, 0xFF, true, false)) |
| 108 DEF_BENCH(return new BitmapRectBench(p, 0x80, true, false)) | 107 DEF_BENCH(return new BitmapRectBench(p, 0x80, true, false)) |
| 109 | 108 |
| 110 DEF_BENCH(return new BitmapRectBench(p, 0xFF, false, true)) | 109 DEF_BENCH(return new BitmapRectBench(p, 0xFF, false, true)) |
| 111 DEF_BENCH(return new BitmapRectBench(p, 0xFF, true, true)) | 110 DEF_BENCH(return new BitmapRectBench(p, 0xFF, true, true)) |
| OLD | NEW |