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

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: cleanup 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 50ecac48ba0c74a33d27dbf29bd1f203ab9f3051..d192f8fa5b23573c4d186c072e9727180fa74fae 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;
};
class GrGLCaps;
@@ -56,6 +56,12 @@ private:
typedef GrProcessor INHERITED;
};
+enum GPInput {
bsalomon 2014/12/12 14:29:35 Can this be nested inside GrGP? Otherwise it needs
+ kAllOnes_GPInput,
+ kAttribute_GPInput,
+ kUniform_GPInput,
+};
+
/**
* A GrGeometryProcessor is used to perform computation in the vertex shader and
* add support for custom vertex attributes. A GrGemeotryProcessor is typically
@@ -151,15 +157,31 @@ 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
bsalomon 2014/12/12 14:29:35 From discussion with Greg, I think this will becom
+ */
struct InitBT {
bool fOutputColor;
bool fOutputCoverage;
+ bool fRemoveColorAttr;
+ bool fRemoveCoverageAttr;
GrColor fColor;
GrColor fCoverage;
};
- virtual void initBatchTracker(GrBatchTracker*, const InitBT&) const {}
+ virtual void initBatchTracker(GrBatchTracker*, const InitBT&) const = 0;
+ // TODO this call is temporary. Once we have deferred geometry, GPs can always make themselves
+ // equal
+ bool canBatch(const GrBatchTracker& left, const GrBatchTracker& right) const {
+ return this->onCanBatch(left, right);
+ }
+
+ virtual bool onCanBatch(const GrBatchTracker&, const GrBatchTracker&) const = 0;
+
GrColor color() const { return fColor; }
uint8_t coverage() const { return fCoverage; }
@@ -173,6 +195,30 @@ public:
void getInvariantOutputCoverage(GrInitInvariantOutput* out) const SK_OVERRIDE;
protected:
+ static GPInput GetColorInputType(const InitBT& init, bool hasVertexColor) {
bsalomon 2014/12/12 14:29:35 Document?
+ bool hasUniformColor = (init.fOutputColor && !hasVertexColor) || init.fRemoveColorAttr;
+ if (!init.fOutputColor) {
+ return kAllOnes_GPInput;
+ } else if (hasUniformColor) {
+ return kUniform_GPInput;
+ } else {
+ SkASSERT(hasVertexColor);
+ return kAttribute_GPInput;
+ }
+ }
+
+ static bool CanCombineOutput(GPInput left, GrColor lColor, GPInput right, GrColor rColor) {
bsalomon 2014/12/12 14:29:35 Document?
+ if (left != right) {
+ return false;
+ }
+
+ if (kUniform_GPInput == left && lColor != rColor) {
+ return false;
+ }
+
+ return true;
+ }
+
/**
* 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