OLD | NEW |
1 /* | 1 /* |
2 * Copyright 2011 Google Inc. | 2 * Copyright 2011 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 "SkColorMatrixFilterRowMajor255.h" | 8 #include "SkColorMatrixFilterRowMajor255.h" |
9 #include "SkColorPriv.h" | 9 #include "SkColorPriv.h" |
10 #include "SkNx.h" | 10 #include "SkNx.h" |
(...skipping 90 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
101 float srcA = srcf.kth<SkPM4f::A>(); | 101 float srcA = srcf.kth<SkPM4f::A>(); |
102 | 102 |
103 if (0 == srcA) { | 103 if (0 == srcA) { |
104 dst[i] = matrix_translate_pmcolor; | 104 dst[i] = matrix_translate_pmcolor; |
105 continue; | 105 continue; |
106 } | 106 } |
107 if (1 != srcA) { | 107 if (1 != srcA) { |
108 srcf = unpremul(srcf); | 108 srcf = unpremul(srcf); |
109 } | 109 } |
110 | 110 |
111 Sk4f r4 = SkNx_dup<SK_R32_SHIFT/8>(srcf); | 111 Sk4f r4 = srcf.kth<SK_R32_SHIFT/8>(); |
112 Sk4f g4 = SkNx_dup<SK_G32_SHIFT/8>(srcf); | 112 Sk4f g4 = srcf.kth<SK_G32_SHIFT/8>(); |
113 Sk4f b4 = SkNx_dup<SK_B32_SHIFT/8>(srcf); | 113 Sk4f b4 = srcf.kth<SK_B32_SHIFT/8>(); |
114 Sk4f a4 = SkNx_dup<SK_A32_SHIFT/8>(srcf); | 114 Sk4f a4 = srcf.kth<SK_A32_SHIFT/8>(); |
115 | 115 |
116 // apply matrix | 116 // apply matrix |
117 Sk4f dst4 = c0 * r4 + c1 * g4 + c2 * b4 + c3 * a4 + c4; | 117 Sk4f dst4 = c0 * r4 + c1 * g4 + c2 * b4 + c3 * a4 + c4; |
118 | 118 |
119 dst[i] = Adaptor::From4f(premul(clamp_0_1(dst4))); | 119 dst[i] = Adaptor::From4f(premul(clamp_0_1(dst4))); |
120 } | 120 } |
121 } | 121 } |
122 | 122 |
123 struct SkPMColorAdaptor { | 123 struct SkPMColorAdaptor { |
124 static SkPMColor From4f(const Sk4f& c4) { | 124 static SkPMColor From4f(const Sk4f& c4) { |
(...skipping 297 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
422 SkColorFilter* SkColorMatrixFilterRowMajor255::CreateSingleChannelOutput(const S
kScalar row[5]) { | 422 SkColorFilter* SkColorMatrixFilterRowMajor255::CreateSingleChannelOutput(const S
kScalar row[5]) { |
423 SkASSERT(row); | 423 SkASSERT(row); |
424 SkColorMatrixFilterRowMajor255* cf = new SkColorMatrixFilterRowMajor255(); | 424 SkColorMatrixFilterRowMajor255* cf = new SkColorMatrixFilterRowMajor255(); |
425 static_assert(sizeof(SkScalar) * 5 * 4 == sizeof(cf->fMatrix), "sizes don't
match"); | 425 static_assert(sizeof(SkScalar) * 5 * 4 == sizeof(cf->fMatrix), "sizes don't
match"); |
426 for (int i = 0; i < 4; ++i) { | 426 for (int i = 0; i < 4; ++i) { |
427 memcpy(cf->fMatrix + 5 * i, row, sizeof(SkScalar) * 5); | 427 memcpy(cf->fMatrix + 5 * i, row, sizeof(SkScalar) * 5); |
428 } | 428 } |
429 cf->initState(); | 429 cf->initState(); |
430 return cf; | 430 return cf; |
431 } | 431 } |
OLD | NEW |