aboutsummaryrefslogtreecommitdiffhomepage
path: root/src/gpu/GrGeometryProcessor.h
diff options
context:
space:
mode:
authorGravatar joshualitt <joshualitt@chromium.org>2014-12-19 13:45:20 -0800
committerGravatar Commit bot <commit-bot@chromium.org>2014-12-19 13:45:20 -0800
commit290c09b8bbd8d221d363150e2ce87158f4668df0 (patch)
tree7989675060a6bd1bcd7626139810079d5add3d76 /src/gpu/GrGeometryProcessor.h
parentbd2f0f34cfa0debf2b60fd864c432ef5cbe96503 (diff)
initial changes to add local matrix to primitive processor
Diffstat (limited to 'src/gpu/GrGeometryProcessor.h')
-rw-r--r--src/gpu/GrGeometryProcessor.h46
1 files changed, 37 insertions, 9 deletions
diff --git a/src/gpu/GrGeometryProcessor.h b/src/gpu/GrGeometryProcessor.h
index f3ec0b5af3..fb2300ed67 100644
--- a/src/gpu/GrGeometryProcessor.h
+++ b/src/gpu/GrGeometryProcessor.h
@@ -90,6 +90,10 @@ enum GrGPInput {
*/
class GrPrimitiveProcessor : public GrProcessor {
public:
+ // TODO let the PrimProc itself set this in its setData call, this should really live on the
+ // bundle of primitive data
+ const SkMatrix& localMatrix() const { return fLocalMatrix; }
+
/*
* This struct allows the optstate to communicate requirements to the GrPrimitiveProcessor.
*/
@@ -97,6 +101,7 @@ public:
bool fColorIgnored;
bool fCoverageIgnored;
GrColor fOverrideColor;
+ bool fUsesLocalCoords;
};
virtual void initBatchTracker(GrBatchTracker*, const InitBT&) const = 0;
@@ -130,6 +135,8 @@ public:
virtual GrGLGeometryProcessor* createGLInstance(const GrBatchTracker& bt) const = 0;
protected:
+ GrPrimitiveProcessor(const SkMatrix& localMatrix) : fLocalMatrix(localMatrix) {}
+
/*
* CanCombineOutput will return true if two draws are 'batchable' from a color perspective.
* TODO remove this when GPs can upgrade to attribute color
@@ -146,7 +153,23 @@ protected:
return true;
}
+ static bool CanCombineLocalMatrices(const GrPrimitiveProcessor& left,
+ bool leftUsesLocalCoords,
+ const GrPrimitiveProcessor& right,
+ bool rightUsesLocalCoords) {
+ if (leftUsesLocalCoords != rightUsesLocalCoords) {
+ return false;
+ }
+
+ if (leftUsesLocalCoords && !left.localMatrix().cheapEqualTo(right.localMatrix())) {
+ return false;
+ }
+ return true;
+ }
+
private:
+ SkMatrix fLocalMatrix;
+
typedef GrProcessor INHERITED;
};
@@ -161,8 +184,11 @@ class GrGeometryProcessor : public GrPrimitiveProcessor {
public:
// TODO the Hint can be handled in a much more clean way when we have deferred geometry or
// atleast bundles
- GrGeometryProcessor(GrColor color, bool opaqueVertexColors = false)
- : fVertexStride(0)
+ GrGeometryProcessor(GrColor color,
+ bool opaqueVertexColors = false,
+ const SkMatrix& localMatrix = SkMatrix::I())
+ : INHERITED(localMatrix)
+ , fVertexStride(0)
, fColor(color)
, fOpaqueVertexColors(opaqueVertexColors)
, fWillUseGeoShader(false)
@@ -223,7 +249,7 @@ public:
return false;
}
- return this->onCanMakeEqual(mine, theirs);
+ return this->onCanMakeEqual(mine, other, theirs);
}
@@ -293,7 +319,9 @@ protected:
virtual void onGetInvariantOutputCoverage(GrInitInvariantOutput*) const = 0;
private:
- virtual bool onCanMakeEqual(const GrBatchTracker& mine, const GrBatchTracker& theirs) const = 0;
+ virtual bool onCanMakeEqual(const GrBatchTracker& mine,
+ const GrGeometryProcessor& that,
+ const GrBatchTracker& theirs) const = 0;
// TODO delete this when we have more advanced equality testing via bundles and the BT
virtual bool onIsEqual(const GrGeometryProcessor&) const = 0;
@@ -305,7 +333,7 @@ private:
bool fHasVertexColor;
bool fHasLocalCoords;
- typedef GrProcessor INHERITED;
+ typedef GrPrimitiveProcessor INHERITED;
};
/*
@@ -314,8 +342,8 @@ private:
*/
class GrPathProcessor : public GrPrimitiveProcessor {
public:
- static GrPathProcessor* Create(GrColor color) {
- return SkNEW_ARGS(GrPathProcessor, (color));
+ static GrPathProcessor* Create(GrColor color, const SkMatrix& localMatrix = SkMatrix::I()) {
+ return SkNEW_ARGS(GrPathProcessor, (color, localMatrix));
}
void initBatchTracker(GrBatchTracker*, const InitBT&) const SK_OVERRIDE;
@@ -338,9 +366,9 @@ public:
virtual GrGLGeometryProcessor* createGLInstance(const GrBatchTracker& bt) const SK_OVERRIDE;
private:
- GrPathProcessor(GrColor color);
+ GrPathProcessor(GrColor color, const SkMatrix& localMatrix);
GrColor fColor;
- typedef GrProcessor INHERITED;
+ typedef GrPrimitiveProcessor INHERITED;
};
#endif