Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(106)

Side by Side Diff: src/gpu/glsl/GrGLSLVertexShaderBuilder.cpp

Issue 1490283004: Create GLSLUniformHandler class for gpu backend (Closed) Base URL: https://skia.googlesource.com/skia.git@master
Patch Set: clean up public api of uniformhandler Created 5 years ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « src/gpu/glsl/GrGLSLVertexShaderBuilder.h ('k') | src/gpu/glsl/GrGLSLXferProcessor.h » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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(const GrShaderVar& po sVar) {
18 SkASSERT(!fRtAdjustName); 19 SkASSERT(!fRtAdjustName);
19 20
20 GrSLPrecision precision = kDefault_GrSLPrecision; 21 GrSLPrecision precision = kDefault_GrSLPrecision;
21 if (fProgramBuilder->glslCaps()->forceHighPrecisionNDSTransform()) { 22 if (fProgramBuilder->glslCaps()->forceHighPrecisionNDSTransform()) {
22 precision = kHigh_GrSLPrecision; 23 precision = kHigh_GrSLPrecision;
23 } 24 }
24 25
25 // setup RT Uniform 26 // setup RT Uniform
26 fProgramBuilder->fUniformHandles.fRTAdjustmentUni = 27 fProgramBuilder->addRTAdjustmentUniform(precision,
27 fProgramBuilder->addUniform(GrGLSLProgramBuilder::kVertex_Visibility , 28 fProgramBuilder->rtAdjustment(),
28 kVec4f_GrSLType, precision, 29 &fRtAdjustName);
29 fProgramBuilder->rtAdjustment(),
30 &fRtAdjustName);
31 if (this->getProgramBuilder()->desc().header().fSnapVerticesToPixelCenters) { 30 if (this->getProgramBuilder()->desc().header().fSnapVerticesToPixelCenters) {
32 if (kVec3f_GrSLType == posVar.getType()) { 31 if (kVec3f_GrSLType == posVar.getType()) {
33 const char* p = posVar.c_str(); 32 const char* p = posVar.c_str();
34 this->codeAppendf("{vec2 _posTmp = vec2(%s.x/%s.z, %s.y/%s.z);", p, p, p, p); 33 this->codeAppendf("{vec2 _posTmp = vec2(%s.x/%s.z, %s.y/%s.z);", p, p, p, p);
35 } else { 34 } else {
36 SkASSERT(kVec2f_GrSLType == posVar.getType()); 35 SkASSERT(kVec2f_GrSLType == posVar.getType());
37 this->codeAppendf("{vec2 _posTmp = %s;", posVar.c_str()); 36 this->codeAppendf("{vec2 _posTmp = %s;", posVar.c_str());
38 } 37 }
39 this->codeAppendf("_posTmp = floor(_posTmp) + vec2(0.5, 0.5);" 38 this->codeAppendf("_posTmp = floor(_posTmp) + vec2(0.5, 0.5);"
40 "gl_Position = vec4(_posTmp.x * %s.x + %s.y," 39 "gl_Position = vec4(_posTmp.x * %s.x + %s.y,"
(...skipping 12 matching lines...) Expand all
53 } 52 }
54 // We could have the GrGeometryProcessor do this, but its just easier to hav e it performed 53 // 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 54 // here. If we ever need to set variable pointsize, then we can reinvestigat e
56 this->codeAppend("gl_PointSize = 1.0;"); 55 this->codeAppend("gl_PointSize = 1.0;");
57 } 56 }
58 57
59 void GrGLSLVertexBuilder::onFinalize() { 58 void GrGLSLVertexBuilder::onFinalize() {
60 fProgramBuilder->varyingHandler()->getVertexDecls(&this->inputs(), &this->ou tputs()); 59 fProgramBuilder->varyingHandler()->getVertexDecls(&this->inputs(), &this->ou tputs());
61 } 60 }
62 61
OLDNEW
« no previous file with comments | « src/gpu/glsl/GrGLSLVertexShaderBuilder.h ('k') | src/gpu/glsl/GrGLSLXferProcessor.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698