| 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 "SkLumaXfermode.h" | 8 #include "SkLumaXfermode.h" |
| 9 #include "SkColorPriv.h" | 9 #include "SkColorPriv.h" |
| 10 #include "SkFlattenableBuffers.h" | 10 #include "SkFlattenableBuffers.h" |
| 11 #include "SkString.h" | 11 #include "SkString.h" |
| 12 | 12 |
| 13 #if SK_SUPPORT_GPU | 13 #if SK_SUPPORT_GPU |
| 14 #include "gl/GrGLEffect.h" | 14 #include "gl/GrGLEffect.h" |
| 15 #include "gl/GrGLEffectMatrix.h" | 15 #include "gl/GrGLEffectMatrix.h" |
| 16 #include "GrContext.h" | 16 #include "GrContext.h" |
| 17 #include "GrTBackendEffectFactory.h" | 17 #include "GrTBackendEffectFactory.h" |
| 18 #endif | 18 #endif |
| 19 | 19 |
| 20 class SkLumaMaskXfermodeSrcOver : public SkLumaMaskXfermode { | 20 class SkLumaMaskXfermodeSrcOver : public SkLumaMaskXfermode { |
| 21 typedef SkLumaMaskXfermode INHERITED; |
| 22 |
| 21 public: | 23 public: |
| 22 SkLumaMaskXfermodeSrcOver(); | 24 SkLumaMaskXfermodeSrcOver(); |
| 23 | 25 |
| 24 SK_DECLARE_PUBLIC_FLATTENABLE_DESERIALIZATION_PROCS(SkLumaMaskXfermodeSrcOve
r) | 26 SK_DECLARE_PUBLIC_FLATTENABLE_DESERIALIZATION_PROCS(SkLumaMaskXfermodeSrcOve
r) |
| 25 | 27 |
| 26 protected: | 28 protected: |
| 27 SkLumaMaskXfermodeSrcOver(SkFlattenableReadBuffer&); | 29 SkLumaMaskXfermodeSrcOver(SkFlattenableReadBuffer&); |
| 28 | 30 |
| 29 private: | 31 private: |
| 30 typedef SkLumaMaskXfermode INHERITED; | |
| 31 | 32 |
| 32 virtual SkPMColor lumaProc(const SkPMColor a, const SkPMColor b) const; | 33 virtual SkPMColor lumaProc(const SkPMColor a, const SkPMColor b) const; |
| 33 }; | 34 }; |
| 34 | 35 |
| 35 SkPMColor SkLumaMaskXfermode::lumaProc(const SkPMColor a, const SkPMColor b) con
st { | 36 SkPMColor SkLumaMaskXfermode::lumaProc(const SkPMColor a, const SkPMColor b) con
st { |
| 36 unsigned luma = SkComputeLuminance(SkGetPackedR32(b), | 37 unsigned luma = SkComputeLuminance(SkGetPackedR32(b), |
| 37 SkGetPackedG32(b), | 38 SkGetPackedG32(b), |
| 38 SkGetPackedB32(b)); | 39 SkGetPackedB32(b)); |
| 39 return SkAlphaMulQ(a, SkAlpha255To256(luma)); | 40 return SkAlphaMulQ(a, SkAlpha255To256(luma)); |
| 40 } | 41 } |
| (...skipping 227 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 268 // No background texture support. | 269 // No background texture support. |
| 269 if (effect && !background) { | 270 if (effect && !background) { |
| 270 *effect = GrLumaMaskEffect::Create(fMode); | 271 *effect = GrLumaMaskEffect::Create(fMode); |
| 271 return true; | 272 return true; |
| 272 } | 273 } |
| 273 | 274 |
| 274 return false; | 275 return false; |
| 275 } | 276 } |
| 276 | 277 |
| 277 #endif // SK_SUPPORT_GPU | 278 #endif // SK_SUPPORT_GPU |
| OLD | NEW |