OLD | NEW |
1 /* | 1 /* |
2 * Copyright 2013 Google Inc. | 2 * Copyright 2013 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 "SkLumaColorFilter.h" | 8 #include "SkLumaColorFilter.h" |
9 | 9 |
10 #include "SkColorPriv.h" | 10 #include "SkColorPriv.h" |
(...skipping 47 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
58 #if SK_SUPPORT_GPU | 58 #if SK_SUPPORT_GPU |
59 class LumaColorFilterEffect : public GrFragmentProcessor { | 59 class LumaColorFilterEffect : public GrFragmentProcessor { |
60 public: | 60 public: |
61 static GrFragmentProcessor* Create() { | 61 static GrFragmentProcessor* Create() { |
62 GR_CREATE_STATIC_PROCESSOR(gLumaEffect, LumaColorFilterEffect, ()); | 62 GR_CREATE_STATIC_PROCESSOR(gLumaEffect, LumaColorFilterEffect, ()); |
63 return SkRef(gLumaEffect); | 63 return SkRef(gLumaEffect); |
64 } | 64 } |
65 | 65 |
66 const char* name() const override { return "Luminance-to-Alpha"; } | 66 const char* name() const override { return "Luminance-to-Alpha"; } |
67 | 67 |
68 virtual void getGLProcessorKey(const GrGLSLCaps& caps, | |
69 GrProcessorKeyBuilder* b) const override { | |
70 GLProcessor::GenKey(*this, caps, b); | |
71 } | |
72 | |
73 GrGLFragmentProcessor* createGLInstance() const override { | 68 GrGLFragmentProcessor* createGLInstance() const override { |
74 return SkNEW_ARGS(GLProcessor, (*this)); | 69 return SkNEW_ARGS(GLProcessor, (*this)); |
75 } | 70 } |
76 | 71 |
77 class GLProcessor : public GrGLFragmentProcessor { | 72 class GLProcessor : public GrGLFragmentProcessor { |
78 public: | 73 public: |
79 GLProcessor(const GrProcessor&) {} | 74 GLProcessor(const GrProcessor&) {} |
80 | 75 |
81 static void GenKey(const GrProcessor&, const GrGLSLCaps&, GrProcessorKey
Builder* b) {} | 76 static void GenKey(const GrProcessor&, const GrGLSLCaps&, GrProcessorKey
Builder* b) {} |
82 | 77 |
(...skipping 15 matching lines...) Expand all Loading... |
98 | 93 |
99 private: | 94 private: |
100 typedef GrGLFragmentProcessor INHERITED; | 95 typedef GrGLFragmentProcessor INHERITED; |
101 }; | 96 }; |
102 | 97 |
103 private: | 98 private: |
104 LumaColorFilterEffect() { | 99 LumaColorFilterEffect() { |
105 this->initClassID<LumaColorFilterEffect>(); | 100 this->initClassID<LumaColorFilterEffect>(); |
106 } | 101 } |
107 | 102 |
| 103 virtual void onGetGLProcessorKey(const GrGLSLCaps& caps, |
| 104 GrProcessorKeyBuilder* b) const override { |
| 105 GLProcessor::GenKey(*this, caps, b); |
| 106 } |
| 107 |
108 bool onIsEqual(const GrFragmentProcessor&) const override { return true; } | 108 bool onIsEqual(const GrFragmentProcessor&) const override { return true; } |
109 | 109 |
110 void onComputeInvariantOutput(GrInvariantOutput* inout) const override { | 110 void onComputeInvariantOutput(GrInvariantOutput* inout) const override { |
111 // The output is always black. The alpha value for the color passed in i
s arbitrary. | 111 // The output is always black. The alpha value for the color passed in i
s arbitrary. |
112 inout->setToOther(kRGB_GrColorComponentFlags, GrColorPackRGBA(0, 0, 0, 0
), | 112 inout->setToOther(kRGB_GrColorComponentFlags, GrColorPackRGBA(0, 0, 0, 0
), |
113 GrInvariantOutput::kWill_ReadInput); | 113 GrInvariantOutput::kWill_ReadInput); |
114 } | 114 } |
115 }; | 115 }; |
116 | 116 |
117 bool SkLumaColorFilter::asFragmentProcessors(GrContext*, GrProcessorDataManager*
, | 117 bool SkLumaColorFilter::asFragmentProcessors(GrContext*, GrProcessorDataManager*
, |
118 SkTDArray<GrFragmentProcessor*>* ar
ray) const { | 118 SkTDArray<GrFragmentProcessor*>* ar
ray) const { |
119 | 119 |
120 GrFragmentProcessor* frag = LumaColorFilterEffect::Create(); | 120 GrFragmentProcessor* frag = LumaColorFilterEffect::Create(); |
121 if (frag) { | 121 if (frag) { |
122 if (array) { | 122 if (array) { |
123 *array->append() = frag; | 123 *array->append() = frag; |
124 } else { | 124 } else { |
125 frag->unref(); | 125 frag->unref(); |
126 SkDEBUGCODE(frag = NULL;) | 126 SkDEBUGCODE(frag = NULL;) |
127 } | 127 } |
128 return true; | 128 return true; |
129 } | 129 } |
130 return false; | 130 return false; |
131 } | 131 } |
132 #endif | 132 #endif |
OLD | NEW |