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 "gl/builders/GrGLProgramBuilder.h" | 8 #include "gl/builders/GrGLProgramBuilder.h" |
9 #include "GrDitherEffect.h" | 9 #include "GrDitherEffect.h" |
10 | 10 |
11 #include "gl/GrGLProcessor.h" | 11 #include "gl/GrGLProcessor.h" |
12 #include "gl/GrGLSL.h" | 12 #include "gl/GrGLSL.h" |
13 #include "GrTBackendProcessorFactory.h" | 13 #include "GrTBackendProcessorFactory.h" |
14 | 14 |
15 #include "SkRect.h" | 15 #include "SkRect.h" |
16 | 16 |
17 ////////////////////////////////////////////////////////////////////////////// | 17 ////////////////////////////////////////////////////////////////////////////// |
18 | 18 |
19 class GLDitherEffect; | 19 class GLDitherEffect; |
20 | 20 |
21 class DitherEffect : public GrFragmentProcessor { | 21 class DitherEffect : public GrFragmentProcessor { |
22 public: | 22 public: |
23 static GrFragmentProcessor* Create() { | 23 static GrFragmentProcessor* Create() { |
24 GR_CREATE_STATIC_FRAGMENT_PROCESSOR(gDitherEffect, DitherEffect, ()) | 24 GR_CREATE_STATIC_PROCESSOR(gDitherEffect, DitherEffect, ()) |
25 return SkRef(gDitherEffect); | 25 return SkRef(gDitherEffect); |
26 } | 26 } |
27 | 27 |
28 virtual ~DitherEffect() {}; | 28 virtual ~DitherEffect() {}; |
29 static const char* Name() { return "Dither"; } | 29 static const char* Name() { return "Dither"; } |
30 | 30 |
31 typedef GLDitherEffect GLProcessor; | 31 typedef GLDitherEffect GLProcessor; |
32 | 32 |
33 virtual const GrBackendFragmentProcessorFactory& getFactory() const SK_OVERR
IDE { | 33 virtual const GrBackendFragmentProcessorFactory& getFactory() const SK_OVERR
IDE { |
34 return GrTBackendFragmentProcessorFactory<DitherEffect>::getInstance(); | 34 return GrTBackendFragmentProcessorFactory<DitherEffect>::getInstance(); |
(...skipping 72 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
107 fsBuilder->codeAppendf("\t\tfloat r = " | 107 fsBuilder->codeAppendf("\t\tfloat r = " |
108 "fract(sin(dot(%s.xy ,vec2(12.9898,78.233))) * 43758.
5453);\n", | 108 "fract(sin(dot(%s.xy ,vec2(12.9898,78.233))) * 43758.
5453);\n", |
109 fsBuilder->fragmentPosition()); | 109 fsBuilder->fragmentPosition()); |
110 fsBuilder->codeAppendf("\t\t%s = (1.0/255.0) * vec4(r, r, r, r) + %s;\n", | 110 fsBuilder->codeAppendf("\t\t%s = (1.0/255.0) * vec4(r, r, r, r) + %s;\n", |
111 outputColor, GrGLSLExpr4(inputColor).c_str()); | 111 outputColor, GrGLSLExpr4(inputColor).c_str()); |
112 } | 112 } |
113 | 113 |
114 ////////////////////////////////////////////////////////////////////////////// | 114 ////////////////////////////////////////////////////////////////////////////// |
115 | 115 |
116 GrFragmentProcessor* GrDitherEffect::Create() { return DitherEffect::Create(); } | 116 GrFragmentProcessor* GrDitherEffect::Create() { return DitherEffect::Create(); } |
OLD | NEW |