| OLD | NEW |
| 1 /* | 1 /* |
| 2 * Copyright 2015 Google Inc. | 2 * Copyright 2015 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 | 7 |
| 8 #include "Benchmark.h" | 8 #include "Benchmark.h" |
| 9 #include "SkBitmap.h" | 9 #include "SkBitmap.h" |
| 10 #include "SkMipMap.h" | 10 #include "SkMipMap.h" |
| 11 | 11 |
| 12 class MipMapBench: public Benchmark { | 12 class MipMapBench: public Benchmark { |
| 13 SkBitmap fBitmap; | 13 SkBitmap fBitmap; |
| 14 SkString fName; |
| 15 const int fN; |
| 14 | 16 |
| 15 public: | 17 public: |
| 16 MipMapBench() {} | 18 MipMapBench(int N) : fN(N) { |
| 19 fName.printf("mipmap_build_%d", N); |
| 20 } |
| 17 | 21 |
| 18 protected: | 22 protected: |
| 19 bool isSuitableFor(Backend backend) override { | 23 bool isSuitableFor(Backend backend) override { |
| 20 return kNonRendering_Backend == backend; | 24 return kNonRendering_Backend == backend; |
| 21 } | 25 } |
| 22 | 26 |
| 23 const char* onGetName() override { return "mipmap_build"; } | 27 const char* onGetName() override { return fName.c_str(); } |
| 24 | 28 |
| 25 void onDelayedSetup() override { | 29 void onDelayedSetup() override { |
| 26 fBitmap.allocN32Pixels(1000, 1000, true); | 30 fBitmap.allocN32Pixels(fN, fN, true); |
| 27 fBitmap.eraseColor(SK_ColorWHITE); // so we don't read uninitialized me
mory | 31 fBitmap.eraseColor(SK_ColorWHITE); // so we don't read uninitialized me
mory |
| 28 } | 32 } |
| 29 | 33 |
| 30 void onDraw(int loops, SkCanvas*) override { | 34 void onDraw(int loops, SkCanvas*) override { |
| 31 for (int i = 0; i < loops; i++) { | 35 for (int i = 0; i < loops * 4; i++) { |
| 32 SkMipMap::Build(fBitmap, nullptr)->unref(); | 36 SkMipMap::Build(fBitmap, nullptr)->unref(); |
| 33 } | 37 } |
| 34 } | 38 } |
| 35 | 39 |
| 36 private: | 40 private: |
| 37 typedef Benchmark INHERITED; | 41 typedef Benchmark INHERITED; |
| 38 }; | 42 }; |
| 39 | 43 |
| 40 DEF_BENCH( return new MipMapBench; ) | 44 DEF_BENCH( return new MipMapBench(511); ) |
| 45 DEF_BENCH( return new MipMapBench(512); ) |
| OLD | NEW |