diff options
author | 2015-09-14 13:16:26 -0700 | |
---|---|---|
committer | 2015-09-14 13:16:26 -0700 | |
commit | 506c802a3dd3b6dc8a172621ff2a1f9bda202a13 (patch) | |
tree | 45db20ee4dfc71615d85a7da127fa1bf6f75cac3 /src/gpu | |
parent | 07344a5386b70f682b16b40bc6eb83acf76d6921 (diff) |
Add helper for creating leaf FPs inside GrFP::TestCreate functions
Review URL: https://codereview.chromium.org/1334273003
Diffstat (limited to 'src/gpu')
-rw-r--r-- | src/gpu/GrProcessor.cpp | 2 | ||||
-rw-r--r-- | src/gpu/GrProcessorUnitTest.cpp | 23 | ||||
-rw-r--r-- | src/gpu/effects/GrExtractAlphaFragmentProcessor.cpp | 7 | ||||
-rw-r--r-- | src/gpu/effects/GrXfermodeFragmentProcessor.cpp | 19 |
4 files changed, 33 insertions, 18 deletions
diff --git a/src/gpu/GrProcessor.cpp b/src/gpu/GrProcessor.cpp index 6ab5561942..782b82ba5c 100644 --- a/src/gpu/GrProcessor.cpp +++ b/src/gpu/GrProcessor.cpp @@ -50,7 +50,7 @@ GrProcessorTestFactory<GrGeometryProcessor>::GetFactories() { * we verify the count is as expected. If a new factory is added, then these numbers must be * manually adjusted. */ -static const int kFPFactoryCount = 38; +static const int kFPFactoryCount = 39; static const int kGPFactoryCount = 14; static const int kXPFactoryCount = 5; diff --git a/src/gpu/GrProcessorUnitTest.cpp b/src/gpu/GrProcessorUnitTest.cpp new file mode 100644 index 0000000000..bdc602c9bf --- /dev/null +++ b/src/gpu/GrProcessorUnitTest.cpp @@ -0,0 +1,23 @@ +/* + * Copyright 2015 Google Inc. + * + * Use of this source code is governed by a BSD-style license that can be + * found in the LICENSE file. + */ + +#include "GrProcessorUnitTest.h" +#include "GrFragmentProcessor.h" + +const GrFragmentProcessor* GrProcessorUnitTest::CreateChildFP(GrProcessorTestData* data) { +#if SK_ALLOW_STATIC_GLOBAL_INITIALIZERS + SkAutoTUnref<const GrFragmentProcessor> fp; + do { + fp.reset(GrProcessorTestFactory<GrFragmentProcessor>::Create(data)); + SkASSERT(fp); + } while (fp->numChildProcessors() != 0); + return SkRef(fp.get()); +#else + SkFAIL("Should not be called if !SK_ALLOW_STATIC_GLOBAL_INITIALIZERS"); + return nullptr; +#endif +} diff --git a/src/gpu/effects/GrExtractAlphaFragmentProcessor.cpp b/src/gpu/effects/GrExtractAlphaFragmentProcessor.cpp index 8f6af65ca7..483df64502 100644 --- a/src/gpu/effects/GrExtractAlphaFragmentProcessor.cpp +++ b/src/gpu/effects/GrExtractAlphaFragmentProcessor.cpp @@ -47,3 +47,10 @@ void GrExtractAlphaFragmentProcessor::onComputeInvariantOutput(GrInvariantOutput } this->childProcessor(0).computeInvariantOutput(inout); } + +GR_DEFINE_FRAGMENT_PROCESSOR_TEST(GrExtractAlphaFragmentProcessor); + +const GrFragmentProcessor* GrExtractAlphaFragmentProcessor::TestCreate(GrProcessorTestData* d) { + SkAutoTUnref<const GrFragmentProcessor> child(GrProcessorUnitTest::CreateChildFP(d)); + return SkNEW_ARGS(GrExtractAlphaFragmentProcessor, (child)); +} diff --git a/src/gpu/effects/GrXfermodeFragmentProcessor.cpp b/src/gpu/effects/GrXfermodeFragmentProcessor.cpp index c039db3433..ab944d86fc 100644 --- a/src/gpu/effects/GrXfermodeFragmentProcessor.cpp +++ b/src/gpu/effects/GrXfermodeFragmentProcessor.cpp @@ -72,28 +72,13 @@ private: GR_DEFINE_FRAGMENT_PROCESSOR_TEST(GrComposeTwoFragmentProcessor); const GrFragmentProcessor* GrComposeTwoFragmentProcessor::TestCreate(GrProcessorTestData* d) { -#if SK_ALLOW_STATIC_GLOBAL_INITIALIZERS // Create two random frag procs. - // For now, we'll prevent either children from being a shader with children to prevent the - // possibility of an arbitrarily large tree of procs. - SkAutoTUnref<const GrFragmentProcessor> fpA; - do { - fpA.reset(GrProcessorTestFactory<GrFragmentProcessor>::Create(d)); - SkASSERT(fpA); - } while (fpA->numChildProcessors() != 0); - SkAutoTUnref<const GrFragmentProcessor> fpB; - do { - fpB.reset(GrProcessorTestFactory<GrFragmentProcessor>::Create(d)); - SkASSERT(fpB); - } while (fpB->numChildProcessors() != 0); + SkAutoTUnref<const GrFragmentProcessor> fpA(GrProcessorUnitTest::CreateChildFP(d)); + SkAutoTUnref<const GrFragmentProcessor> fpB(GrProcessorUnitTest::CreateChildFP(d)); SkXfermode::Mode mode = static_cast<SkXfermode::Mode>( d->fRandom->nextRangeU(0, SkXfermode::kLastCoeffMode)); return SkNEW_ARGS(GrComposeTwoFragmentProcessor, (fpA, fpB, mode)); -#else - SkFAIL("Should not be called if !SK_ALLOW_STATIC_GLOBAL_INITIALIZERS"); - return nullptr; -#endif } GrGLFragmentProcessor* GrComposeTwoFragmentProcessor::onCreateGLInstance() const{ |