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 878 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
889 const int rowIndex = (y & 1) << 1; | 889 const int rowIndex = (y & 1) << 1; |
890 dither0 = ditherCell[rowIndex]; | 890 dither0 = ditherCell[rowIndex]; |
891 dither1 = ditherCell[rowIndex + 1]; | 891 dither1 = ditherCell[rowIndex + 1]; |
892 if (x & 1) { | 892 if (x & 1) { |
893 SkTSwap(dither0, dither1); | 893 SkTSwap(dither0, dither1); |
894 } | 894 } |
895 } | 895 } |
896 const float dither[2] = { dither0, dither1 }; | 896 const float dither[2] = { dither0, dither1 }; |
897 const float invDx = 1 / dx; | 897 const float invDx = 1 / dx; |
898 | 898 |
899 if (SkScalarNearlyZero(dx)) { // gradient is vertical | 899 if (SkScalarNearlyZero(dx * count)) { // gradient is vertical |
900 const float pinFx = SkTPin(fx, 0.0f, 1.0f); | 900 const float pinFx = SkTPin(fx, 0.0f, 1.0f); |
901 Sk4f c = lerp_color(pinFx, find_forward(fRecs.begin(), pinFx)); | 901 Sk4f c = lerp_color(pinFx, find_forward(fRecs.begin(), pinFx)); |
902 if (fApplyAlphaAfterInterp) { | 902 if (fApplyAlphaAfterInterp) { |
903 fill<true>(dstC, count, c + dither0, c + dither1); | 903 fill<true>(dstC, count, c + dither0, c + dither1); |
904 } else { | 904 } else { |
905 fill<false>(dstC, count, c + dither0, c + dither1); | 905 fill<false>(dstC, count, c + dither0, c + dither1); |
906 } | 906 } |
907 return; | 907 return; |
908 } | 908 } |
909 | 909 |
910 if (dx > 0) { | 910 if (dx > 0) { |
911 if (fApplyAlphaAfterInterp) { | 911 if (fApplyAlphaAfterInterp) { |
912 this->shade4_dx_clamp<true, true>(dstC, count, fx, dx, invDx, dither
); | 912 this->shade4_dx_clamp<true, true>(dstC, count, fx, dx, invDx, dither
); |
913 } else { | 913 } else { |
914 this->shade4_dx_clamp<false, true>(dstC, count, fx, dx, invDx, dithe
r); | 914 this->shade4_dx_clamp<false, true>(dstC, count, fx, dx, invDx, dithe
r); |
915 } | 915 } |
916 } else { | 916 } else { |
917 if (fApplyAlphaAfterInterp) { | 917 if (fApplyAlphaAfterInterp) { |
918 this->shade4_dx_clamp<true, false>(dstC, count, fx, dx, invDx, dithe
r); | 918 this->shade4_dx_clamp<true, false>(dstC, count, fx, dx, invDx, dithe
r); |
919 } else { | 919 } else { |
920 this->shade4_dx_clamp<false, false>(dstC, count, fx, dx, invDx, dith
er); | 920 this->shade4_dx_clamp<false, false>(dstC, count, fx, dx, invDx, dith
er); |
921 } | 921 } |
922 } | 922 } |
923 } | 923 } |
924 | 924 |
OLD | NEW |