| OLD | NEW |
| 1 | 1 |
| 2 /* | 2 /* |
| 3 * Copyright 2013 Google Inc. | 3 * Copyright 2013 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 | 8 |
| 9 #include "SkBenchmark.h" | 9 #include "SkBenchmark.h" |
| 10 #include "SkCanvas.h" | 10 #include "SkCanvas.h" |
| (...skipping 28 matching lines...) Expand all Loading... |
| 39 for (int h = 0; h < size.height(); ++h) { | 39 for (int h = 0; h < size.height(); ++h) { |
| 40 for (int w = 0; w < size.width(); ++w) | 40 for (int w = 0; w < size.width(); ++w) |
| 41 pixels[h * size.width() + w] = SkPackConfig8888(fUnPremulConfig, | 41 pixels[h * size.width() + w] = SkPackConfig8888(fUnPremulConfig, |
| 42 h & 0xFF, w & 0xFF, w & 0xFF, w & 0xFF); | 42 h & 0xFF, w & 0xFF, w & 0xFF, w & 0xFF); |
| 43 } | 43 } |
| 44 | 44 |
| 45 SkBitmap bmp2; | 45 SkBitmap bmp2; |
| 46 bmp2.setConfig(SkBitmap::kARGB_8888_Config, size.width(), | 46 bmp2.setConfig(SkBitmap::kARGB_8888_Config, size.width(), |
| 47 size.height()); | 47 size.height()); |
| 48 | 48 |
| 49 static const int kLoopCount = SkBENCHLOOP(10); | 49 for (int loop = 0; loop < this->getLoops(); ++loop) { |
| 50 for (int loop = 0; loop < kLoopCount; ++loop) { | |
| 51 // Unpremul -> Premul | 50 // Unpremul -> Premul |
| 52 canvas->writePixels(bmp1, 0, 0, fUnPremulConfig); | 51 canvas->writePixels(bmp1, 0, 0, fUnPremulConfig); |
| 53 // Premul -> Unpremul | 52 // Premul -> Unpremul |
| 54 canvas->readPixels(&bmp2, 0, 0, fUnPremulConfig); | 53 canvas->readPixels(&bmp2, 0, 0, fUnPremulConfig); |
| 55 } | 54 } |
| 56 } | 55 } |
| 57 | 56 |
| 58 private: | 57 private: |
| 59 SkCanvas::Config8888 fUnPremulConfig; | 58 SkCanvas::Config8888 fUnPremulConfig; |
| 60 SkString fName; | 59 SkString fName; |
| 61 typedef SkBenchmark INHERITED; | 60 typedef SkBenchmark INHERITED; |
| 62 }; | 61 }; |
| 63 | 62 |
| 64 static SkBenchmark* fact0(void* p) { | 63 static SkBenchmark* fact0(void* p) { |
| 65 return new PremulAndUnpremulAlphaOpsBench(p, | 64 return new PremulAndUnpremulAlphaOpsBench(p, |
| 66 SkCanvas::kRGBA_Unpremul_Config8888); | 65 SkCanvas::kRGBA_Unpremul_Config8888); |
| 67 } | 66 } |
| 68 static SkBenchmark* fact1(void* p) { | 67 static SkBenchmark* fact1(void* p) { |
| 69 return new PremulAndUnpremulAlphaOpsBench(p, | 68 return new PremulAndUnpremulAlphaOpsBench(p, |
| 70 SkCanvas::kNative_Unpremul_Config8888); | 69 SkCanvas::kNative_Unpremul_Config8888); |
| 71 } | 70 } |
| 72 | 71 |
| 73 static BenchRegistry gReg0(fact0); | 72 static BenchRegistry gReg0(fact0); |
| 74 static BenchRegistry gReg1(fact1); | 73 static BenchRegistry gReg1(fact1); |
| OLD | NEW |