Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(576)

Side by Side Diff: src/effects/SkDisplacementMapEffect.cpp

Issue 182983003: Factory methods for heap-allocated SkImageFilter objects. (Closed) Base URL: https://skia.googlesource.com/skia.git@master
Patch Set: Rebase Created 6 years, 9 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « samplecode/SampleFilterFuzz.cpp ('k') | src/effects/SkDropShadowImageFilter.cpp » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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 #endif 18 #endif
19 19
20 namespace { 20 namespace {
21 21
22 #define kChannelSelectorKeyBits 3; // Max value is 4, so 3 bits are required at most
23
22 template<SkDisplacementMapEffect::ChannelSelectorType type> 24 template<SkDisplacementMapEffect::ChannelSelectorType type>
23 uint32_t getValue(SkColor, const SkUnPreMultiply::Scale*) { 25 uint32_t getValue(SkColor, const SkUnPreMultiply::Scale*) {
24 SkDEBUGFAIL("Unknown channel selector"); 26 SkDEBUGFAIL("Unknown channel selector");
25 return 0; 27 return 0;
26 } 28 }
27 29
28 template<> uint32_t getValue<SkDisplacementMapEffect::kR_ChannelSelectorType>( 30 template<> uint32_t getValue<SkDisplacementMapEffect::kR_ChannelSelectorType>(
29 SkColor l, const SkUnPreMultiply::Scale* table) { 31 SkColor l, const SkUnPreMultiply::Scale* table) {
30 return SkUnPreMultiply::ApplyScale(table[SkGetPackedA32(l)], SkGetPackedR32( l)); 32 return SkUnPreMultiply::ApplyScale(table[SkGetPackedA32(l)], SkGetPackedR32( l));
31 } 33 }
(...skipping 563 matching lines...) Expand 10 before | Expand all | Expand 10 after
595 colorTex->origin() == kTopLeft_GrSurfaceOrigin ? 597 colorTex->origin() == kTopLeft_GrSurfaceOrigin ?
596 SkScalarToFloat(scaleY) : SkScalarToFloat(-scaleY)); 598 SkScalarToFloat(scaleY) : SkScalarToFloat(-scaleY));
597 } 599 }
598 600
599 GrGLEffect::EffectKey GrGLDisplacementMapEffect::GenKey(const GrDrawEffect& draw Effect, 601 GrGLEffect::EffectKey GrGLDisplacementMapEffect::GenKey(const GrDrawEffect& draw Effect,
600 const GrGLCaps&) { 602 const GrGLCaps&) {
601 const GrDisplacementMapEffect& displacementMap = 603 const GrDisplacementMapEffect& displacementMap =
602 drawEffect.castEffect<GrDisplacementMapEffect>(); 604 drawEffect.castEffect<GrDisplacementMapEffect>();
603 605
604 EffectKey xKey = displacementMap.xChannelSelector(); 606 EffectKey xKey = displacementMap.xChannelSelector();
605 EffectKey yKey = displacementMap.yChannelSelector() << SkDisplacementMapEffe ct::kKeyBits; 607 EffectKey yKey = displacementMap.yChannelSelector() << kChannelSelectorKeyBi ts;
606 608
607 return xKey | yKey; 609 return xKey | yKey;
608 } 610 }
609 #endif 611 #endif
OLDNEW
« no previous file with comments | « samplecode/SampleFilterFuzz.cpp ('k') | src/effects/SkDropShadowImageFilter.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698