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

Unified Diff: src/gpu/GrGeometryProcessor.h

Issue 791743003: Remove GP from drawstate, revision of invariant output for GP (Closed) Base URL: https://skia.googlesource.com/skia.git@color-to-gp
Patch Set: more windows fix Created 6 years 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
« no previous file with comments | « src/gpu/GrDrawTarget.cpp ('k') | src/gpu/GrInOrderDrawBuffer.h » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: src/gpu/GrGeometryProcessor.h
diff --git a/src/gpu/GrGeometryProcessor.h b/src/gpu/GrGeometryProcessor.h
index a0cfc09d4536d7cfef2e5e101ef8eb1d9784f34f..50ecac48ba0c74a33d27dbf29bd1f203ab9f3051 100644
--- a/src/gpu/GrGeometryProcessor.h
+++ b/src/gpu/GrGeometryProcessor.h
@@ -39,6 +39,23 @@ class GrGLCaps;
class GrGLGeometryProcessor;
class GrOptDrawState;
+struct GrInitInvariantOutput;
+
+/*
+ * GrGeometryProcessors and GrPathProcessors may effect invariantColor
+ */
+class GrPrimitiveProcessor : public GrProcessor {
+public:
+ // TODO GPs and PPs have to provide an initial coverage because the coverage invariant code is
+ // broken right now
+ virtual uint8_t coverage() const = 0;
+ virtual void getInvariantOutputColor(GrInitInvariantOutput* out) const = 0;
+ virtual void getInvariantOutputCoverage(GrInitInvariantOutput* out) const = 0;
+
+private:
+ typedef GrProcessor INHERITED;
+};
+
/**
* A GrGeometryProcessor is used to perform computation in the vertex shader and
* add support for custom vertex attributes. A GrGemeotryProcessor is typically
@@ -49,12 +66,15 @@ class GrOptDrawState;
* added to the vertex attribute array specified on the GrDrawState.
* GrGeometryProcessor subclasses should be immutable after construction.
*/
-class GrGeometryProcessor : public GrProcessor {
+class GrGeometryProcessor : public GrPrimitiveProcessor {
public:
- GrGeometryProcessor(GrColor color, uint8_t coverage = 0xff)
+ // 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, uint8_t coverage = 0xff)
: fVertexStride(0)
, fColor(color)
, fCoverage(coverage)
+ , fOpaqueVertexColors(opaqueVertexColors)
, fWillUseGeoShader(false)
, fHasVertexColor(false)
, fHasVertexCoverage(false)
@@ -114,11 +134,18 @@ public:
return false;
}
- if (!fHasVertexColor && this->getColor() != that.getColor()) {
+ // TODO remove the hint
+ if (fHasVertexColor && fOpaqueVertexColors != that.fOpaqueVertexColors) {
+ return false;
+ }
+
+ if (!fHasVertexColor && this->color() != that.color()) {
return false;
}
- if (!fHasVertexCoverage && this->getCoverage() != that.getCoverage()) {
+ // TODO this is fragile, most gps set their coverage to 0xff so this is okay. In the long
+ // term this should move to subclasses which set explicit coverage
+ if (!fHasVertexCoverage && this->coverage() != that.coverage()) {
return false;
}
return this->onIsEqual(that);
@@ -133,8 +160,8 @@ public:
virtual void initBatchTracker(GrBatchTracker*, const InitBT&) const {}
- GrColor getColor() const { return fColor; }
- uint8_t getCoverage() const { return fCoverage; }
+ GrColor color() const { return fColor; }
+ uint8_t coverage() const { return fCoverage; }
// TODO this is a total hack until the gp can own whether or not it uses uniform
// color / coverage
@@ -142,7 +169,8 @@ public:
bool hasVertexCoverage() const { return fHasVertexCoverage; }
bool hasLocalCoords() const { return fHasLocalCoords; }
- void computeInvariantColor(GrInvariantOutput* inout) const;
+ void getInvariantOutputColor(GrInitInvariantOutput* out) const SK_OVERRIDE;
+ void getInvariantOutputCoverage(GrInitInvariantOutput* out) const SK_OVERRIDE;
protected:
/**
@@ -163,6 +191,9 @@ protected:
void setHasVertexCoverage() { fHasVertexCoverage = true; }
void setHasLocalCoords() { fHasLocalCoords = true; }
+ virtual void onGetInvariantOutputColor(GrInitInvariantOutput*) const {}
+ virtual void onGetInvariantOutputCoverage(GrInitInvariantOutput*) const = 0;
+
private:
virtual bool onIsEqual(const GrGeometryProcessor&) const = 0;
@@ -170,6 +201,7 @@ private:
size_t fVertexStride;
GrColor fColor;
uint8_t fCoverage;
+ bool fOpaqueVertexColors;
bool fWillUseGeoShader;
bool fHasVertexColor;
bool fHasVertexCoverage;
@@ -177,4 +209,26 @@ private:
typedef GrProcessor INHERITED;
};
+
+/*
+ * The path equivalent of the GP. For now this just manages color. In the long term we plan on
+ * extending this class to handle all nvpr uniform / varying / program work.
+ */
+class GrPathProcessor : public GrPrimitiveProcessor {
+public:
+ static GrPathProcessor* Create(GrColor color) {
+ return SkNEW_ARGS(GrPathProcessor, (color));
+ }
+
+ const char* name() const SK_OVERRIDE { return "PathProcessor"; }
+ uint8_t coverage() const SK_OVERRIDE { return 0xff; }
+ void getInvariantOutputColor(GrInitInvariantOutput* out) const SK_OVERRIDE;
+ void getInvariantOutputCoverage(GrInitInvariantOutput* out) const SK_OVERRIDE;
+
+private:
+ GrPathProcessor(GrColor color) : fColor(color) {}
+ GrColor fColor;
+
+ typedef GrProcessor INHERITED;
+};
#endif
« no previous file with comments | « src/gpu/GrDrawTarget.cpp ('k') | src/gpu/GrInOrderDrawBuffer.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698