Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(283)

Side by Side Diff: src/effects/gradients/SkLinearGradient.cpp

Issue 1456783005: Fix nearly-vertical gradient assert (Closed) Base URL: https://chromium.googlesource.com/skia.git@master
Patch Set: Created 5 years, 1 month ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « no previous file | tests/GradientTest.cpp » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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 874 matching lines...) Expand 10 before | Expand all | Expand 10 after
885 const int rowIndex = (y & 1) << 1; 885 const int rowIndex = (y & 1) << 1;
886 dither0 = ditherCell[rowIndex]; 886 dither0 = ditherCell[rowIndex];
887 dither1 = ditherCell[rowIndex + 1]; 887 dither1 = ditherCell[rowIndex + 1];
888 if (x & 1) { 888 if (x & 1) {
889 SkTSwap(dither0, dither1); 889 SkTSwap(dither0, dither1);
890 } 890 }
891 } 891 }
892 const float dither[2] = { dither0, dither1 }; 892 const float dither[2] = { dither0, dither1 };
893 const float invDx = 1 / dx; 893 const float invDx = 1 / dx;
894 894
895 if (!SkScalarIsFinite(invDx)) { // dx is effectively zero, gradient is verti cal 895 if (SkScalarNearlyZero(dx)) { // gradient is vertical
896 Sk4f c = lerp_color(fx, find_forward(fRecs.begin(), SkTPin(fx, 0.0f, 1.0 f))); 896 Sk4f c = lerp_color(fx, find_forward(fRecs.begin(), SkTPin(fx, 0.0f, 1.0 f)));
897 if (fApplyAlphaAfterInterp) { 897 if (fApplyAlphaAfterInterp) {
898 fill<true>(dstC, count, c + dither0, c + dither1); 898 fill<true>(dstC, count, c + dither0, c + dither1);
899 } else { 899 } else {
900 fill<false>(dstC, count, c + dither0, c + dither1); 900 fill<false>(dstC, count, c + dither0, c + dither1);
901 } 901 }
902 return; 902 return;
903 } 903 }
904 904
905 if (dx > 0) { 905 if (dx > 0) {
906 if (fApplyAlphaAfterInterp) { 906 if (fApplyAlphaAfterInterp) {
907 this->shade4_dx_clamp<true, true>(dstC, count, fx, dx, invDx, dither ); 907 this->shade4_dx_clamp<true, true>(dstC, count, fx, dx, invDx, dither );
908 } else { 908 } else {
909 this->shade4_dx_clamp<false, true>(dstC, count, fx, dx, invDx, dithe r); 909 this->shade4_dx_clamp<false, true>(dstC, count, fx, dx, invDx, dithe r);
910 } 910 }
911 } else { 911 } else {
912 if (fApplyAlphaAfterInterp) { 912 if (fApplyAlphaAfterInterp) {
913 this->shade4_dx_clamp<true, false>(dstC, count, fx, dx, invDx, dithe r); 913 this->shade4_dx_clamp<true, false>(dstC, count, fx, dx, invDx, dithe r);
914 } else { 914 } else {
915 this->shade4_dx_clamp<false, false>(dstC, count, fx, dx, invDx, dith er); 915 this->shade4_dx_clamp<false, false>(dstC, count, fx, dx, invDx, dith er);
916 } 916 }
917 } 917 }
918 } 918 }
919 919
OLDNEW
« no previous file with comments | « no previous file | tests/GradientTest.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698