| 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 "SkLinearGradient.h" | 8 #include "SkLinearGradient.h" |
| 9 | 9 |
| 10 static const float kInv255Float = 1.0f / 255; | 10 static const float kInv255Float = 1.0f / 255; |
| (...skipping 730 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 741 | 741 |
| 742 template <bool apply_alpha> void ramp(SkPMColor dstC[], int n, const Sk4f& c, co
nst Sk4f& dc, | 742 template <bool apply_alpha> void ramp(SkPMColor dstC[], int n, const Sk4f& c, co
nst Sk4f& dc, |
| 743 const Sk4f& dither0, const Sk4f& dither1)
{ | 743 const Sk4f& dither0, const Sk4f& dither1)
{ |
| 744 Sk4f dc2 = dc + dc; | 744 Sk4f dc2 = dc + dc; |
| 745 Sk4f dc4 = dc2 + dc2; | 745 Sk4f dc4 = dc2 + dc2; |
| 746 Sk4f cd0 = c + dither0; | 746 Sk4f cd0 = c + dither0; |
| 747 Sk4f cd1 = c + dc + dither1; | 747 Sk4f cd1 = c + dc + dither1; |
| 748 Sk4f cd2 = cd0 + dc2; | 748 Sk4f cd2 = cd0 + dc2; |
| 749 Sk4f cd3 = cd1 + dc2; | 749 Sk4f cd3 = cd1 + dc2; |
| 750 while (n >= 4) { | 750 while (n >= 4) { |
| 751 *dstC++ = trunc_from_255<apply_alpha>(cd0); | 751 if (!apply_alpha) { |
| 752 *dstC++ = trunc_from_255<apply_alpha>(cd1); | 752 Sk4f::ToBytes((uint8_t*)dstC, cd0, cd1, cd2, cd3); |
| 753 *dstC++ = trunc_from_255<apply_alpha>(cd2); | 753 dstC += 4; |
| 754 *dstC++ = trunc_from_255<apply_alpha>(cd3); | 754 } else { |
| 755 *dstC++ = trunc_from_255<apply_alpha>(cd0); |
| 756 *dstC++ = trunc_from_255<apply_alpha>(cd1); |
| 757 *dstC++ = trunc_from_255<apply_alpha>(cd2); |
| 758 *dstC++ = trunc_from_255<apply_alpha>(cd3); |
| 759 } |
| 755 cd0 = cd0 + dc4; | 760 cd0 = cd0 + dc4; |
| 756 cd1 = cd1 + dc4; | 761 cd1 = cd1 + dc4; |
| 757 cd2 = cd2 + dc4; | 762 cd2 = cd2 + dc4; |
| 758 cd3 = cd3 + dc4; | 763 cd3 = cd3 + dc4; |
| 759 n -= 4; | 764 n -= 4; |
| 760 } | 765 } |
| 761 if (n & 2) { | 766 if (n & 2) { |
| 762 *dstC++ = trunc_from_255<apply_alpha>(cd0); | 767 *dstC++ = trunc_from_255<apply_alpha>(cd0); |
| 763 *dstC++ = trunc_from_255<apply_alpha>(cd1); | 768 *dstC++ = trunc_from_255<apply_alpha>(cd1); |
| 764 cd0 = cd0 + dc2; | 769 cd0 = cd0 + dc2; |
| (...skipping 89 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 854 SkASSERT(count >= 0); | 859 SkASSERT(count >= 0); |
| 855 if (dx_is_pos) { | 860 if (dx_is_pos) { |
| 856 SkASSERT(0 == count || fx >= p1); | 861 SkASSERT(0 == count || fx >= p1); |
| 857 } else { | 862 } else { |
| 858 SkASSERT(0 == count || fx <= p0); | 863 SkASSERT(0 == count || fx <= p0); |
| 859 } | 864 } |
| 860 | 865 |
| 861 ramp<apply_alpha>(dstC, n, c, dc, dither0, dither1); | 866 ramp<apply_alpha>(dstC, n, c, dc, dither0, dither1); |
| 862 dstC += n; | 867 dstC += n; |
| 863 SkASSERT(dstC <= endDstC); | 868 SkASSERT(dstC <= endDstC); |
| 864 | 869 |
| 865 if (n & 1) { | 870 if (n & 1) { |
| 866 SkTSwap(dither0, dither1); | 871 SkTSwap(dither0, dither1); |
| 867 } | 872 } |
| 868 } | 873 } |
| 869 } | 874 } |
| 870 | 875 |
| 871 void SkLinearGradient::LinearGradientContext::shade4_clamp(int x, int y, SkPMCol
or dstC[], | 876 void SkLinearGradient::LinearGradientContext::shade4_clamp(int x, int y, SkPMCol
or dstC[], |
| 872 int count) { | 877 int count) { |
| 873 SkASSERT(count > 0); | 878 SkASSERT(count > 0); |
| 874 SkASSERT(kLinear_MatrixClass == fDstToIndexClass); | 879 SkASSERT(kLinear_MatrixClass == fDstToIndexClass); |
| (...skipping 40 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 915 } | 920 } |
| 916 } else { | 921 } else { |
| 917 if (fApplyAlphaAfterInterp) { | 922 if (fApplyAlphaAfterInterp) { |
| 918 this->shade4_dx_clamp<true, false>(dstC, count, fx, dx, invDx, dithe
r); | 923 this->shade4_dx_clamp<true, false>(dstC, count, fx, dx, invDx, dithe
r); |
| 919 } else { | 924 } else { |
| 920 this->shade4_dx_clamp<false, false>(dstC, count, fx, dx, invDx, dith
er); | 925 this->shade4_dx_clamp<false, false>(dstC, count, fx, dx, invDx, dith
er); |
| 921 } | 926 } |
| 922 } | 927 } |
| 923 } | 928 } |
| 924 | 929 |
| OLD | NEW |