OLD | NEW |
1 // Copyright 2015 The Chromium Authors. All rights reserved. | 1 // Copyright 2015 The Chromium Authors. All rights reserved. |
2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
4 | 4 |
5 #ifndef SkColorCubeFilter_opts_DEFINED | 5 #ifndef SkColorCubeFilter_opts_DEFINED |
6 #define SkColorCubeFilter_opts_DEFINED | 6 #define SkColorCubeFilter_opts_DEFINED |
7 | 7 |
8 #include "SkColor.h" | 8 #include "SkColor.h" |
9 #include "SkNx.h" | 9 #include "SkNx.h" |
10 #include "SkUnPreMultiply.h" | 10 #include "SkUnPreMultiply.h" |
(...skipping 32 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
43 const Sk4f g0b0(g0*b0), | 43 const Sk4f g0b0(g0*b0), |
44 g0b1(g0*b1), | 44 g0b1(g0*b1), |
45 g1b0(g1*b0), | 45 g1b0(g1*b0), |
46 g1b1(g1*b1); | 46 g1b1(g1*b1); |
47 | 47 |
48 const int i00 = (colorToIndex[0][g] + colorToIndex[0][b] * dim) * dim; | 48 const int i00 = (colorToIndex[0][g] + colorToIndex[0][b] * dim) * dim; |
49 const int i01 = (colorToIndex[0][g] + colorToIndex[1][b] * dim) * dim; | 49 const int i01 = (colorToIndex[0][g] + colorToIndex[1][b] * dim) * dim; |
50 const int i10 = (colorToIndex[1][g] + colorToIndex[0][b] * dim) * dim; | 50 const int i10 = (colorToIndex[1][g] + colorToIndex[0][b] * dim) * dim; |
51 const int i11 = (colorToIndex[1][g] + colorToIndex[1][b] * dim) * dim; | 51 const int i11 = (colorToIndex[1][g] + colorToIndex[1][b] * dim) * dim; |
52 | 52 |
53 Sk4f color(0,0,0,0); | 53 Sk4f color(0.5f); // Starting from 0.5f gets us rounding for free. |
54 for (int x = 0; x < 2; ++x) { | 54 for (int x = 0; x < 2; ++x) { |
55 const int ix = colorToIndex[x][r]; | 55 const int ix = colorToIndex[x][r]; |
56 | 56 |
57 const SkColor lutColor00 = colorCube[ix + i00]; | 57 const SkColor lutColor00 = colorCube[ix + i00]; |
58 const SkColor lutColor01 = colorCube[ix + i01]; | 58 const SkColor lutColor01 = colorCube[ix + i01]; |
59 const SkColor lutColor10 = colorCube[ix + i10]; | 59 const SkColor lutColor10 = colorCube[ix + i10]; |
60 const SkColor lutColor11 = colorCube[ix + i11]; | 60 const SkColor lutColor11 = colorCube[ix + i11]; |
61 | 61 |
62 Sk4f sum = Sk4f::FromBytes((const uint8_t*)&lutColor00) * g0b0; | 62 Sk4f sum = Sk4f::FromBytes((const uint8_t*)&lutColor00) * g0b0; |
63 sum = sum + Sk4f::FromBytes((const uint8_t*)&lutColor01) * g0b1; | 63 sum = sum + Sk4f::FromBytes((const uint8_t*)&lutColor01) * g0b1; |
(...skipping 11 matching lines...) Expand all Loading... |
75 #endif | 75 #endif |
76 uint8_t* dstBytes = (uint8_t*)(dst+i); | 76 uint8_t* dstBytes = (uint8_t*)(dst+i); |
77 color.toBytes(dstBytes); | 77 color.toBytes(dstBytes); |
78 dstBytes[SK_A32_SHIFT/8] = a; | 78 dstBytes[SK_A32_SHIFT/8] = a; |
79 } | 79 } |
80 } | 80 } |
81 | 81 |
82 } // namespace SK_OPTS NS | 82 } // namespace SK_OPTS NS |
83 | 83 |
84 #endif // SkColorCubeFilter_opts_DEFINED | 84 #endif // SkColorCubeFilter_opts_DEFINED |
OLD | NEW |