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 53 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
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) { |
74 GrGLFPFragmentBuilder* 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()
); |
84 } | 84 } |
(...skipping 226 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
311 }; | 311 }; |
312 | 312 |
313 SkTArray<Prim*> fPrims; | 313 SkTArray<Prim*> fPrims; |
314 | 314 |
315 typedef GM INHERITED; | 315 typedef GM INHERITED; |
316 }; | 316 }; |
317 | 317 |
318 DEF_GM( return SkNEW(DCShaderGM); ) | 318 DEF_GM( return SkNEW(DCShaderGM); ) |
319 } | 319 } |
320 #endif | 320 #endif |
OLD | NEW |