| 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 19 matching lines...) Expand all Loading... |
| 30 * LumA = (k1 * r / a + k2 * g / a + k3 * b / a) * a | 30 * LumA = (k1 * r / a + k2 * g / a + k3 * b / a) * a |
| 31 * LumA = (k1 * r + k2 * g + k3 * b) | 31 * LumA = (k1 * r + k2 * g + k3 * b) |
| 32 */ | 32 */ |
| 33 unsigned luma = SkComputeLuminance(SkGetPackedR32(c), | 33 unsigned luma = SkComputeLuminance(SkGetPackedR32(c), |
| 34 SkGetPackedG32(c), | 34 SkGetPackedG32(c), |
| 35 SkGetPackedB32(c)); | 35 SkGetPackedB32(c)); |
| 36 dst[i] = SkPackARGB32(luma, 0, 0, 0); | 36 dst[i] = SkPackARGB32(luma, 0, 0, 0); |
| 37 } | 37 } |
| 38 } | 38 } |
| 39 | 39 |
| 40 SkColorFilter* SkLumaColorFilter::Create() { | 40 SkColorFilter* SkLumaColorFilter::Create() { return new SkLumaColorFilter; } |
| 41 return SkNEW(SkLumaColorFilter); | |
| 42 } | |
| 43 | 41 |
| 44 SkLumaColorFilter::SkLumaColorFilter() : INHERITED() {} | 42 SkLumaColorFilter::SkLumaColorFilter() : INHERITED() {} |
| 45 | 43 |
| 46 SkFlattenable* SkLumaColorFilter::CreateProc(SkReadBuffer&) { | 44 SkFlattenable* SkLumaColorFilter::CreateProc(SkReadBuffer&) { return new SkLumaC
olorFilter; } |
| 47 return SkNEW(SkLumaColorFilter); | |
| 48 } | |
| 49 | 45 |
| 50 void SkLumaColorFilter::flatten(SkWriteBuffer&) const {} | 46 void SkLumaColorFilter::flatten(SkWriteBuffer&) const {} |
| 51 | 47 |
| 52 #ifndef SK_IGNORE_TO_STRING | 48 #ifndef SK_IGNORE_TO_STRING |
| 53 void SkLumaColorFilter::toString(SkString* str) const { | 49 void SkLumaColorFilter::toString(SkString* str) const { |
| 54 str->append("SkLumaColorFilter "); | 50 str->append("SkLumaColorFilter "); |
| 55 } | 51 } |
| 56 #endif | 52 #endif |
| 57 | 53 |
| 58 #if SK_SUPPORT_GPU | 54 #if SK_SUPPORT_GPU |
| (...skipping 30 matching lines...) Expand all Loading... |
| 89 | 85 |
| 90 private: | 86 private: |
| 91 typedef GrGLFragmentProcessor INHERITED; | 87 typedef GrGLFragmentProcessor INHERITED; |
| 92 }; | 88 }; |
| 93 | 89 |
| 94 private: | 90 private: |
| 95 LumaColorFilterEffect() { | 91 LumaColorFilterEffect() { |
| 96 this->initClassID<LumaColorFilterEffect>(); | 92 this->initClassID<LumaColorFilterEffect>(); |
| 97 } | 93 } |
| 98 | 94 |
| 99 GrGLFragmentProcessor* onCreateGLInstance() const override { | 95 GrGLFragmentProcessor* onCreateGLInstance() const override { return new GLPr
ocessor(*this); } |
| 100 return SkNEW_ARGS(GLProcessor, (*this)); | |
| 101 } | |
| 102 | 96 |
| 103 virtual void onGetGLProcessorKey(const GrGLSLCaps& caps, | 97 virtual void onGetGLProcessorKey(const GrGLSLCaps& caps, |
| 104 GrProcessorKeyBuilder* b) const override { | 98 GrProcessorKeyBuilder* b) const override { |
| 105 GLProcessor::GenKey(*this, caps, b); | 99 GLProcessor::GenKey(*this, caps, b); |
| 106 } | 100 } |
| 107 | 101 |
| 108 bool onIsEqual(const GrFragmentProcessor&) const override { return true; } | 102 bool onIsEqual(const GrFragmentProcessor&) const override { return true; } |
| 109 | 103 |
| 110 void onComputeInvariantOutput(GrInvariantOutput* inout) const override { | 104 void onComputeInvariantOutput(GrInvariantOutput* inout) const override { |
| 111 // 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. |
| (...skipping 11 matching lines...) Expand all Loading... |
| 123 *array->append() = frag; | 117 *array->append() = frag; |
| 124 } else { | 118 } else { |
| 125 frag->unref(); | 119 frag->unref(); |
| 126 SkDEBUGCODE(frag = NULL;) | 120 SkDEBUGCODE(frag = NULL;) |
| 127 } | 121 } |
| 128 return true; | 122 return true; |
| 129 } | 123 } |
| 130 return false; | 124 return false; |
| 131 } | 125 } |
| 132 #endif | 126 #endif |
| OLD | NEW |