| 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 GrGLFragmentProcessor* createGLInstance() const override { | |
| 69 return SkNEW_ARGS(GLProcessor, (*this)); | |
| 70 } | |
| 71 | |
| 72 class GLProcessor : public GrGLFragmentProcessor { | 68 class GLProcessor : public GrGLFragmentProcessor { |
| 73 public: | 69 public: |
| 74 GLProcessor(const GrProcessor&) {} | 70 GLProcessor(const GrProcessor&) {} |
| 75 | 71 |
| 76 static void GenKey(const GrProcessor&, const GrGLSLCaps&, GrProcessorKey
Builder* b) {} | 72 static void GenKey(const GrProcessor&, const GrGLSLCaps&, GrProcessorKey
Builder* b) {} |
| 77 | 73 |
| 78 virtual void emitCode(EmitArgs& args) override { | 74 virtual void emitCode(EmitArgs& args) override { |
| 79 if (NULL == args.fInputColor) { | 75 if (NULL == args.fInputColor) { |
| 80 args.fInputColor = "vec4(1)"; | 76 args.fInputColor = "vec4(1)"; |
| 81 } | 77 } |
| (...skipping 11 matching lines...) Expand all Loading... |
| 93 | 89 |
| 94 private: | 90 private: |
| 95 typedef GrGLFragmentProcessor INHERITED; | 91 typedef GrGLFragmentProcessor INHERITED; |
| 96 }; | 92 }; |
| 97 | 93 |
| 98 private: | 94 private: |
| 99 LumaColorFilterEffect() { | 95 LumaColorFilterEffect() { |
| 100 this->initClassID<LumaColorFilterEffect>(); | 96 this->initClassID<LumaColorFilterEffect>(); |
| 101 } | 97 } |
| 102 | 98 |
| 99 GrGLFragmentProcessor* onCreateGLInstance() const override { |
| 100 return SkNEW_ARGS(GLProcessor, (*this)); |
| 101 } |
| 102 |
| 103 virtual void onGetGLProcessorKey(const GrGLSLCaps& caps, | 103 virtual void onGetGLProcessorKey(const GrGLSLCaps& caps, |
| 104 GrProcessorKeyBuilder* b) const override { | 104 GrProcessorKeyBuilder* b) const override { |
| 105 GLProcessor::GenKey(*this, caps, b); | 105 GLProcessor::GenKey(*this, caps, b); |
| 106 } | 106 } |
| 107 | 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
), |
| (...skipping 10 matching lines...) Expand all Loading... |
| 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 |