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

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

Issue 22875037: My clang now doesn't complain about !"foo". (Closed) Base URL: https://skia.googlecode.com/svn/trunk
Patch Set: Created 7 years, 4 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 | Annotate | Revision Log
« no previous file with comments | « src/doc/SkDocument.cpp ('k') | src/gpu/GrAtlas.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 "SkFlattenableBuffers.h" 9 #include "SkFlattenableBuffers.h"
10 #include "SkUnPreMultiply.h" 10 #include "SkUnPreMultiply.h"
11 #include "SkColorPriv.h" 11 #include "SkColorPriv.h"
12 #if SK_SUPPORT_GPU 12 #if SK_SUPPORT_GPU
13 #include "GrContext.h" 13 #include "GrContext.h"
14 #include "gl/GrGLEffect.h" 14 #include "gl/GrGLEffect.h"
15 #include "gl/GrGLEffectMatrix.h" 15 #include "gl/GrGLEffectMatrix.h"
16 #include "GrTBackendEffectFactory.h" 16 #include "GrTBackendEffectFactory.h"
17 #include "SkImageFilterUtils.h" 17 #include "SkImageFilterUtils.h"
18 #endif 18 #endif
19 19
20 namespace { 20 namespace {
21 21
22 template<SkDisplacementMapEffect::ChannelSelectorType type> 22 template<SkDisplacementMapEffect::ChannelSelectorType type>
23 uint32_t getValue(SkColor, const SkUnPreMultiply::Scale*) { 23 uint32_t getValue(SkColor, const SkUnPreMultiply::Scale*) {
24 SkASSERT(!"Unknown channel selector"); 24 SkDEBUGFAIL("Unknown channel selector");
25 return 0; 25 return 0;
26 } 26 }
27 27
28 template<> uint32_t getValue<SkDisplacementMapEffect::kR_ChannelSelectorType>( 28 template<> uint32_t getValue<SkDisplacementMapEffect::kR_ChannelSelectorType>(
29 SkColor l, const SkUnPreMultiply::Scale* table) { 29 SkColor l, const SkUnPreMultiply::Scale* table) {
30 return SkUnPreMultiply::ApplyScale(table[SkGetPackedA32(l)], SkGetPackedR32( l)); 30 return SkUnPreMultiply::ApplyScale(table[SkGetPackedA32(l)], SkGetPackedR32( l));
31 } 31 }
32 32
33 template<> uint32_t getValue<SkDisplacementMapEffect::kG_ChannelSelectorType>( 33 template<> uint32_t getValue<SkDisplacementMapEffect::kG_ChannelSelectorType>(
34 SkColor l, const SkUnPreMultiply::Scale* table) { 34 SkColor l, const SkUnPreMultiply::Scale* table) {
(...skipping 55 matching lines...) Expand 10 before | Expand all | Expand 10 after
90 case SkDisplacementMapEffect::kB_ChannelSelectorType: 90 case SkDisplacementMapEffect::kB_ChannelSelectorType:
91 computeDisplacement<typeX, SkDisplacementMapEffect::kB_ChannelSelectorTy pe>( 91 computeDisplacement<typeX, SkDisplacementMapEffect::kB_ChannelSelectorTy pe>(
92 scale, dst, displ, src); 92 scale, dst, displ, src);
93 break; 93 break;
94 case SkDisplacementMapEffect::kA_ChannelSelectorType: 94 case SkDisplacementMapEffect::kA_ChannelSelectorType:
95 computeDisplacement<typeX, SkDisplacementMapEffect::kA_ChannelSelectorTy pe>( 95 computeDisplacement<typeX, SkDisplacementMapEffect::kA_ChannelSelectorTy pe>(
96 scale, dst, displ, src); 96 scale, dst, displ, src);
97 break; 97 break;
98 case SkDisplacementMapEffect::kUnknown_ChannelSelectorType: 98 case SkDisplacementMapEffect::kUnknown_ChannelSelectorType:
99 default: 99 default:
100 SkASSERT(!"Unknown Y channel selector"); 100 SkDEBUGFAIL("Unknown Y channel selector");
101 } 101 }
102 } 102 }
103 103
104 void computeDisplacement(SkDisplacementMapEffect::ChannelSelectorType xChannelSe lector, 104 void computeDisplacement(SkDisplacementMapEffect::ChannelSelectorType xChannelSe lector,
105 SkDisplacementMapEffect::ChannelSelectorType yChannelSe lector, 105 SkDisplacementMapEffect::ChannelSelectorType yChannelSe lector,
106 SkScalar scale, SkBitmap* dst, SkBitmap* displ, SkBitma p* src) 106 SkScalar scale, SkBitmap* dst, SkBitmap* displ, SkBitma p* src)
107 { 107 {
108 switch (xChannelSelector) { 108 switch (xChannelSelector) {
109 case SkDisplacementMapEffect::kR_ChannelSelectorType: 109 case SkDisplacementMapEffect::kR_ChannelSelectorType:
110 computeDisplacement<SkDisplacementMapEffect::kR_ChannelSelectorType>( 110 computeDisplacement<SkDisplacementMapEffect::kR_ChannelSelectorType>(
111 yChannelSelector, scale, dst, displ, src); 111 yChannelSelector, scale, dst, displ, src);
112 break; 112 break;
113 case SkDisplacementMapEffect::kG_ChannelSelectorType: 113 case SkDisplacementMapEffect::kG_ChannelSelectorType:
114 computeDisplacement<SkDisplacementMapEffect::kG_ChannelSelectorType>( 114 computeDisplacement<SkDisplacementMapEffect::kG_ChannelSelectorType>(
115 yChannelSelector, scale, dst, displ, src); 115 yChannelSelector, scale, dst, displ, src);
116 break; 116 break;
117 case SkDisplacementMapEffect::kB_ChannelSelectorType: 117 case SkDisplacementMapEffect::kB_ChannelSelectorType:
118 computeDisplacement<SkDisplacementMapEffect::kB_ChannelSelectorType>( 118 computeDisplacement<SkDisplacementMapEffect::kB_ChannelSelectorType>(
119 yChannelSelector, scale, dst, displ, src); 119 yChannelSelector, scale, dst, displ, src);
120 break; 120 break;
121 case SkDisplacementMapEffect::kA_ChannelSelectorType: 121 case SkDisplacementMapEffect::kA_ChannelSelectorType:
122 computeDisplacement<SkDisplacementMapEffect::kA_ChannelSelectorType>( 122 computeDisplacement<SkDisplacementMapEffect::kA_ChannelSelectorType>(
123 yChannelSelector, scale, dst, displ, src); 123 yChannelSelector, scale, dst, displ, src);
124 break; 124 break;
125 case SkDisplacementMapEffect::kUnknown_ChannelSelectorType: 125 case SkDisplacementMapEffect::kUnknown_ChannelSelectorType:
126 default: 126 default:
127 SkASSERT(!"Unknown X channel selector"); 127 SkDEBUGFAIL("Unknown X channel selector");
128 } 128 }
129 } 129 }
130 130
131 } // end namespace 131 } // end namespace
132 132
133 /////////////////////////////////////////////////////////////////////////////// 133 ///////////////////////////////////////////////////////////////////////////////
134 134
135 SkDisplacementMapEffect::SkDisplacementMapEffect(ChannelSelectorType xChannelSel ector, 135 SkDisplacementMapEffect::SkDisplacementMapEffect(ChannelSelectorType xChannelSel ector,
136 ChannelSelectorType yChannelSel ector, 136 ChannelSelectorType yChannelSel ector,
137 SkScalar scale, 137 SkScalar scale,
(...skipping 311 matching lines...) Expand 10 before | Expand all | Expand 10 after
449 builder->fsCodeAppend("g"); 449 builder->fsCodeAppend("g");
450 break; 450 break;
451 case SkDisplacementMapEffect::kB_ChannelSelectorType: 451 case SkDisplacementMapEffect::kB_ChannelSelectorType:
452 builder->fsCodeAppend("b"); 452 builder->fsCodeAppend("b");
453 break; 453 break;
454 case SkDisplacementMapEffect::kA_ChannelSelectorType: 454 case SkDisplacementMapEffect::kA_ChannelSelectorType:
455 builder->fsCodeAppend("a"); 455 builder->fsCodeAppend("a");
456 break; 456 break;
457 case SkDisplacementMapEffect::kUnknown_ChannelSelectorType: 457 case SkDisplacementMapEffect::kUnknown_ChannelSelectorType:
458 default: 458 default:
459 SkASSERT(!"Unknown X channel selector"); 459 SkDEBUGFAIL("Unknown X channel selector");
460 } 460 }
461 461
462 switch (fYChannelSelector) { 462 switch (fYChannelSelector) {
463 case SkDisplacementMapEffect::kR_ChannelSelectorType: 463 case SkDisplacementMapEffect::kR_ChannelSelectorType:
464 builder->fsCodeAppend("r"); 464 builder->fsCodeAppend("r");
465 break; 465 break;
466 case SkDisplacementMapEffect::kG_ChannelSelectorType: 466 case SkDisplacementMapEffect::kG_ChannelSelectorType:
467 builder->fsCodeAppend("g"); 467 builder->fsCodeAppend("g");
468 break; 468 break;
469 case SkDisplacementMapEffect::kB_ChannelSelectorType: 469 case SkDisplacementMapEffect::kB_ChannelSelectorType:
470 builder->fsCodeAppend("b"); 470 builder->fsCodeAppend("b");
471 break; 471 break;
472 case SkDisplacementMapEffect::kA_ChannelSelectorType: 472 case SkDisplacementMapEffect::kA_ChannelSelectorType:
473 builder->fsCodeAppend("a"); 473 builder->fsCodeAppend("a");
474 break; 474 break;
475 case SkDisplacementMapEffect::kUnknown_ChannelSelectorType: 475 case SkDisplacementMapEffect::kUnknown_ChannelSelectorType:
476 default: 476 default:
477 SkASSERT(!"Unknown Y channel selector"); 477 SkDEBUGFAIL("Unknown Y channel selector");
478 } 478 }
479 builder->fsCodeAppend("-vec2(0.5));\t\t"); 479 builder->fsCodeAppend("-vec2(0.5));\t\t");
480 480
481 // FIXME : This can be achieved with a "clamp to border" texture repeat mode and 481 // FIXME : This can be achieved with a "clamp to border" texture repeat mode and
482 // a 0 border color instead of computing if cCoords is out of bounds here. 482 // a 0 border color instead of computing if cCoords is out of bounds here.
483 builder->fsCodeAppendf( 483 builder->fsCodeAppendf(
484 "bool %s = (%s.x < 0.0) || (%s.y < 0.0) || (%s.x > 1.0) || (%s.y > 1.0); \t\t", 484 "bool %s = (%s.x < 0.0) || (%s.y < 0.0) || (%s.x > 1.0) || (%s.y > 1.0); \t\t",
485 outOfBounds, cCoords, cCoords, cCoords, cCoords); 485 outOfBounds, cCoords, cCoords, cCoords, cCoords);
486 builder->fsCodeAppendf("%s = %s ? vec4(0.0) : ", outputColor, outOfBounds); 486 builder->fsCodeAppendf("%s = %s ? vec4(0.0) : ", outputColor, outOfBounds);
487 builder->appendTextureLookup(GrGLShaderBuilder::kFragment_ShaderType, 487 builder->appendTextureLookup(GrGLShaderBuilder::kFragment_ShaderType,
(...skipping 44 matching lines...) Expand 10 before | Expand all | Expand 10 after
532 colorTex); 532 colorTex);
533 533
534 colorKey <<= GrGLEffectMatrix::kKeyBits; 534 colorKey <<= GrGLEffectMatrix::kKeyBits;
535 EffectKey xKey = displacementMap.xChannelSelector() << (2 * GrGLEffectMatrix ::kKeyBits); 535 EffectKey xKey = displacementMap.xChannelSelector() << (2 * GrGLEffectMatrix ::kKeyBits);
536 EffectKey yKey = displacementMap.yChannelSelector() << (2 * GrGLEffectMatrix ::kKeyBits + 536 EffectKey yKey = displacementMap.yChannelSelector() << (2 * GrGLEffectMatrix ::kKeyBits +
537 SkDisplacementMapEff ect::kKeyBits); 537 SkDisplacementMapEff ect::kKeyBits);
538 538
539 return xKey | yKey | displKey | colorKey; 539 return xKey | yKey | displKey | colorKey;
540 } 540 }
541 #endif 541 #endif
OLDNEW
« no previous file with comments | « src/doc/SkDocument.cpp ('k') | src/gpu/GrAtlas.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698