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

Side by Side Diff: gm/dcshader.cpp

Issue 1287023009: Added tree structure to GrGLFragmentProcessor, i.e. GL instances (Closed) Base URL: https://skia.googlesource.com/skia@cs3_isequal_nonrecursive
Patch Set: moved onSetData from public to protected, onCreateGLInstance from public to private in subclasses Created 5 years, 4 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 | « no previous file | gyp/gpu.gypi » ('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 /* 2 /*
3 * Copyright 2014 Google Inc. 3 * Copyright 2014 Google Inc.
4 * 4 *
5 * Use of this source code is governed by a BSD-style license that can be 5 * Use of this source code is governed by a BSD-style license that can be
6 * found in the LICENSE file. 6 * found in the LICENSE file.
7 */ 7 */
8 8
9 #include "gm.h" 9 #include "gm.h"
10 #if SK_SUPPORT_GPU 10 #if SK_SUPPORT_GPU
(...skipping 42 matching lines...) Expand 10 before | Expand all | Expand 10 after
53 return SkNEW_ARGS(DCShader, (matrix)); 53 return SkNEW_ARGS(DCShader, (matrix));
54 } 54 }
55 55
56 class DCFP : public GrFragmentProcessor { 56 class DCFP : public GrFragmentProcessor {
57 public: 57 public:
58 DCFP(GrProcessorDataManager*, const SkMatrix& m) : fDeviceTransform(kDevice_ GrCoordSet, m) { 58 DCFP(GrProcessorDataManager*, const SkMatrix& m) : fDeviceTransform(kDevice_ GrCoordSet, m) {
59 this->addCoordTransform(&fDeviceTransform); 59 this->addCoordTransform(&fDeviceTransform);
60 this->initClassID<DCFP>(); 60 this->initClassID<DCFP>();
61 } 61 }
62 62
63 GrGLFragmentProcessor* createGLInstance() const override { 63 GrGLFragmentProcessor* onCreateGLInstance() const override {
64 class DCGLFP : public GrGLFragmentProcessor { 64 class DCGLFP : public GrGLFragmentProcessor {
65 void emitCode(EmitArgs& args) override { 65 void emitCode(EmitArgs& args) override {
66 GrGLFragmentBuilder* fpb = args.fBuilder->getFragmentShaderBuild er(); 66 GrGLFragmentBuilder* fpb = args.fBuilder->getFragmentShaderBuild er();
67 fpb->codeAppendf("vec2 c = %s;", fpb->ensureFSCoords2D(args.fCoo rds, 0).c_str()); 67 fpb->codeAppendf("vec2 c = %s;", fpb->ensureFSCoords2D(args.fCoo rds, 0).c_str());
68 fpb->codeAppend("vec2 r = mod(c, vec2(20.0));"); 68 fpb->codeAppend("vec2 r = mod(c, vec2(20.0));");
69 fpb->codeAppend("vec4 color = vec4(0.5*sin(c.x / 15.0) + 0.5," 69 fpb->codeAppend("vec4 color = vec4(0.5*sin(c.x / 15.0) + 0.5,"
70 "0.5*cos((c.x + c.y) / 15.0) + 0.5," 70 "0.5*cos((c.x + c.y) / 15.0) + 0.5,"
71 "(r.x + r.y) / 20.0," 71 "(r.x + r.y) / 20.0,"
72 "distance(r, vec2(15.0)) / 2 0.0 + 0.2);"); 72 "distance(r, vec2(15.0)) / 2 0.0 + 0.2);");
73 fpb->codeAppendf("color.rgb *= color.a;" 73 fpb->codeAppendf("color.rgb *= color.a;"
74 "%s = color * %s;", 74 "%s = color * %s;",
75 args.fOutputColor, GrGLSLExpr4(args.fInputCo lor).c_str()); 75 args.fOutputColor, GrGLSLExpr4(args.fInputCo lor).c_str());
76 } 76 }
77 void setData(const GrGLProgramDataManager&, const GrProcessor&) over ride {} 77 void onSetData(const GrGLProgramDataManager&, const GrProcessor&) ov erride {}
78 }; 78 };
79 return SkNEW(DCGLFP); 79 return SkNEW(DCGLFP);
80 } 80 }
81 81
82 const char* name() const override { return "DCFP"; } 82 const char* name() const override { return "DCFP"; }
83 83
84 void onComputeInvariantOutput(GrInvariantOutput* inout) const override { 84 void onComputeInvariantOutput(GrInvariantOutput* inout) const override {
85 inout->mulByUnknownFourComponents(); 85 inout->mulByUnknownFourComponents();
86 } 86 }
87 87
(...skipping 199 matching lines...) Expand 10 before | Expand all | Expand 10 after
287 }; 287 };
288 288
289 SkTArray<Prim*> fPrims; 289 SkTArray<Prim*> fPrims;
290 290
291 typedef GM INHERITED; 291 typedef GM INHERITED;
292 }; 292 };
293 293
294 DEF_GM( return SkNEW(DCShaderGM); ) 294 DEF_GM( return SkNEW(DCShaderGM); )
295 } 295 }
296 #endif 296 #endif
OLDNEW
« no previous file with comments | « no previous file | gyp/gpu.gypi » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698