OLD | NEW |
1 /* | 1 /* |
2 * Copyright 2015 Google Inc. | 2 * Copyright 2015 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 "effects/GrXfermodeFragmentProcessor.h" | 8 #include "effects/GrXfermodeFragmentProcessor.h" |
9 | 9 |
10 #include "GrFragmentProcessor.h" | 10 #include "GrFragmentProcessor.h" |
(...skipping 54 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
65 | 65 |
66 private: | 66 private: |
67 typedef GrGLFragmentProcessor INHERITED; | 67 typedef GrGLFragmentProcessor INHERITED; |
68 }; | 68 }; |
69 | 69 |
70 ///////////////////////////////////////////////////////////////////// | 70 ///////////////////////////////////////////////////////////////////// |
71 | 71 |
72 GR_DEFINE_FRAGMENT_PROCESSOR_TEST(GrComposeTwoFragmentProcessor); | 72 GR_DEFINE_FRAGMENT_PROCESSOR_TEST(GrComposeTwoFragmentProcessor); |
73 | 73 |
74 const GrFragmentProcessor* GrComposeTwoFragmentProcessor::TestCreate(GrProcessor
TestData* d) { | 74 const GrFragmentProcessor* GrComposeTwoFragmentProcessor::TestCreate(GrProcessor
TestData* d) { |
75 #if SK_ALLOW_STATIC_GLOBAL_INITIALIZERS | |
76 // Create two random frag procs. | 75 // Create two random frag procs. |
77 // For now, we'll prevent either children from being a shader with children
to prevent the | 76 SkAutoTUnref<const GrFragmentProcessor> fpA(GrProcessorUnitTest::CreateChild
FP(d)); |
78 // possibility of an arbitrarily large tree of procs. | 77 SkAutoTUnref<const GrFragmentProcessor> fpB(GrProcessorUnitTest::CreateChild
FP(d)); |
79 SkAutoTUnref<const GrFragmentProcessor> fpA; | |
80 do { | |
81 fpA.reset(GrProcessorTestFactory<GrFragmentProcessor>::Create(d)); | |
82 SkASSERT(fpA); | |
83 } while (fpA->numChildProcessors() != 0); | |
84 SkAutoTUnref<const GrFragmentProcessor> fpB; | |
85 do { | |
86 fpB.reset(GrProcessorTestFactory<GrFragmentProcessor>::Create(d)); | |
87 SkASSERT(fpB); | |
88 } while (fpB->numChildProcessors() != 0); | |
89 | 78 |
90 SkXfermode::Mode mode = static_cast<SkXfermode::Mode>( | 79 SkXfermode::Mode mode = static_cast<SkXfermode::Mode>( |
91 d->fRandom->nextRangeU(0, SkXfermode::kLastCoeffMode)); | 80 d->fRandom->nextRangeU(0, SkXfermode::kLastCoeffMode)); |
92 return SkNEW_ARGS(GrComposeTwoFragmentProcessor, (fpA, fpB, mode)); | 81 return SkNEW_ARGS(GrComposeTwoFragmentProcessor, (fpA, fpB, mode)); |
93 #else | |
94 SkFAIL("Should not be called if !SK_ALLOW_STATIC_GLOBAL_INITIALIZERS"); | |
95 return nullptr; | |
96 #endif | |
97 } | 82 } |
98 | 83 |
99 GrGLFragmentProcessor* GrComposeTwoFragmentProcessor::onCreateGLInstance() const
{ | 84 GrGLFragmentProcessor* GrComposeTwoFragmentProcessor::onCreateGLInstance() const
{ |
100 return SkNEW_ARGS(GrGLComposeTwoFragmentProcessor, (*this)); | 85 return SkNEW_ARGS(GrGLComposeTwoFragmentProcessor, (*this)); |
101 } | 86 } |
102 | 87 |
103 ///////////////////////////////////////////////////////////////////// | 88 ///////////////////////////////////////////////////////////////////// |
104 | 89 |
105 void GrGLComposeTwoFragmentProcessor::emitCode(EmitArgs& args) { | 90 void GrGLComposeTwoFragmentProcessor::emitCode(EmitArgs& args) { |
106 | 91 |
(...skipping 53 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
160 case SkXfermode::kSrc_Mode: | 145 case SkXfermode::kSrc_Mode: |
161 return SkRef(src); | 146 return SkRef(src); |
162 break; | 147 break; |
163 case SkXfermode::kDst_Mode: | 148 case SkXfermode::kDst_Mode: |
164 return SkRef(dst); | 149 return SkRef(dst); |
165 break; | 150 break; |
166 default: | 151 default: |
167 return new GrComposeTwoFragmentProcessor(src, dst, mode); | 152 return new GrComposeTwoFragmentProcessor(src, dst, mode); |
168 } | 153 } |
169 } | 154 } |
OLD | NEW |