diff options
author | 2016-10-17 12:48:13 -0400 | |
---|---|---|
committer | 2016-10-18 13:01:28 +0000 | |
commit | a2196536782903d22011ed7145b8640c66fc72ff (patch) | |
tree | 065f25088074f908a3531acce43d1c3a26367863 /src/effects/gradients/SkGradientShader.cpp | |
parent | 8bf4e672f2c40ef313274f8b79c2c9304f9fff3f (diff) |
Include 4f variants of random gradients during testing
BUG=skia:
GOLD_TRYBOT_URL= https://gold.skia.org/search?issue=3538
Change-Id: Ieee6e49cb830b6aab87b0ecd7865c65ffb90dfe8
Reviewed-on: https://skia-review.googlesource.com/3538
Reviewed-by: Florin Malita <fmalita@chromium.org>
Commit-Queue: Brian Osman <brianosman@google.com>
Diffstat (limited to 'src/effects/gradients/SkGradientShader.cpp')
-rw-r--r-- | src/effects/gradients/SkGradientShader.cpp | 19 |
1 files changed, 18 insertions, 1 deletions
diff --git a/src/effects/gradients/SkGradientShader.cpp b/src/effects/gradients/SkGradientShader.cpp index eee2cbfadc..03f03b20b1 100644 --- a/src/effects/gradients/SkGradientShader.cpp +++ b/src/effects/gradients/SkGradientShader.cpp @@ -6,6 +6,7 @@ */ #include "Sk4fLinearGradient.h" +#include "SkColorSpace_Base.h" #include "SkGradientShaderPriv.h" #include "SkHalf.h" #include "SkLinearGradient.h" @@ -1733,6 +1734,7 @@ void GrGradientEffect::onComputeInvariantOutput(GrInvariantOutput* inout) const GrGradientEffect::RandomGradientParams::RandomGradientParams(SkRandom* random) { fColorCount = random->nextRangeU(1, kMaxRandomGradientColors); + fUseColors4f = random->nextBool(); // if one color, omit stops, otherwise randomly decide whether or not to if (fColorCount == 1 || (fColorCount >= 2 && random->nextBool())) { @@ -1741,9 +1743,24 @@ GrGradientEffect::RandomGradientParams::RandomGradientParams(SkRandom* random) { fStops = fStopStorage; } + // if using SkColor4f, attach a random (possibly null) color space (with linear gamma) + if (fUseColors4f) { + fColorSpace = GrTest::TestColorSpace(random); + if (fColorSpace) { + fColorSpace = as_CSB(fColorSpace)->makeLinearGamma(); + } + } + SkScalar stop = 0.f; for (int i = 0; i < fColorCount; ++i) { - fColors[i] = random->nextU(); + if (fUseColors4f) { + fColors4f[i].fR = random->nextUScalar1(); + fColors4f[i].fG = random->nextUScalar1(); + fColors4f[i].fB = random->nextUScalar1(); + fColors4f[i].fA = random->nextUScalar1(); + } else { + fColors[i] = random->nextU(); + } if (fStops) { fStops[i] = stop; stop = i < fColorCount - 1 ? stop + random->nextUScalar1() * (1.f - stop) : 1.f; |