| OLD | NEW |
| 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 "GrGLSLVertexShaderBuilder.h" | 8 #include "GrGLSLVertexShaderBuilder.h" |
| 9 #include "glsl/GrGLSLProgramBuilder.h" | 9 #include "glsl/GrGLSLProgramBuilder.h" |
| 10 | 10 |
| (...skipping 15 matching lines...) Expand all Loading... |
| 26 int vaCount = gp.numAttribs(); | 26 int vaCount = gp.numAttribs(); |
| 27 for (int i = 0; i < vaCount; i++) { | 27 for (int i = 0; i < vaCount; i++) { |
| 28 this->addAttribute(&gp.getAttrib(i)); | 28 this->addAttribute(&gp.getAttrib(i)); |
| 29 } | 29 } |
| 30 return; | 30 return; |
| 31 } | 31 } |
| 32 | 32 |
| 33 void GrGLSLVertexBuilder::transformToNormalizedDeviceSpace(const GrShaderVar& po
sVar) { | 33 void GrGLSLVertexBuilder::transformToNormalizedDeviceSpace(const GrShaderVar& po
sVar) { |
| 34 SkASSERT(!fRtAdjustName); | 34 SkASSERT(!fRtAdjustName); |
| 35 | 35 |
| 36 GrSLPrecision precision = kDefault_GrSLPrecision; | |
| 37 if (fProgramBuilder->glslCaps()->forceHighPrecisionNDSTransform()) { | |
| 38 precision = kHigh_GrSLPrecision; | |
| 39 } | |
| 40 | |
| 41 // setup RT Uniform | 36 // setup RT Uniform |
| 42 fProgramBuilder->fUniformHandles.fRTAdjustmentUni = | 37 fProgramBuilder->fUniformHandles.fRTAdjustmentUni = |
| 43 fProgramBuilder->addUniform(GrGLSLProgramBuilder::kVertex_Visibility
, | 38 fProgramBuilder->addUniform(GrGLSLProgramBuilder::kVertex_Visibility
, |
| 44 kVec4f_GrSLType, precision, | 39 kVec4f_GrSLType, kHigh_GrSLPrecision, |
| 45 fProgramBuilder->rtAdjustment(), | 40 fProgramBuilder->rtAdjustment(), |
| 46 &fRtAdjustName); | 41 &fRtAdjustName); |
| 47 if (this->getProgramBuilder()->desc().header().fSnapVerticesToPixelCenters)
{ | 42 if (this->getProgramBuilder()->desc().header().fSnapVerticesToPixelCenters)
{ |
| 48 if (kVec3f_GrSLType == posVar.getType()) { | 43 if (kVec3f_GrSLType == posVar.getType()) { |
| 49 const char* p = posVar.c_str(); | 44 const char* p = posVar.c_str(); |
| 50 this->codeAppendf("{vec2 _posTmp = vec2(%s.x/%s.z, %s.y/%s.z);", p,
p, p, p); | 45 this->codeAppendf("{vec2 _posTmp = vec2(%s.x/%s.z, %s.y/%s.z);", p,
p, p, p); |
| 51 } else { | 46 } else { |
| 52 SkASSERT(kVec2f_GrSLType == posVar.getType()); | 47 SkASSERT(kVec2f_GrSLType == posVar.getType()); |
| 53 this->codeAppendf("{vec2 _posTmp = %s;", posVar.c_str()); | 48 this->codeAppendf("{vec2 _posTmp = %s;", posVar.c_str()); |
| 54 } | 49 } |
| (...skipping 23 matching lines...) Expand all Loading... |
| 78 const GrGLSLShaderVar& attr = fInputs[i]; | 73 const GrGLSLShaderVar& attr = fInputs[i]; |
| 79 // if attribute already added, don't add it again | 74 // if attribute already added, don't add it again |
| 80 if (attr.getName().equals(var.getName())) { | 75 if (attr.getName().equals(var.getName())) { |
| 81 return false; | 76 return false; |
| 82 } | 77 } |
| 83 } | 78 } |
| 84 fInputs.push_back(var); | 79 fInputs.push_back(var); |
| 85 return true; | 80 return true; |
| 86 } | 81 } |
| 87 | 82 |
| OLD | NEW |