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

Unified Diff: include/gpu/GrXferProcessor.h

Issue 767873006: Check XpFactory equality in DrawState (Closed) Base URL: https://skia.googlesource.com/skia.git@moveXPHeader
Patch Set: Rebase 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
« no previous file with comments | « no previous file | include/gpu/effects/GrPorterDuffXferProcessor.h » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: include/gpu/GrXferProcessor.h
diff --git a/include/gpu/GrXferProcessor.h b/include/gpu/GrXferProcessor.h
index ee3764deda89a31d3970ebf00b4526e169bdbc53..10ecf54c758c25e938cb9b1b7fe549f016a9e727 100644
--- a/include/gpu/GrXferProcessor.h
+++ b/include/gpu/GrXferProcessor.h
@@ -54,7 +54,50 @@ public:
*/
virtual bool supportsRGBCoverage(GrColor knownColor, uint32_t knownColorFlags) const = 0;
+ bool isEqual(const GrXPFactory& that) const {
+ if (this->classID() != that.classID()) {
+ return false;
+ }
+ return this->onIsEqual(that);
+ }
+
+ /**
+ * Helper for down-casting to a GrXPFactory subclass
+ */
+ template <typename T> const T& cast() const { return *static_cast<const T*>(this); }
+
+ uint32_t classID() const { SkASSERT(kIllegalXPFClassID != fClassID); return fClassID; }
+
+protected:
+ GrXPFactory() : fClassID(kIllegalXPFClassID) {}
+
+ template <typename XPF_SUBCLASS> void initClassID() {
+ static uint32_t kClassID = GenClassID();
+ fClassID = kClassID;
+ }
+
+ uint32_t fClassID;
+
private:
+ virtual bool onIsEqual(const GrXPFactory&) const = 0;
+
+ static uint32_t GenClassID() {
+ // fCurrXPFactoryID has been initialized to kIllegalXPFactoryID. The
+ // atomic inc returns the old value not the incremented value. So we add
+ // 1 to the returned value.
+ uint32_t id = static_cast<uint32_t>(sk_atomic_inc(&gCurrXPFClassID)) + 1;
+ if (!id) {
+ SkFAIL("This should never wrap as it should only be called once for each GrXPFactory "
+ "subclass.");
+ }
+ return id;
+ }
+
+ enum {
+ kIllegalXPFClassID = 0,
+ };
+ static int32_t gCurrXPFClassID;
+
typedef GrProgramElement INHERITED;
};
« no previous file with comments | « no previous file | include/gpu/effects/GrPorterDuffXferProcessor.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698