diff options
author | Brian Salomon <bsalomon@google.com> | 2017-02-09 11:16:46 -0500 |
---|---|---|
committer | Skia Commit-Bot <skia-commit-bot@chromium.org> | 2017-02-09 19:25:21 +0000 |
commit | 5d4cd9ea8818f65bb4878c050dbdb9dcd48505ad (patch) | |
tree | 1cbcb0c31ffd9c5d592f8c84cfe59b7da3c074ec /src | |
parent | e659c7f36fef20a6b1605c6b29d1642b4f1f01b5 (diff) |
Re-enable processor optimization test with some fixes.
Enables on GL (for now)
Change-Id: I5f5a38632963dd705f8434e8627eb33446e8f027
Reviewed-on: https://skia-review.googlesource.com/7721
Reviewed-by: Greg Daniel <egdaniel@google.com>
Commit-Queue: Brian Salomon <bsalomon@google.com>
Diffstat (limited to 'src')
-rw-r--r-- | src/effects/GrAlphaThresholdFragmentProcessor.cpp | 8 | ||||
-rw-r--r-- | src/effects/SkAlphaThresholdFilter.cpp | 3 | ||||
-rw-r--r-- | src/effects/gradients/SkGradientShader.cpp | 4 | ||||
-rw-r--r-- | src/effects/gradients/SkGradientShaderPriv.h | 2 | ||||
-rw-r--r-- | src/effects/gradients/SkRadialGradient.cpp | 22 | ||||
-rw-r--r-- | src/gpu/effects/GrConfigConversionEffect.cpp | 11 | ||||
-rw-r--r-- | src/gpu/effects/GrXfermodeFragmentProcessor.cpp | 13 | ||||
-rw-r--r-- | src/gpu/glsl/GrGLSLBlend.cpp | 9 |
8 files changed, 49 insertions, 23 deletions
diff --git a/src/effects/GrAlphaThresholdFragmentProcessor.cpp b/src/effects/GrAlphaThresholdFragmentProcessor.cpp index a18fb9c1e9..37ca3efbcc 100644 --- a/src/effects/GrAlphaThresholdFragmentProcessor.cpp +++ b/src/effects/GrAlphaThresholdFragmentProcessor.cpp @@ -174,8 +174,12 @@ GR_DEFINE_FRAGMENT_PROCESSOR_TEST(GrAlphaThresholdFragmentProcessor); sk_sp<GrFragmentProcessor> GrAlphaThresholdFragmentProcessor::TestCreate(GrProcessorTestData* d) { GrTexture* bmpTex = d->fTextures[GrProcessorUnitTest::kSkiaPMTextureIdx]; GrTexture* maskTex = d->fTextures[GrProcessorUnitTest::kAlphaTextureIdx]; - float innerThresh = d->fRandom->nextUScalar1(); - float outerThresh = d->fRandom->nextUScalar1(); + // Make the inner and outer thresholds be in (0, 1) exclusive and be sorted correctly. + float innerThresh = d->fRandom->nextUScalar1() * .99f + 0.005f; + float outerThresh = d->fRandom->nextUScalar1() * .99f + 0.005f; + if (innerThresh > outerThresh) { + SkTSwap(innerThresh, outerThresh); + } const int kMaxWidth = 1000; const int kMaxHeight = 1000; uint32_t width = d->fRandom->nextULessThan(kMaxWidth); diff --git a/src/effects/SkAlphaThresholdFilter.cpp b/src/effects/SkAlphaThresholdFilter.cpp index 0e38cccd65..96f8365d60 100644 --- a/src/effects/SkAlphaThresholdFilter.cpp +++ b/src/effects/SkAlphaThresholdFilter.cpp @@ -65,6 +65,9 @@ sk_sp<SkImageFilter> SkAlphaThresholdFilter::Make(const SkRegion& region, const SkImageFilter::CropRect* cropRect) { innerThreshold = pin_0_1(innerThreshold); outerThreshold = pin_0_1(outerThreshold); + if (innerThreshold > outerThreshold) { + return nullptr; + } if (!SkScalarIsFinite(innerThreshold) || !SkScalarIsFinite(outerThreshold)) { return nullptr; } diff --git a/src/effects/gradients/SkGradientShader.cpp b/src/effects/gradients/SkGradientShader.cpp index f50311b97e..9b38cb5b83 100644 --- a/src/effects/gradients/SkGradientShader.cpp +++ b/src/effects/gradients/SkGradientShader.cpp @@ -1754,7 +1754,9 @@ void GrGradientEffect::onComputeInvariantOutput(GrInvariantOutput* inout) const #if GR_TEST_UTILS GrGradientEffect::RandomGradientParams::RandomGradientParams(SkRandom* random) { - fColorCount = random->nextRangeU(1, kMaxRandomGradientColors); + // Set color count to min of 2 so that we don't trigger the const color optimization and make + // a non-gradient processor. + fColorCount = random->nextRangeU(2, kMaxRandomGradientColors); fUseColors4f = random->nextBool(); // if one color, omit stops, otherwise randomly decide whether or not to diff --git a/src/effects/gradients/SkGradientShaderPriv.h b/src/effects/gradients/SkGradientShaderPriv.h index a9eef7df0e..fe238ff18c 100644 --- a/src/effects/gradients/SkGradientShaderPriv.h +++ b/src/effects/gradients/SkGradientShaderPriv.h @@ -410,7 +410,7 @@ protected: the gradient factory. (The constructor may decide not to use stops, in which case fStops will be nullptr). */ struct RandomGradientParams { - static const int kMaxRandomGradientColors = 4; + static const int kMaxRandomGradientColors = 5; RandomGradientParams(SkRandom* r); diff --git a/src/effects/gradients/SkRadialGradient.cpp b/src/effects/gradients/SkRadialGradient.cpp index 7e56863993..f282babf82 100644 --- a/src/effects/gradients/SkRadialGradient.cpp +++ b/src/effects/gradients/SkRadialGradient.cpp @@ -303,15 +303,19 @@ GR_DEFINE_FRAGMENT_PROCESSOR_TEST(GrRadialGradient); #if GR_TEST_UTILS sk_sp<GrFragmentProcessor> GrRadialGradient::TestCreate(GrProcessorTestData* d) { - SkPoint center = {d->fRandom->nextUScalar1(), d->fRandom->nextUScalar1()}; - SkScalar radius = d->fRandom->nextUScalar1(); - - RandomGradientParams params(d->fRandom); - auto shader = params.fUseColors4f ? - SkGradientShader::MakeRadial(center, radius, params.fColors4f, params.fColorSpace, - params.fStops, params.fColorCount, params.fTileMode) : - SkGradientShader::MakeRadial(center, radius, params.fColors, - params.fStops, params.fColorCount, params.fTileMode); + sk_sp<SkShader> shader; + do { + RandomGradientParams params(d->fRandom); + SkPoint center = {d->fRandom->nextUScalar1(), d->fRandom->nextUScalar1()}; + SkScalar radius = d->fRandom->nextUScalar1(); + shader = params.fUseColors4f + ? SkGradientShader::MakeRadial(center, radius, params.fColors4f, + params.fColorSpace, params.fStops, + params.fColorCount, params.fTileMode) + : SkGradientShader::MakeRadial(center, radius, params.fColors, + params.fStops, params.fColorCount, + params.fTileMode); + } while (!shader); GrTest::TestAsFPArgs asFPArgs(d); sk_sp<GrFragmentProcessor> fp = shader->asFragmentProcessor(asFPArgs.args()); GrAlwaysAssert(fp); diff --git a/src/gpu/effects/GrConfigConversionEffect.cpp b/src/gpu/effects/GrConfigConversionEffect.cpp index d9a6fefc1e..771eba80f7 100644 --- a/src/gpu/effects/GrConfigConversionEffect.cpp +++ b/src/gpu/effects/GrConfigConversionEffect.cpp @@ -98,7 +98,7 @@ GrConfigConversionEffect::GrConfigConversionEffect(GrTexture* texture, const GrSwizzle& swizzle, PMConversion pmConversion, const SkMatrix& matrix) - : INHERITED(texture, nullptr, matrix, ModulationFlags(texture->config())) + : INHERITED(texture, nullptr, matrix, kNone_OptimizationFlags) , fSwizzle(swizzle) , fPMConversion(pmConversion) { this->initClassID<GrConfigConversionEffect>(); @@ -112,13 +112,14 @@ GrConfigConversionEffect::GrConfigConversionEffect(GrTexture* texture, } GrConfigConversionEffect::GrConfigConversionEffect(GrContext* context, - sk_sp<GrTextureProxy> proxy, + sk_sp<GrTextureProxy> + proxy, const GrSwizzle& swizzle, PMConversion pmConversion, const SkMatrix& matrix) - : INHERITED(context, ModulationFlags(proxy->config()), proxy, nullptr, matrix) - , fSwizzle(swizzle) - , fPMConversion(pmConversion) { + : INHERITED(context, kNone_OptimizationFlags, proxy, nullptr, matrix) + , fSwizzle(swizzle) + , fPMConversion(pmConversion) { this->initClassID<GrConfigConversionEffect>(); // We expect to get here with non-BGRA/RGBA only if we're doing not doing a premul/unpremul // conversion. diff --git a/src/gpu/effects/GrXfermodeFragmentProcessor.cpp b/src/gpu/effects/GrXfermodeFragmentProcessor.cpp index 0ecb4bd3c0..935b29406b 100644 --- a/src/gpu/effects/GrXfermodeFragmentProcessor.cpp +++ b/src/gpu/effects/GrXfermodeFragmentProcessor.cpp @@ -39,9 +39,10 @@ private: static OptimizationFlags OptFlags(const GrFragmentProcessor* src, const GrFragmentProcessor* dst, SkBlendMode mode) { // We only attempt the constant output optimization. - // The CPU and GPU implementations differ significantly for the advanced modes. - if (mode <= SkBlendMode::kLastSeparableMode && src->hasConstantOutputForConstantInput() && - dst->hasConstantOutputForConstantInput()) { + // The CPU and GPU implementations differ significantly for the advanced modes and + // softlight. + if (mode <= SkBlendMode::kLastSeparableMode && mode != SkBlendMode::kSoftLight && + src->hasConstantOutputForConstantInput() && dst->hasConstantOutputForConstantInput()) { return kConstantOutputForConstantInput_OptimizationFlag; } return kNone_OptimizationFlags; @@ -197,8 +198,10 @@ public: private: OptimizationFlags OptFlags(const GrFragmentProcessor* child, SkBlendMode mode) { // We only attempt the constant output optimization. - // The CPU and GPU implementations differ significantly for the advanced modes. - if (mode <= SkBlendMode::kLastSeparableMode && child->hasConstantOutputForConstantInput()) { + // The CPU and GPU implementations differ significantly for the advanced modes and + // softlight. + if (mode <= SkBlendMode::kLastSeparableMode && mode != SkBlendMode::kSoftLight && + child->hasConstantOutputForConstantInput()) { return kConstantOutputForConstantInput_OptimizationFlag; } return kNone_OptimizationFlags; diff --git a/src/gpu/glsl/GrGLSLBlend.cpp b/src/gpu/glsl/GrGLSLBlend.cpp index e9a9f50f84..2f41c4e588 100644 --- a/src/gpu/glsl/GrGLSLBlend.cpp +++ b/src/gpu/glsl/GrGLSLBlend.cpp @@ -422,7 +422,13 @@ void GrGLSLBlend::AppendMode(GrGLSLFragmentBuilder* fsBuilder, const char* srcCo SkXfermode::Coeff srcCoeff, dstCoeff; if (SkXfermode::ModeAsCoeff(mode, &srcCoeff, &dstCoeff)) { + // The only coeff mode that can go out of range is plus. + bool clamp = mode == SkBlendMode::kPlus; + fsBuilder->codeAppendf("%s = ", outColor); + if (clamp) { + fsBuilder->codeAppend("clamp("); + } // append src blend bool didAppend = append_porterduff_term(fsBuilder, srcCoeff, srcColor, srcColor, dstColor, false); @@ -430,6 +436,9 @@ void GrGLSLBlend::AppendMode(GrGLSLFragmentBuilder* fsBuilder, const char* srcCo if(!append_porterduff_term(fsBuilder, dstCoeff, dstColor, srcColor, dstColor, didAppend)) { fsBuilder->codeAppend("vec4(0, 0, 0, 0)"); } + if (clamp) { + fsBuilder->codeAppend(", 0, 1);"); + } fsBuilder->codeAppend(";"); } else { emit_advanced_xfermode_code(fsBuilder, srcColor, dstColor, outColor, mode); |