| 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 36 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 47 | 47 |
| 48 #ifndef SK_IGNORE_TO_STRING | 48 #ifndef SK_IGNORE_TO_STRING |
| 49 void SkLumaColorFilter::toString(SkString* str) const { | 49 void SkLumaColorFilter::toString(SkString* str) const { |
| 50 str->append("SkLumaColorFilter "); | 50 str->append("SkLumaColorFilter "); |
| 51 } | 51 } |
| 52 #endif | 52 #endif |
| 53 | 53 |
| 54 #if SK_SUPPORT_GPU | 54 #if SK_SUPPORT_GPU |
| 55 class LumaColorFilterEffect : public GrFragmentProcessor { | 55 class LumaColorFilterEffect : public GrFragmentProcessor { |
| 56 public: | 56 public: |
| 57 static GrFragmentProcessor* Create() { | 57 static const GrFragmentProcessor* Create() { |
| 58 static LumaColorFilterEffect gLumaEffect; | 58 static LumaColorFilterEffect gLumaEffect; |
| 59 return SkRef(&gLumaEffect); | 59 return SkRef(&gLumaEffect); |
| 60 } | 60 } |
| 61 | 61 |
| 62 const char* name() const override { return "Luminance-to-Alpha"; } | 62 const char* name() const override { return "Luminance-to-Alpha"; } |
| 63 | 63 |
| 64 class GLProcessor : public GrGLFragmentProcessor { | 64 class GLProcessor : public GrGLFragmentProcessor { |
| 65 public: | 65 public: |
| 66 GLProcessor(const GrProcessor&) {} | 66 GLProcessor(const GrProcessor&) {} |
| 67 | 67 |
| (...skipping 33 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 101 | 101 |
| 102 bool onIsEqual(const GrFragmentProcessor&) const override { return true; } | 102 bool onIsEqual(const GrFragmentProcessor&) const override { return true; } |
| 103 | 103 |
| 104 void onComputeInvariantOutput(GrInvariantOutput* inout) const override { | 104 void onComputeInvariantOutput(GrInvariantOutput* inout) const override { |
| 105 // The output is always black. The alpha value for the color passed in i
s arbitrary. | 105 // The output is always black. The alpha value for the color passed in i
s arbitrary. |
| 106 inout->setToOther(kRGB_GrColorComponentFlags, GrColorPackRGBA(0, 0, 0, 0
), | 106 inout->setToOther(kRGB_GrColorComponentFlags, GrColorPackRGBA(0, 0, 0, 0
), |
| 107 GrInvariantOutput::kWill_ReadInput); | 107 GrInvariantOutput::kWill_ReadInput); |
| 108 } | 108 } |
| 109 }; | 109 }; |
| 110 | 110 |
| 111 bool SkLumaColorFilter::asFragmentProcessors(GrContext*, GrProcessorDataManager*
, | 111 const GrFragmentProcessor* SkLumaColorFilter::asFragmentProcessor(GrContext*, |
| 112 SkTDArray<const GrFragmentProcessor
*>* array) const { | 112 GrProcessorDat
aManager*) const { |
| 113 | 113 |
| 114 GrFragmentProcessor* frag = LumaColorFilterEffect::Create(); | 114 return LumaColorFilterEffect::Create(); |
| 115 if (frag) { | |
| 116 if (array) { | |
| 117 *array->append() = frag; | |
| 118 } else { | |
| 119 frag->unref(); | |
| 120 SkDEBUGCODE(frag = nullptr;) | |
| 121 } | |
| 122 return true; | |
| 123 } | |
| 124 return false; | |
| 125 } | 115 } |
| 126 #endif | 116 #endif |
| OLD | NEW |