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 |
(...skipping 52 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
63 void getGLProcessorKey(const GrGLSLCaps& caps, | 63 void getGLProcessorKey(const GrGLSLCaps& caps, |
64 GrProcessorKeyBuilder* b) const override {} | 64 GrProcessorKeyBuilder* b) const override {} |
65 | 65 |
66 GrGLFragmentProcessor* createGLInstance() const override { | 66 GrGLFragmentProcessor* createGLInstance() const override { |
67 class DCGLFP : public GrGLFragmentProcessor { | 67 class DCGLFP : public GrGLFragmentProcessor { |
68 void emitCode(GrGLFPBuilder* builder, | 68 void emitCode(GrGLFPBuilder* builder, |
69 const GrFragmentProcessor& fp, | 69 const GrFragmentProcessor& fp, |
70 const char* outputColor, | 70 const char* outputColor, |
71 const char* inputColor, | 71 const char* inputColor, |
72 const TransformedCoordsArray& coords, | 72 const TransformedCoordsArray& coords, |
73 const TextureSamplerArray& samplers) { | 73 const TextureSamplerArray& samplers) override { |
74 GrGLFragmentBuilder* fpb = builder->getFragmentShaderBuilder(); | 74 GrGLFragmentBuilder* fpb = builder->getFragmentShaderBuilder(); |
75 fpb->codeAppendf("vec2 c = %s;", fpb->ensureFSCoords2D(coords, 0
).c_str()); | 75 fpb->codeAppendf("vec2 c = %s;", fpb->ensureFSCoords2D(coords, 0
).c_str()); |
76 fpb->codeAppend("vec2 r = mod(c, vec2(20.0));"); | 76 fpb->codeAppend("vec2 r = mod(c, vec2(20.0));"); |
77 fpb->codeAppend("vec4 color = vec4(0.5*sin(c.x / 15.0) + 0.5," | 77 fpb->codeAppend("vec4 color = vec4(0.5*sin(c.x / 15.0) + 0.5," |
78 "0.5*cos((c.x + c.y) / 15.0)
+ 0.5," | 78 "0.5*cos((c.x + c.y) / 15.0)
+ 0.5," |
79 "(r.x + r.y) / 20.0," | 79 "(r.x + r.y) / 20.0," |
80 "distance(r, vec2(15.0)) / 2
0.0 + 0.2);"); | 80 "distance(r, vec2(15.0)) / 2
0.0 + 0.2);"); |
81 fpb->codeAppendf("color.rgb *= color.a;" | 81 fpb->codeAppendf("color.rgb *= color.a;" |
82 "%s = color * %s;", | 82 "%s = color * %s;", |
83 outputColor, GrGLSLExpr4(inputColor).c_str()
); | 83 outputColor, GrGLSLExpr4(inputColor).c_str()
); |
(...skipping 221 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
305 }; | 305 }; |
306 | 306 |
307 SkTArray<Prim*> fPrims; | 307 SkTArray<Prim*> fPrims; |
308 | 308 |
309 typedef GM INHERITED; | 309 typedef GM INHERITED; |
310 }; | 310 }; |
311 | 311 |
312 DEF_GM( return SkNEW(DCShaderGM); ) | 312 DEF_GM( return SkNEW(DCShaderGM); ) |
313 } | 313 } |
314 #endif | 314 #endif |
OLD | NEW |