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