Chromium Code Reviews| OLD | NEW |
|---|---|
| 1 /* | 1 /* |
| 2 * Copyright 2012 Google Inc. | 2 * Copyright 2012 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 #include "Sk4fLinearGradient.h" | 8 #include "Sk4fLinearGradient.h" |
| 9 #include "SkLinearGradient.h" | 9 #include "SkLinearGradient.h" |
| 10 | 10 |
| (...skipping 594 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 605 Sk4f dither1(dither[1]); | 605 Sk4f dither1(dither[1]); |
| 606 const Rec* rec = fRecs.begin(); | 606 const Rec* rec = fRecs.begin(); |
| 607 | 607 |
| 608 const Sk4f dx4 = Sk4f(dx); | 608 const Sk4f dx4 = Sk4f(dx); |
| 609 SkDEBUGCODE(SkPMColor* endDstC = dstC + count;) | 609 SkDEBUGCODE(SkPMColor* endDstC = dstC + count;) |
| 610 | 610 |
| 611 if (dx_is_pos) { | 611 if (dx_is_pos) { |
| 612 if (fx < 0) { | 612 if (fx < 0) { |
| 613 // count is guaranteed to be positive, but the first arg may overflo w int32 after | 613 // count is guaranteed to be positive, but the first arg may overflo w int32 after |
| 614 // increment => casting to uint32 ensures correct clamping. | 614 // increment => casting to uint32 ensures correct clamping. |
| 615 int n = SkTMin<uint32_t>(SkFloatToIntFloor(-fx * invDx) + 1, count); | 615 int n = SkTMin<uint32_t>(static_cast<uint32_t>(SkFloatToIntFloor(-fx * invDx)) + 1, |
|
mtklein
2016/05/27 05:17:03
See if I'm following this correctly?
1) We're a
| |
| 616 count); | |
| 616 SkASSERT(n > 0); | 617 SkASSERT(n > 0); |
| 617 fill<apply_alpha>(dstC, n, rec[0].fColor); | 618 fill<apply_alpha>(dstC, n, rec[0].fColor); |
| 618 count -= n; | 619 count -= n; |
| 619 dstC += n; | 620 dstC += n; |
| 620 fx += n * dx; | 621 fx += n * dx; |
| 621 SkASSERT(0 == count || fx >= 0); | 622 SkASSERT(0 == count || fx >= 0); |
| 622 if (n & 1) { | 623 if (n & 1) { |
| 623 SkTSwap(dither0, dither1); | 624 SkTSwap(dither0, dither1); |
| 624 } | 625 } |
| 625 } | 626 } |
| 626 } else { // dx < 0 | 627 } else { // dx < 0 |
| 627 if (fx > 1) { | 628 if (fx > 1) { |
| 628 // count is guaranteed to be positive, but the first arg may overflo w int32 after | 629 // count is guaranteed to be positive, but the first arg may overflo w int32 after |
| 629 // increment => casting to uint32 ensures correct clamping. | 630 // increment => casting to uint32 ensures correct clamping. |
| 630 int n = SkTMin<uint32_t>(SkFloatToIntFloor((1 - fx) * invDx) + 1, co unt); | 631 int n = SkTMin<uint32_t>(static_cast<uint32_t>(SkFloatToIntFloor((1 - fx) * invDx)) + 1, |
| 632 count); | |
| 631 SkASSERT(n > 0); | 633 SkASSERT(n > 0); |
| 632 fill<apply_alpha>(dstC, n, rec[fRecs.count() - 1].fColor); | 634 fill<apply_alpha>(dstC, n, rec[fRecs.count() - 1].fColor); |
| 633 count -= n; | 635 count -= n; |
| 634 dstC += n; | 636 dstC += n; |
| 635 fx += n * dx; | 637 fx += n * dx; |
| 636 SkASSERT(0 == count || fx <= 1); | 638 SkASSERT(0 == count || fx <= 1); |
| 637 if (n & 1) { | 639 if (n & 1) { |
| 638 SkTSwap(dither0, dither1); | 640 SkTSwap(dither0, dither1); |
| 639 } | 641 } |
| 640 } | 642 } |
| (...skipping 111 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 752 this->shade4_dx_clamp<false, true>(dstC, count, fx, dx, invDx, dithe r); | 754 this->shade4_dx_clamp<false, true>(dstC, count, fx, dx, invDx, dithe r); |
| 753 } | 755 } |
| 754 } else { | 756 } else { |
| 755 if (fApplyAlphaAfterInterp) { | 757 if (fApplyAlphaAfterInterp) { |
| 756 this->shade4_dx_clamp<true, false>(dstC, count, fx, dx, invDx, dithe r); | 758 this->shade4_dx_clamp<true, false>(dstC, count, fx, dx, invDx, dithe r); |
| 757 } else { | 759 } else { |
| 758 this->shade4_dx_clamp<false, false>(dstC, count, fx, dx, invDx, dith er); | 760 this->shade4_dx_clamp<false, false>(dstC, count, fx, dx, invDx, dith er); |
| 759 } | 761 } |
| 760 } | 762 } |
| 761 } | 763 } |
| OLD | NEW |