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 #include "Benchmark.h" | 7 #include "Benchmark.h" |
8 #include "SkColorPriv.h" | 8 #include "SkColorPriv.h" |
9 #include "SkRandom.h" | 9 #include "SkRandom.h" |
10 #include "SkString.h" | 10 #include "SkString.h" |
(...skipping 21 matching lines...) Expand all Loading... |
32 fDsts[i] = SkPreMultiplyColor(rand.nextU()); | 32 fDsts[i] = SkPreMultiplyColor(rand.nextU()); |
33 } | 33 } |
34 | 34 |
35 // We'll exhaustively test all scales instead of using random numbers. | 35 // We'll exhaustively test all scales instead of using random numbers. |
36 for (int i = 0; i <= 256; i++) { | 36 for (int i = 0; i <= 256; i++) { |
37 fScales[i] = i; | 37 fScales[i] = i; |
38 } | 38 } |
39 if (kScale) fScales[256] = 255; // We'll just do 255 twice if we're lim
ited to [0,255]. | 39 if (kScale) fScales[256] = 255; // We'll just do 255 twice if we're lim
ited to [0,255]. |
40 } | 40 } |
41 | 41 |
42 void onDraw(const int loops, SkCanvas*) override { | 42 void onDraw(int loops, SkCanvas*) override { |
43 // We xor results of FourByteInterp into junk to make sure the function
runs. | 43 // We xor results of FourByteInterp into junk to make sure the function
runs. |
44 volatile SkPMColor junk = 0; | 44 volatile SkPMColor junk = 0; |
45 | 45 |
46 for (int loop = 0; loop < loops; loop++) { | 46 for (int loop = 0; loop < loops; loop++) { |
47 for (int i = 0; i < kInputs; i++) { | 47 for (int i = 0; i < kInputs; i++) { |
48 for (size_t j = 0; j <= 256; j++) { | 48 for (size_t j = 0; j <= 256; j++) { |
49 // Note: we really want to load src and dst here and not out
side in the i-loop. | 49 // Note: we really want to load src and dst here and not out
side in the i-loop. |
50 // If we put the loads there, a clever compiler will do the
not-insignificant | 50 // If we put the loads there, a clever compiler will do the
not-insignificant |
51 // work in the FourByteInterps that depends only on src and
dst outside this | 51 // work in the FourByteInterps that depends only on src and
dst outside this |
52 // loop, so we'd only be benchmarking the back half of those
functions that also | 52 // loop, so we'd only be benchmarking the back half of those
functions that also |
(...skipping 25 matching lines...) Expand all Loading... |
78 volatile unsigned fDsts[kInputs]; | 78 volatile unsigned fDsts[kInputs]; |
79 unsigned fScales[257]; // We need space for [0, 256]. | 79 unsigned fScales[257]; // We need space for [0, 256]. |
80 }; | 80 }; |
81 | 81 |
82 #define COMMA , | 82 #define COMMA , |
83 DEF_BENCH(return (new FourByteInterpBench<true COMMA true>);) | 83 DEF_BENCH(return (new FourByteInterpBench<true COMMA true>);) |
84 DEF_BENCH(return (new FourByteInterpBench<true COMMA false>);) | 84 DEF_BENCH(return (new FourByteInterpBench<true COMMA false>);) |
85 DEF_BENCH(return (new FourByteInterpBench<false COMMA true>);) | 85 DEF_BENCH(return (new FourByteInterpBench<false COMMA true>);) |
86 DEF_BENCH(return (new FourByteInterpBench<false COMMA false>);) | 86 DEF_BENCH(return (new FourByteInterpBench<false COMMA false>);) |
87 #undef COMMA | 87 #undef COMMA |
OLD | NEW |