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

Unified Diff: src/gpu/gl/builders/GrGLVertexShaderBuilder.cpp

Issue 678953002: Default geometry processor (Closed) Base URL: https://skia.googlesource.com/skia.git@master
Patch Set: fix Created 6 years, 1 month 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « src/gpu/gl/builders/GrGLVertexShaderBuilder.h ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: src/gpu/gl/builders/GrGLVertexShaderBuilder.cpp
diff --git a/src/gpu/gl/builders/GrGLVertexShaderBuilder.cpp b/src/gpu/gl/builders/GrGLVertexShaderBuilder.cpp
index 2bef113410343cdcb3e22132adc9d13c899f35e5..7af5ce9843af40507f694b314b3b7d3db50671af 100644
--- a/src/gpu/gl/builders/GrGLVertexShaderBuilder.cpp
+++ b/src/gpu/gl/builders/GrGLVertexShaderBuilder.cpp
@@ -20,6 +20,7 @@ GrGLVertexBuilder::GrGLVertexBuilder(GrGLProgramBuilder* program)
: INHERITED(program)
, fPositionVar(NULL)
, fLocalCoordsVar(NULL)
+ , fRtAdjustName(NULL)
, fEffectAttribOffset(0) {
}
@@ -31,9 +32,22 @@ void GrGLVertexBuilder::addVarying(const char* name, GrGLVarying* v) {
v->fVsOut = fOutputs.back().getName().c_str();
}
-void GrGLVertexBuilder::setupLocalCoords() {
+void GrGLVertexBuilder::setupUniformViewMatrix() {
+ fProgramBuilder->fUniformHandles.fViewMatrixUni =
+ fProgramBuilder->addUniform(GrGLProgramBuilder::kVertex_Visibility,
+ kMat33f_GrSLType,
+ this->uViewM());
+}
+
+void GrGLVertexBuilder::setupPositionAndLocalCoords() {
+ // Setup position
+ this->codeAppendf("vec3 %s;", this->glPosition());
+
+ // setup position and local coords attribute
fPositionVar = &fInputs.push_back();
- fPositionVar->set(kVec2f_GrSLType, GrGLShaderVar::kAttribute_TypeModifier, "inPosition");
+ fPositionVar->set(kVec2f_GrSLType,
+ GrGLShaderVar::kAttribute_TypeModifier,
+ this->inPosition());
if (-1 != fProgramBuilder->header().fLocalCoordAttributeIndex) {
fLocalCoordsVar = &fInputs.push_back();
fLocalCoordsVar->set(kVec2f_GrSLType,
@@ -45,18 +59,6 @@ void GrGLVertexBuilder::setupLocalCoords() {
fEffectAttribOffset = fInputs.count();
}
-void GrGLVertexBuilder::transformGLToSkiaCoords() {
- const char* viewMName;
- fProgramBuilder->fUniformHandles.fViewMatrixUni =
- fProgramBuilder->addUniform(GrGLProgramBuilder::kVertex_Visibility,
- kMat33f_GrSLType,
- "ViewM",
- &viewMName);
-
- // Transform the position into Skia's device coords.
- this->codeAppendf("vec3 pos3 = %s * vec3(%s, 1);", viewMName, fPositionVar->c_str());
-}
-
void GrGLVertexBuilder::setupBuiltinVertexAttribute(const char* inName, GrGLSLExpr1* out) {
GrGLVertToFrag v(kFloat_GrSLType);
fProgramBuilder->addVarying(inName, &v);
@@ -91,17 +93,34 @@ void GrGLVertexBuilder::emitAttributes(const GrGeometryProcessor& gp) {
}
}
-void GrGLVertexBuilder::transformSkiaToGLCoords() {
- const char* rtAdjustName;
+void GrGLVertexBuilder::transformToNormalizedDeviceSpace() {
+ // setup RT Uniform
fProgramBuilder->fUniformHandles.fRTAdjustmentUni =
fProgramBuilder->addUniform(GrGLProgramBuilder::kVertex_Visibility,
kVec4f_GrSLType,
- "rtAdjustment",
- &rtAdjustName);
+ fProgramBuilder->rtAdjustment(),
+ &fRtAdjustName);
+ // Wire transforms
+ SkTArray<GrGLProgramBuilder::TransformVarying, true>& transVs = fProgramBuilder->fCoordVaryings;
+ int transformCount = transVs.count();
+ for (int i = 0; i < transformCount; i++) {
+ const char* coords = transVs[i].fSourceCoords.c_str();
+
+ // varying = matrix * coords (logically)
+ const GrGLVarying& v = transVs[i].fV;
+ if (kVec2f_GrSLType == v.fType) {
+ this->codeAppendf("%s = (%s * vec3(%s, 1)).xy;", v.fVsOut, transVs[i].fUniName.c_str(),
+ coords);
+ } else {
+ this->codeAppendf("%s = %s * vec3(%s, 1);", v.fVsOut, transVs[i].fUniName.c_str(),
+ coords);
+ }
+ }
// Transform from Skia's device coords to GL's normalized device coords.
- this->codeAppendf("gl_Position = vec4(dot(pos3.xz, %s.xy), dot(pos3.yz, %s.zw), 0, pos3.z);",
- rtAdjustName, rtAdjustName);
+ this->codeAppendf("gl_Position = vec4(dot(%s.xz, %s.xy), dot(%s.yz, %s.zw), 0, %s.z);",
+ this->glPosition(), fRtAdjustName, this->glPosition(), fRtAdjustName,
+ this->glPosition());
}
void GrGLVertexBuilder::bindVertexAttributes(GrGLuint programID) {
« no previous file with comments | « src/gpu/gl/builders/GrGLVertexShaderBuilder.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698