| Index: src/gpu/GrGeometryProcessor.h
|
| diff --git a/src/gpu/GrGeometryProcessor.h b/src/gpu/GrGeometryProcessor.h
|
| index 6d27f0b4f123788f9eb29ae7c0334f972731268f..d89155e317e47c78cf40ad066dceb39a63fc2c16 100644
|
| --- a/src/gpu/GrGeometryProcessor.h
|
| +++ b/src/gpu/GrGeometryProcessor.h
|
| @@ -25,19 +25,31 @@
|
| class GrGeometryProcessor : public GrProcessor {
|
| public:
|
| GrGeometryProcessor()
|
| - : fWillUseGeoShader(false) {}
|
| + : fVertexStride(0)
|
| + , fWillUseGeoShader(false)
|
| + , fHasVertexColor(false)
|
| + , fHasVertexCoverage(false)
|
| + , fHasLocalCoords(false) {}
|
|
|
| virtual const GrBackendGeometryProcessorFactory& getFactory() const = 0;
|
|
|
| /*
|
| - * This only has a max because GLProgramsTest needs to generate test arrays, and these have to
|
| - * be static
|
| - * TODO make this truly dynamic
|
| + * 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 = 2;
|
| - typedef SkTArray<GrShaderVar, true> VertexAttribArray;
|
| + static const int kMaxVertexAttribs = 6;
|
|
|
| - const VertexAttribArray& getVertexAttribs() const { return fVertexAttribs; }
|
| + struct GrAttribute {
|
| + GrAttribute(const char* name, GrVertexAttribType type) : fName(name), fType(type) {}
|
| + const char* fName;
|
| + GrVertexAttribType fType;
|
| + };
|
| +
|
| + typedef SkTArray<GrAttribute, true> VertexAttribArray;
|
| +
|
| + const VertexAttribArray& getAttribs() const { return fAttribs; }
|
| +
|
| + size_t getVertexStride() const { return fVertexStride; }
|
|
|
| bool willUseGeoShader() const { return fWillUseGeoShader; }
|
|
|
| @@ -54,24 +66,37 @@ public:
|
| return this->onIsEqual(that);
|
| }
|
|
|
| + // TODO this is a total hack until the gp can own whether or not it uses uniform
|
| + // color / coverage
|
| + bool hasVertexColor() const { return fHasVertexColor; }
|
| + bool hasVertexCoverage() const { return fHasVertexCoverage; }
|
| + bool hasLocalCoords() const { return fHasLocalCoords; }
|
| +
|
| protected:
|
| /**
|
| - * Subclasses call this from their constructor to register vertex attributes (at most
|
| - * kMaxVertexAttribs). This must only be called from the constructor because GrProcessors are
|
| - * immutable.
|
| + * Subclasses call this from their constructor to register vertex attributes
|
| */
|
| - const GrShaderVar& addVertexAttrib(const GrShaderVar& var) {
|
| - SkASSERT(fVertexAttribs.count() < kMaxVertexAttribs);
|
| - return fVertexAttribs.push_back(var);
|
| + const GrAttribute& addVertexAttrib(const GrAttribute& attribute) {
|
| + fVertexStride += GrVertexAttribTypeSize(attribute.fType);
|
| + return fAttribs.push_back(attribute);
|
| }
|
|
|
| void setWillUseGeoShader() { fWillUseGeoShader = true; }
|
|
|
| + // TODO hack see above
|
| + void setHasVertexColor() { fHasVertexColor = true; }
|
| + void setHasVertexCoverage() { fHasVertexCoverage = true; }
|
| + void setHasLocalCoords() { fHasLocalCoords = true; }
|
| +
|
| private:
|
| virtual bool onIsEqual(const GrGeometryProcessor&) const = 0;
|
|
|
| - SkSTArray<kMaxVertexAttribs, GrShaderVar, true> fVertexAttribs;
|
| + SkSTArray<kMaxVertexAttribs, GrAttribute, true> fAttribs;
|
| + size_t fVertexStride;
|
| bool fWillUseGeoShader;
|
| + bool fHasVertexColor;
|
| + bool fHasVertexCoverage;
|
| + bool fHasLocalCoords;
|
|
|
| typedef GrProcessor INHERITED;
|
| };
|
|
|