diff options
author | joshualitt <joshualitt@chromium.org> | 2014-12-18 07:47:16 -0800 |
---|---|---|
committer | Commit bot <commit-bot@chromium.org> | 2014-12-18 07:47:17 -0800 |
commit | 16b278989532ee9f9a38e3eb4754b228ff495cb8 (patch) | |
tree | e4739a6b85ddd286b0af1788bbdf3fea0b5c585d /src/gpu/gl/builders | |
parent | 66644a830f83d6200ddffe3e0e378fe7de83d6d3 (diff) |
Change to create device coord coordset
BUG=skia:
Review URL: https://codereview.chromium.org/812063002
Diffstat (limited to 'src/gpu/gl/builders')
-rw-r--r-- | src/gpu/gl/builders/GrGLProgramBuilder.cpp | 6 | ||||
-rw-r--r-- | src/gpu/gl/builders/GrGLProgramBuilder.h | 6 | ||||
-rw-r--r-- | src/gpu/gl/builders/GrGLVertexShaderBuilder.cpp | 35 |
3 files changed, 34 insertions, 13 deletions
diff --git a/src/gpu/gl/builders/GrGLProgramBuilder.cpp b/src/gpu/gl/builders/GrGLProgramBuilder.cpp index 6f3214f23a..861410bf13 100644 --- a/src/gpu/gl/builders/GrGLProgramBuilder.cpp +++ b/src/gpu/gl/builders/GrGLProgramBuilder.cpp @@ -401,12 +401,10 @@ void GrGLProgramBuilder::emitTransforms(const GrPendingFragmentStage& stage, varyingName = suffixedVaryingName.c_str(); } - bool useLocalCoords = kLocal_GrCoordSet == processor->coordTransform(t).sourceCoords(); - const char* coords = useLocalCoords ? fVS.localCoords() : fVS.positionCoords(); - + GrCoordSet coordType = processor->coordTransform(t).sourceCoords(); GrGLVertToFrag v(varyingType); this->addVarying(varyingName, &v, precision); - fCoordVaryings.push_back(TransformVarying(v, uniName, coords)); + fCoordVaryings.push_back(TransformVarying(v, uniName, coordType)); SkASSERT(kVec2f_GrSLType == varyingType || kVec3f_GrSLType == varyingType); SkNEW_APPEND_TO_TARRAY(outCoords, GrGLProcessor::TransformedCoords, diff --git a/src/gpu/gl/builders/GrGLProgramBuilder.h b/src/gpu/gl/builders/GrGLProgramBuilder.h index 3fdccca393..032fa57fa2 100644 --- a/src/gpu/gl/builders/GrGLProgramBuilder.h +++ b/src/gpu/gl/builders/GrGLProgramBuilder.h @@ -352,11 +352,11 @@ protected: int stageIndex() const { return fStageIndex; } struct TransformVarying { - TransformVarying(const GrGLVarying& v, const char* uniName, const char* sourceCoords) - : fV(v), fUniName(uniName), fSourceCoords(sourceCoords) {} + TransformVarying(const GrGLVarying& v, const char* uniName, GrCoordSet coordSet) + : fV(v), fUniName(uniName), fCoordSet(coordSet) {} GrGLVarying fV; SkString fUniName; - SkString fSourceCoords; + GrCoordSet fCoordSet; }; const char* rtAdjustment() const { return "rtAdjustment"; } diff --git a/src/gpu/gl/builders/GrGLVertexShaderBuilder.cpp b/src/gpu/gl/builders/GrGLVertexShaderBuilder.cpp index 1d97e85234..317657e61f 100644 --- a/src/gpu/gl/builders/GrGLVertexShaderBuilder.cpp +++ b/src/gpu/gl/builders/GrGLVertexShaderBuilder.cpp @@ -53,16 +53,39 @@ void GrGLVertexBuilder::transformToNormalizedDeviceSpace() { 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(); + GrCoordSet coordSet = transVs[i].fCoordSet; + const char* coords; + switch (coordSet) { + default: + SkFAIL("Case missing"); + case kPosition_GrCoordSet: + coords = this->positionCoords(); + break; + case kLocal_GrCoordSet: + coords = this->localCoords(); + break; + case kDevice_GrCoordSet: + coords = this->glPosition(); + break; + } // 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); + if (kDevice_GrCoordSet == coordSet) { + if (kVec2f_GrSLType == v.fType) { + this->codeAppendf("%s = (%s * %s).xy;", v.fVsOut, transVs[i].fUniName.c_str(), + coords); + } else { + this->codeAppendf("%s = %s * %s;", v.fVsOut, transVs[i].fUniName.c_str(), coords); + } } else { - this->codeAppendf("%s = %s * vec3(%s, 1);", v.fVsOut, transVs[i].fUniName.c_str(), - coords); + 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); + } } } |