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

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

Issue 1666773002: Clean up GrGLSLFragmentProcessor-derived classes (Closed) Base URL: https://skia.googlesource.com/skia.git@master
Patch Set: Created 4 years, 10 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/GrTextureDomain.cpp ('k') | src/gpu/effects/GrYUVEffect.cpp » ('j') | 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 41 matching lines...) Expand 10 before | Expand all | Expand 10 after
52 52
53 GR_DECLARE_FRAGMENT_PROCESSOR_TEST; 53 GR_DECLARE_FRAGMENT_PROCESSOR_TEST;
54 54
55 typedef GrFragmentProcessor INHERITED; 55 typedef GrFragmentProcessor INHERITED;
56 }; 56 };
57 57
58 ///////////////////////////////////////////////////////////////////// 58 /////////////////////////////////////////////////////////////////////
59 59
60 class GLComposeTwoFragmentProcessor : public GrGLSLFragmentProcessor { 60 class GLComposeTwoFragmentProcessor : public GrGLSLFragmentProcessor {
61 public: 61 public:
62 GLComposeTwoFragmentProcessor(const GrProcessor& processor) {}
63
64 void emitCode(EmitArgs&) override; 62 void emitCode(EmitArgs&) override;
65 63
66 private: 64 private:
67 typedef GrGLSLFragmentProcessor INHERITED; 65 typedef GrGLSLFragmentProcessor INHERITED;
68 }; 66 };
69 67
70 ///////////////////////////////////////////////////////////////////// 68 /////////////////////////////////////////////////////////////////////
71 69
72 GR_DEFINE_FRAGMENT_PROCESSOR_TEST(ComposeTwoFragmentProcessor); 70 GR_DEFINE_FRAGMENT_PROCESSOR_TEST(ComposeTwoFragmentProcessor);
73 71
74 const GrFragmentProcessor* ComposeTwoFragmentProcessor::TestCreate(GrProcessorTe stData* d) { 72 const GrFragmentProcessor* ComposeTwoFragmentProcessor::TestCreate(GrProcessorTe stData* d) {
75 // Create two random frag procs. 73 // Create two random frag procs.
76 SkAutoTUnref<const GrFragmentProcessor> fpA(GrProcessorUnitTest::CreateChild FP(d)); 74 SkAutoTUnref<const GrFragmentProcessor> fpA(GrProcessorUnitTest::CreateChild FP(d));
77 SkAutoTUnref<const GrFragmentProcessor> fpB(GrProcessorUnitTest::CreateChild FP(d)); 75 SkAutoTUnref<const GrFragmentProcessor> fpB(GrProcessorUnitTest::CreateChild FP(d));
78 76
79 SkXfermode::Mode mode = static_cast<SkXfermode::Mode>( 77 SkXfermode::Mode mode = static_cast<SkXfermode::Mode>(
80 d->fRandom->nextRangeU(0, SkXfermode::kLastMode)); 78 d->fRandom->nextRangeU(0, SkXfermode::kLastMode));
81 return new ComposeTwoFragmentProcessor(fpA, fpB, mode); 79 return new ComposeTwoFragmentProcessor(fpA, fpB, mode);
82 } 80 }
83 81
84 GrGLSLFragmentProcessor* ComposeTwoFragmentProcessor::onCreateGLSLInstance() con st{ 82 GrGLSLFragmentProcessor* ComposeTwoFragmentProcessor::onCreateGLSLInstance() con st{
85 return new GLComposeTwoFragmentProcessor(*this); 83 return new GLComposeTwoFragmentProcessor;
86 } 84 }
87 85
88 ///////////////////////////////////////////////////////////////////// 86 /////////////////////////////////////////////////////////////////////
89 87
90 void GLComposeTwoFragmentProcessor::emitCode(EmitArgs& args) { 88 void GLComposeTwoFragmentProcessor::emitCode(EmitArgs& args) {
91 89
92 GrGLSLFragmentBuilder* fragBuilder = args.fFragBuilder; 90 GrGLSLFragmentBuilder* fragBuilder = args.fFragBuilder;
93 const ComposeTwoFragmentProcessor& cs = args.fFp.cast<ComposeTwoFragmentProc essor>(); 91 const ComposeTwoFragmentProcessor& cs = args.fFp.cast<ComposeTwoFragmentProc essor>();
94 92
95 const char* inputColor = nullptr; 93 const char* inputColor = nullptr;
(...skipping 126 matching lines...) Expand 10 before | Expand all | Expand 10 after
222 220
223 GR_DECLARE_FRAGMENT_PROCESSOR_TEST; 221 GR_DECLARE_FRAGMENT_PROCESSOR_TEST;
224 222
225 typedef GrFragmentProcessor INHERITED; 223 typedef GrFragmentProcessor INHERITED;
226 }; 224 };
227 225
228 ////////////////////////////////////////////////////////////////////////////// 226 //////////////////////////////////////////////////////////////////////////////
229 227
230 class GLComposeOneFragmentProcessor : public GrGLSLFragmentProcessor { 228 class GLComposeOneFragmentProcessor : public GrGLSLFragmentProcessor {
231 public: 229 public:
232 GLComposeOneFragmentProcessor(const GrProcessor& processor) {}
233
234 void emitCode(EmitArgs& args) override { 230 void emitCode(EmitArgs& args) override {
235 GrGLSLFragmentBuilder* fragBuilder = args.fFragBuilder; 231 GrGLSLFragmentBuilder* fragBuilder = args.fFragBuilder;
236 SkXfermode::Mode mode = args.fFp.cast<ComposeOneFragmentProcessor>().mod e(); 232 SkXfermode::Mode mode = args.fFp.cast<ComposeOneFragmentProcessor>().mod e();
237 ComposeOneFragmentProcessor::Child child = 233 ComposeOneFragmentProcessor::Child child =
238 args.fFp.cast<ComposeOneFragmentProcessor>().child(); 234 args.fFp.cast<ComposeOneFragmentProcessor>().child();
239 SkString childColor("child"); 235 SkString childColor("child");
240 this->emitChild(0, nullptr, &childColor, args); 236 this->emitChild(0, nullptr, &childColor, args);
241 237
242 const char* inputColor = args.fInputColor; 238 const char* inputColor = args.fInputColor;
243 // We don't try to optimize for this case at all 239 // We don't try to optimize for this case at all
(...skipping 27 matching lines...) Expand all
271 SkAutoTUnref<const GrFragmentProcessor> dst(GrProcessorUnitTest::CreateChild FP(d)); 267 SkAutoTUnref<const GrFragmentProcessor> dst(GrProcessorUnitTest::CreateChild FP(d));
272 SkXfermode::Mode mode = static_cast<SkXfermode::Mode>( 268 SkXfermode::Mode mode = static_cast<SkXfermode::Mode>(
273 d->fRandom->nextRangeU(0, SkXfermode::kLastMode)); 269 d->fRandom->nextRangeU(0, SkXfermode::kLastMode));
274 ComposeOneFragmentProcessor::Child child = d->fRandom->nextBool() ? 270 ComposeOneFragmentProcessor::Child child = d->fRandom->nextBool() ?
275 ComposeOneFragmentProcessor::kDst_Child : 271 ComposeOneFragmentProcessor::kDst_Child :
276 ComposeOneFragmentProcessor::kSrc_Child; 272 ComposeOneFragmentProcessor::kSrc_Child;
277 return new ComposeOneFragmentProcessor(dst, mode, child); 273 return new ComposeOneFragmentProcessor(dst, mode, child);
278 } 274 }
279 275
280 GrGLSLFragmentProcessor* ComposeOneFragmentProcessor::onCreateGLSLInstance() con st { 276 GrGLSLFragmentProcessor* ComposeOneFragmentProcessor::onCreateGLSLInstance() con st {
281 return new GLComposeOneFragmentProcessor(*this); 277 return new GLComposeOneFragmentProcessor;
282 } 278 }
283 279
284 ////////////////////////////////////////////////////////////////////////////// 280 //////////////////////////////////////////////////////////////////////////////
285 281
286 const GrFragmentProcessor* GrXfermodeFragmentProcessor::CreateFromDstProcessor( 282 const GrFragmentProcessor* GrXfermodeFragmentProcessor::CreateFromDstProcessor(
287 const GrFragmentProcessor* dst, SkXfermode::Mode mode) { 283 const GrFragmentProcessor* dst, SkXfermode::Mode mode) {
288 switch (mode) { 284 switch (mode) {
289 case SkXfermode::kClear_Mode: 285 case SkXfermode::kClear_Mode:
290 return GrConstColorProcessor::Create(GrColor_TRANSPARENT_BLACK, 286 return GrConstColorProcessor::Create(GrColor_TRANSPARENT_BLACK,
291 GrConstColorProcessor::kIgnore_ InputMode); 287 GrConstColorProcessor::kIgnore_ InputMode);
(...skipping 11 matching lines...) Expand all
303 case SkXfermode::kClear_Mode: 299 case SkXfermode::kClear_Mode:
304 return GrConstColorProcessor::Create(GrColor_TRANSPARENT_BLACK, 300 return GrConstColorProcessor::Create(GrColor_TRANSPARENT_BLACK,
305 GrConstColorProcessor::kIgnore_ InputMode); 301 GrConstColorProcessor::kIgnore_ InputMode);
306 case SkXfermode::kDst_Mode: 302 case SkXfermode::kDst_Mode:
307 return nullptr; 303 return nullptr;
308 default: 304 default:
309 return new ComposeOneFragmentProcessor(src, mode, 305 return new ComposeOneFragmentProcessor(src, mode,
310 ComposeOneFragmentProcessor:: kSrc_Child); 306 ComposeOneFragmentProcessor:: kSrc_Child);
311 } 307 }
312 } 308 }
OLDNEW
« no previous file with comments | « src/gpu/effects/GrTextureDomain.cpp ('k') | src/gpu/effects/GrYUVEffect.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698