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

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

Issue 2114993002: GrFP can express distance vector field req., program builder declares variable for it (Closed) Base URL: https://skia.googlesource.com/skia@dvonbeck-bevel-api-change
Patch Set: rebase Created 4 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
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 "GrGLSLFragmentShaderBuilder.h" 8 #include "GrGLSLFragmentShaderBuilder.h"
9 #include "GrRenderTarget.h" 9 #include "GrRenderTarget.h"
10 #include "GrRenderTargetPriv.h" 10 #include "GrRenderTargetPriv.h"
(...skipping 171 matching lines...) Expand 10 before | Expand all | Expand 10 after
182 this->codePrependf("\t%svec4 %s = vec4(%s.x, %s - %s.y, 1.0, 1.0);\n ", 182 this->codePrependf("\t%svec4 %s = vec4(%s.x, %s - %s.y, 1.0, 1.0);\n ",
183 precision, kCoordName, kTempName, rtHeightName, k TempName); 183 precision, kCoordName, kTempName, rtHeightName, k TempName);
184 this->codePrependf("%svec2 %s = gl_FragCoord.xy;", precision, kTempN ame); 184 this->codePrependf("%svec2 %s = gl_FragCoord.xy;", precision, kTempN ame);
185 fSetupFragPosition = true; 185 fSetupFragPosition = true;
186 } 186 }
187 SkASSERT(fProgramBuilder->fUniformHandles.fRTHeightUni.isValid()); 187 SkASSERT(fProgramBuilder->fUniformHandles.fRTHeightUni.isValid());
188 return kCoordName; 188 return kCoordName;
189 } 189 }
190 } 190 }
191 191
192 bool GrGLSLFragmentShaderBuilder::hasDistanceVectorOutput() const {
193 return !fDistanceVectorOutput.isEmpty();
194 }
195
196 void GrGLSLFragmentShaderBuilder::enableDistanceVector(const SkString& name) {
197 SkASSERT(!this->hasDistanceVectorOutput());
198 fDistanceVectorOutput = name;
199 }
200
201 const char* GrGLSLFragmentShaderBuilder::distanceVectorName() const {
202 SkASSERT(this->hasDistanceVectorOutput());
203 return fDistanceVectorOutput.c_str();
204 }
205
192 void GrGLSLFragmentShaderBuilder::appendOffsetToSample(const char* sampleIdx, Co ordinates coords) { 206 void GrGLSLFragmentShaderBuilder::appendOffsetToSample(const char* sampleIdx, Co ordinates coords) {
193 SkASSERT(fProgramBuilder->header().fSamplePatternKey); 207 SkASSERT(fProgramBuilder->header().fSamplePatternKey);
194 SkDEBUGCODE(fUsedProcessorFeatures |= GrProcessor::kSampleLocations_Required Feature); 208 SkDEBUGCODE(fUsedProcessorFeatures |= GrProcessor::kSampleLocations_Required Feature);
195 if (kTopLeft_GrSurfaceOrigin == this->getSurfaceOrigin()) { 209 if (kTopLeft_GrSurfaceOrigin == this->getSurfaceOrigin()) {
196 // With a top left origin, device and window space are equal, so we only use device coords. 210 // With a top left origin, device and window space are equal, so we only use device coords.
197 coords = kSkiaDevice_Coordinates; 211 coords = kSkiaDevice_Coordinates;
198 } 212 }
199 this->codeAppendf("%s[%s]", sample_offset_array_name(coords), sampleIdx); 213 this->codeAppendf("%s[%s]", sample_offset_array_name(coords), sampleIdx);
200 fUsedSampleOffsetArrays |= (1 << coords); 214 fUsedSampleOffsetArrays |= (1 << coords);
201 } 215 }
(...skipping 183 matching lines...) Expand 10 before | Expand all | Expand 10 after
385 fMangleString.appendf("_c%d", fSubstageIndices[fSubstageIndices.count() - 2] ); 399 fMangleString.appendf("_c%d", fSubstageIndices[fSubstageIndices.count() - 2] );
386 } 400 }
387 401
388 void GrGLSLFragmentShaderBuilder::onAfterChildProcEmitCode() { 402 void GrGLSLFragmentShaderBuilder::onAfterChildProcEmitCode() {
389 SkASSERT(fSubstageIndices.count() >= 2); 403 SkASSERT(fSubstageIndices.count() >= 2);
390 fSubstageIndices.pop_back(); 404 fSubstageIndices.pop_back();
391 fSubstageIndices.back()++; 405 fSubstageIndices.back()++;
392 int removeAt = fMangleString.findLastOf('_'); 406 int removeAt = fMangleString.findLastOf('_');
393 fMangleString.remove(removeAt, fMangleString.size() - removeAt); 407 fMangleString.remove(removeAt, fMangleString.size() - removeAt);
394 } 408 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698