| OLD | NEW |
| 1 /* | 1 /* |
| 2 * Copyright 2014 Google Inc. | 2 * Copyright 2014 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 "gm.h" | 8 #include "gm.h" |
| 9 #if SK_SUPPORT_GPU | 9 #if SK_SUPPORT_GPU |
| 10 #include "GrFragmentProcessor.h" | 10 #include "GrFragmentProcessor.h" |
| (...skipping 47 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 58 public: | 58 public: |
| 59 DCFP(const SkMatrix& m) : fDeviceTransform(kDevice_GrCoordSet, m) { | 59 DCFP(const SkMatrix& m) : fDeviceTransform(kDevice_GrCoordSet, m) { |
| 60 this->addCoordTransform(&fDeviceTransform); | 60 this->addCoordTransform(&fDeviceTransform); |
| 61 this->initClassID<DCFP>(); | 61 this->initClassID<DCFP>(); |
| 62 } | 62 } |
| 63 | 63 |
| 64 GrGLSLFragmentProcessor* onCreateGLSLInstance() const override { | 64 GrGLSLFragmentProcessor* onCreateGLSLInstance() const override { |
| 65 class DCGLFP : public GrGLSLFragmentProcessor { | 65 class DCGLFP : public GrGLSLFragmentProcessor { |
| 66 void emitCode(EmitArgs& args) override { | 66 void emitCode(EmitArgs& args) override { |
| 67 GrGLSLFragmentBuilder* fragBuilder = args.fFragBuilder; | 67 GrGLSLFragmentBuilder* fragBuilder = args.fFragBuilder; |
| 68 fragBuilder->codeAppendf("vec2 c = %s;", | 68 SkString coords2d = fragBuilder->ensureCoords2D(args.fTransforme
dCoords[0]); |
| 69 fragBuilder->ensureFSCoords2D(args.fCoo
rds, 0).c_str()); | 69 fragBuilder->codeAppendf("vec2 c = %s;", coords2d.c_str()); |
| 70 fragBuilder->codeAppend("vec2 r = mod(c, vec2(20.0));"); | 70 fragBuilder->codeAppend("vec2 r = mod(c, vec2(20.0));"); |
| 71 fragBuilder->codeAppend("vec4 color = vec4(0.5*sin(c.x / 15.0) +
0.5," | 71 fragBuilder->codeAppend("vec4 color = vec4(0.5*sin(c.x / 15.0) +
0.5," |
| 72 "0.5*cos((c.x + c.y) / 15.
0) + 0.5," | 72 "0.5*cos((c.x + c.y) / 15.
0) + 0.5," |
| 73 "(r.x + r.y) / 20.0," | 73 "(r.x + r.y) / 20.0," |
| 74 "distance(r, vec2(15.0)) /
20.0 + 0.2);"); | 74 "distance(r, vec2(15.0)) /
20.0 + 0.2);"); |
| 75 fragBuilder->codeAppendf("color.rgb *= color.a;" | 75 fragBuilder->codeAppendf("color.rgb *= color.a;" |
| 76 "%s = color * %s;", | 76 "%s = color * %s;", |
| 77 args.fOutputColor, GrGLSLExpr4(args.fIn
putColor).c_str()); | 77 args.fOutputColor, GrGLSLExpr4(args.fIn
putColor).c_str()); |
| 78 } | 78 } |
| 79 void onSetData(const GrGLSLProgramDataManager&, const GrProcessor&)
override {} | 79 void onSetData(const GrGLSLProgramDataManager&, const GrProcessor&)
override {} |
| (...skipping 205 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 285 }; | 285 }; |
| 286 | 286 |
| 287 SkTArray<Prim*> fPrims; | 287 SkTArray<Prim*> fPrims; |
| 288 | 288 |
| 289 typedef GM INHERITED; | 289 typedef GM INHERITED; |
| 290 }; | 290 }; |
| 291 | 291 |
| 292 DEF_GM(return new DCShaderGM;) | 292 DEF_GM(return new DCShaderGM;) |
| 293 } | 293 } |
| 294 #endif | 294 #endif |
| OLD | NEW |