Replace fWillReadFragmentPosition with a bitfield
Replaces fWillReadFragmentPosition on GrProcessor with a
"RequiredFeatures" bitfield. This will allow us to add additional
built-in features. Completely removes information about reading the
fragment position from GrPipeline and GrProcOptInfo.
BUG=skia:
GOLD_TRYBOT_URL= https://gold.skia.org/search2?unt=true&query=source_type%3Dgm&master=false&issue=1734163002
Review URL: https://codereview.chromium.org/1734163002
diff --git a/include/gpu/GrProcessor.h b/include/gpu/GrProcessor.h
index 9b5db5e..5afd8ea 100644
--- a/include/gpu/GrProcessor.h
+++ b/include/gpu/GrProcessor.h
@@ -79,8 +79,17 @@
/** Shortcut for textureAccess(index).texture(); */
GrTexture* texture(int index) const { return this->textureAccess(index).getTexture(); }
- /** Will this processor read the fragment position? */
- bool willReadFragmentPosition() const { return fWillReadFragmentPosition; }
+ /**
+ * Platform specific built-in features that a processor can request for the fragment shader.
+ */
+ enum RequiredFeatures {
+ kNone_RequiredFeatures = 0,
+ kFragmentPosition_RequiredFeature = 1
+ };
+
+ GR_DECL_BITFIELD_OPS_FRIENDS(RequiredFeatures);
+
+ RequiredFeatures requiredFeatures() const { return fRequiredFeatures; }
void* operator new(size_t size);
void operator delete(void* target);
@@ -100,7 +109,7 @@
uint32_t classID() const { SkASSERT(kIllegalProcessorClassID != fClassID); return fClassID; }
protected:
- GrProcessor() : fClassID(kIllegalProcessorClassID), fWillReadFragmentPosition(false) {}
+ GrProcessor() : fClassID(kIllegalProcessorClassID), fRequiredFeatures(kNone_RequiredFeatures) {}
/**
* Subclasses call this from their constructor to register GrTextureAccesses. The processor
@@ -117,7 +126,11 @@
* position in the FS then it must call this method from its constructor. Otherwise, the
* request to access the fragment position will be denied.
*/
- void setWillReadFragmentPosition() { fWillReadFragmentPosition = true; }
+ void setWillReadFragmentPosition() { fRequiredFeatures |= kFragmentPosition_RequiredFeature; }
+
+ void combineRequiredFeatures(const GrProcessor& other) {
+ fRequiredFeatures |= other.fRequiredFeatures;
+ }
template <typename PROC_SUBCLASS> void initClassID() {
static uint32_t kClassID = GenClassID();
@@ -145,9 +158,11 @@
};
static int32_t gCurrProcessorClassID;
- bool fWillReadFragmentPosition;
+ RequiredFeatures fRequiredFeatures;
typedef GrProgramElement INHERITED;
};
+GR_MAKE_BITFIELD_OPS(GrProcessor::RequiredFeatures);
+
#endif