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

Unified Diff: src/gpu/GrGeometryProcessor.h

Issue 746423007: Draft change to start pulling uniform color into GP (Closed) Base URL: https://skia.googlesource.com/skia.git@no_factories
Patch Set: 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
Index: src/gpu/GrGeometryProcessor.h
diff --git a/src/gpu/GrGeometryProcessor.h b/src/gpu/GrGeometryProcessor.h
index 9e621d82a04a66e603976c7305745bd2da34c742..57ac2deaaef8a8190c2d430f30dbdfd653fe0a14 100644
--- a/src/gpu/GrGeometryProcessor.h
+++ b/src/gpu/GrGeometryProcessor.h
@@ -20,18 +20,18 @@ class GrBatchTracker {
public:
template <typename T> const T& cast() const {
SkASSERT(sizeof(T) <= kMaxSize);
- return *reinterpret_cast<const T*>(fData);
+ return *reinterpret_cast<const T*>(fData.get());
}
template <typename T> T* cast() {
SkASSERT(sizeof(T) <= kMaxSize);
- return reinterpret_cast<T*>(fData);
+ return reinterpret_cast<T*>(fData.get());
}
static const size_t kMaxSize = 32;
private:
- uint8_t fData[kMaxSize];
+ mutable SkAlignedSStorage<kMaxSize> fData;
};
class GrGLCaps;
@@ -51,7 +51,7 @@ class GrOptDrawState;
class GrGeometryProcessor : public GrProcessor {
public:
GrGeometryProcessor()
- : fVertexStride(0)
+ : /*TODO HACK*/fNewStyle(false), fVertexStride(0)
, fWillUseGeoShader(false)
, fHasVertexColor(false)
, fHasVertexCoverage(false)
@@ -110,22 +110,55 @@ public:
return this->onIsEqual(that);
}
+ /*
+ * This struct allows the optstate to communicate requirements to the GP.
+ * TODO when the GP can encapsulate draw information in bundles, we can refactor this struct.
+ * Ultimately, when setColor and setCoverage live on the GP, this struct can be replaced with
+ * a simple override color passed into initBatchTracker
+ */
struct InitBT {
bool fOutputColor;
bool fOutputCoverage;
+ bool fRemoveColorAttr;
+ bool fRemoveCoverageAttr;
GrColor fColor;
GrColor fCoverage;
};
virtual void initBatchTracker(GrBatchTracker*, const InitBT&) const {}
+ // TODO this call is temporary. Once we have deferred geometry, GPs can always make themselves
+ // equal
+ virtual bool canBatch(const GrBatchTracker&, const GrBatchTracker&) const { SkFAIL("s"); return false; }
+
// 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; }
+ // TODO hack
+ bool fNewStyle;
+
protected:
+ enum Output {
+ kAllOnes_Output,
+ kAttribute_Output,
+ kUniform_Output,
+ };
+
+ static Output GetColorOutputType(const InitBT& init, bool hasVertexColor) {
+ bool hasUniformColor = (init.fOutputColor && !hasVertexColor) || init.fRemoveColorAttr;
+ if (!init.fOutputColor) {
+ return kAllOnes_Output;
+ } else if (hasUniformColor) {
+ return kUniform_Output;
+ } else {
+ SkASSERT(hasVertexColor);
+ return kAttribute_Output;
+ }
+ }
+
/**
* Subclasses call this from their constructor to register vertex attributes. Attributes
* will be padded to the nearest 4 bytes for performance reasons.

Powered by Google App Engine
This is Rietveld 408576698