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 "SkDisplacementMapEffect.h" | 8 #include "SkDisplacementMapEffect.h" |
9 #include "SkReadBuffer.h" | 9 #include "SkReadBuffer.h" |
10 #include "SkWriteBuffer.h" | 10 #include "SkWriteBuffer.h" |
11 #include "SkUnPreMultiply.h" | 11 #include "SkUnPreMultiply.h" |
12 #include "SkColorPriv.h" | 12 #include "SkColorPriv.h" |
13 #if SK_SUPPORT_GPU | 13 #if SK_SUPPORT_GPU |
14 #include "GrContext.h" | 14 #include "GrContext.h" |
15 #include "GrCoordTransform.h" | 15 #include "GrCoordTransform.h" |
16 #include "gl/GrGLEffect.h" | 16 #include "gl/GrGLEffect.h" |
17 #include "GrTBackendEffectFactory.h" | 17 #include "GrTBackendEffectFactory.h" |
18 #include "SkImageFilterUtils.h" | 18 #include "SkImageFilterUtils.h" |
19 #endif | 19 #endif |
20 | 20 |
21 namespace { | 21 namespace { |
22 | 22 |
| 23 #define kChannelSelectorKeyBits 3; // Max value is 4, so 3 bits are required at
most |
| 24 |
23 template<SkDisplacementMapEffect::ChannelSelectorType type> | 25 template<SkDisplacementMapEffect::ChannelSelectorType type> |
24 uint32_t getValue(SkColor, const SkUnPreMultiply::Scale*) { | 26 uint32_t getValue(SkColor, const SkUnPreMultiply::Scale*) { |
25 SkDEBUGFAIL("Unknown channel selector"); | 27 SkDEBUGFAIL("Unknown channel selector"); |
26 return 0; | 28 return 0; |
27 } | 29 } |
28 | 30 |
29 template<> uint32_t getValue<SkDisplacementMapEffect::kR_ChannelSelectorType>( | 31 template<> uint32_t getValue<SkDisplacementMapEffect::kR_ChannelSelectorType>( |
30 SkColor l, const SkUnPreMultiply::Scale* table) { | 32 SkColor l, const SkUnPreMultiply::Scale* table) { |
31 return SkUnPreMultiply::ApplyScale(table[SkGetPackedA32(l)], SkGetPackedR32(
l)); | 33 return SkUnPreMultiply::ApplyScale(table[SkGetPackedA32(l)], SkGetPackedR32(
l)); |
32 } | 34 } |
(...skipping 561 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
594 colorTex->origin() == kTopLeft_GrSurfaceOrigin ? | 596 colorTex->origin() == kTopLeft_GrSurfaceOrigin ? |
595 SkScalarToFloat(scaleY) : SkScalarToFloat(-scaleY)); | 597 SkScalarToFloat(scaleY) : SkScalarToFloat(-scaleY)); |
596 } | 598 } |
597 | 599 |
598 GrGLEffect::EffectKey GrGLDisplacementMapEffect::GenKey(const GrDrawEffect& draw
Effect, | 600 GrGLEffect::EffectKey GrGLDisplacementMapEffect::GenKey(const GrDrawEffect& draw
Effect, |
599 const GrGLCaps&) { | 601 const GrGLCaps&) { |
600 const GrDisplacementMapEffect& displacementMap = | 602 const GrDisplacementMapEffect& displacementMap = |
601 drawEffect.castEffect<GrDisplacementMapEffect>(); | 603 drawEffect.castEffect<GrDisplacementMapEffect>(); |
602 | 604 |
603 EffectKey xKey = displacementMap.xChannelSelector(); | 605 EffectKey xKey = displacementMap.xChannelSelector(); |
604 EffectKey yKey = displacementMap.yChannelSelector() << SkDisplacementMapEffe
ct::kKeyBits; | 606 EffectKey yKey = displacementMap.yChannelSelector() << kChannelSelectorKeyBi
ts; |
605 | 607 |
606 return xKey | yKey; | 608 return xKey | yKey; |
607 } | 609 } |
608 #endif | 610 #endif |
OLD | NEW |