aboutsummaryrefslogtreecommitdiffhomepage
path: root/src/gpu
diff options
context:
space:
mode:
authorGravatar joshualitt <joshualitt@chromium.org>2014-12-29 09:04:40 -0800
committerGravatar Commit bot <commit-bot@chromium.org>2014-12-29 09:04:40 -0800
commit40d4bd8dafe9ed844f29a3de3d8965672248ee73 (patch)
tree44045b2daa070790e500d956fa00510370e7464a /src/gpu
parentd27f73ef27ff65a6a0a5d00aa8e5b784b1a0b47e (diff)
removing coord change matrices
Diffstat (limited to 'src/gpu')
-rw-r--r--src/gpu/GrDrawState.cpp21
-rw-r--r--src/gpu/GrDrawState.h5
-rw-r--r--src/gpu/GrDrawTarget.cpp4
-rw-r--r--src/gpu/GrOptDrawState.cpp8
-rw-r--r--src/gpu/GrPaint.cpp8
-rw-r--r--src/gpu/GrPendingFragmentStage.h21
-rw-r--r--src/gpu/GrProcOptInfo.cpp2
-rw-r--r--src/gpu/gl/GrGLProgram.cpp26
-rw-r--r--src/gpu/gl/GrGLProgramDesc.cpp6
-rw-r--r--src/gpu/gl/builders/GrGLLegacyNvprProgramBuilder.cpp2
-rw-r--r--src/gpu/gl/builders/GrGLNvprProgramBuilder.cpp2
-rw-r--r--src/gpu/gl/builders/GrGLProgramBuilder.cpp20
12 files changed, 37 insertions, 88 deletions
diff --git a/src/gpu/GrDrawState.cpp b/src/gpu/GrDrawState.cpp
index 67a356a1fa..6694100cc2 100644
--- a/src/gpu/GrDrawState.cpp
+++ b/src/gpu/GrDrawState.cpp
@@ -30,14 +30,12 @@ bool GrDrawState::isEqual(const GrDrawState& that, bool explicitLocalCoords) con
}
for (int i = 0; i < this->numColorStages(); i++) {
- if (!GrFragmentStage::AreCompatible(this->getColorStage(i), that.getColorStage(i),
- explicitLocalCoords)) {
+ if (this->getColorStage(i) != that.getColorStage(i)) {
return false;
}
}
for (int i = 0; i < this->numCoverageStages(); i++) {
- if (!GrFragmentStage::AreCompatible(this->getCoverageStage(i), that.getCoverageStage(i),
- explicitLocalCoords)) {
+ if (this->getCoverageStage(i) != that.getCoverageStage(i)) {
return false;
}
}
@@ -45,20 +43,7 @@ bool GrDrawState::isEqual(const GrDrawState& that, bool explicitLocalCoords) con
return true;
}
-//////////////////////////////////////////////////////////////////////////////s
-
-GrDrawState::GrDrawState(const GrDrawState& state, const SkMatrix& preConcatMatrix) {
- SkDEBUGCODE(fBlockEffectRemovalCnt = 0;)
- *this = state;
- if (!preConcatMatrix.isIdentity()) {
- for (int i = 0; i < this->numColorStages(); ++i) {
- fColorStages[i].localCoordChange(preConcatMatrix);
- }
- for (int i = 0; i < this->numCoverageStages(); ++i) {
- fCoverageStages[i].localCoordChange(preConcatMatrix);
- }
- }
-}
+//////////////////////////////////////////////////////////////////////////////
GrDrawState& GrDrawState::operator=(const GrDrawState& that) {
fRenderTarget.reset(SkSafeRef(that.fRenderTarget.get()));
diff --git a/src/gpu/GrDrawState.h b/src/gpu/GrDrawState.h
index 1f469d537e..b552e77e05 100644
--- a/src/gpu/GrDrawState.h
+++ b/src/gpu/GrDrawState.h
@@ -48,11 +48,6 @@ public:
*this = state;
}
- /**
- * Copies another draw state with a preconcat to the view matrix.
- **/
- GrDrawState(const GrDrawState& state, const SkMatrix& preConcatMatrix);
-
virtual ~GrDrawState();
/**
diff --git a/src/gpu/GrDrawTarget.cpp b/src/gpu/GrDrawTarget.cpp
index 18ea72cd57..1b641d84e4 100644
--- a/src/gpu/GrDrawTarget.cpp
+++ b/src/gpu/GrDrawTarget.cpp
@@ -359,7 +359,7 @@ bool GrDrawTarget::checkDraw(const GrDrawState& drawState,
}
for (int s = 0; s < drawState.numColorStages(); ++s) {
- const GrProcessor* effect = drawState.getColorStage(s).getProcessor();
+ const GrProcessor* effect = drawState.getColorStage(s).processor();
int numTextures = effect->numTextures();
for (int t = 0; t < numTextures; ++t) {
GrTexture* texture = effect->texture(t);
@@ -367,7 +367,7 @@ bool GrDrawTarget::checkDraw(const GrDrawState& drawState,
}
}
for (int s = 0; s < drawState.numCoverageStages(); ++s) {
- const GrProcessor* effect = drawState.getCoverageStage(s).getProcessor();
+ const GrProcessor* effect = drawState.getCoverageStage(s).processor();
int numTextures = effect->numTextures();
for (int t = 0; t < numTextures; ++t) {
GrTexture* texture = effect->texture(t);
diff --git a/src/gpu/GrOptDrawState.cpp b/src/gpu/GrOptDrawState.cpp
index 082db326a5..eea022236e 100644
--- a/src/gpu/GrOptDrawState.cpp
+++ b/src/gpu/GrOptDrawState.cpp
@@ -112,18 +112,18 @@ GrOptDrawState::GrOptDrawState(const GrDrawState& drawState,
for (int i = firstColorStageIdx; i < drawState.numColorStages(); ++i) {
SkNEW_APPEND_TO_TARRAY(&fFragmentStages,
GrPendingFragmentStage,
- (drawState.fColorStages[i], hasLocalCoords));
+ (drawState.fColorStages[i]));
usesLocalCoords = usesLocalCoords ||
- drawState.fColorStages[i].getProcessor()->usesLocalCoords();
+ drawState.fColorStages[i].processor()->usesLocalCoords();
}
fNumColorStages = fFragmentStages.count();
for (int i = firstCoverageStageIdx; i < drawState.numCoverageStages(); ++i) {
SkNEW_APPEND_TO_TARRAY(&fFragmentStages,
GrPendingFragmentStage,
- (drawState.fCoverageStages[i], hasLocalCoords));
+ (drawState.fCoverageStages[i]));
usesLocalCoords = usesLocalCoords ||
- drawState.fCoverageStages[i].getProcessor()->usesLocalCoords();
+ drawState.fCoverageStages[i].processor()->usesLocalCoords();
}
// let the GP init the batch tracker
diff --git a/src/gpu/GrPaint.cpp b/src/gpu/GrPaint.cpp
index da6408c9c5..1df2b39d1c 100644
--- a/src/gpu/GrPaint.cpp
+++ b/src/gpu/GrPaint.cpp
@@ -21,14 +21,14 @@ void GrPaint::addCoverageTextureProcessor(GrTexture* texture, const SkMatrix& ma
}
void GrPaint::addColorTextureProcessor(GrTexture* texture,
- const SkMatrix& matrix,
- const GrTextureParams& params) {
+ const SkMatrix& matrix,
+ const GrTextureParams& params) {
this->addColorProcessor(GrSimpleTextureEffect::Create(texture, matrix, params))->unref();
}
void GrPaint::addCoverageTextureProcessor(GrTexture* texture,
- const SkMatrix& matrix,
- const GrTextureParams& params) {
+ const SkMatrix& matrix,
+ const GrTextureParams& params) {
this->addCoverageProcessor(GrSimpleTextureEffect::Create(texture, matrix, params))->unref();
}
diff --git a/src/gpu/GrPendingFragmentStage.h b/src/gpu/GrPendingFragmentStage.h
index 6c61029eca..0bf984ab7d 100644
--- a/src/gpu/GrPendingFragmentStage.h
+++ b/src/gpu/GrPendingFragmentStage.h
@@ -12,55 +12,42 @@
#include "GrCoordTransform.h"
#include "GrFragmentProcessor.h"
#include "GrPendingProgramElement.h"
-#include "SkMatrix.h"
/**
* This a baked variant of GrFragmentStage, as recorded in GrOptDrawState.
*/
class GrPendingFragmentStage {
public:
- GrPendingFragmentStage(const GrFragmentStage& stage, bool ignoreMatrix)
- : fProc(stage.getProcessor())
- , fCoordChangeMatrix(ignoreMatrix ? SkMatrix::I() : stage.getCoordChangeMatrix()) {
- }
+ GrPendingFragmentStage(const GrFragmentStage& stage) : fProc(stage.processor()) {}
GrPendingFragmentStage(const GrPendingFragmentStage& that) { *this = that; }
GrPendingFragmentStage& operator=(const GrPendingFragmentStage& that) {
fProc.reset(that.fProc.get());
- fCoordChangeMatrix = that.fCoordChangeMatrix;
return *this;
}
bool operator==(const GrPendingFragmentStage& that) const {
- return this->getProcessor()->isEqual(*that.getProcessor()) &&
- fCoordChangeMatrix == that.fCoordChangeMatrix;
+ return this->processor()->isEqual(*that.processor());
}
bool operator!=(const GrPendingFragmentStage& that) const { return !(*this == that); }
- const SkMatrix& getCoordChangeMatrix() const { return fCoordChangeMatrix; }
-
/**
* For a coord transform on the fragment processor, does it or the coord change matrix (if
* relevant) contain perspective?
*/
bool isPerspectiveCoordTransform(int matrixIndex) const {
- const GrCoordTransform& coordTransform = this->getProcessor()->coordTransform(matrixIndex);
+ const GrCoordTransform& coordTransform = this->processor()->coordTransform(matrixIndex);
uint32_t type = coordTransform.getMatrix().getType();
- if (kLocal_GrCoordSet == coordTransform.sourceCoords()) {
- type |= this->getCoordChangeMatrix().getType();
- }
-
return SkToBool(SkMatrix::kPerspective_Mask & type);
}
const char* name() const { return fProc->name(); }
- const GrFragmentProcessor* getProcessor() const { return fProc.get(); }
+ const GrFragmentProcessor* processor() const { return fProc.get(); }
protected:
GrPendingProgramElement<const GrFragmentProcessor> fProc;
- SkMatrix fCoordChangeMatrix;
};
#endif
diff --git a/src/gpu/GrProcOptInfo.cpp b/src/gpu/GrProcOptInfo.cpp
index 6fad760071..274c5305de 100644
--- a/src/gpu/GrProcOptInfo.cpp
+++ b/src/gpu/GrProcOptInfo.cpp
@@ -52,7 +52,7 @@ void GrProcOptInfo::internalCalc(const GrFragmentStage* stages,
fReadsFragPosition = initWillReadFragmentPosition;
for (int i = 0; i < stageCount; ++i) {
- const GrFragmentProcessor* processor = stages[i].getProcessor();
+ const GrFragmentProcessor* processor = stages[i].processor();
fInOut.resetWillUseInputColor();
processor->computeInvariantOutput(&fInOut);
SkDEBUGCODE(fInOut.validate());
diff --git a/src/gpu/gl/GrGLProgram.cpp b/src/gpu/gl/GrGLProgram.cpp
index 245086db6c..60d97a2969 100644
--- a/src/gpu/gl/GrGLProgram.cpp
+++ b/src/gpu/gl/GrGLProgram.cpp
@@ -30,24 +30,12 @@
static SkMatrix get_transform_matrix(const GrPendingFragmentStage& stage,
int transformIdx,
const SkMatrix& localMatrix) {
- const GrCoordTransform& coordTransform = stage.getProcessor()->coordTransform(transformIdx);
+ const GrCoordTransform& coordTransform = stage.processor()->coordTransform(transformIdx);
SkMatrix combined;
+ // We only apply the localmatrix to localcoords
if (kLocal_GrCoordSet == coordTransform.sourceCoords()) {
- // If we have explicit local coords or are in device coords then we shouldn't need a coord
- // change.
- // TODO shortly we will get rid of coord change matrices entirely, and the PrimProc will
- // always have a local matrix, often Identity, which can be used to transform coord
- // transforms. Until we actually do this, we need some way for a PrimProc to say 'use my
- // matrix' instead of the coord change mechanism. Temporarily, we have overloaded
- // The identity matrix to be this value, ie if a primproc has an identity matrix for a
- // local matrix then use the coord change matrix, otherwise use the matrix on the primproc
- if (localMatrix.isIdentity()) {
- const SkMatrix& ccm = stage.getCoordChangeMatrix();
- combined.setConcat(coordTransform.getMatrix(), ccm);
- } else {
- combined.setConcat(coordTransform.getMatrix(), localMatrix);
- }
+ combined.setConcat(coordTransform.getMatrix(), localMatrix);
} else {
combined = coordTransform.getMatrix();
}
@@ -190,7 +178,7 @@ void GrGLProgram::setFragmentData(const GrOptDrawState& optState) {
int numProcessors = fFragmentProcessors->fProcs.count();
for (int e = 0; e < numProcessors; ++e) {
const GrPendingFragmentStage& stage = optState.getFragmentStage(e);
- const GrProcessor& processor = *stage.getProcessor();
+ const GrProcessor& processor = *stage.processor();
fFragmentProcessors->fProcs[e]->fGLProc->setData(fProgramDataManager, processor);
const SkMatrix& localMatrix = optState.getPrimitiveProcessor()->localMatrix();
this->setTransformData(stage, localMatrix, fFragmentProcessors->fProcs[e]);
@@ -202,7 +190,7 @@ void GrGLProgram::setTransformData(const GrPendingFragmentStage& processor,
GrGLInstalledFragProc* ip) {
SkTArray<GrGLInstalledFragProc::Transform, true>& transforms = ip->fTransforms;
int numTransforms = transforms.count();
- SkASSERT(numTransforms == processor.getProcessor()->numTransforms());
+ SkASSERT(numTransforms == processor.processor()->numTransforms());
for (int t = 0; t < numTransforms; ++t) {
SkASSERT(transforms[t].fHandle.isValid());
const SkMatrix& matrix = get_transform_matrix(processor, t, localMatrix);
@@ -309,7 +297,7 @@ void GrGLNvprProgram::setTransformData(const GrPendingFragmentStage& proc,
GrGLInstalledFragProc* ip) {
SkTArray<GrGLInstalledFragProc::Transform, true>& transforms = ip->fTransforms;
int numTransforms = transforms.count();
- SkASSERT(numTransforms == proc.getProcessor()->numTransforms());
+ SkASSERT(numTransforms == proc.processor()->numTransforms());
for (int t = 0; t < numTransforms; ++t) {
SkASSERT(transforms[t].fHandle.isValid());
const SkMatrix& transform = get_transform_matrix(proc, t, localMatrix);
@@ -354,7 +342,7 @@ GrGLLegacyNvprProgram::setTransformData(const GrPendingFragmentStage& proc,
GrGLInstalledFragProc* ip) {
// We've hidden the texcoord index in the first entry of the transforms array for each effect
int texCoordIndex = ip->fTransforms[0].fHandle.handle();
- int numTransforms = proc.getProcessor()->numTransforms();
+ int numTransforms = proc.processor()->numTransforms();
for (int t = 0; t < numTransforms; ++t) {
const SkMatrix& transform = get_transform_matrix(proc, t, localMatrix);
GrGLPathRendering::PathTexGenComponents components =
diff --git a/src/gpu/gl/GrGLProgramDesc.cpp b/src/gpu/gl/GrGLProgramDesc.cpp
index 76e9e0a64e..d5dc84c65b 100644
--- a/src/gpu/gl/GrGLProgramDesc.cpp
+++ b/src/gpu/gl/GrGLProgramDesc.cpp
@@ -69,7 +69,7 @@ enum MatrixType {
static uint32_t gen_transform_key(const GrPendingFragmentStage& stage, bool useExplicitLocalCoords) {
uint32_t totalKey = 0;
- int numTransforms = stage.getProcessor()->numTransforms();
+ int numTransforms = stage.processor()->numTransforms();
for (int t = 0; t < numTransforms; ++t) {
uint32_t key = 0;
if (stage.isPerspectiveCoordTransform(t)) {
@@ -78,7 +78,7 @@ static uint32_t gen_transform_key(const GrPendingFragmentStage& stage, bool useE
key |= kNoPersp_MatrixType;
}
- const GrCoordTransform& coordTransform = stage.getProcessor()->coordTransform(t);
+ const GrCoordTransform& coordTransform = stage.processor()->coordTransform(t);
if (kLocal_GrCoordSet == coordTransform.sourceCoords() && !useExplicitLocalCoords) {
key |= kPositionCoords_Flag;
} else if (kDevice_GrCoordSet == coordTransform.sourceCoords()) {
@@ -170,7 +170,7 @@ bool GrGLProgramDescBuilder::Build(const GrOptDrawState& optState,
for (int s = 0; s < optState.numFragmentStages(); ++s) {
const GrPendingFragmentStage& fps = optState.getFragmentStage(s);
- const GrFragmentProcessor& fp = *fps.getProcessor();
+ const GrFragmentProcessor& fp = *fps.processor();
fp.getGLProcessorKey(gpu->glCaps(), &b);
if (!get_meta_key(fp, gpu->glCaps(),
gen_transform_key(fps, requiresLocalCoordAttrib), &b)) {
diff --git a/src/gpu/gl/builders/GrGLLegacyNvprProgramBuilder.cpp b/src/gpu/gl/builders/GrGLLegacyNvprProgramBuilder.cpp
index f7600f50cc..e8b4075b03 100644
--- a/src/gpu/gl/builders/GrGLLegacyNvprProgramBuilder.cpp
+++ b/src/gpu/gl/builders/GrGLLegacyNvprProgramBuilder.cpp
@@ -24,7 +24,7 @@ int GrGLLegacyNvprProgramBuilder::addTexCoordSets(int count) {
void GrGLLegacyNvprProgramBuilder::emitTransforms(const GrPendingFragmentStage& processorStage,
GrGLProcessor::TransformedCoordsArray* outCoords,
GrGLInstalledFragProc* ifp) {
- int numTransforms = processorStage.getProcessor()->numTransforms();
+ int numTransforms = processorStage.processor()->numTransforms();
int texCoordIndex = this->addTexCoordSets(numTransforms);
// Use the first uniform location as the texcoord index. This may seem a bit hacky but it
diff --git a/src/gpu/gl/builders/GrGLNvprProgramBuilder.cpp b/src/gpu/gl/builders/GrGLNvprProgramBuilder.cpp
index c45a911a06..e50037d098 100644
--- a/src/gpu/gl/builders/GrGLNvprProgramBuilder.cpp
+++ b/src/gpu/gl/builders/GrGLNvprProgramBuilder.cpp
@@ -20,7 +20,7 @@ GrGLNvprProgramBuilder::GrGLNvprProgramBuilder(GrGLGpu* gpu,
void GrGLNvprProgramBuilder::emitTransforms(const GrPendingFragmentStage& processorStage,
GrGLProcessor::TransformedCoordsArray* outCoords,
GrGLInstalledFragProc* ifp) {
- const GrFragmentProcessor* effect = processorStage.getProcessor();
+ const GrFragmentProcessor* effect = processorStage.processor();
int numTransforms = effect->numTransforms();
ifp->fTransforms.push_back_n(numTransforms);
diff --git a/src/gpu/gl/builders/GrGLProgramBuilder.cpp b/src/gpu/gl/builders/GrGLProgramBuilder.cpp
index 13a14534cf..c414aba9ff 100644
--- a/src/gpu/gl/builders/GrGLProgramBuilder.cpp
+++ b/src/gpu/gl/builders/GrGLProgramBuilder.cpp
@@ -277,7 +277,7 @@ void GrGLProgramBuilder::emitAndInstallProc(const GrPendingFragmentStage& fs,
const char* inColor) {
GrGLInstalledFragProc* ifp = SkNEW(GrGLInstalledFragProc);
- const GrFragmentProcessor& fp = *fs.getProcessor();
+ const GrFragmentProcessor& fp = *fs.processor();
ifp->fGLProc.reset(fp.createGLInstance());
SkSTArray<4, GrGLProcessor::TextureSampler> samplers(fp.numTextures());
@@ -372,7 +372,7 @@ void GrGLProgramBuilder::verify(const GrFragmentProcessor& fp) {
void GrGLProgramBuilder::emitTransforms(const GrPendingFragmentStage& stage,
GrGLProcessor::TransformedCoordsArray* outCoords,
GrGLInstalledFragProc* ifp) {
- const GrFragmentProcessor* processor = stage.getProcessor();
+ const GrFragmentProcessor* processor = stage.processor();
int numTransforms = processor->numTransforms();
ifp->fTransforms.push_back_n(numTransforms);
@@ -380,20 +380,14 @@ void GrGLProgramBuilder::emitTransforms(const GrPendingFragmentStage& stage,
const char* uniName = "StageMatrix";
GrSLType varyingType;
- // TODO when we have deleted the coord change matrices we can get rid of the below check
GrCoordSet coordType = processor->coordTransform(t).sourceCoords();
const SkMatrix& localMatrix = fOptState.getPrimitiveProcessor()->localMatrix();
- if (localMatrix.isIdentity()) {
- varyingType = stage.isPerspectiveCoordTransform(t) ? kVec3f_GrSLType :
- kVec2f_GrSLType;
- } else {
- uint32_t type = processor->coordTransform(t).getMatrix().getType();
- if (kLocal_GrCoordSet == coordType) {
- type |= localMatrix.getType();
- }
- varyingType = SkToBool(SkMatrix::kPerspective_Mask & type) ? kVec3f_GrSLType :
- kVec2f_GrSLType;
+ uint32_t type = processor->coordTransform(t).getMatrix().getType();
+ if (kLocal_GrCoordSet == coordType) {
+ type |= localMatrix.getType();
}
+ varyingType = SkToBool(SkMatrix::kPerspective_Mask & type) ? kVec3f_GrSLType :
+ kVec2f_GrSLType;
GrSLPrecision precision = processor->coordTransform(t).precision();
SkString suffixedUniName;