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

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: feedback incorporated 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 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.

Powered by Google App Engine
This is Rietveld 408576698