| 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 "SkCanvas.h" | 10 #include "SkCanvas.h" |
| (...skipping 71 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 82 } | 82 } |
| 83 } | 83 } |
| 84 } | 84 } |
| 85 | 85 |
| 86 class RepeatTileBench : public SkBenchmark { | 86 class RepeatTileBench : public SkBenchmark { |
| 87 SkPaint fPaint; | 87 SkPaint fPaint; |
| 88 SkString fName; | 88 SkString fName; |
| 89 SkBitmap fBitmap; | 89 SkBitmap fBitmap; |
| 90 bool fIsOpaque; | 90 bool fIsOpaque; |
| 91 SkBitmap::Config fConfig; | 91 SkBitmap::Config fConfig; |
| 92 enum { N = SkBENCHLOOP(20) }; | |
| 93 public: | 92 public: |
| 94 RepeatTileBench(void* param, SkBitmap::Config c, bool isOpaque = false) : IN
HERITED(param) { | 93 RepeatTileBench(void* param, SkBitmap::Config c, bool isOpaque = false) : IN
HERITED(param) { |
| 95 const int w = 50; | 94 const int w = 50; |
| 96 const int h = 50; | 95 const int h = 50; |
| 97 fConfig = c; | 96 fConfig = c; |
| 98 fIsOpaque = isOpaque; | 97 fIsOpaque = isOpaque; |
| 99 | 98 |
| 100 if (SkBitmap::kIndex8_Config == fConfig) { | 99 if (SkBitmap::kIndex8_Config == fConfig) { |
| 101 fBitmap.setConfig(SkBitmap::kARGB_8888_Config, w, h); | 100 fBitmap.setConfig(SkBitmap::kARGB_8888_Config, w, h); |
| 102 } else { | 101 } else { |
| (...skipping 25 matching lines...) Expand all Loading... |
| 128 SkShader::kRepeat_TileMode, | 127 SkShader::kRepeat_TileMode, |
| 129 SkShader::kRepeat_TileMode); | 128 SkShader::kRepeat_TileMode); |
| 130 fPaint.setShader(s)->unref(); | 129 fPaint.setShader(s)->unref(); |
| 131 } | 130 } |
| 132 | 131 |
| 133 | 132 |
| 134 virtual void onDraw(SkCanvas* canvas) SK_OVERRIDE { | 133 virtual void onDraw(SkCanvas* canvas) SK_OVERRIDE { |
| 135 SkPaint paint(fPaint); | 134 SkPaint paint(fPaint); |
| 136 this->setupPaint(&paint); | 135 this->setupPaint(&paint); |
| 137 | 136 |
| 138 for (int i = 0; i < N; i++) { | 137 for (int i = 0; i < this->getLoops(); i++) { |
| 139 canvas->drawPaint(paint); | 138 canvas->drawPaint(paint); |
| 140 } | 139 } |
| 141 } | 140 } |
| 142 | 141 |
| 143 private: | 142 private: |
| 144 typedef SkBenchmark INHERITED; | 143 typedef SkBenchmark INHERITED; |
| 145 }; | 144 }; |
| 146 | 145 |
| 147 DEF_BENCH(return new RepeatTileBench(p, SkBitmap::kARGB_8888_Config, true)) | 146 DEF_BENCH(return new RepeatTileBench(p, SkBitmap::kARGB_8888_Config, true)) |
| 148 DEF_BENCH(return new RepeatTileBench(p, SkBitmap::kARGB_8888_Config, false)) | 147 DEF_BENCH(return new RepeatTileBench(p, SkBitmap::kARGB_8888_Config, false)) |
| 149 DEF_BENCH(return new RepeatTileBench(p, SkBitmap::kRGB_565_Config)) | 148 DEF_BENCH(return new RepeatTileBench(p, SkBitmap::kRGB_565_Config)) |
| 150 DEF_BENCH(return new RepeatTileBench(p, SkBitmap::kIndex8_Config)) | 149 DEF_BENCH(return new RepeatTileBench(p, SkBitmap::kIndex8_Config)) |
| OLD | NEW |