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 "GrGLShaderStringBuilder.h" | 10 #include "GrGLShaderStringBuilder.h" |
(...skipping 29 matching lines...) Expand all Loading... |
40 // setup RT Uniform | 40 // setup RT Uniform |
41 fProgramBuilder->fUniformHandles.fRTAdjustmentUni = | 41 fProgramBuilder->fUniformHandles.fRTAdjustmentUni = |
42 fProgramBuilder->addUniform(GrGLProgramBuilder::kVertex_Visibility, | 42 fProgramBuilder->addUniform(GrGLProgramBuilder::kVertex_Visibility, |
43 kVec4f_GrSLType, kDefault_GrSLPrecision, | 43 kVec4f_GrSLType, kDefault_GrSLPrecision, |
44 fProgramBuilder->rtAdjustment(), | 44 fProgramBuilder->rtAdjustment(), |
45 &fRtAdjustName); | 45 &fRtAdjustName); |
46 | 46 |
47 // Transform from Skia's device coords to GL's normalized device coords. Not
e that | 47 // Transform from Skia's device coords to GL's normalized device coords. Not
e that |
48 // because we want to "nudge" the device space positions we are converting t
o | 48 // because we want to "nudge" the device space positions we are converting t
o |
49 // non-homogeneous NDC. | 49 // non-homogeneous NDC. |
| 50 // The "0.003" nudge serves to match the raster path's rounding for bw draws
. |
| 51 // For aa draws we just assume the impact will be minimal - so we always per
form the nudge. |
50 if (kVec3f_GrSLType == posVar.getType()) { | 52 if (kVec3f_GrSLType == posVar.getType()) { |
51 this->codeAppendf("gl_Position = vec4(dot(%s.xz, %s.xy)/%s.z, dot(%s.yz,
%s.zw)/%s.z, 0, 1);", | 53 this->codeAppendf("gl_Position = vec4((dot(%s.xz, %s.xy)/%s.z) + 0.003 *
%s.x, (dot(%s.yz, %s.zw)/%s.z) + 0.003 * %s.z, 0, 1);", |
52 posVar.c_str(), fRtAdjustName, posVar.c_str(), | 54 posVar.c_str(), fRtAdjustName, posVar.c_str(), fRtAdju
stName, |
53 posVar.c_str(), fRtAdjustName, posVar.c_str()); | 55 posVar.c_str(), fRtAdjustName, posVar.c_str(), fRtAdju
stName); |
54 } else { | 56 } else { |
55 SkASSERT(kVec2f_GrSLType == posVar.getType()); | 57 SkASSERT(kVec2f_GrSLType == posVar.getType()); |
56 this->codeAppendf("gl_Position = vec4(%s.x * %s.x + %s.y, %s.y * %s.z +
%s.w, 0, 1);", | 58 this->codeAppendf("gl_Position = vec4((%s.x + 0.003) * %s.x + %s.y, (%s.
y + 0.003) * %s.z + %s.w, 0, 1);", |
57 posVar.c_str(), fRtAdjustName, fRtAdjustName, | 59 posVar.c_str(), fRtAdjustName, fRtAdjustName, |
58 posVar.c_str(), fRtAdjustName, fRtAdjustName); | 60 posVar.c_str(), fRtAdjustName, fRtAdjustName); |
59 } | 61 } |
60 | 62 |
61 // We could have the GrGeometryProcessor do this, but its just easier to hav
e it performed here. | 63 // We could have the GrGeometryProcessor do this, but its just easier to hav
e it performed here. |
62 // If we ever need to set variable pointsize, then we can reinvestigate | 64 // If we ever need to set variable pointsize, then we can reinvestigate |
63 this->codeAppend("gl_PointSize = 1.0;"); | 65 this->codeAppend("gl_PointSize = 1.0;"); |
64 } | 66 } |
65 | 67 |
66 void GrGLVertexBuilder::bindVertexAttributes(GrGLuint programID) { | 68 void GrGLVertexBuilder::bindVertexAttributes(GrGLuint programID) { |
(...skipping 33 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
100 for (int i = 0; i < fInputs.count(); ++i) { | 102 for (int i = 0; i < fInputs.count(); ++i) { |
101 const GrGLShaderVar& attr = fInputs[i]; | 103 const GrGLShaderVar& attr = fInputs[i]; |
102 // if attribute already added, don't add it again | 104 // if attribute already added, don't add it again |
103 if (attr.getName().equals(var.getName())) { | 105 if (attr.getName().equals(var.getName())) { |
104 return false; | 106 return false; |
105 } | 107 } |
106 } | 108 } |
107 fInputs.push_back(var); | 109 fInputs.push_back(var); |
108 return true; | 110 return true; |
109 } | 111 } |
OLD | NEW |