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 | |
parent | 66644a830f83d6200ddffe3e0e378fe7de83d6d3 (diff) |
Change to create device coord coordset
BUG=skia:
Review URL: https://codereview.chromium.org/812063002
Diffstat (limited to 'src/gpu/gl')
-rw-r--r-- | src/gpu/gl/GrGLProgram.cpp | 3 | ||||
-rw-r--r-- | src/gpu/gl/GrGLProgramDesc.cpp | 7 | ||||
-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 |
5 files changed, 41 insertions, 16 deletions
diff --git a/src/gpu/gl/GrGLProgram.cpp b/src/gpu/gl/GrGLProgram.cpp index 0f4b70de2b..f8770b3664 100644 --- a/src/gpu/gl/GrGLProgram.cpp +++ b/src/gpu/gl/GrGLProgram.cpp @@ -32,7 +32,8 @@ static SkMatrix get_transform_matrix(const GrPendingFragmentStage& stage, int tr SkMatrix combined; if (kLocal_GrCoordSet == coordTransform.sourceCoords()) { - // If we have explicit local coords then we shouldn't need a coord change. + // If we have explicit local coords or are in device coords then we shouldn't need a coord + // change. const SkMatrix& ccm = stage.getCoordChangeMatrix(); combined.setConcat(coordTransform.getMatrix(), ccm); } else { diff --git a/src/gpu/gl/GrGLProgramDesc.cpp b/src/gpu/gl/GrGLProgramDesc.cpp index 06377c758e..6e3128ceaf 100644 --- a/src/gpu/gl/GrGLProgramDesc.cpp +++ b/src/gpu/gl/GrGLProgramDesc.cpp @@ -52,8 +52,9 @@ enum { kPrecisionShift = kMatrixTypeKeyBits, kPositionCoords_Flag = (1 << (kPrecisionShift + kPrecisionBits)), + kDeviceCoords_Flag = kPositionCoords_Flag + kPositionCoords_Flag, - kTransformKeyBits = kMatrixTypeKeyBits + kPrecisionBits + 1, + kTransformKeyBits = kMatrixTypeKeyBits + kPrecisionBits + 2, }; GR_STATIC_ASSERT(kHigh_GrSLPrecision < (1 << kPrecisionBits)); @@ -78,8 +79,10 @@ static uint32_t gen_transform_key(const GrPendingFragmentStage& stage, bool useE } const GrCoordTransform& coordTransform = stage.getProcessor()->coordTransform(t); - if (kLocal_GrCoordSet != coordTransform.sourceCoords() && useExplicitLocalCoords) { + if (kLocal_GrCoordSet == coordTransform.sourceCoords() && !useExplicitLocalCoords) { key |= kPositionCoords_Flag; + } else if (kDevice_GrCoordSet == coordTransform.sourceCoords()) { + key |= kDeviceCoords_Flag; } GR_STATIC_ASSERT(kGrSLPrecisionCount <= (1 << kPrecisionBits)); 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); + } } } |