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 "GrDitherEffect.h" | 8 #include "GrDitherEffect.h" |
9 | 9 |
10 #include "gl/GrGLEffect.h" | 10 #include "gl/GrGLEffect.h" |
11 #include "gl/GrGLSL.h" | 11 #include "gl/GrGLSL.h" |
12 #include "GrTBackendEffectFactory.h" | 12 #include "GrTBackendEffectFactory.h" |
13 | 13 |
14 #include "SkRect.h" | 14 #include "SkRect.h" |
15 | 15 |
16 ////////////////////////////////////////////////////////////////////////////// | 16 ////////////////////////////////////////////////////////////////////////////// |
17 | 17 |
18 class GLDitherEffect; | 18 class GLDitherEffect; |
19 | 19 |
20 class DitherEffect : public GrEffect { | 20 class DitherEffect : public GrEffect { |
21 public: | 21 public: |
22 static GrEffectRef* Create() { | 22 static GrEffectRef* Create() { |
23 return CreateEffectRef(AutoEffectUnref(SkNEW(DitherEffect))); | 23 GR_CREATE_STATIC_EFFECT(gDitherEffect, DitherEffect, ()) |
| 24 return SkRef(gDitherEffect); |
24 } | 25 } |
25 | 26 |
26 virtual ~DitherEffect() {}; | 27 virtual ~DitherEffect() {}; |
27 static const char* Name() { return "Dither"; } | 28 static const char* Name() { return "Dither"; } |
28 | 29 |
29 typedef GLDitherEffect GLEffect; | 30 typedef GLDitherEffect GLEffect; |
30 | 31 |
31 virtual void getConstantColorComponents(GrColor* color, uint32_t* validFlags
) const SK_OVERRIDE; | 32 virtual void getConstantColorComponents(GrColor* color, uint32_t* validFlags
) const SK_OVERRIDE; |
32 | 33 |
33 virtual const GrBackendEffectFactory& getFactory() const SK_OVERRIDE { | 34 virtual const GrBackendEffectFactory& getFactory() const SK_OVERRIDE { |
(...skipping 72 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
106 builder->fragmentPosition()); | 107 builder->fragmentPosition()); |
107 builder->fsCodeAppendf("\t\t%s = (1.0/255.0) * vec4(r, r, r, r) + %s;\n", | 108 builder->fsCodeAppendf("\t\t%s = (1.0/255.0) * vec4(r, r, r, r) + %s;\n", |
108 outputColor, GrGLSLExpr4(inputColor).c_str()); | 109 outputColor, GrGLSLExpr4(inputColor).c_str()); |
109 } | 110 } |
110 | 111 |
111 ////////////////////////////////////////////////////////////////////////////// | 112 ////////////////////////////////////////////////////////////////////////////// |
112 | 113 |
113 GrEffectRef* GrDitherEffect::Create() { | 114 GrEffectRef* GrDitherEffect::Create() { |
114 return DitherEffect::Create(); | 115 return DitherEffect::Create(); |
115 } | 116 } |
OLD | NEW |