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 "SkAvoidXfermode.h" | 8 #include "SkAvoidXfermode.h" |
9 #include "SkColorPriv.h" | 9 #include "SkColorPriv.h" |
10 #include "SkReadBuffer.h" | 10 #include "SkReadBuffer.h" |
(...skipping 90 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
101 int d = color_dist32(dst[i], opR, opG, opB); | 101 int d = color_dist32(dst[i], opR, opG, opB); |
102 // now reverse d if we need to | 102 // now reverse d if we need to |
103 d = MAX + (d ^ mask) - mask; | 103 d = MAX + (d ^ mask) - mask; |
104 SkASSERT((unsigned)d <= 255); | 104 SkASSERT((unsigned)d <= 255); |
105 d = Accurate255To256(d); | 105 d = Accurate255To256(d); |
106 | 106 |
107 d = scale_dist_14(d, mul, sub); | 107 d = scale_dist_14(d, mul, sub); |
108 SkASSERT(d <= 256); | 108 SkASSERT(d <= 256); |
109 | 109 |
110 if (d > 0) { | 110 if (d > 0) { |
111 if (NULL != aa) { | 111 if (aa) { |
112 d = SkAlphaMul(d, Accurate255To256(*aa++)); | 112 d = SkAlphaMul(d, Accurate255To256(*aa++)); |
113 if (0 == d) { | 113 if (0 == d) { |
114 continue; | 114 continue; |
115 } | 115 } |
116 } | 116 } |
117 dst[i] = SkFourByteInterp256(src[i], dst[i], d); | 117 dst[i] = SkFourByteInterp256(src[i], dst[i], d); |
118 } | 118 } |
119 } | 119 } |
120 } | 120 } |
121 | 121 |
(...skipping 28 matching lines...) Expand all Loading... |
150 int d = color_dist16(dst[i], opR, opG, opB); | 150 int d = color_dist16(dst[i], opR, opG, opB); |
151 // now reverse d if we need to | 151 // now reverse d if we need to |
152 d = MAX + (d ^ mask) - mask; | 152 d = MAX + (d ^ mask) - mask; |
153 SkASSERT((unsigned)d <= 31); | 153 SkASSERT((unsigned)d <= 31); |
154 // convert from 0..31 to 0..32 | 154 // convert from 0..31 to 0..32 |
155 d += d >> 4; | 155 d += d >> 4; |
156 d = scale_dist_14(d, mul, sub); | 156 d = scale_dist_14(d, mul, sub); |
157 SkASSERT(d <= 32); | 157 SkASSERT(d <= 32); |
158 | 158 |
159 if (d > 0) { | 159 if (d > 0) { |
160 if (NULL != aa) { | 160 if (aa) { |
161 d = SkAlphaMul(d, Accurate255To256(*aa++)); | 161 d = SkAlphaMul(d, Accurate255To256(*aa++)); |
162 if (0 == d) { | 162 if (0 == d) { |
163 continue; | 163 continue; |
164 } | 164 } |
165 } | 165 } |
166 dst[i] = SkBlend3216(src[i], dst[i], d); | 166 dst[i] = SkBlend3216(src[i], dst[i], d); |
167 } | 167 } |
168 } | 168 } |
169 } | 169 } |
170 | 170 |
171 void SkAvoidXfermode::xferA8(SkAlpha dst[], const SkPMColor src[], int count, | 171 void SkAvoidXfermode::xferA8(SkAlpha dst[], const SkPMColor src[], int count, |
172 const SkAlpha aa[]) const { | 172 const SkAlpha aa[]) const { |
173 // override in subclass | 173 // override in subclass |
174 } | 174 } |
175 | 175 |
176 #ifndef SK_IGNORE_TO_STRING | 176 #ifndef SK_IGNORE_TO_STRING |
177 void SkAvoidXfermode::toString(SkString* str) const { | 177 void SkAvoidXfermode::toString(SkString* str) const { |
178 str->append("SkAvoidXfermode: opColor: "); | 178 str->append("SkAvoidXfermode: opColor: "); |
179 str->appendHex(fOpColor); | 179 str->appendHex(fOpColor); |
180 str->appendf("distMul: %d ", fDistMul); | 180 str->appendf("distMul: %d ", fDistMul); |
181 | 181 |
182 static const char* gModeStrings[] = { "Avoid", "Target" }; | 182 static const char* gModeStrings[] = { "Avoid", "Target" }; |
183 | 183 |
184 str->appendf("mode: %s", gModeStrings[fMode]); | 184 str->appendf("mode: %s", gModeStrings[fMode]); |
185 } | 185 } |
186 #endif | 186 #endif |
OLD | NEW |