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 "gl/GrGLProcessor.h" | 12 #include "gl/GrGLProcessor.h" |
13 #include "gl/GrGLSL.h" | 13 #include "gl/GrGLSL.h" |
14 #include "gl/builders/GrGLProgramBuilder.h" | 14 #include "gl/builders/GrGLProgramBuilder.h" |
15 | 15 |
16 ////////////////////////////////////////////////////////////////////////////// | 16 ////////////////////////////////////////////////////////////////////////////// |
17 | 17 |
18 class DitherEffect : public GrFragmentProcessor { | 18 class DitherEffect : public GrFragmentProcessor { |
19 public: | 19 public: |
20 static GrFragmentProcessor* Create() { | 20 static GrFragmentProcessor* Create() { |
21 GR_CREATE_STATIC_PROCESSOR(gDitherEffect, DitherEffect, ()) | 21 GR_CREATE_STATIC_PROCESSOR(gDitherEffect, DitherEffect, ()) |
22 return SkRef(gDitherEffect); | 22 return SkRef(gDitherEffect); |
23 } | 23 } |
24 | 24 |
25 virtual ~DitherEffect() {}; | 25 virtual ~DitherEffect() {}; |
26 | 26 |
27 const char* name() const SK_OVERRIDE { return "Dither"; } | 27 const char* name() const override { return "Dither"; } |
28 | 28 |
29 void getGLProcessorKey(const GrGLCaps&, GrProcessorKeyBuilder*) const SK_OVE
RRIDE; | 29 void getGLProcessorKey(const GrGLCaps&, GrProcessorKeyBuilder*) const overri
de; |
30 | 30 |
31 GrGLFragmentProcessor* createGLInstance() const SK_OVERRIDE; | 31 GrGLFragmentProcessor* createGLInstance() const override; |
32 | 32 |
33 private: | 33 private: |
34 DitherEffect() { | 34 DitherEffect() { |
35 this->initClassID<DitherEffect>(); | 35 this->initClassID<DitherEffect>(); |
36 this->setWillReadFragmentPosition(); | 36 this->setWillReadFragmentPosition(); |
37 } | 37 } |
38 | 38 |
39 // All dither effects are equal | 39 // All dither effects are equal |
40 bool onIsEqual(const GrFragmentProcessor&) const SK_OVERRIDE { return true;
} | 40 bool onIsEqual(const GrFragmentProcessor&) const override { return true; } |
41 | 41 |
42 void onComputeInvariantOutput(GrInvariantOutput* inout) const SK_OVERRIDE; | 42 void onComputeInvariantOutput(GrInvariantOutput* inout) const override; |
43 | 43 |
44 GR_DECLARE_FRAGMENT_PROCESSOR_TEST; | 44 GR_DECLARE_FRAGMENT_PROCESSOR_TEST; |
45 | 45 |
46 typedef GrFragmentProcessor INHERITED; | 46 typedef GrFragmentProcessor INHERITED; |
47 }; | 47 }; |
48 | 48 |
49 void DitherEffect::onComputeInvariantOutput(GrInvariantOutput* inout) const { | 49 void DitherEffect::onComputeInvariantOutput(GrInvariantOutput* inout) const { |
50 inout->setToUnknown(GrInvariantOutput::kWill_ReadInput); | 50 inout->setToUnknown(GrInvariantOutput::kWill_ReadInput); |
51 } | 51 } |
52 | 52 |
(...skipping 12 matching lines...) Expand all Loading... |
65 | 65 |
66 class GLDitherEffect : public GrGLFragmentProcessor { | 66 class GLDitherEffect : public GrGLFragmentProcessor { |
67 public: | 67 public: |
68 GLDitherEffect(const GrProcessor&); | 68 GLDitherEffect(const GrProcessor&); |
69 | 69 |
70 virtual void emitCode(GrGLFPBuilder* builder, | 70 virtual void emitCode(GrGLFPBuilder* builder, |
71 const GrFragmentProcessor& fp, | 71 const GrFragmentProcessor& fp, |
72 const char* outputColor, | 72 const char* outputColor, |
73 const char* inputColor, | 73 const char* inputColor, |
74 const TransformedCoordsArray&, | 74 const TransformedCoordsArray&, |
75 const TextureSamplerArray&) SK_OVERRIDE; | 75 const TextureSamplerArray&) override; |
76 | 76 |
77 private: | 77 private: |
78 typedef GrGLFragmentProcessor INHERITED; | 78 typedef GrGLFragmentProcessor INHERITED; |
79 }; | 79 }; |
80 | 80 |
81 GLDitherEffect::GLDitherEffect(const GrProcessor&) { | 81 GLDitherEffect::GLDitherEffect(const GrProcessor&) { |
82 } | 82 } |
83 | 83 |
84 void GLDitherEffect::emitCode(GrGLFPBuilder* builder, | 84 void GLDitherEffect::emitCode(GrGLFPBuilder* builder, |
85 const GrFragmentProcessor& fp, | 85 const GrFragmentProcessor& fp, |
(...skipping 23 matching lines...) Expand all Loading... |
109 void DitherEffect::getGLProcessorKey(const GrGLCaps& caps, | 109 void DitherEffect::getGLProcessorKey(const GrGLCaps& caps, |
110 GrProcessorKeyBuilder* b) const { | 110 GrProcessorKeyBuilder* b) const { |
111 GLDitherEffect::GenKey(*this, caps, b); | 111 GLDitherEffect::GenKey(*this, caps, b); |
112 } | 112 } |
113 | 113 |
114 GrGLFragmentProcessor* DitherEffect::createGLInstance() const { | 114 GrGLFragmentProcessor* DitherEffect::createGLInstance() const { |
115 return SkNEW_ARGS(GLDitherEffect, (*this)); | 115 return SkNEW_ARGS(GLDitherEffect, (*this)); |
116 } | 116 } |
117 | 117 |
118 GrFragmentProcessor* GrDitherEffect::Create() { return DitherEffect::Create(); } | 118 GrFragmentProcessor* GrDitherEffect::Create() { return DitherEffect::Create(); } |
OLD | NEW |