OLD | NEW |
1 /* | 1 /* |
2 * Copyright 2013 Google Inc. | 2 * Copyright 2013 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 "SkCanvas.h" | 9 #include "SkCanvas.h" |
10 #include "SkConfig8888.h" | 10 #include "SkConfig8888.h" |
(...skipping 25 matching lines...) Expand all Loading... |
36 for (int h = 0; h < H; ++h) { | 36 for (int h = 0; h < H; ++h) { |
37 for (int w = 0; w < W; ++w) { | 37 for (int w = 0; w < W; ++w) { |
38 // SkColor places A in the right slot for either RGBA or BGRA | 38 // SkColor places A in the right slot for either RGBA or BGRA |
39 *fBmp1.getAddr32(w, h) = SkColorSetARGB(h & 0xFF, w & 0xFF, w &
0xFF, w & 0xFF); | 39 *fBmp1.getAddr32(w, h) = SkColorSetARGB(h & 0xFF, w & 0xFF, w &
0xFF, w & 0xFF); |
40 } | 40 } |
41 } | 41 } |
42 | 42 |
43 fBmp2.allocPixels(info); // used in readPixels() | 43 fBmp2.allocPixels(info); // used in readPixels() |
44 } | 44 } |
45 | 45 |
46 void onDraw(const int loops, SkCanvas* canvas) override { | 46 void onDraw(int loops, SkCanvas* canvas) override { |
47 canvas->clear(SK_ColorBLACK); | 47 canvas->clear(SK_ColorBLACK); |
48 | 48 |
49 for (int loop = 0; loop < loops; ++loop) { | 49 for (int loop = 0; loop < loops; ++loop) { |
50 // Unpremul -> Premul | 50 // Unpremul -> Premul |
51 canvas->writePixels(fBmp1.info(), fBmp1.getPixels(), fBmp1.rowBytes(
), 0, 0); | 51 canvas->writePixels(fBmp1.info(), fBmp1.getPixels(), fBmp1.rowBytes(
), 0, 0); |
52 // Premul -> Unpremul | 52 // Premul -> Unpremul |
53 canvas->readPixels(fBmp2.info(), fBmp2.getPixels(), fBmp2.rowBytes()
, 0, 0); | 53 canvas->readPixels(fBmp2.info(), fBmp2.getPixels(), fBmp2.rowBytes()
, 0, 0); |
54 } | 54 } |
55 } | 55 } |
56 | 56 |
57 private: | 57 private: |
58 SkColorType fColorType; | 58 SkColorType fColorType; |
59 SkString fName; | 59 SkString fName; |
60 | 60 |
61 typedef Benchmark INHERITED; | 61 typedef Benchmark INHERITED; |
62 }; | 62 }; |
63 | 63 |
64 | 64 |
65 DEF_BENCH(return new PremulAndUnpremulAlphaOpsBench(kRGBA_8888_SkColorType)); | 65 DEF_BENCH(return new PremulAndUnpremulAlphaOpsBench(kRGBA_8888_SkColorType)); |
66 DEF_BENCH(return new PremulAndUnpremulAlphaOpsBench(kBGRA_8888_SkColorType)); | 66 DEF_BENCH(return new PremulAndUnpremulAlphaOpsBench(kBGRA_8888_SkColorType)); |
OLD | NEW |