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

Unified Diff: src/gpu/GrGeometryProcessor.cpp

Issue 854013002: Refactor position computation to enable device space "nudge" (Closed) Base URL: https://skia.googlesource.com/skia.git@master
Patch Set: Update to ToT Created 5 years, 11 months 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/GrGeometryProcessor.h ('k') | src/gpu/GrOvalRenderer.cpp » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: src/gpu/GrGeometryProcessor.cpp
diff --git a/src/gpu/GrGeometryProcessor.cpp b/src/gpu/GrGeometryProcessor.cpp
index 344dccc731861f7e71b32562eb8b18ced4884049..662f28f38694eaee2556a0eff6b15016b8569469 100644
--- a/src/gpu/GrGeometryProcessor.cpp
+++ b/src/gpu/GrGeometryProcessor.cpp
@@ -163,13 +163,13 @@ void GrGLPrimitiveProcessor::setUniformViewMatrix(const GrGLProgramDataManager&
void GrGLGeometryProcessor::emitCode(EmitArgs& args) {
GrGLVertexBuilder* vsBuilder = args.fPB->getVertexShaderBuilder();
- vsBuilder->codeAppendf("vec3 %s;", this->position());
- this->onEmitCode(args);
- vsBuilder->transformToNormalizedDeviceSpace(this->position());
+ GrGPArgs gpArgs;
+ this->onEmitCode(args, &gpArgs);
+ vsBuilder->transformToNormalizedDeviceSpace(gpArgs.fPositionVar);
}
void GrGLGeometryProcessor::emitTransforms(GrGLGPBuilder* pb,
- const char* position,
+ const GrShaderVar& posVar,
const char* localCoords,
const SkMatrix& localMatrix,
const TransformsIn& tin,
@@ -214,9 +214,19 @@ void GrGLGeometryProcessor::emitTransforms(GrGLGPBuilder* pb,
// varying = matrix * coords (logically)
if (kDevice_GrCoordSet == coordType) {
if (kVec2f_GrSLType == varyingType) {
- vb->codeAppendf("%s = (%s * %s).xy;", v.vsOut(), uniName, position);
+ if (kVec2f_GrSLType == posVar.getType()) {
+ vb->codeAppendf("%s = (%s * vec3(%s, 1)).xy;",
+ v.vsOut(), uniName, posVar.c_str());
+ } else {
+ vb->codeAppendf("%s = (%s * %s).xy;", v.vsOut(), uniName, posVar.c_str());
bsalomon 2015/01/20 15:19:51 Is this right? It seems like we know that the vm i
+ }
} else {
- vb->codeAppendf("%s = %s * %s;", v.vsOut(), uniName, position);
+ if (kVec2f_GrSLType == posVar.getType()) {
+ vb->codeAppendf("%s = %s * vec3(%s, 1);",
+ v.vsOut(), uniName, posVar.c_str());
+ } else {
+ vb->codeAppendf("%s = %s * %s;", v.vsOut(), uniName, posVar.c_str());
+ }
}
} else {
if (kVec2f_GrSLType == varyingType) {
@@ -247,6 +257,28 @@ GrGLGeometryProcessor::setTransformData(const GrPrimitiveProcessor* primProc,
}
}
+void GrGLGeometryProcessor::SetupPosition(GrGLVertexBuilder* vsBuilder,
+ GrGPArgs* gpArgs,
+ const char* posName,
+ const SkMatrix& mat,
+ const char* matName) {
+ if (mat.isIdentity()) {
+ gpArgs->fPositionVar.set(kVec2f_GrSLType, "pos2");
+
+ vsBuilder->codeAppendf("vec2 %s = %s;", gpArgs->fPositionVar.c_str(), posName);
+ } else if (!mat.hasPerspective()) {
+ gpArgs->fPositionVar.set(kVec2f_GrSLType, "pos2");
+
+ vsBuilder->codeAppendf("vec2 %s = vec2(%s * vec3(%s, 1));",
+ gpArgs->fPositionVar.c_str(), matName, posName);
+ } else {
+ gpArgs->fPositionVar.set(kVec3f_GrSLType, "pos3");
+
+ vsBuilder->codeAppendf("vec3 %s = %s * vec3(%s, 1);",
+ gpArgs->fPositionVar.c_str(), matName, posName);
+ }
+}
+
///////////////////////////////////////////////////////////////////////////////////////////////////
#include "gl/GrGLGpu.h"
« no previous file with comments | « src/gpu/GrGeometryProcessor.h ('k') | src/gpu/GrOvalRenderer.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698