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

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

Issue 1245703004: Fix tile drop-out on S4 for texture decal mode. (Closed) Base URL: https://skia.googlesource.com/skia.git@master
Patch Set: Fix y denominator Created 5 years, 5 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 | « no previous file | no next file » | 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 "GrTextureDomain.h" 8 #include "GrTextureDomain.h"
9 #include "GrInvariantOutput.h" 9 #include "GrInvariantOutput.h"
10 #include "GrSimpleTextureEffect.h" 10 #include "GrSimpleTextureEffect.h"
(...skipping 46 matching lines...) Expand 10 before | Expand all | Expand 10 after
57 uniName.appendS32(textureDomain.fIndex); 57 uniName.appendS32(textureDomain.fIndex);
58 } 58 }
59 fDomainUni = program->addUniform(GrGLProgramBuilder::kFragment_Visibilit y, 59 fDomainUni = program->addUniform(GrGLProgramBuilder::kFragment_Visibilit y,
60 kVec4f_GrSLType, kDefault_GrSLPrecision , 60 kVec4f_GrSLType, kDefault_GrSLPrecision ,
61 uniName.c_str(), &name); 61 uniName.c_str(), &name);
62 fDomainName = name; 62 fDomainName = name;
63 } 63 }
64 64
65 switch (textureDomain.mode()) { 65 switch (textureDomain.mode()) {
66 case kIgnore_Mode: { 66 case kIgnore_Mode: {
67 builder->codeAppendf("\t%s = ", outColor); 67 builder->codeAppendf("%s = ", outColor);
68 builder->appendTextureLookupAndModulate(inModulateColor, sampler, 68 builder->appendTextureLookupAndModulate(inModulateColor, sampler,
69 inCoords.c_str()); 69 inCoords.c_str());
70 builder->codeAppend(";\n"); 70 builder->codeAppend(";");
71 break; 71 break;
72 } 72 }
73 case kClamp_Mode: { 73 case kClamp_Mode: {
74 SkString clampedCoords; 74 SkString clampedCoords;
75 clampedCoords.appendf("\tclamp(%s, %s.xy, %s.zw)", 75 clampedCoords.appendf("clamp(%s, %s.xy, %s.zw)",
76 inCoords.c_str(), fDomainName.c_str(), fDomain Name.c_str()); 76 inCoords.c_str(), fDomainName.c_str(), fDomain Name.c_str());
77 77
78 builder->codeAppendf("\t%s = ", outColor); 78 builder->codeAppendf("%s = ", outColor);
79 builder->appendTextureLookupAndModulate(inModulateColor, sampler, 79 builder->appendTextureLookupAndModulate(inModulateColor, sampler,
80 clampedCoords.c_str()); 80 clampedCoords.c_str());
81 builder->codeAppend(";\n"); 81 builder->codeAppend(";");
82 break; 82 break;
83 } 83 }
84 case kDecal_Mode: { 84 case kDecal_Mode: {
85 // Add a block since we're going to declare variables. 85 // Add a block since we're going to declare variables.
86 GrGLShaderBuilder::ShaderBlock block(builder); 86 GrGLShaderBuilder::ShaderBlock block(builder);
87 87
88 const char* domain = fDomainName.c_str(); 88 const char* domain = fDomainName.c_str();
89 if (kImagination_GrGLVendor == program->ctxInfo().vendor()) { 89 if (kImagination_GrGLVendor == program->ctxInfo().vendor()) {
90 // On the NexusS and GalaxyNexus, the other path (with the 'any' 90 // On the NexusS and GalaxyNexus, the other path (with the 'any'
91 // call) causes the compilation error "Calls to any function tha t 91 // call) causes the compilation error "Calls to any function tha t
92 // may require a gradient calculation inside a conditional block 92 // may require a gradient calculation inside a conditional block
93 // may return undefined results". This appears to be an issue wi th 93 // may return undefined results". This appears to be an issue wi th
94 // the 'any' call since even the simple "result=black; if (any() ) 94 // the 'any' call since even the simple "result=black; if (any() )
95 // result=white;" code fails to compile. 95 // result=white;" code fails to compile.
96 builder->codeAppend("\tvec4 outside = vec4(0.0, 0.0, 0.0, 0.0);\ n"); 96 builder->codeAppend("vec4 outside = vec4(0.0, 0.0, 0.0, 0.0);");
97 builder->codeAppend("\tvec4 inside = "); 97 builder->codeAppend("vec4 inside = ");
98 builder->appendTextureLookupAndModulate(inModulateColor, sampler , 98 builder->appendTextureLookupAndModulate(inModulateColor, sampler ,
99 inCoords.c_str()); 99 inCoords.c_str());
100 builder->codeAppend(";\n"); 100 builder->codeAppend(";");
101 builder->codeAppendf("\tfloat x = (%s).x;\n", inCoords.c_str()); 101
102 builder->codeAppendf("\tfloat y = (%s).y;\n", inCoords.c_str()); 102 builder->codeAppend(GrGLShaderVar::PrecisionString(kHigh_GrSLPre cision,
103 program->ctxI nfo().standard()));
104 builder->codeAppendf("float x = (%s).x;", inCoords.c_str());
105 builder->codeAppend(GrGLShaderVar::PrecisionString(kHigh_GrSLPre cision,
106 program->ctxI nfo().standard()));
107 builder->codeAppendf("float y = (%s).y;", inCoords.c_str());
103 108
104 builder->codeAppendf("\tx = abs(2.0*(x - %s.x)/(%s.z - %s.x) - 1 .0);\n", 109 builder->codeAppendf("x = abs(2.0*(x - %s.x)/(%s.z - %s.x) - 1.0 );",
105 domain, domain, domain); 110 domain, domain, domain);
106 builder->codeAppendf("\ty = abs(2.0*(y - %s.y)/(%s.w - %s.y) - 1 .0);\n", 111 builder->codeAppendf("y = abs(2.0*(y - %s.y)/(%s.w - %s.y) - 1.0 );",
107 domain, domain, domain); 112 domain, domain, domain);
108 builder->codeAppend("\tfloat blend = step(1.0, max(x, y));\n"); 113 builder->codeAppend("float blend = step(1.0, max(x, y));");
109 builder->codeAppendf("\t%s = mix(inside, outside, blend);\n", ou tColor); 114 builder->codeAppendf("%s = mix(inside, outside, blend);", outCol or);
110 } else { 115 } else {
111 builder->codeAppend("\tbvec4 outside;\n"); 116 builder->codeAppend("bvec4 outside;\n");
112 builder->codeAppendf("\toutside.xy = lessThan(%s, %s.xy);\n", in Coords.c_str(), 117 builder->codeAppendf("outside.xy = lessThan(%s, %s.xy);", inCoor ds.c_str(),
113 domain); 118 domain);
114 builder->codeAppendf("\toutside.zw = greaterThan(%s, %s.zw);\n", inCoords.c_str(), 119 builder->codeAppendf("outside.zw = greaterThan(%s, %s.zw);", inC oords.c_str(),
115 domain); 120 domain);
116 builder->codeAppendf("\t%s = any(outside) ? vec4(0.0, 0.0, 0.0, 0.0) : ", 121 builder->codeAppendf("%s = any(outside) ? vec4(0.0, 0.0, 0.0, 0. 0) : ",
117 outColor); 122 outColor);
118 builder->appendTextureLookupAndModulate(inModulateColor, sampler , 123 builder->appendTextureLookupAndModulate(inModulateColor, sampler ,
119 inCoords.c_str()); 124 inCoords.c_str());
120 builder->codeAppend(";\n"); 125 builder->codeAppend(";");
121 } 126 }
122 break; 127 break;
123 } 128 }
124 case kRepeat_Mode: { 129 case kRepeat_Mode: {
125 SkString clampedCoords; 130 SkString clampedCoords;
126 clampedCoords.printf("\tmod(%s - %s.xy, %s.zw - %s.xy) + %s.xy", 131 clampedCoords.printf("mod(%s - %s.xy, %s.zw - %s.xy) + %s.xy",
127 inCoords.c_str(), fDomainName.c_str(), fDomainN ame.c_str(), 132 inCoords.c_str(), fDomainName.c_str(), fDomainN ame.c_str(),
128 fDomainName.c_str(), fDomainName.c_str()); 133 fDomainName.c_str(), fDomainName.c_str());
129 134
130 builder->codeAppendf("\t%s = ", outColor); 135 builder->codeAppendf("%s = ", outColor);
131 builder->appendTextureLookupAndModulate(inModulateColor, sampler, 136 builder->appendTextureLookupAndModulate(inModulateColor, sampler,
132 clampedCoords.c_str()); 137 clampedCoords.c_str());
133 builder->codeAppend(";\n"); 138 builder->codeAppend(";");
134 break; 139 break;
135 } 140 }
136 } 141 }
137 } 142 }
138 143
139 void GrTextureDomain::GLDomain::setData(const GrGLProgramDataManager& pdman, 144 void GrTextureDomain::GLDomain::setData(const GrGLProgramDataManager& pdman,
140 const GrTextureDomain& textureDomain, 145 const GrTextureDomain& textureDomain,
141 GrSurfaceOrigin textureOrigin) { 146 GrSurfaceOrigin textureOrigin) {
142 SkASSERT(textureDomain.mode() == fMode); 147 SkASSERT(textureDomain.mode() == fMode);
143 if (kIgnore_Mode != textureDomain.mode()) { 148 if (kIgnore_Mode != textureDomain.mode()) {
(...skipping 159 matching lines...) Expand 10 before | Expand all | Expand 10 after
303 bool bilerp = mode != GrTextureDomain::kRepeat_Mode ? d->fRandom->nextBool() : false; 308 bool bilerp = mode != GrTextureDomain::kRepeat_Mode ? d->fRandom->nextBool() : false;
304 GrCoordSet coords = d->fRandom->nextBool() ? kLocal_GrCoordSet : kDevice_GrC oordSet; 309 GrCoordSet coords = d->fRandom->nextBool() ? kLocal_GrCoordSet : kDevice_GrC oordSet;
305 return GrTextureDomainEffect::Create(d->fProcDataManager, 310 return GrTextureDomainEffect::Create(d->fProcDataManager,
306 d->fTextures[texIdx], 311 d->fTextures[texIdx],
307 matrix, 312 matrix,
308 domain, 313 domain,
309 mode, 314 mode,
310 bilerp ? GrTextureParams::kBilerp_Filte rMode : GrTextureParams::kNone_FilterMode, 315 bilerp ? GrTextureParams::kBilerp_Filte rMode : GrTextureParams::kNone_FilterMode,
311 coords); 316 coords);
312 } 317 }
OLDNEW
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698