Index: src/gpu/GrGeometryProcessor.h |
diff --git a/src/gpu/GrGeometryProcessor.h b/src/gpu/GrGeometryProcessor.h |
index 074fffcfb08410e64ebe572a6506665ade05d611..3098ed7db5e907494d0ce932a1f8117e12b50cd6 100644 |
--- a/src/gpu/GrGeometryProcessor.h |
+++ b/src/gpu/GrGeometryProcessor.h |
@@ -121,6 +121,35 @@ public: |
virtual void getInvariantOutputColor(GrInitInvariantOutput* out) const = 0; |
virtual void getInvariantOutputCoverage(GrInitInvariantOutput* out) const = 0; |
+ // Only the GrGeometryProcessor subclass actually has a geo shader or vertex attributes, but |
+ // we put these calls on the base class to prevent having to cast |
+ virtual bool willUseGeoShader() const = 0; |
+ |
+ /* |
+ * This is a safeguard to prevent GrPrimitiveProcessor's from going beyond platform specific |
+ * attribute limits. This number can almost certainly be raised if required. |
+ */ |
+ static const int kMaxVertexAttribs = 6; |
+ |
+ struct GrAttribute { |
bsalomon
2015/01/13 14:31:44
Should just be "Attribute" if it is nested inside
|
+ GrAttribute(const char* name, GrVertexAttribType type) |
+ : fName(name) |
+ , fType(type) |
+ , fOffset(SkAlign4(GrVertexAttribTypeSize(type))) {} |
+ const char* fName; |
+ GrVertexAttribType fType; |
+ size_t fOffset; |
+ }; |
+ |
+ typedef SkTArray<GrAttribute, true> VertexAttribArray; |
+ |
+ const VertexAttribArray& getAttribs() const { return fAttribs; } |
+ |
+ // Returns the vertex stride of the GP. A common use case is to request geometry from a |
+ // drawtarget based off of the stride, and to populate this memory using an implicit array of |
+ // structs. In this case, it is best to assert the vertexstride == sizeof(VertexStruct). |
+ size_t getVertexStride() const { return fVertexStride; } |
+ |
/** |
* Gets a transformKey from an array of coord transforms |
*/ |
@@ -143,7 +172,8 @@ public: |
protected: |
GrPrimitiveProcessor(const SkMatrix& viewMatrix, const SkMatrix& localMatrix) |
- : fViewMatrix(viewMatrix) |
+ : fVertexStride(0) |
+ , fViewMatrix(viewMatrix) |
, fLocalMatrix(localMatrix) {} |
/* |
@@ -176,6 +206,9 @@ protected: |
return true; |
} |
+ SkSTArray<kMaxVertexAttribs, GrAttribute, true> fAttribs; |
bsalomon
2015/01/13 14:31:45
If it's really capped why not just
Attribute fAtt
|
+ size_t fVertexStride; |
+ |
private: |
virtual bool hasExplicitLocalCoords() const = 0; |
@@ -201,38 +234,12 @@ public: |
const SkMatrix& localMatrix = SkMatrix::I(), |
bool opaqueVertexColors = false) |
: INHERITED(viewMatrix, localMatrix) |
- , fVertexStride(0) |
, fColor(color) |
, fOpaqueVertexColors(opaqueVertexColors) |
, fWillUseGeoShader(false) |
, fHasVertexColor(false) |
, fHasLocalCoords(false) {} |
- /* |
- * This is a safeguard to prevent GPs from going beyond platform specific attribute limits. |
- * This number can almost certainly be raised if required. |
- */ |
- static const int kMaxVertexAttribs = 6; |
- |
- struct GrAttribute { |
- GrAttribute(const char* name, GrVertexAttribType type) |
- : fName(name) |
- , fType(type) |
- , fOffset(SkAlign4(GrVertexAttribTypeSize(type))) {} |
- const char* fName; |
- GrVertexAttribType fType; |
- size_t fOffset; |
- }; |
- |
- typedef SkTArray<GrAttribute, true> VertexAttribArray; |
- |
- const VertexAttribArray& getAttribs() const { return fAttribs; } |
- |
- // Returns the vertex stride of the GP. A common use case is to request geometry from a |
- // drawtarget based off of the stride, and to populate this memory using an implicit array of |
- // structs. In this case, it is best to assert the vertexstride == sizeof(VertexStruct). |
- size_t getVertexStride() const { return fVertexStride; } |
- |
bool willUseGeoShader() const { return fWillUseGeoShader; } |
/* |
@@ -342,8 +349,6 @@ private: |
bool hasExplicitLocalCoords() const SK_OVERRIDE { return fHasLocalCoords; } |
- SkSTArray<kMaxVertexAttribs, GrAttribute, true> fAttribs; |
- size_t fVertexStride; |
GrColor fColor; |
bool fOpaqueVertexColors; |
bool fWillUseGeoShader; |
@@ -378,6 +383,8 @@ public: |
void getInvariantOutputColor(GrInitInvariantOutput* out) const SK_OVERRIDE; |
void getInvariantOutputCoverage(GrInitInvariantOutput* out) const SK_OVERRIDE; |
+ bool willUseGeoShader() const SK_OVERRIDE { return false; } |
+ |
virtual void getGLProcessorKey(const GrBatchTracker& bt, |
const GrGLCaps& caps, |
GrProcessorKeyBuilder* b) const SK_OVERRIDE; |