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

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

Issue 1881513002: Add appendPrecisionModifier method to GrGLSLShaderBuilder (Closed) Base URL: https://skia.googlesource.com/skia.git@master
Patch Set: Created 4 years, 8 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 | « src/gpu/effects/GrDistanceFieldGeoProc.cpp ('k') | src/gpu/glsl/GrGLSL.h » ('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 "GrTextureDomain.h" 8 #include "GrTextureDomain.h"
9 #include "GrInvariantOutput.h" 9 #include "GrInvariantOutput.h"
10 #include "GrSimpleTextureEffect.h" 10 #include "GrSimpleTextureEffect.h"
(...skipping 85 matching lines...) Expand 10 before | Expand all | Expand 10 after
96 // may require a gradient calculation inside a conditional block 96 // may require a gradient calculation inside a conditional block
97 // may return undefined results". This appears to be an issue wi th 97 // may return undefined results". This appears to be an issue wi th
98 // the 'any' call since even the simple "result=black; if (any() ) 98 // the 'any' call since even the simple "result=black; if (any() )
99 // result=white;" code fails to compile. 99 // result=white;" code fails to compile.
100 builder->codeAppend("vec4 outside = vec4(0.0, 0.0, 0.0, 0.0);"); 100 builder->codeAppend("vec4 outside = vec4(0.0, 0.0, 0.0, 0.0);");
101 builder->codeAppend("vec4 inside = "); 101 builder->codeAppend("vec4 inside = ");
102 builder->appendTextureLookupAndModulate(inModulateColor, sampler , 102 builder->appendTextureLookupAndModulate(inModulateColor, sampler ,
103 inCoords.c_str()); 103 inCoords.c_str());
104 builder->codeAppend(";"); 104 builder->codeAppend(";");
105 105
106 builder->codeAppend(GrGLSLShaderVar::PrecisionString(glslCaps, 106 builder->appendPrecisionModifier(kHigh_GrSLPrecision);
107 kHigh_GrSLP recision));
108 builder->codeAppendf("float x = (%s).x;", inCoords.c_str()); 107 builder->codeAppendf("float x = (%s).x;", inCoords.c_str());
109 builder->codeAppend(GrGLSLShaderVar::PrecisionString(glslCaps, 108 builder->appendPrecisionModifier(kHigh_GrSLPrecision);
110 kHigh_GrSLP recision));
111 builder->codeAppendf("float y = (%s).y;", inCoords.c_str()); 109 builder->codeAppendf("float y = (%s).y;", inCoords.c_str());
112 110
113 builder->codeAppendf("x = abs(2.0*(x - %s.x)/(%s.z - %s.x) - 1.0 );", 111 builder->codeAppendf("x = abs(2.0*(x - %s.x)/(%s.z - %s.x) - 1.0 );",
114 domain, domain, domain); 112 domain, domain, domain);
115 builder->codeAppendf("y = abs(2.0*(y - %s.y)/(%s.w - %s.y) - 1.0 );", 113 builder->codeAppendf("y = abs(2.0*(y - %s.y)/(%s.w - %s.y) - 1.0 );",
116 domain, domain, domain); 114 domain, domain, domain);
117 builder->codeAppend("float blend = step(1.0, max(x, y));"); 115 builder->codeAppend("float blend = step(1.0, max(x, y));");
118 builder->codeAppendf("%s = mix(inside, outside, blend);", outCol or); 116 builder->codeAppendf("%s = mix(inside, outside, blend);", outCol or);
119 } else { 117 } else {
120 builder->codeAppend("bvec4 outside;\n"); 118 builder->codeAppend("bvec4 outside;\n");
(...skipping 173 matching lines...) Expand 10 before | Expand all | Expand 10 after
294 bool bilerp = mode != GrTextureDomain::kRepeat_Mode ? d->fRandom->nextBool() : false; 292 bool bilerp = mode != GrTextureDomain::kRepeat_Mode ? d->fRandom->nextBool() : false;
295 GrCoordSet coords = d->fRandom->nextBool() ? kLocal_GrCoordSet : kDevice_GrC oordSet; 293 GrCoordSet coords = d->fRandom->nextBool() ? kLocal_GrCoordSet : kDevice_GrC oordSet;
296 return GrTextureDomainEffect::Create( 294 return GrTextureDomainEffect::Create(
297 d->fTextures[texIdx], 295 d->fTextures[texIdx],
298 matrix, 296 matrix,
299 domain, 297 domain,
300 mode, 298 mode,
301 bilerp ? GrTextureParams::kBilerp_FilterMode : GrTextureParams::kNone_Fi lterMode, 299 bilerp ? GrTextureParams::kBilerp_FilterMode : GrTextureParams::kNone_Fi lterMode,
302 coords); 300 coords);
303 } 301 }
OLDNEW
« no previous file with comments | « src/gpu/effects/GrDistanceFieldGeoProc.cpp ('k') | src/gpu/glsl/GrGLSL.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698