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

Side by Side Diff: src/gpu/effects/GrTextureDomainEffect.cpp

Issue 23826002: Rename ShaderType enum to ShaderVisibility (Closed) Base URL: https://skia.googlecode.com/svn/trunk
Patch Set: Created 7 years, 3 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/gpu/effects/GrSimpleTextureEffect.cpp ('k') | src/gpu/gl/GrGLEffectMatrix.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 2012 Google Inc. 2 * Copyright 2012 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 "GrTextureDomainEffect.h" 8 #include "GrTextureDomainEffect.h"
9 #include "GrSimpleTextureEffect.h" 9 #include "GrSimpleTextureEffect.h"
10 #include "GrTBackendEffectFactory.h" 10 #include "GrTBackendEffectFactory.h"
(...skipping 35 matching lines...) Expand 10 before | Expand all | Expand 10 after
46 const GrDrawEffect& drawEffect, 46 const GrDrawEffect& drawEffect,
47 EffectKey key, 47 EffectKey key,
48 const char* outputColor, 48 const char* outputColor,
49 const char* inputColor, 49 const char* inputColor,
50 const TextureSamplerArray& samplers) { 50 const TextureSamplerArray& samplers) {
51 const GrTextureDomainEffect& texDom = drawEffect.castEffect<GrTextureDomainE ffect>(); 51 const GrTextureDomainEffect& texDom = drawEffect.castEffect<GrTextureDomainE ffect>();
52 52
53 SkString coords; 53 SkString coords;
54 fEffectMatrix.emitCodeMakeFSCoords2D(builder, key, &coords); 54 fEffectMatrix.emitCodeMakeFSCoords2D(builder, key, &coords);
55 const char* domain; 55 const char* domain;
56 fNameUni = builder->addUniform(GrGLShaderBuilder::kFragment_ShaderType, 56 fNameUni = builder->addUniform(GrGLShaderBuilder::kFragment_Visibility,
57 kVec4f_GrSLType, "TexDom", &domain); 57 kVec4f_GrSLType, "TexDom", &domain);
58 if (GrTextureDomainEffect::kClamp_WrapMode == texDom.wrapMode()) { 58 if (GrTextureDomainEffect::kClamp_WrapMode == texDom.wrapMode()) {
59 59
60 builder->fsCodeAppendf("\tvec2 clampCoord = clamp(%s, %s.xy, %s.zw);\n", 60 builder->fsCodeAppendf("\tvec2 clampCoord = clamp(%s, %s.xy, %s.zw);\n",
61 coords.c_str(), domain, domain); 61 coords.c_str(), domain, domain);
62 62
63 builder->fsCodeAppendf("\t%s = ", outputColor); 63 builder->fsCodeAppendf("\t%s = ", outputColor);
64 builder->appendTextureLookupAndModulate(GrGLShaderBuilder::kFragment_Sha derType, 64 builder->fsAppendTextureLookupAndModulate(inputColor, samplers[0], "clam pCoord");
65 inputColor,
66 samplers[0],
67 "clampCoord");
68 builder->fsCodeAppend(";\n"); 65 builder->fsCodeAppend(";\n");
69 } else { 66 } else {
70 SkASSERT(GrTextureDomainEffect::kDecal_WrapMode == texDom.wrapMode()); 67 SkASSERT(GrTextureDomainEffect::kDecal_WrapMode == texDom.wrapMode());
71 68
72 if (kImagination_GrGLVendor == builder->ctxInfo().vendor()) { 69 if (kImagination_GrGLVendor == builder->ctxInfo().vendor()) {
73 // On the NexusS and GalaxyNexus, the other path (with the 'any' 70 // On the NexusS and GalaxyNexus, the other path (with the 'any'
74 // call) causes the compilation error "Calls to any function that 71 // call) causes the compilation error "Calls to any function that
75 // may require a gradient calculation inside a conditional block 72 // may require a gradient calculation inside a conditional block
76 // may return undefined results". This appears to be an issue with 73 // may return undefined results". This appears to be an issue with
77 // the 'any' call since even the simple "result=black; if (any()) 74 // the 'any' call since even the simple "result=black; if (any())
78 // result=white;" code fails to compile. 75 // result=white;" code fails to compile.
79 builder->fsCodeAppend("\tvec4 outside = vec4(0.0, 0.0, 0.0, 0.0);\n" ); 76 builder->fsCodeAppend("\tvec4 outside = vec4(0.0, 0.0, 0.0, 0.0);\n" );
80 builder->fsCodeAppend("\tvec4 inside = "); 77 builder->fsCodeAppend("\tvec4 inside = ");
81 builder->appendTextureLookupAndModulate(GrGLShaderBuilder::kFragment _ShaderType, 78 builder->fsAppendTextureLookupAndModulate(inputColor, samplers[0], c oords.c_str());
82 inputColor,
83 samplers[0],
84 coords.c_str());
85 builder->fsCodeAppend(";\n"); 79 builder->fsCodeAppend(";\n");
86 80
87 builder->fsCodeAppendf("\tfloat x = abs(2.0*(%s.x - %s.x)/(%s.z - %s .x) - 1.0);\n", 81 builder->fsCodeAppendf("\tfloat x = abs(2.0*(%s.x - %s.x)/(%s.z - %s .x) - 1.0);\n",
88 coords.c_str(), domain, domain, domain); 82 coords.c_str(), domain, domain, domain);
89 builder->fsCodeAppendf("\tfloat y = abs(2.0*(%s.y - %s.y)/(%s.w - %s .y) - 1.0);\n", 83 builder->fsCodeAppendf("\tfloat y = abs(2.0*(%s.y - %s.y)/(%s.w - %s .y) - 1.0);\n",
90 coords.c_str(), domain, domain, domain); 84 coords.c_str(), domain, domain, domain);
91 builder->fsCodeAppend("\tfloat blend = step(1.0, max(x, y));\n"); 85 builder->fsCodeAppend("\tfloat blend = step(1.0, max(x, y));\n");
92 builder->fsCodeAppendf("\t%s = mix(inside, outside, blend);\n", outp utColor); 86 builder->fsCodeAppendf("\t%s = mix(inside, outside, blend);\n", outp utColor);
93 } else { 87 } else {
94 builder->fsCodeAppend("\tbvec4 outside;\n"); 88 builder->fsCodeAppend("\tbvec4 outside;\n");
95 builder->fsCodeAppendf("\toutside.xy = lessThan(%s, %s.xy);\n", coor ds.c_str(), domain); 89 builder->fsCodeAppendf("\toutside.xy = lessThan(%s, %s.xy);\n", coor ds.c_str(), domain);
96 builder->fsCodeAppendf("\toutside.zw = greaterThan(%s, %s.zw);\n", c oords.c_str(), domain); 90 builder->fsCodeAppendf("\toutside.zw = greaterThan(%s, %s.zw);\n", c oords.c_str(), domain);
97 builder->fsCodeAppendf("\t%s = any(outside) ? vec4(0.0, 0.0, 0.0, 0. 0) : ", outputColor); 91 builder->fsCodeAppendf("\t%s = any(outside) ? vec4(0.0, 0.0, 0.0, 0. 0) : ", outputColor);
98 builder->appendTextureLookupAndModulate(GrGLShaderBuilder::kFragment _ShaderType, 92 builder->fsAppendTextureLookupAndModulate(inputColor, samplers[0], c oords.c_str());
99 inputColor,
100 samplers[0],
101 coords.c_str());
102 builder->fsCodeAppend(";\n"); 93 builder->fsCodeAppend(";\n");
103 } 94 }
104 } 95 }
105 } 96 }
106 97
107 void GrGLTextureDomainEffect::setData(const GrGLUniformManager& uman, 98 void GrGLTextureDomainEffect::setData(const GrGLUniformManager& uman,
108 const GrDrawEffect& drawEffect) { 99 const GrDrawEffect& drawEffect) {
109 const GrTextureDomainEffect& texDom = drawEffect.castEffect<GrTextureDomainE ffect>(); 100 const GrTextureDomainEffect& texDom = drawEffect.castEffect<GrTextureDomainE ffect>();
110 const SkRect& domain = texDom.domain(); 101 const SkRect& domain = texDom.domain();
111 102
(...skipping 122 matching lines...) Expand 10 before | Expand all | Expand 10 after
234 const SkMatrix& matrix = GrEffectUnitTest::TestMatrix(random); 225 const SkMatrix& matrix = GrEffectUnitTest::TestMatrix(random);
235 bool bilerp = random->nextBool(); 226 bool bilerp = random->nextBool();
236 CoordsType coords = random->nextBool() ? kLocal_CoordsType : kPosition_Coord sType; 227 CoordsType coords = random->nextBool() ? kLocal_CoordsType : kPosition_Coord sType;
237 return GrTextureDomainEffect::Create(textures[texIdx], 228 return GrTextureDomainEffect::Create(textures[texIdx],
238 matrix, 229 matrix,
239 domain, 230 domain,
240 wrapMode, 231 wrapMode,
241 bilerp ? GrTextureParams::kBilerp_Filte rMode : GrTextureParams::kNone_FilterMode, 232 bilerp ? GrTextureParams::kBilerp_Filte rMode : GrTextureParams::kNone_FilterMode,
242 coords); 233 coords);
243 } 234 }
OLDNEW
« no previous file with comments | « src/gpu/effects/GrSimpleTextureEffect.cpp ('k') | src/gpu/gl/GrGLEffectMatrix.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698