Fix Ganesh perspective projection bug

BUG=skia:3326

Review URL: https://codereview.chromium.org/1352883002
This commit is contained in:
robertphillips 2015-09-17 11:21:06 -07:00 committed by Commit bot
parent 2582dc5395
commit ef4ba3da0b
2 changed files with 7 additions and 5 deletions

View File

@ -72,7 +72,7 @@ public:
* coords. Assuming the transformed position, pos, is a homogeneous vec3, the vec, v, is * coords. Assuming the transformed position, pos, is a homogeneous vec3, the vec, v, is
* applied as such: * applied as such:
* pos.x = dot(v.xy, pos.xz) * pos.x = dot(v.xy, pos.xz)
* pos.y = dot(v.zq, pos.yz) * pos.y = dot(v.zw, pos.yz)
*/ */
void getRTAdjustmentVec(GrGLfloat* destVec) { void getRTAdjustmentVec(GrGLfloat* destVec) {
destVec[0] = 2.f / fRenderTargetSize.fWidth; destVec[0] = 2.f / fRenderTargetSize.fWidth;

View File

@ -58,12 +58,14 @@ void GrGLVertexBuilder::transformToNormalizedDeviceSpace(const GrShaderVar& posV
this->codeAppendf("{vec2 _posTmp = %s;", posVar.c_str()); this->codeAppendf("{vec2 _posTmp = %s;", posVar.c_str());
} }
this->codeAppendf("_posTmp = floor(_posTmp) + vec2(0.5, 0.5);" this->codeAppendf("_posTmp = floor(_posTmp) + vec2(0.5, 0.5);"
"gl_Position = vec4(_posTmp.x * %s.x + %s.y, _posTmp.y * %s.z + %s.w, 0, 1);}", "gl_Position = vec4(_posTmp.x * %s.x + %s.y,"
"_posTmp.y * %s.z + %s.w, 0, 1);}",
fRtAdjustName, fRtAdjustName, fRtAdjustName, fRtAdjustName); fRtAdjustName, fRtAdjustName, fRtAdjustName, fRtAdjustName);
} else if (kVec3f_GrSLType == posVar.getType()) { } else if (kVec3f_GrSLType == posVar.getType()) {
this->codeAppendf("gl_Position = vec4(dot(%s.xz, %s.xy)/%s.z, dot(%s.yz, %s.zw)/%s.z, 0, 1);", this->codeAppendf("gl_Position = vec4(dot(%s.xz, %s.xy), dot(%s.yz, %s.zw), 0, %s.z);",
posVar.c_str(), fRtAdjustName, posVar.c_str(), posVar.c_str(), fRtAdjustName,
posVar.c_str(), fRtAdjustName, posVar.c_str()); posVar.c_str(), fRtAdjustName,
posVar.c_str());
} else { } else {
SkASSERT(kVec2f_GrSLType == posVar.getType()); SkASSERT(kVec2f_GrSLType == posVar.getType());
this->codeAppendf("gl_Position = vec4(%s.x * %s.x + %s.y, %s.y * %s.z + %s.w, 0, 1);", this->codeAppendf("gl_Position = vec4(%s.x * %s.x + %s.y, %s.y * %s.z + %s.w, 0, 1);",