OLD | NEW |
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 |
11 #include "GrFragmentProcessor.h" | 11 #include "GrFragmentProcessor.h" |
12 #include "GrCoordTransform.h" | 12 #include "GrCoordTransform.h" |
13 #include "effects/GrXfermodeFragmentProcessor.h" | 13 #include "effects/GrXfermodeFragmentProcessor.h" |
14 #include "gl/GrGLFragmentProcessor.h" | 14 #include "gl/GrGLFragmentProcessor.h" |
15 #include "gl/builders/GrGLProgramBuilder.h" | 15 #include "glsl/GrGLSLFragmentShaderBuilder.h" |
| 16 #include "glsl/GrGLSLProgramBuilder.h" |
16 #include "glsl/GrGLSLProgramDataManager.h" | 17 #include "glsl/GrGLSLProgramDataManager.h" |
17 #include "Resources.h" | 18 #include "Resources.h" |
18 #include "SkReadBuffer.h" | 19 #include "SkReadBuffer.h" |
19 #include "SkShader.h" | 20 #include "SkShader.h" |
20 #include "SkStream.h" | 21 #include "SkStream.h" |
21 #include "SkTypeface.h" | 22 #include "SkTypeface.h" |
22 #include "SkWriteBuffer.h" | 23 #include "SkWriteBuffer.h" |
23 | 24 |
24 namespace skiagm { | 25 namespace skiagm { |
25 | 26 |
(...skipping 33 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
59 class DCFP : public GrFragmentProcessor { | 60 class DCFP : public GrFragmentProcessor { |
60 public: | 61 public: |
61 DCFP(const SkMatrix& m) : fDeviceTransform(kDevice_GrCoordSet, m) { | 62 DCFP(const SkMatrix& m) : fDeviceTransform(kDevice_GrCoordSet, m) { |
62 this->addCoordTransform(&fDeviceTransform); | 63 this->addCoordTransform(&fDeviceTransform); |
63 this->initClassID<DCFP>(); | 64 this->initClassID<DCFP>(); |
64 } | 65 } |
65 | 66 |
66 GrGLFragmentProcessor* onCreateGLInstance() const override { | 67 GrGLFragmentProcessor* onCreateGLInstance() const override { |
67 class DCGLFP : public GrGLFragmentProcessor { | 68 class DCGLFP : public GrGLFragmentProcessor { |
68 void emitCode(EmitArgs& args) override { | 69 void emitCode(EmitArgs& args) override { |
69 GrGLFragmentBuilder* fpb = args.fBuilder->getFragmentShaderBuild
er(); | 70 GrGLSLFragmentBuilder* fpb = args.fBuilder->getFragmentShaderBui
lder(); |
70 fpb->codeAppendf("vec2 c = %s;", fpb->ensureFSCoords2D(args.fCoo
rds, 0).c_str()); | 71 fpb->codeAppendf("vec2 c = %s;", fpb->ensureFSCoords2D(args.fCoo
rds, 0).c_str()); |
71 fpb->codeAppend("vec2 r = mod(c, vec2(20.0));"); | 72 fpb->codeAppend("vec2 r = mod(c, vec2(20.0));"); |
72 fpb->codeAppend("vec4 color = vec4(0.5*sin(c.x / 15.0) + 0.5," | 73 fpb->codeAppend("vec4 color = vec4(0.5*sin(c.x / 15.0) + 0.5," |
73 "0.5*cos((c.x + c.y) / 15.0)
+ 0.5," | 74 "0.5*cos((c.x + c.y) / 15.0)
+ 0.5," |
74 "(r.x + r.y) / 20.0," | 75 "(r.x + r.y) / 20.0," |
75 "distance(r, vec2(15.0)) / 2
0.0 + 0.2);"); | 76 "distance(r, vec2(15.0)) / 2
0.0 + 0.2);"); |
76 fpb->codeAppendf("color.rgb *= color.a;" | 77 fpb->codeAppendf("color.rgb *= color.a;" |
77 "%s = color * %s;", | 78 "%s = color * %s;", |
78 args.fOutputColor, GrGLSLExpr4(args.fInputCo
lor).c_str()); | 79 args.fOutputColor, GrGLSLExpr4(args.fInputCo
lor).c_str()); |
79 } | 80 } |
(...skipping 209 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
289 }; | 290 }; |
290 | 291 |
291 SkTArray<Prim*> fPrims; | 292 SkTArray<Prim*> fPrims; |
292 | 293 |
293 typedef GM INHERITED; | 294 typedef GM INHERITED; |
294 }; | 295 }; |
295 | 296 |
296 DEF_GM(return new DCShaderGM;) | 297 DEF_GM(return new DCShaderGM;) |
297 } | 298 } |
298 #endif | 299 #endif |
OLD | NEW |