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

Side by Side Diff: src/gpu/glsl/GrGLSLShaderBuilder.cpp

Issue 1594483003: Texturing support for RECTANGLE textures. (Closed) Base URL: https://skia.googlesource.com/skia.git@rectangle
Patch Set: fix float->int warnings Created 4 years, 11 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/gl/SkGLContext.cpp ('k') | 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 2014 Google Inc. 2 * Copyright 2014 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 "GrSwizzle.h" 8 #include "GrSwizzle.h"
9 #include "glsl/GrGLSLShaderBuilder.h" 9 #include "glsl/GrGLSLShaderBuilder.h"
10 #include "glsl/GrGLSLCaps.h" 10 #include "glsl/GrGLSLCaps.h"
(...skipping 45 matching lines...) Expand 10 before | Expand all | Expand 10 after
56 this->functions().append("}\n\n"); 56 this->functions().append("}\n\n");
57 } 57 }
58 58
59 void GrGLSLShaderBuilder::appendTextureLookup(SkString* out, 59 void GrGLSLShaderBuilder::appendTextureLookup(SkString* out,
60 const GrGLSLTextureSampler& sample r, 60 const GrGLSLTextureSampler& sample r,
61 const char* coordName, 61 const char* coordName,
62 GrSLType varyingType) const { 62 GrSLType varyingType) const {
63 const GrGLSLCaps* glslCaps = fProgramBuilder->glslCaps(); 63 const GrGLSLCaps* glslCaps = fProgramBuilder->glslCaps();
64 GrGLSLUniformHandler* uniformHandler = fProgramBuilder->uniformHandler(); 64 GrGLSLUniformHandler* uniformHandler = fProgramBuilder->uniformHandler();
65 GrSLType samplerType = uniformHandler->getUniformVariable(sampler.fSamplerUn iform).getType(); 65 GrSLType samplerType = uniformHandler->getUniformVariable(sampler.fSamplerUn iform).getType();
66 out->appendf("%s(%s, %s)", 66 if (samplerType == kSampler2DRect_GrSLType) {
67 GrGLSLTexture2DFunctionName(varyingType, samplerType, glslCaps- >generation()), 67 if (varyingType == kVec2f_GrSLType) {
68 uniformHandler->getUniformCStr(sampler.fSamplerUniform), 68 out->appendf("%s(%s, textureSize(%s) * %s)",
69 coordName); 69 GrGLSLTexture2DFunctionName(varyingType, samplerType,
70 glslCaps->generation()),
71 uniformHandler->getUniformCStr(sampler.fSamplerUniform) ,
72 uniformHandler->getUniformCStr(sampler.fSamplerUniform) ,
73 coordName);
74 } else {
75 out->appendf("%s(%s, vec3(textureSize(%s) * %s.xy, %s.z))",
76 GrGLSLTexture2DFunctionName(varyingType, samplerType,
77 glslCaps->generation()),
78 uniformHandler->getUniformCStr(sampler.fSamplerUniform) ,
79 uniformHandler->getUniformCStr(sampler.fSamplerUniform) ,
80 coordName,
81 coordName);
82 }
83 } else {
84 out->appendf("%s(%s, %s)",
85 GrGLSLTexture2DFunctionName(varyingType, samplerType, glslC aps->generation()),
86 uniformHandler->getUniformCStr(sampler.fSamplerUniform),
87 coordName);
88 }
70 89
71 // This refers to any swizzling we may need to get from some backend interna l format to the 90 // This refers to any swizzling we may need to get from some backend interna l format to the
72 // format used in GrPixelConfig. If this is implemented by the GrGpu object, then swizzle will 91 // format used in GrPixelConfig. If this is implemented by the GrGpu object, then swizzle will
73 // be rgba. For shader prettiness we omit the swizzle rather than appending ".rgba". 92 // be rgba. For shader prettiness we omit the swizzle rather than appending ".rgba".
74 const GrSwizzle& configSwizzle = glslCaps->configTextureSwizzle(sampler.conf ig()); 93 const GrSwizzle& configSwizzle = glslCaps->configTextureSwizzle(sampler.conf ig());
75 94
76 if (configSwizzle != GrSwizzle::RGBA()) { 95 if (configSwizzle != GrSwizzle::RGBA()) {
77 out->appendf(".%s", configSwizzle.c_str()); 96 out->appendf(".%s", configSwizzle.c_str());
78 } 97 }
79 } 98 }
(...skipping 68 matching lines...) Expand 10 before | Expand all | Expand 10 after
148 this->code().append("}"); 167 this->code().append("}");
149 168
150 for (int i = 0; i <= fCodeIndex; i++) { 169 for (int i = 0; i <= fCodeIndex; i++) {
151 fCompilerStrings[i] = fShaderStrings[i].c_str(); 170 fCompilerStrings[i] = fShaderStrings[i].c_str();
152 fCompilerStringLengths[i] = (int)fShaderStrings[i].size(); 171 fCompilerStringLengths[i] = (int)fShaderStrings[i].size();
153 } 172 }
154 173
155 fFinalized = true; 174 fFinalized = true;
156 } 175 }
157 176
OLDNEW
« no previous file with comments | « src/gpu/gl/SkGLContext.cpp ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698