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 40 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
51 &fRtAdjustName); | 51 &fRtAdjustName); |
52 if (this->getProgramBuilder()->desc().header().fSnapVerticesToPixelCenters) { | 52 if (this->getProgramBuilder()->desc().header().fSnapVerticesToPixelCenters) { |
53 if (kVec3f_GrSLType == posVar.getType()) { | 53 if (kVec3f_GrSLType == posVar.getType()) { |
54 const char* p = posVar.c_str(); | 54 const char* p = posVar.c_str(); |
55 this->codeAppendf("{vec2 _posTmp = vec2(%s.x/%s.z, %s.y/%s.z);", p, p, p, p); | 55 this->codeAppendf("{vec2 _posTmp = vec2(%s.x/%s.z, %s.y/%s.z);", p, p, p, p); |
56 } else { | 56 } else { |
57 SkASSERT(kVec2f_GrSLType == posVar.getType()); | 57 SkASSERT(kVec2f_GrSLType == posVar.getType()); |
58 this->codeAppendf("{vec2 _posTmp = %s;", posVar.c_str()); | 58 this->codeAppendf("{vec2 _posTmp = %s;", posVar.c_str()); |
59 } | 59 } |
60 this->codeAppendf("_posTmp = floor(_posTmp) + vec2(0.5, 0.5);" | 60 this->codeAppendf("_posTmp = floor(_posTmp) + vec2(0.5, 0.5);" |
61 "gl_Position = vec4(_posTmp.x * %s.x + %s.y, _posTmp.y * %s.z + %s.w, 0, 1);}", | 61 "gl_Position = vec4(_posTmp.x * %s.x + %s.y, _posTmp.y * %s.z + %s.w, 0, 1);}", |
joshualitt
2015/09/17 16:40:51
line wrap :-p
robertphillips
2015/09/17 16:45:41
Done.
| |
62 fRtAdjustName, fRtAdjustName, fRtAdjustName, fRtAdjust Name); | 62 fRtAdjustName, fRtAdjustName, fRtAdjustName, fRtAdjust Name); |
63 } else if (kVec3f_GrSLType == posVar.getType()) { | 63 } else if (kVec3f_GrSLType == posVar.getType()) { |
64 this->codeAppendf("gl_Position = vec4(dot(%s.xz, %s.xy)/%s.z, dot(%s.yz, %s.zw)/%s.z, 0, 1);", | 64 this->codeAppendf("gl_Position = vec4(dot(%s.xz, %s.xy), dot(%s.yz, %s.z w), 0, %s.z);", |
65 posVar.c_str(), fRtAdjustName, posVar.c_str(), | 65 posVar.c_str(), fRtAdjustName, |
66 posVar.c_str(), fRtAdjustName, posVar.c_str()); | 66 posVar.c_str(), fRtAdjustName, |
67 posVar.c_str()); | |
67 } else { | 68 } else { |
68 SkASSERT(kVec2f_GrSLType == posVar.getType()); | 69 SkASSERT(kVec2f_GrSLType == posVar.getType()); |
69 this->codeAppendf("gl_Position = vec4(%s.x * %s.x + %s.y, %s.y * %s.z + %s.w, 0, 1);", | 70 this->codeAppendf("gl_Position = vec4(%s.x * %s.x + %s.y, %s.y * %s.z + %s.w, 0, 1);", |
70 posVar.c_str(), fRtAdjustName, fRtAdjustName, | 71 posVar.c_str(), fRtAdjustName, fRtAdjustName, |
71 posVar.c_str(), fRtAdjustName, fRtAdjustName); | 72 posVar.c_str(), fRtAdjustName, fRtAdjustName); |
72 } | 73 } |
73 // We could have the GrGeometryProcessor do this, but its just easier to hav e it performed | 74 // We could have the GrGeometryProcessor do this, but its just easier to hav e it performed |
74 // here. If we ever need to set variable pointsize, then we can reinvestigat e | 75 // here. If we ever need to set variable pointsize, then we can reinvestigat e |
75 this->codeAppend("gl_PointSize = 1.0;"); | 76 this->codeAppend("gl_PointSize = 1.0;"); |
76 } | 77 } |
(...skipping 23 matching lines...) Expand all Loading... | |
100 for (int i = 0; i < fInputs.count(); ++i) { | 101 for (int i = 0; i < fInputs.count(); ++i) { |
101 const GrGLShaderVar& attr = fInputs[i]; | 102 const GrGLShaderVar& attr = fInputs[i]; |
102 // if attribute already added, don't add it again | 103 // if attribute already added, don't add it again |
103 if (attr.getName().equals(var.getName())) { | 104 if (attr.getName().equals(var.getName())) { |
104 return false; | 105 return false; |
105 } | 106 } |
106 } | 107 } |
107 fInputs.push_back(var); | 108 fInputs.push_back(var); |
108 return true; | 109 return true; |
109 } | 110 } |
OLD | NEW |