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 #include "glsl/GrGLSLUniformHandler.h" |
10 #include "glsl/GrGLSLVarying.h" | 11 #include "glsl/GrGLSLVarying.h" |
11 | 12 |
12 GrGLSLVertexBuilder::GrGLSLVertexBuilder(GrGLSLProgramBuilder* program) | 13 GrGLSLVertexBuilder::GrGLSLVertexBuilder(GrGLSLProgramBuilder* program) |
13 : INHERITED(program) | 14 : INHERITED(program) |
14 , fRtAdjustName(nullptr) { | 15 , fRtAdjustName(nullptr) { |
15 } | 16 } |
16 | 17 |
17 void GrGLSLVertexBuilder::transformToNormalizedDeviceSpace(const GrShaderVar& po
sVar) { | 18 void GrGLSLVertexBuilder::transformToNormalizedDeviceSpace(GrGLSLUniformHandler*
uniformHandler, |
| 19 const GrShaderVar& po
sVar) { |
18 SkASSERT(!fRtAdjustName); | 20 SkASSERT(!fRtAdjustName); |
19 | 21 |
20 GrSLPrecision precision = kDefault_GrSLPrecision; | 22 GrSLPrecision precision = kDefault_GrSLPrecision; |
21 if (fProgramBuilder->glslCaps()->forceHighPrecisionNDSTransform()) { | 23 if (fProgramBuilder->glslCaps()->forceHighPrecisionNDSTransform()) { |
22 precision = kHigh_GrSLPrecision; | 24 precision = kHigh_GrSLPrecision; |
23 } | 25 } |
24 | 26 |
25 // setup RT Uniform | 27 // setup RT Uniform |
26 fProgramBuilder->fUniformHandles.fRTAdjustmentUni = | 28 uniformHandler->addRTAdjustmentUniform(precision, |
27 fProgramBuilder->addUniform(GrGLSLProgramBuilder::kVertex_Visibility
, | 29 fProgramBuilder->rtAdjustment(), |
28 kVec4f_GrSLType, precision, | 30 &fRtAdjustName); |
29 fProgramBuilder->rtAdjustment(), | |
30 &fRtAdjustName); | |
31 if (this->getProgramBuilder()->desc().header().fSnapVerticesToPixelCenters)
{ | 31 if (this->getProgramBuilder()->desc().header().fSnapVerticesToPixelCenters)
{ |
32 if (kVec3f_GrSLType == posVar.getType()) { | 32 if (kVec3f_GrSLType == posVar.getType()) { |
33 const char* p = posVar.c_str(); | 33 const char* p = posVar.c_str(); |
34 this->codeAppendf("{vec2 _posTmp = vec2(%s.x/%s.z, %s.y/%s.z);", p,
p, p, p); | 34 this->codeAppendf("{vec2 _posTmp = vec2(%s.x/%s.z, %s.y/%s.z);", p,
p, p, p); |
35 } else { | 35 } else { |
36 SkASSERT(kVec2f_GrSLType == posVar.getType()); | 36 SkASSERT(kVec2f_GrSLType == posVar.getType()); |
37 this->codeAppendf("{vec2 _posTmp = %s;", posVar.c_str()); | 37 this->codeAppendf("{vec2 _posTmp = %s;", posVar.c_str()); |
38 } | 38 } |
39 this->codeAppendf("_posTmp = floor(_posTmp) + vec2(0.5, 0.5);" | 39 this->codeAppendf("_posTmp = floor(_posTmp) + vec2(0.5, 0.5);" |
40 "gl_Position = vec4(_posTmp.x * %s.x + %s.y," | 40 "gl_Position = vec4(_posTmp.x * %s.x + %s.y," |
(...skipping 12 matching lines...) Expand all Loading... |
53 } | 53 } |
54 // We could have the GrGeometryProcessor do this, but its just easier to hav
e it performed | 54 // We could have the GrGeometryProcessor do this, but its just easier to hav
e it performed |
55 // here. If we ever need to set variable pointsize, then we can reinvestigat
e | 55 // here. If we ever need to set variable pointsize, then we can reinvestigat
e |
56 this->codeAppend("gl_PointSize = 1.0;"); | 56 this->codeAppend("gl_PointSize = 1.0;"); |
57 } | 57 } |
58 | 58 |
59 void GrGLSLVertexBuilder::onFinalize() { | 59 void GrGLSLVertexBuilder::onFinalize() { |
60 fProgramBuilder->varyingHandler()->getVertexDecls(&this->inputs(), &this->ou
tputs()); | 60 fProgramBuilder->varyingHandler()->getVertexDecls(&this->inputs(), &this->ou
tputs()); |
61 } | 61 } |
62 | 62 |
OLD | NEW |