OLD | NEW |
1 /* | 1 /* |
2 * Copyright 2006 The Android Open Source Project | 2 * Copyright 2006 The Android Open Source Project |
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 "SkColorFilter.h" | 8 #include "SkColorFilter.h" |
9 #include "SkReadBuffer.h" | 9 #include "SkReadBuffer.h" |
10 #include "SkRefCnt.h" | 10 #include "SkRefCnt.h" |
(...skipping 19 matching lines...) Expand all Loading... |
30 bool SkColorFilter::asComponentTable(SkBitmap*) const { | 30 bool SkColorFilter::asComponentTable(SkBitmap*) const { |
31 return false; | 31 return false; |
32 } | 32 } |
33 | 33 |
34 #if SK_SUPPORT_GPU | 34 #if SK_SUPPORT_GPU |
35 sk_sp<GrFragmentProcessor> SkColorFilter::asFragmentProcessor(GrContext*) const
{ | 35 sk_sp<GrFragmentProcessor> SkColorFilter::asFragmentProcessor(GrContext*) const
{ |
36 return nullptr; | 36 return nullptr; |
37 } | 37 } |
38 #endif | 38 #endif |
39 | 39 |
40 void SkColorFilter::filterSpan4f(const SkPM4f[], int count, SkPM4f span[]) const
{ | 40 void SkColorFilter::filterSpan4f(const SkPM4f src[], int count, SkPM4f result[])
const { |
41 const int N = 128; | 41 const int N = 128; |
42 SkPMColor tmp[N]; | 42 SkPMColor tmp[N]; |
43 while (count > 0) { | 43 while (count > 0) { |
44 int n = SkTMin(count, N); | 44 int n = SkTMin(count, N); |
45 for (int i = 0; i < n; ++i) { | 45 for (int i = 0; i < n; ++i) { |
46 SkNx_cast<uint8_t>(Sk4f::Load(span[i].fVec) * Sk4f(255) + Sk4f(0.5f)
).store(&tmp[i]); | 46 SkNx_cast<uint8_t>(Sk4f::Load(src[i].fVec) * Sk4f(255) + Sk4f(0.5f))
.store(&tmp[i]); |
47 } | 47 } |
48 this->filterSpan(tmp, n, tmp); | 48 this->filterSpan(tmp, n, tmp); |
49 for (int i = 0; i < n; ++i) { | 49 for (int i = 0; i < n; ++i) { |
50 span[i] = SkPM4f::FromPMColor(tmp[i]); | 50 result[i] = SkPM4f::FromPMColor(tmp[i]); |
51 } | 51 } |
52 span += n; | 52 src += n; |
| 53 result += n; |
53 count -= n; | 54 count -= n; |
54 } | 55 } |
55 } | 56 } |
56 | 57 |
57 SkColor SkColorFilter::filterColor(SkColor c) const { | 58 SkColor SkColorFilter::filterColor(SkColor c) const { |
58 SkPMColor dst, src = SkPreMultiplyColor(c); | 59 SkPMColor dst, src = SkPreMultiplyColor(c); |
59 this->filterSpan(&src, 1, &dst); | 60 this->filterSpan(&src, 1, &dst); |
60 return SkUnPreMultiply::PMColorToColor(dst); | 61 return SkUnPreMultiply::PMColorToColor(dst); |
61 } | 62 } |
62 | 63 |
(...skipping 114 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
177 } | 178 } |
178 return sk_sp<SkColorFilter>(new SkComposeColorFilter(std::move(outer), std::
move(inner),count)); | 179 return sk_sp<SkColorFilter>(new SkComposeColorFilter(std::move(outer), std::
move(inner),count)); |
179 } | 180 } |
180 | 181 |
181 #include "SkModeColorFilter.h" | 182 #include "SkModeColorFilter.h" |
182 | 183 |
183 SK_DEFINE_FLATTENABLE_REGISTRAR_GROUP_START(SkColorFilter) | 184 SK_DEFINE_FLATTENABLE_REGISTRAR_GROUP_START(SkColorFilter) |
184 SK_DEFINE_FLATTENABLE_REGISTRAR_ENTRY(SkComposeColorFilter) | 185 SK_DEFINE_FLATTENABLE_REGISTRAR_ENTRY(SkComposeColorFilter) |
185 SK_DEFINE_FLATTENABLE_REGISTRAR_ENTRY(SkModeColorFilter) | 186 SK_DEFINE_FLATTENABLE_REGISTRAR_ENTRY(SkModeColorFilter) |
186 SK_DEFINE_FLATTENABLE_REGISTRAR_GROUP_END | 187 SK_DEFINE_FLATTENABLE_REGISTRAR_GROUP_END |
OLD | NEW |