OLD | NEW |
1 /* | 1 /* |
2 * Copyright 2015 Google Inc. | 2 * Copyright 2015 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 #ifndef Sk4pxXfermode_DEFINED | 8 #ifndef Sk4pxXfermode_DEFINED |
9 #define Sk4pxXfermode_DEFINED | 9 #define Sk4pxXfermode_DEFINED |
10 | 10 |
(...skipping 71 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
82 return Sk4px::Wide(noAA.mulWiden(aa) + d.mulWiden(Sk4px(aa).inv())) | 82 return Sk4px::Wide(noAA.mulWiden(aa) + d.mulWiden(Sk4px(aa).inv())) |
83 .div255RoundNarrow(); | 83 .div255RoundNarrow(); |
84 } | 84 } |
85 | 85 |
86 // For some transfermodes we specialize AA, either for correctness or performanc
e. | 86 // For some transfermodes we specialize AA, either for correctness or performanc
e. |
87 #ifndef SK_NO_SPECIALIZED_AA_XFERMODES | 87 #ifndef SK_NO_SPECIALIZED_AA_XFERMODES |
88 #define XFERMODE_AA(Name) \ | 88 #define XFERMODE_AA(Name) \ |
89 template <> Sk4px xfer_aa<Name>(const Sk4px& s, const Sk4px& d, const Sk
16b& aa) | 89 template <> Sk4px xfer_aa<Name>(const Sk4px& s, const Sk4px& d, const Sk
16b& aa) |
90 | 90 |
91 // Plus' clamp needs to happen after AA. skia:3852 | 91 // Plus' clamp needs to happen after AA. skia:3852 |
92 XFERMODE_AA(Plus) { // [ clamp(D + AA*S) ] | 92 XFERMODE_AA(Plus) { // [ clamp( (1-AA)D + (AA)(S+D) ) == clamp(D + AA*S) ] |
93 // We implement this as D + Min(S*AA, (1-D)) to fit the arguments to Min
in 16 bits. | 93 return d.saturatedAdd(s.fastMulDiv255Round(aa)); |
94 return d + | |
95 Sk4px::Wide(Sk16h::Min(s.mulWiden(aa), d.inv().mul255Widen())).div25
5RoundNarrow(); | |
96 } | 94 } |
97 | 95 |
98 #undef XFERMODE_AA | 96 #undef XFERMODE_AA |
99 #endif | 97 #endif |
100 | 98 |
101 template <typename ProcType> | 99 template <typename ProcType> |
102 class SkT4pxXfermode : public SkProcCoeffXfermode { | 100 class SkT4pxXfermode : public SkProcCoeffXfermode { |
103 public: | 101 public: |
104 static SkProcCoeffXfermode* Create(const ProcCoeff& rec) { | 102 static SkProcCoeffXfermode* Create(const ProcCoeff& rec) { |
105 return SkNEW_ARGS(SkT4pxXfermode, (rec)); | 103 return SkNEW_ARGS(SkT4pxXfermode, (rec)); |
(...skipping 41 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
147 case SkXfermode::kExclusion_Mode: return SkT4pxXfermode<Exclusion>::Cre
ate(rec); | 145 case SkXfermode::kExclusion_Mode: return SkT4pxXfermode<Exclusion>::Cre
ate(rec); |
148 default: break; | 146 default: break; |
149 } | 147 } |
150 #endif | 148 #endif |
151 return nullptr; | 149 return nullptr; |
152 } | 150 } |
153 | 151 |
154 } // namespace | 152 } // namespace |
155 | 153 |
156 #endif//Sk4pxXfermode_DEFINED | 154 #endif//Sk4pxXfermode_DEFINED |
OLD | NEW |