Index: src/gpu/GrGeometryProcessor.h |
diff --git a/src/gpu/GrGeometryProcessor.h b/src/gpu/GrGeometryProcessor.h |
index fa4de7912dea455e9496898101718280e41e291f..28ad1bd0b62e1a7e43e1808b09f483adf852453c 100644 |
--- a/src/gpu/GrGeometryProcessor.h |
+++ b/src/gpu/GrGeometryProcessor.h |
@@ -21,18 +21,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; |
bsalomon
2014/12/10 18:36:20
Maybe these just shouldn't be const if this field
|
}; |
class GrGLCaps; |
@@ -69,7 +69,7 @@ private: |
class GrGeometryProcessor : public GrPrimitiveProcessor { |
public: |
GrGeometryProcessor(GrColor color, uint8_t coverage = 0xff) |
- : fVertexStride(0) |
+ : /*TODO HACK*/fNewStyle(false), fVertexStride(0) |
, fColor(color) |
, fCoverage(coverage) |
, fWillUseGeoShader(false) |
@@ -143,15 +143,27 @@ 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 |
bsalomon
2014/12/10 18:36:20
can/should we fold this into isEqual, that is repl
|
+ // equal |
+ virtual bool canBatch(const GrBatchTracker&, const GrBatchTracker&) const { SkFAIL("s"); return false; } |
+ |
GrColor color() const { return fColor; } |
uint8_t coverage() const { return fCoverage; } |
@@ -163,8 +175,28 @@ public: |
void getOutputColor(GrInitInvariantOutput* out) const SK_OVERRIDE; |
void getOutputCoverage(GrInitInvariantOutput* out) const SK_OVERRIDE; |
+ // TODO hack |
+ bool fNewStyle; |
bsalomon
2014/12/10 18:36:20
I know it's a hack but can you formalize this a li
|
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. |