Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(331)

Side by Side Diff: src/gpu/effects/GrXfermodeFragmentProcessor.cpp

Issue 1334273003: Add helper for creating leaf FPs inside GrFP::TestCreate functions (Closed) Base URL: https://skia.googlesource.com/skia.git@noinputtest
Patch Set: address comment Created 5 years, 3 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « src/gpu/effects/GrExtractAlphaFragmentProcessor.cpp ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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
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
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 }
OLDNEW
« no previous file with comments | « src/gpu/effects/GrExtractAlphaFragmentProcessor.cpp ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698