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