diff options
author | Automerger Merge Worker <android-build-automerger-merge-worker@system.gserviceaccount.com> | 2020-02-20 17:45:00 +0000 |
---|---|---|
committer | Automerger Merge Worker <android-build-automerger-merge-worker@system.gserviceaccount.com> | 2020-02-20 17:45:00 +0000 |
commit | 434b714f90ebe5afa183594789b194c498a36736 (patch) | |
tree | 94b6b0f8913db7f2b1e68f4b6319ddc9a9aefcf6 | |
parent | 0242a91d97a70acbbf186678e636d99a565c0bf0 (diff) | |
parent | 4306b1d2ac0a346d148cf4507c7852fc0e0f5776 (diff) | |
download | skqp-434b714f90ebe5afa183594789b194c498a36736.tar.gz |
Reland "Add small offset to t in GrLinearGradientLayout." am: 5540432b78 am: 4306b1d2ac
Change-Id: Ie2be82905e726808312dc791dca04ea34d92e5f5
-rw-r--r-- | src/gpu/gradients/GrLinearGradientLayout.cpp | 6 | ||||
-rw-r--r-- | src/gpu/gradients/GrLinearGradientLayout.fp | 9 |
2 files changed, 12 insertions, 3 deletions
diff --git a/src/gpu/gradients/GrLinearGradientLayout.cpp b/src/gpu/gradients/GrLinearGradientLayout.cpp index cd53b36bcd..d809e004b0 100644 --- a/src/gpu/gradients/GrLinearGradientLayout.cpp +++ b/src/gpu/gradients/GrLinearGradientLayout.cpp @@ -25,8 +25,10 @@ public: auto gradientMatrix = _outer.gradientMatrix(); (void)gradientMatrix; SkString sk_TransformedCoords2D_0 = fragBuilder->ensureCoords2D(args.fTransformedCoords[0]); - fragBuilder->codeAppendf("half t = half(%s.x);\n%s = half4(t, 1.0, 0.0, 0.0);\n", - sk_TransformedCoords2D_0.c_str(), args.fOutputColor); + fragBuilder->codeAppendf( + "half t = half(%s.x) + 1.0000000000000001e-05;\n%s = half4(t, 1.0, 0.0, 0.0);\n", + sk_TransformedCoords2D_0.c_str(), + args.fOutputColor); } private: diff --git a/src/gpu/gradients/GrLinearGradientLayout.fp b/src/gpu/gradients/GrLinearGradientLayout.fp index 3a187f321c..bd144316e8 100644 --- a/src/gpu/gradients/GrLinearGradientLayout.fp +++ b/src/gpu/gradients/GrLinearGradientLayout.fp @@ -12,7 +12,14 @@ in half4x4 gradientMatrix; } void main() { - half t = sk_TransformedCoords2D[0].x; + // We add a tiny delta to t. When gradient stops are set up so that a hard stop in a vertically + // or horizontally oriented gradient falls exactly at a column or row of pixel centers we can + // we can get slightly different interpolated t values along the column/row. By adding the delta + // we will consistently get the color to the "right" of the stop. Of course if the hard stop + // falls at X.5 - delta then we still could get inconsistent results, but that is much less + // likely. crbug.com/938592 + // If/when we add filtering of the gradient this can be removed. + half t = half(sk_TransformedCoords2D[0].x) + 0.00001; sk_OutColor = half4(t, 1, 0, 0); // y = 1 for always valid } |