144 |
144 |
145 /* |
145 /* |
146 result = 0 |
146 result = 0 |
147 d = d * cia |
147 d = d * cia |
148 */ |
148 */ |
|
149 #define comp_func_Clear_impl(dest, length, const_alpha)\ |
|
150 {\ |
|
151 if (const_alpha == 255) {\ |
|
152 qt_memfill(static_cast<quint32*>(dest), quint32(0), length);\ |
|
153 } else {\ |
|
154 C_FF; C_80; C_00;\ |
|
155 m64 ia = MM::negate(MM::load_alpha(const_alpha));\ |
|
156 for (int i = 0; i < length; ++i) {\ |
|
157 dest[i] = MM::store(MM::byte_mul(MM::load(dest[i]), ia));\ |
|
158 }\ |
|
159 MM::end();\ |
|
160 }\ |
|
161 } |
|
162 |
149 template <class MM> |
163 template <class MM> |
150 static void QT_FASTCALL comp_func_solid_Clear(uint *dest, int length, uint, uint const_alpha) |
164 static void QT_FASTCALL comp_func_solid_Clear(uint *dest, int length, uint, uint const_alpha) |
151 { |
165 { |
152 if (!length) |
166 comp_func_Clear_impl(dest, length, const_alpha); |
153 return; |
|
154 |
|
155 if (const_alpha == 255) { |
|
156 qt_memfill(static_cast<quint32*>(dest), quint32(0), length); |
|
157 } else { |
|
158 C_FF; C_80; C_00; |
|
159 m64 ia = MM::negate(MM::load_alpha(const_alpha)); |
|
160 for (int i = 0; i < length; ++i) { |
|
161 dest[i] = MM::store(MM::byte_mul(MM::load(dest[i]), ia)); |
|
162 } |
|
163 } |
|
164 MM::end(); |
|
165 } |
167 } |
166 |
168 |
167 template <class MM> |
169 template <class MM> |
168 static void QT_FASTCALL comp_func_Clear(uint *dest, const uint *, int length, uint const_alpha) |
170 static void QT_FASTCALL comp_func_Clear(uint *dest, const uint *, int length, uint const_alpha) |
169 { |
171 { |
170 if (const_alpha == 255) { |
172 comp_func_Clear_impl(dest, length, const_alpha); |
171 qt_memfill(static_cast<quint32*>(dest), quint32(0), length); |
|
172 } else { |
|
173 C_FF; C_80; C_00; |
|
174 m64 ia = MM::negate(MM::load_alpha(const_alpha)); |
|
175 for (int i = 0; i < length; ++i) |
|
176 dest[i] = MM::store(MM::byte_mul(MM::load(dest[i]), ia)); |
|
177 } |
|
178 MM::end(); |
|
179 } |
173 } |
180 |
174 |
181 /* |
175 /* |
182 result = s |
176 result = s |
183 dest = s * ca + d * cia |
177 dest = s * ca + d * cia |
244 static void QT_FASTCALL comp_func_SourceOver(uint *dest, const uint *src, int length, uint const_alpha) |
238 static void QT_FASTCALL comp_func_SourceOver(uint *dest, const uint *src, int length, uint const_alpha) |
245 { |
239 { |
246 C_FF; C_80; C_00; |
240 C_FF; C_80; C_00; |
247 if (const_alpha == 255) { |
241 if (const_alpha == 255) { |
248 for (int i = 0; i < length; ++i) { |
242 for (int i = 0; i < length; ++i) { |
249 if ((0xff000000 & src[i]) == 0xff000000) { |
243 const uint alphaMaskedSource = 0xff000000 & src[i]; |
|
244 if (alphaMaskedSource == 0) |
|
245 continue; |
|
246 if (alphaMaskedSource == 0xff000000) { |
250 dest[i] = src[i]; |
247 dest[i] = src[i]; |
251 } else { |
248 } else { |
252 m64 s = MM::load(src[i]); |
249 m64 s = MM::load(src[i]); |
253 m64 ia = MM::negate(MM::alpha(s)); |
250 m64 ia = MM::negate(MM::alpha(s)); |
254 dest[i] = MM::store(MM::add(s, MM::byte_mul(MM::load(dest[i]), ia))); |
251 dest[i] = MM::store(MM::add(s, MM::byte_mul(MM::load(dest[i]), ia))); |
255 } |
252 } |
256 } |
253 } |
257 } else { |
254 } else { |
258 m64 ca = MM::load_alpha(const_alpha); |
255 m64 ca = MM::load_alpha(const_alpha); |
259 for (int i = 0; i < length; ++i) { |
256 for (int i = 0; i < length; ++i) { |
|
257 if ((0xff000000 & src[i]) == 0) |
|
258 continue; |
260 m64 s = MM::byte_mul(MM::load(src[i]), ca); |
259 m64 s = MM::byte_mul(MM::load(src[i]), ca); |
261 m64 ia = MM::negate(MM::alpha(s)); |
260 m64 ia = MM::negate(MM::alpha(s)); |
262 dest[i] = MM::store(MM::add(s, MM::byte_mul(MM::load(dest[i]), ia))); |
261 dest[i] = MM::store(MM::add(s, MM::byte_mul(MM::load(dest[i]), ia))); |
263 } |
262 } |
264 } |
263 } |