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 "GrGLVertexShaderBuilder.h" | 8 #include "GrGLVertexShaderBuilder.h" |
9 #include "GrGLProgramBuilder.h" | 9 #include "GrGLProgramBuilder.h" |
10 #include "../GrGLGpu.h" | 10 #include "../GrGLGpu.h" |
(...skipping 18 matching lines...) Expand all Loading... |
29 int vaCount = gp.numAttribs(); | 29 int vaCount = gp.numAttribs(); |
30 for (int i = 0; i < vaCount; i++) { | 30 for (int i = 0; i < vaCount; i++) { |
31 this->addAttribute(&gp.getAttrib(i)); | 31 this->addAttribute(&gp.getAttrib(i)); |
32 } | 32 } |
33 return; | 33 return; |
34 } | 34 } |
35 | 35 |
36 void GrGLVertexBuilder::transformToNormalizedDeviceSpace(const GrShaderVar& posV
ar) { | 36 void GrGLVertexBuilder::transformToNormalizedDeviceSpace(const GrShaderVar& posV
ar) { |
37 SkASSERT(!fRtAdjustName); | 37 SkASSERT(!fRtAdjustName); |
38 | 38 |
| 39 GrSLPrecision precision = kDefault_GrSLPrecision; |
| 40 if (fProgramBuilder->ctxInfo().vendor() == kARM_GrGLVendor) { |
| 41 precision = kHigh_GrSLPrecision; |
| 42 } |
| 43 |
39 // setup RT Uniform | 44 // setup RT Uniform |
40 fProgramBuilder->fUniformHandles.fRTAdjustmentUni = | 45 fProgramBuilder->fUniformHandles.fRTAdjustmentUni = |
41 fProgramBuilder->addUniform(GrGLProgramBuilder::kVertex_Visibility, | 46 fProgramBuilder->addUniform(GrGLProgramBuilder::kVertex_Visibility, |
42 kVec4f_GrSLType, kDefault_GrSLPrecision, | 47 kVec4f_GrSLType, precision, |
43 fProgramBuilder->rtAdjustment(), | 48 fProgramBuilder->rtAdjustment(), |
44 &fRtAdjustName); | 49 &fRtAdjustName); |
45 if (this->getProgramBuilder()->desc().header().fSnapVerticesToPixelCenters)
{ | 50 if (this->getProgramBuilder()->desc().header().fSnapVerticesToPixelCenters)
{ |
46 if (kVec3f_GrSLType == posVar.getType()) { | 51 if (kVec3f_GrSLType == posVar.getType()) { |
47 const char* p = posVar.c_str(); | 52 const char* p = posVar.c_str(); |
48 this->codeAppendf("{vec2 _posTmp = vec2(%s.x/%s.z, %s.y/%s.z);", p,
p, p, p); | 53 this->codeAppendf("{vec2 _posTmp = vec2(%s.x/%s.z, %s.y/%s.z);", p,
p, p, p); |
49 } else { | 54 } else { |
50 SkASSERT(kVec2f_GrSLType == posVar.getType()); | 55 SkASSERT(kVec2f_GrSLType == posVar.getType()); |
51 this->codeAppendf("{vec2 _posTmp = %s;", posVar.c_str()); | 56 this->codeAppendf("{vec2 _posTmp = %s;", posVar.c_str()); |
52 } | 57 } |
(...skipping 40 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
93 for (int i = 0; i < fInputs.count(); ++i) { | 98 for (int i = 0; i < fInputs.count(); ++i) { |
94 const GrGLShaderVar& attr = fInputs[i]; | 99 const GrGLShaderVar& attr = fInputs[i]; |
95 // if attribute already added, don't add it again | 100 // if attribute already added, don't add it again |
96 if (attr.getName().equals(var.getName())) { | 101 if (attr.getName().equals(var.getName())) { |
97 return false; | 102 return false; |
98 } | 103 } |
99 } | 104 } |
100 fInputs.push_back(var); | 105 fInputs.push_back(var); |
101 return true; | 106 return true; |
102 } | 107 } |
OLD | NEW |