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 267 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
278 s = Load(src), | 278 s = Load(src), |
279 b = Xfermode()(d, s); | 279 b = Xfermode()(d, s); |
280 if (aa) { | 280 if (aa) { |
281 Sk4f a = Sk4f(*aa) * Sk4f(1.0f/255); | 281 Sk4f a = Sk4f(*aa) * Sk4f(1.0f/255); |
282 b = b*a + d*(Sk4f(1)-a); | 282 b = b*a + d*(Sk4f(1)-a); |
283 } | 283 } |
284 return Round(b); | 284 return Round(b); |
285 } | 285 } |
286 | 286 |
287 static Sk4f Load(SkPMColor c) { | 287 static Sk4f Load(SkPMColor c) { |
288 return SkNx_cast<float>(Sk4b::Load((uint8_t*)&c)) * Sk4f(1.0f/255); | 288 return SkNx_cast<float>(Sk4b::Load(&c)) * Sk4f(1.0f/255); |
289 } | 289 } |
290 | 290 |
291 static SkPMColor Round(const Sk4f& f) { | 291 static SkPMColor Round(const Sk4f& f) { |
292 SkPMColor c; | 292 SkPMColor c; |
293 SkNx_cast<uint8_t>(f * Sk4f(255) + Sk4f(0.5f)).store((uint8_t*)&c); | 293 SkNx_cast<uint8_t>(f * Sk4f(255) + Sk4f(0.5f)).store(&c); |
294 return c; | 294 return c; |
295 } | 295 } |
296 | 296 |
297 typedef SkProcCoeffXfermode INHERITED; | 297 typedef SkProcCoeffXfermode INHERITED; |
298 }; | 298 }; |
299 | 299 |
300 } // namespace | 300 } // namespace |
301 | 301 |
302 namespace SK_OPTS_NS { | 302 namespace SK_OPTS_NS { |
303 | 303 |
(...skipping 33 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
337 #undef CASE | 337 #undef CASE |
338 | 338 |
339 default: break; | 339 default: break; |
340 } | 340 } |
341 return nullptr; | 341 return nullptr; |
342 } | 342 } |
343 | 343 |
344 } // namespace SK_OPTS_NS | 344 } // namespace SK_OPTS_NS |
345 | 345 |
346 #endif//Sk4pxXfermode_DEFINED | 346 #endif//Sk4pxXfermode_DEFINED |
OLD | NEW |