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 #include "GrFragmentProcessor.h" | 9 #include "GrFragmentProcessor.h" |
10 #include "GrInvariantOutput.h" | 10 #include "GrInvariantOutput.h" |
11 #include "SkRect.h" | 11 #include "SkRect.h" |
12 #include "glsl/GrGLSLFragmentProcessor.h" | 12 #include "glsl/GrGLSLFragmentProcessor.h" |
13 #include "glsl/GrGLSLFragmentShaderBuilder.h" | 13 #include "glsl/GrGLSLFragmentShaderBuilder.h" |
14 | 14 |
15 ////////////////////////////////////////////////////////////////////////////// | 15 ////////////////////////////////////////////////////////////////////////////// |
16 | 16 |
17 class DitherEffect : public GrFragmentProcessor { | 17 class DitherEffect : public GrFragmentProcessor { |
18 public: | 18 public: |
19 static GrFragmentProcessor* Create() { | 19 static GrFragmentProcessor* Create() { |
20 return new DitherEffect; | 20 return new DitherEffect; |
21 } | 21 } |
22 | 22 |
23 virtual ~DitherEffect() {}; | 23 virtual ~DitherEffect() {}; |
24 | 24 |
25 const char* name() const override { return "Dither"; } | 25 const char* name() const override { return "Dither"; } |
26 | 26 |
27 private: | 27 private: |
28 DitherEffect() { | 28 DitherEffect() { |
29 this->initClassID<DitherEffect>(); | 29 this->initClassID<DitherEffect>(); |
30 this->setWillReadFragmentPosition(); | 30 this->enableBuiltInState(kFragmentPosition_BuiltInState); |
31 } | 31 } |
32 | 32 |
33 GrGLSLFragmentProcessor* onCreateGLSLInstance() const override; | 33 GrGLSLFragmentProcessor* onCreateGLSLInstance() const override; |
34 | 34 |
35 void onGetGLSLProcessorKey(const GrGLSLCaps&, GrProcessorKeyBuilder*) const
override; | 35 void onGetGLSLProcessorKey(const GrGLSLCaps&, GrProcessorKeyBuilder*) const
override; |
36 | 36 |
37 // All dither effects are equal | 37 // All dither effects are equal |
38 bool onIsEqual(const GrFragmentProcessor&) const override { return true; } | 38 bool onIsEqual(const GrFragmentProcessor&) const override { return true; } |
39 | 39 |
40 void onComputeInvariantOutput(GrInvariantOutput* inout) const override; | 40 void onComputeInvariantOutput(GrInvariantOutput* inout) const override; |
(...skipping 48 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
89 void DitherEffect::onGetGLSLProcessorKey(const GrGLSLCaps& caps, | 89 void DitherEffect::onGetGLSLProcessorKey(const GrGLSLCaps& caps, |
90 GrProcessorKeyBuilder* b) const { | 90 GrProcessorKeyBuilder* b) const { |
91 GLDitherEffect::GenKey(*this, caps, b); | 91 GLDitherEffect::GenKey(*this, caps, b); |
92 } | 92 } |
93 | 93 |
94 GrGLSLFragmentProcessor* DitherEffect::onCreateGLSLInstance() const { | 94 GrGLSLFragmentProcessor* DitherEffect::onCreateGLSLInstance() const { |
95 return new GLDitherEffect; | 95 return new GLDitherEffect; |
96 } | 96 } |
97 | 97 |
98 GrFragmentProcessor* GrDitherEffect::Create() { return DitherEffect::Create(); } | 98 GrFragmentProcessor* GrDitherEffect::Create() { return DitherEffect::Create(); } |
OLD | NEW |