OLD | NEW |
1 | 1 |
2 /* | 2 /* |
3 * Copyright 2006 The Android Open Source Project | 3 * Copyright 2006 The Android Open Source Project |
4 * | 4 * |
5 * Use of this source code is governed by a BSD-style license that can be | 5 * Use of this source code is governed by a BSD-style license that can be |
6 * found in the LICENSE file. | 6 * found in the LICENSE file. |
7 */ | 7 */ |
8 | 8 |
9 | 9 |
10 #include "SkXfermode.h" | 10 #include "SkXfermode.h" |
(...skipping 272 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
283 int r = lighten_byte(SkGetPackedR32(src), SkGetPackedR32(dst), sa, da); | 283 int r = lighten_byte(SkGetPackedR32(src), SkGetPackedR32(dst), sa, da); |
284 int g = lighten_byte(SkGetPackedG32(src), SkGetPackedG32(dst), sa, da); | 284 int g = lighten_byte(SkGetPackedG32(src), SkGetPackedG32(dst), sa, da); |
285 int b = lighten_byte(SkGetPackedB32(src), SkGetPackedB32(dst), sa, da); | 285 int b = lighten_byte(SkGetPackedB32(src), SkGetPackedB32(dst), sa, da); |
286 return SkPackARGB32(a, r, g, b); | 286 return SkPackARGB32(a, r, g, b); |
287 } | 287 } |
288 | 288 |
289 // kColorDodge_Mode | 289 // kColorDodge_Mode |
290 static inline int colordodge_byte(int sc, int dc, int sa, int da) { | 290 static inline int colordodge_byte(int sc, int dc, int sa, int da) { |
291 int diff = sa - sc; | 291 int diff = sa - sc; |
292 int rc; | 292 int rc; |
293 if (0 == diff) { | 293 if (0 == dc) { |
| 294 return SkAlphaMulAlpha(sc, 255 - da); |
| 295 } else if (0 == diff) { |
294 rc = sa * da + sc * (255 - da) + dc * (255 - sa); | 296 rc = sa * da + sc * (255 - da) + dc * (255 - sa); |
295 rc = SkDiv255Round(rc); | |
296 } else { | 297 } else { |
297 int tmp = (dc * sa << 15) / (da * diff); | 298 diff = dc * sa / diff; |
298 rc = SkDiv255Round(sa * da) * tmp >> 15; | 299 rc = sa * ((da < diff) ? da : diff) + sc * (255 - da) + dc * (255 - sa); |
299 // don't clamp here, since we'll do it in our modeproc | |
300 } | 300 } |
301 return rc; | 301 return clamp_div255round(rc); |
302 } | 302 } |
303 static SkPMColor colordodge_modeproc(SkPMColor src, SkPMColor dst) { | 303 static SkPMColor colordodge_modeproc(SkPMColor src, SkPMColor dst) { |
304 // added to avoid div-by-zero in colordodge_byte | |
305 if (0 == dst) { | |
306 return src; | |
307 } | |
308 | |
309 int sa = SkGetPackedA32(src); | 304 int sa = SkGetPackedA32(src); |
310 int da = SkGetPackedA32(dst); | 305 int da = SkGetPackedA32(dst); |
311 int a = srcover_byte(sa, da); | 306 int a = srcover_byte(sa, da); |
312 int r = colordodge_byte(SkGetPackedR32(src), SkGetPackedR32(dst), sa, da); | 307 int r = colordodge_byte(SkGetPackedR32(src), SkGetPackedR32(dst), sa, da); |
313 int g = colordodge_byte(SkGetPackedG32(src), SkGetPackedG32(dst), sa, da); | 308 int g = colordodge_byte(SkGetPackedG32(src), SkGetPackedG32(dst), sa, da); |
314 int b = colordodge_byte(SkGetPackedB32(src), SkGetPackedB32(dst), sa, da); | 309 int b = colordodge_byte(SkGetPackedB32(src), SkGetPackedB32(dst), sa, da); |
315 r = clamp_max(r, a); | |
316 g = clamp_max(g, a); | |
317 b = clamp_max(b, a); | |
318 return SkPackARGB32(a, r, g, b); | 310 return SkPackARGB32(a, r, g, b); |
319 } | 311 } |
320 | 312 |
321 // kColorBurn_Mode | 313 // kColorBurn_Mode |
322 static inline int colorburn_byte(int sc, int dc, int sa, int da) { | 314 static inline int colorburn_byte(int sc, int dc, int sa, int da) { |
323 int rc; | 315 int rc; |
324 if (dc == da && 0 == sc) { | 316 if (dc == da) { |
325 rc = sa * da + dc * (255 - sa); | 317 rc = sa * da + sc * (255 - da) + dc * (255 - sa); |
326 } else if (0 == sc) { | 318 } else if (0 == sc) { |
327 return SkAlphaMulAlpha(dc, 255 - sa); | 319 return SkAlphaMulAlpha(dc, 255 - sa); |
328 } else { | 320 } else { |
329 int tmp = (sa * (da - dc) * 256) / (sc * da); | 321 int tmp = (da - dc) * sa / sc; |
330 if (tmp > 256) { | 322 rc = sa * (da - ((da < tmp) ? da : tmp)) |
331 tmp = 256; | 323 + sc * (255 - da) + dc * (255 - sa); |
332 } | |
333 int tmp2 = sa * da; | |
334 rc = tmp2 - (tmp2 * tmp >> 8) + sc * (255 - da) + dc * (255 - sa); | |
335 } | 324 } |
336 return SkDiv255Round(rc); | 325 return clamp_div255round(rc); |
337 } | 326 } |
338 static SkPMColor colorburn_modeproc(SkPMColor src, SkPMColor dst) { | 327 static SkPMColor colorburn_modeproc(SkPMColor src, SkPMColor dst) { |
339 // added to avoid div-by-zero in colorburn_byte | |
340 if (0 == dst) { | |
341 return src; | |
342 } | |
343 | |
344 int sa = SkGetPackedA32(src); | 328 int sa = SkGetPackedA32(src); |
345 int da = SkGetPackedA32(dst); | 329 int da = SkGetPackedA32(dst); |
346 int a = srcover_byte(sa, da); | 330 int a = srcover_byte(sa, da); |
347 int r = colorburn_byte(SkGetPackedR32(src), SkGetPackedR32(dst), sa, da); | 331 int r = colorburn_byte(SkGetPackedR32(src), SkGetPackedR32(dst), sa, da); |
348 int g = colorburn_byte(SkGetPackedG32(src), SkGetPackedG32(dst), sa, da); | 332 int g = colorburn_byte(SkGetPackedG32(src), SkGetPackedG32(dst), sa, da); |
349 int b = colorburn_byte(SkGetPackedB32(src), SkGetPackedB32(dst), sa, da); | 333 int b = colorburn_byte(SkGetPackedB32(src), SkGetPackedB32(dst), sa, da); |
350 return SkPackARGB32(a, r, g, b); | 334 return SkPackARGB32(a, r, g, b); |
351 } | 335 } |
352 | 336 |
353 // kHardLight_Mode | 337 // kHardLight_Mode |
(...skipping 77 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
431 return SkPackARGB32(a, r, g, b); | 415 return SkPackARGB32(a, r, g, b); |
432 } | 416 } |
433 | 417 |
434 // The CSS compositing spec introduces the following formulas: | 418 // The CSS compositing spec introduces the following formulas: |
435 // (See https://dvcs.w3.org/hg/FXTF/rawfile/tip/compositing/index.html#blendingn
onseparable) | 419 // (See https://dvcs.w3.org/hg/FXTF/rawfile/tip/compositing/index.html#blendingn
onseparable) |
436 // SkComputeLuminance is similar to this formula but it uses the new definition
from Rec. 709 | 420 // SkComputeLuminance is similar to this formula but it uses the new definition
from Rec. 709 |
437 // while PDF and CG uses the one from Rec. Rec. 601 | 421 // while PDF and CG uses the one from Rec. Rec. 601 |
438 // See http://www.glennchan.info/articles/technical/hd-versus-sd-color-space/hd-
versus-sd-color-space.htm | 422 // See http://www.glennchan.info/articles/technical/hd-versus-sd-color-space/hd-
versus-sd-color-space.htm |
439 static inline int Lum(int r, int g, int b) | 423 static inline int Lum(int r, int g, int b) |
440 { | 424 { |
441 return (r * 77 + g * 151 + b * 28) >> 8; | 425 return SkDiv255Round(r * 77 + g * 150 + b * 28); |
442 } | 426 } |
443 | 427 |
444 static inline int min2(int a, int b) { return a < b ? a : b; } | 428 static inline int min2(int a, int b) { return a < b ? a : b; } |
445 static inline int max2(int a, int b) { return a > b ? a : b; } | 429 static inline int max2(int a, int b) { return a > b ? a : b; } |
446 #define minimum(a, b, c) min2(min2(a, b), c) | 430 #define minimum(a, b, c) min2(min2(a, b), c) |
447 #define maximum(a, b, c) max2(max2(a, b), c) | 431 #define maximum(a, b, c) max2(max2(a, b), c) |
448 | 432 |
449 static inline int Sat(int r, int g, int b) { | 433 static inline int Sat(int r, int g, int b) { |
450 return maximum(r, g, b) - minimum(r, g, b); | 434 return maximum(r, g, b) - minimum(r, g, b); |
451 } | 435 } |
452 | 436 |
453 static inline void setSaturationComponents(int* Cmin, int* Cmid, int* Cmax, int
s) { | 437 static inline void setSaturationComponents(int* Cmin, int* Cmid, int* Cmax, int
s) { |
454 if(*Cmax > *Cmin) { | 438 if(*Cmax > *Cmin) { |
455 *Cmid = (((*Cmid - *Cmin) * s ) / (*Cmax - *Cmin)); | 439 *Cmid = SkMulDiv(*Cmid - *Cmin, s, *Cmax - *Cmin); |
456 *Cmax = s; | 440 *Cmax = s; |
457 } else { | 441 } else { |
458 *Cmax = 0; | 442 *Cmax = 0; |
459 *Cmid = 0; | 443 *Cmid = 0; |
460 } | 444 } |
461 | 445 |
462 *Cmin = 0; | 446 *Cmin = 0; |
463 } | 447 } |
464 | 448 |
465 static inline void SetSat(int* r, int* g, int* b, int s) { | 449 static inline void SetSat(int* r, int* g, int* b, int s) { |
466 if(*r <= *g) { | 450 if(*r <= *g) { |
467 if(*g <= *b) { | 451 if(*g <= *b) { |
468 setSaturationComponents(r, g, b, s); | 452 setSaturationComponents(r, g, b, s); |
469 } else if(*r <= *b) { | 453 } else if(*r <= *b) { |
470 setSaturationComponents(r, b, g, s); | 454 setSaturationComponents(r, b, g, s); |
471 } else { | 455 } else { |
472 setSaturationComponents(b, r, g, s); | 456 setSaturationComponents(b, r, g, s); |
473 } | 457 } |
474 } else if(*r <= *b) { | 458 } else if(*r <= *b) { |
475 setSaturationComponents(g, r, b, s); | 459 setSaturationComponents(g, r, b, s); |
476 } else if(*g <= *b) { | 460 } else if(*g <= *b) { |
477 setSaturationComponents(g, b, r, s); | 461 setSaturationComponents(g, b, r, s); |
478 } else { | 462 } else { |
479 setSaturationComponents(b, g, r, s); | 463 setSaturationComponents(b, g, r, s); |
480 } | 464 } |
481 } | 465 } |
482 | 466 |
483 static inline void clipColor(int* r, int* g, int* b) { | 467 static inline void clipColor(int* r, int* g, int* b, int a) { |
484 int L = Lum(*r, *g, *b); | 468 int L = Lum(*r, *g, *b); |
485 int n = minimum(*r, *g, *b); | 469 int n = minimum(*r, *g, *b); |
486 int x = maximum(*r, *g, *b); | 470 int x = maximum(*r, *g, *b); |
487 if(n < 0) { | 471 if(n < 0) { |
488 *r = L + (((*r - L) * L) / (L - n)); | 472 *r = L + SkMulDiv(*r - L, L, L - n); |
489 *g = L + (((*g - L) * L) / (L - n)); | 473 *g = L + SkMulDiv(*g - L, L, L - n); |
490 *b = L + (((*b - L) * L) / (L - n)); | 474 *b = L + SkMulDiv(*b - L, L, L - n); |
491 } | 475 } |
492 | 476 |
493 if(x > 255) { | 477 if (x > a) { |
494 *r = L + (((*r - L) * (255 - L)) / (x - L)); | 478 *r = L + SkMulDiv(*r - L, a - L, x - L); |
495 *g = L + (((*g - L) * (255 - L)) / (x - L)); | 479 *g = L + SkMulDiv(*g - L, a - L, x - L); |
496 *b = L + (((*b - L) * (255 - L)) / (x - L)); | 480 *b = L + SkMulDiv(*b - L, a - L, x - L); |
497 } | 481 } |
498 } | 482 } |
499 | 483 |
500 static inline void SetLum(int* r, int* g, int* b, int l) { | 484 static inline void SetLum(int* r, int* g, int* b, int a, int l) { |
501 int d = l - Lum(*r, *g, *b); | 485 int d = l - Lum(*r, *g, *b); |
502 *r += d; | 486 *r += d; |
503 *g += d; | 487 *g += d; |
504 *b += d; | 488 *b += d; |
505 | 489 |
506 clipColor(r, g, b); | 490 clipColor(r, g, b, a); |
507 } | 491 } |
508 | 492 |
509 // non-separable blend modes are done in non-premultiplied alpha | 493 // non-separable blend modes are done in non-premultiplied alpha |
510 #define blendfunc_nonsep_byte(sc, dc, sa, da, blendval) \ | 494 #define blendfunc_nonsep_byte(sc, dc, sa, da, blendval) \ |
511 clamp_div255round(sc * (255 - da) + dc * (255 - sa) + clamp_div255round(sa
* da) * blendval) | 495 clamp_div255round(sc * (255 - da) + dc * (255 - sa) + blendval) |
512 | 496 |
513 // kHue_Mode | 497 // kHue_Mode |
514 // B(Cb, Cs) = SetLum(SetSat(Cs, Sat(Cb)), Lum(Cb)) | 498 // B(Cb, Cs) = SetLum(SetSat(Cs, Sat(Cb)), Lum(Cb)) |
515 // Create a color with the hue of the source color and the saturation and lumino
sity of the backdrop color. | 499 // Create a color with the hue of the source color and the saturation and lumino
sity of the backdrop color. |
516 static SkPMColor hue_modeproc(SkPMColor src, SkPMColor dst) { | 500 static SkPMColor hue_modeproc(SkPMColor src, SkPMColor dst) { |
517 int sr = SkGetPackedR32(src); | 501 int sr = SkGetPackedR32(src); |
518 int sg = SkGetPackedG32(src); | 502 int sg = SkGetPackedG32(src); |
519 int sb = SkGetPackedB32(src); | 503 int sb = SkGetPackedB32(src); |
520 int sa = SkGetPackedA32(src); | 504 int sa = SkGetPackedA32(src); |
521 | 505 |
522 int dr = SkGetPackedR32(dst); | 506 int dr = SkGetPackedR32(dst); |
523 int dg = SkGetPackedG32(dst); | 507 int dg = SkGetPackedG32(dst); |
524 int db = SkGetPackedB32(dst); | 508 int db = SkGetPackedB32(dst); |
525 int da = SkGetPackedA32(dst); | 509 int da = SkGetPackedA32(dst); |
526 int Sr, Sg, Sb; | 510 int Sr, Sg, Sb; |
527 | 511 |
528 if(sa && da) { | 512 if(sa && da) { |
529 Sr = SkMulDiv255Round(sr, sa); | 513 Sr = sr * sa; |
530 Sg = SkMulDiv255Round(sg, sa); | 514 Sg = sg * sa; |
531 Sb = SkMulDiv255Round(sb, sa); | 515 Sb = sb * sa; |
532 int Dr = SkMulDiv255Round(dr, da); | 516 SetSat(&Sr, &Sg, &Sb, Sat(dr, dg, db) * sa); |
533 int Dg = SkMulDiv255Round(dg, da); | 517 SetLum(&Sr, &Sg, &Sb, sa * da, Lum(dr, dg, db) * sa); |
534 int Db = SkMulDiv255Round(db, da); | |
535 SetSat(&Sr, &Sg, &Sb, Sat(Dr, Dg, Db)); | |
536 SetLum(&Sr, &Sg, &Sb, Lum(Dr, Dg, Db)); | |
537 } else { | 518 } else { |
538 Sr = 0; | 519 Sr = 0; |
539 Sg = 0; | 520 Sg = 0; |
540 Sb = 0; | 521 Sb = 0; |
541 } | 522 } |
542 | 523 |
543 int a = srcover_byte(sa, da); | 524 int a = srcover_byte(sa, da); |
544 int r = blendfunc_nonsep_byte(sr, dr, sa, da, Sr); | 525 int r = blendfunc_nonsep_byte(sr, dr, sa, da, Sr); |
545 int g = blendfunc_nonsep_byte(sg, dg, sa, da, Sg); | 526 int g = blendfunc_nonsep_byte(sg, dg, sa, da, Sg); |
546 int b = blendfunc_nonsep_byte(sb, db, sa, da, Sb); | 527 int b = blendfunc_nonsep_byte(sb, db, sa, da, Sb); |
547 return SkPackARGB32(a, r, g, b); | 528 return SkPackARGB32(a, r, g, b); |
548 } | 529 } |
549 | 530 |
550 // kSaturation_Mode | 531 // kSaturation_Mode |
551 // B(Cb, Cs) = SetLum(SetSat(Cb, Sat(Cs)), Lum(Cb)) | 532 // B(Cb, Cs) = SetLum(SetSat(Cb, Sat(Cs)), Lum(Cb)) |
552 // Create a color with the saturation of the source color and the hue and lumino
sity of the backdrop color. | 533 // Create a color with the saturation of the source color and the hue and lumino
sity of the backdrop color. |
553 static SkPMColor saturation_modeproc(SkPMColor src, SkPMColor dst) { | 534 static SkPMColor saturation_modeproc(SkPMColor src, SkPMColor dst) { |
554 int sr = SkGetPackedR32(src); | 535 int sr = SkGetPackedR32(src); |
555 int sg = SkGetPackedG32(src); | 536 int sg = SkGetPackedG32(src); |
556 int sb = SkGetPackedB32(src); | 537 int sb = SkGetPackedB32(src); |
557 int sa = SkGetPackedA32(src); | 538 int sa = SkGetPackedA32(src); |
558 | 539 |
559 int dr = SkGetPackedR32(dst); | 540 int dr = SkGetPackedR32(dst); |
560 int dg = SkGetPackedG32(dst); | 541 int dg = SkGetPackedG32(dst); |
561 int db = SkGetPackedB32(dst); | 542 int db = SkGetPackedB32(dst); |
562 int da = SkGetPackedA32(dst); | 543 int da = SkGetPackedA32(dst); |
563 int Dr, Dg, Db; | 544 int Dr, Dg, Db; |
564 | 545 |
565 if(sa && da) { | 546 if(sa && da) { |
566 int Sr = SkMulDiv255Round(sr, sa); | 547 Dr = dr * sa; |
567 int Sg = SkMulDiv255Round(sg, sa); | 548 Dg = dg * sa; |
568 int Sb = SkMulDiv255Round(sb, sa); | 549 Db = db * sa; |
569 Dr = SkMulDiv255Round(dr, da); | 550 SetSat(&Dr, &Dg, &Db, Sat(sr, sg, sb) * da); |
570 Dg = SkMulDiv255Round(dg, da); | 551 SetLum(&Dr, &Dg, &Db, sa * da, Lum(dr, dg, db) * sa); |
571 Db = SkMulDiv255Round(db, da); | |
572 int LumD = Lum(Dr, Dg, Db); | |
573 SetSat(&Dr, &Dg, &Db, Sat(Sr, Sg, Sb)); | |
574 SetLum(&Dr, &Dg, &Db, LumD); | |
575 } else { | 552 } else { |
576 Dr = 0; | 553 Dr = 0; |
577 Dg = 0; | 554 Dg = 0; |
578 Db = 0; | 555 Db = 0; |
579 } | 556 } |
580 | 557 |
581 int a = srcover_byte(sa, da); | 558 int a = srcover_byte(sa, da); |
582 int r = blendfunc_nonsep_byte(sr, dr, sa, da, Dr); | 559 int r = blendfunc_nonsep_byte(sr, dr, sa, da, Dr); |
583 int g = blendfunc_nonsep_byte(sg, dg, sa, da, Dg); | 560 int g = blendfunc_nonsep_byte(sg, dg, sa, da, Dg); |
584 int b = blendfunc_nonsep_byte(sb, db, sa, da, Db); | 561 int b = blendfunc_nonsep_byte(sb, db, sa, da, Db); |
585 return SkPackARGB32(a, r, g, b); | 562 return SkPackARGB32(a, r, g, b); |
586 } | 563 } |
587 | 564 |
588 // kColor_Mode | 565 // kColor_Mode |
589 // B(Cb, Cs) = SetLum(Cs, Lum(Cb)) | 566 // B(Cb, Cs) = SetLum(Cs, Lum(Cb)) |
590 // Create a color with the hue and saturation of the source color and the lumino
sity of the backdrop color. | 567 // Create a color with the hue and saturation of the source color and the lumino
sity of the backdrop color. |
591 static SkPMColor color_modeproc(SkPMColor src, SkPMColor dst) { | 568 static SkPMColor color_modeproc(SkPMColor src, SkPMColor dst) { |
592 int sr = SkGetPackedR32(src); | 569 int sr = SkGetPackedR32(src); |
593 int sg = SkGetPackedG32(src); | 570 int sg = SkGetPackedG32(src); |
594 int sb = SkGetPackedB32(src); | 571 int sb = SkGetPackedB32(src); |
595 int sa = SkGetPackedA32(src); | 572 int sa = SkGetPackedA32(src); |
596 | 573 |
597 int dr = SkGetPackedR32(dst); | 574 int dr = SkGetPackedR32(dst); |
598 int dg = SkGetPackedG32(dst); | 575 int dg = SkGetPackedG32(dst); |
599 int db = SkGetPackedB32(dst); | 576 int db = SkGetPackedB32(dst); |
600 int da = SkGetPackedA32(dst); | 577 int da = SkGetPackedA32(dst); |
601 int Sr, Sg, Sb; | 578 int Sr, Sg, Sb; |
602 | 579 |
603 if(sa && da) { | 580 if(sa && da) { |
604 Sr = SkMulDiv255Round(sr, sa); | 581 Sr = sr * da; |
605 Sg = SkMulDiv255Round(sg, sa); | 582 Sg = sg * da; |
606 Sb = SkMulDiv255Round(sb, sa); | 583 Sb = sb * da; |
607 int Dr = SkMulDiv255Round(dr, da); | 584 SetLum(&Sr, &Sg, &Sb, sa * da, Lum(dr, dg, db) * sa); |
608 int Dg = SkMulDiv255Round(dg, da); | |
609 int Db = SkMulDiv255Round(db, da); | |
610 SetLum(&Sr, &Sg, &Sb, Lum(Dr, Dg, Db)); | |
611 } else { | 585 } else { |
612 Sr = 0; | 586 Sr = 0; |
613 Sg = 0; | 587 Sg = 0; |
614 Sb = 0; | 588 Sb = 0; |
615 } | 589 } |
616 | 590 |
617 int a = srcover_byte(sa, da); | 591 int a = srcover_byte(sa, da); |
618 int r = blendfunc_nonsep_byte(sr, dr, sa, da, Sr); | 592 int r = blendfunc_nonsep_byte(sr, dr, sa, da, Sr); |
619 int g = blendfunc_nonsep_byte(sg, dg, sa, da, Sg); | 593 int g = blendfunc_nonsep_byte(sg, dg, sa, da, Sg); |
620 int b = blendfunc_nonsep_byte(sb, db, sa, da, Sb); | 594 int b = blendfunc_nonsep_byte(sb, db, sa, da, Sb); |
621 return SkPackARGB32(a, r, g, b); | 595 return SkPackARGB32(a, r, g, b); |
622 } | 596 } |
623 | 597 |
624 // kLuminosity_Mode | 598 // kLuminosity_Mode |
625 // B(Cb, Cs) = SetLum(Cb, Lum(Cs)) | 599 // B(Cb, Cs) = SetLum(Cb, Lum(Cs)) |
626 // Create a color with the luminosity of the source color and the hue and satura
tion of the backdrop color. | 600 // Create a color with the luminosity of the source color and the hue and satura
tion of the backdrop color. |
627 static SkPMColor luminosity_modeproc(SkPMColor src, SkPMColor dst) { | 601 static SkPMColor luminosity_modeproc(SkPMColor src, SkPMColor dst) { |
628 int sr = SkGetPackedR32(src); | 602 int sr = SkGetPackedR32(src); |
629 int sg = SkGetPackedG32(src); | 603 int sg = SkGetPackedG32(src); |
630 int sb = SkGetPackedB32(src); | 604 int sb = SkGetPackedB32(src); |
631 int sa = SkGetPackedA32(src); | 605 int sa = SkGetPackedA32(src); |
632 | 606 |
633 int dr = SkGetPackedR32(dst); | 607 int dr = SkGetPackedR32(dst); |
634 int dg = SkGetPackedG32(dst); | 608 int dg = SkGetPackedG32(dst); |
635 int db = SkGetPackedB32(dst); | 609 int db = SkGetPackedB32(dst); |
636 int da = SkGetPackedA32(dst); | 610 int da = SkGetPackedA32(dst); |
637 int Dr, Dg, Db; | 611 int Dr, Dg, Db; |
638 | 612 |
639 if(sa && da) { | 613 if(sa && da) { |
640 int Sr = SkMulDiv255Round(sr, sa); | 614 Dr = dr * sa; |
641 int Sg = SkMulDiv255Round(sg, sa); | 615 Dg = dg * sa; |
642 int Sb = SkMulDiv255Round(sb, sa); | 616 Db = db * sa; |
643 Dr = SkMulDiv255Round(dr, da); | 617 SetLum(&Dr, &Dg, &Db, sa * da, Lum(sr, sg, sb) * da); |
644 Dg = SkMulDiv255Round(dg, da); | |
645 Db = SkMulDiv255Round(db, da); | |
646 SetLum(&Dr, &Dg, &Db, Lum(Sr, Sg, Sb)); | |
647 } else { | 618 } else { |
648 Dr = 0; | 619 Dr = 0; |
649 Dg = 0; | 620 Dg = 0; |
650 Db = 0; | 621 Db = 0; |
651 } | 622 } |
652 | 623 |
653 int a = srcover_byte(sa, da); | 624 int a = srcover_byte(sa, da); |
654 int r = blendfunc_nonsep_byte(sr, dr, sa, da, Dr); | 625 int r = blendfunc_nonsep_byte(sr, dr, sa, da, Dr); |
655 int g = blendfunc_nonsep_byte(sg, dg, sa, da, Dg); | 626 int g = blendfunc_nonsep_byte(sg, dg, sa, da, Dg); |
656 int b = blendfunc_nonsep_byte(sb, db, sa, da, Db); | 627 int b = blendfunc_nonsep_byte(sb, db, sa, da, Db); |
(...skipping 862 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1519 return proc16; | 1490 return proc16; |
1520 } | 1491 } |
1521 | 1492 |
1522 SK_DEFINE_FLATTENABLE_REGISTRAR_GROUP_START(SkXfermode) | 1493 SK_DEFINE_FLATTENABLE_REGISTRAR_GROUP_START(SkXfermode) |
1523 SK_DEFINE_FLATTENABLE_REGISTRAR_ENTRY(SkProcCoeffXfermode) | 1494 SK_DEFINE_FLATTENABLE_REGISTRAR_ENTRY(SkProcCoeffXfermode) |
1524 SK_DEFINE_FLATTENABLE_REGISTRAR_ENTRY(SkClearXfermode) | 1495 SK_DEFINE_FLATTENABLE_REGISTRAR_ENTRY(SkClearXfermode) |
1525 SK_DEFINE_FLATTENABLE_REGISTRAR_ENTRY(SkSrcXfermode) | 1496 SK_DEFINE_FLATTENABLE_REGISTRAR_ENTRY(SkSrcXfermode) |
1526 SK_DEFINE_FLATTENABLE_REGISTRAR_ENTRY(SkDstInXfermode) | 1497 SK_DEFINE_FLATTENABLE_REGISTRAR_ENTRY(SkDstInXfermode) |
1527 SK_DEFINE_FLATTENABLE_REGISTRAR_ENTRY(SkDstOutXfermode) | 1498 SK_DEFINE_FLATTENABLE_REGISTRAR_ENTRY(SkDstOutXfermode) |
1528 SK_DEFINE_FLATTENABLE_REGISTRAR_GROUP_END | 1499 SK_DEFINE_FLATTENABLE_REGISTRAR_GROUP_END |
OLD | NEW |