Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(224)

Unified Diff: src/gpu/GrGeometryProcessor.h

Issue 761563002: First step to moving vertex attributes to the geometryProcessor (Closed) Base URL: https://skia.googlesource.com/skia.git@master
Patch Set: more cleanup Created 6 years, 1 month ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
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);
bsalomon 2014/12/02 18:06:05 Is this right? Will we wind up with unaligned attr
}
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;
};

Powered by Google App Engine
This is Rietveld 408576698