diff options
author | 2015-09-17 17:35:11 -0700 | |
---|---|---|
committer | 2015-09-17 17:35:11 -0700 | |
commit | 48e3a45ade15c52c0c1a10cb00907dd444897745 (patch) | |
tree | d083ea0485abdfd0b7a4d02182e8eb5f3dee9b52 /src/gpu/batches/GrBatch.h | |
parent | af5bf22e3bf6f2aae08e7d0b62c38656a5e983aa (diff) |
Revert of add a ClassID function to GrBatch (patchset #5 id:80001 of https://codereview.chromium.org/1352813003/ )
Reason for revert:
Speculative revert to unblock DEPS roll
Original issue's description:
> add a ClassID function to GrBatch
>
> BUG=skia:
>
> Committed: https://skia.googlesource.com/skia/+/4078d529e9e199eea13456db7bf3a63a104ab5b9
>
> Committed: https://skia.googlesource.com/skia/+/eb44d53cf96a7eaf103a98d76079ce1f5495e343
TBR=robertphillips@google.com,bsalomon@google.com,joshualitt@google.com,joshualitt@chromium.org
NOPRESUBMIT=true
NOTREECHECKS=true
NOTRY=true
BUG=skia:
Review URL: https://codereview.chromium.org/1353043002
Diffstat (limited to 'src/gpu/batches/GrBatch.h')
-rw-r--r-- | src/gpu/batches/GrBatch.h | 41 |
1 files changed, 15 insertions, 26 deletions
diff --git a/src/gpu/batches/GrBatch.h b/src/gpu/batches/GrBatch.h index c5fc80c5d5..b6eec1f969 100644 --- a/src/gpu/batches/GrBatch.h +++ b/src/gpu/batches/GrBatch.h @@ -41,16 +41,9 @@ class GrBatchFlushState; #define GrBATCH_INFO(...) #endif -// A helper macro to generate a class static id -#define DEFINE_BATCH_CLASS_ID \ - static uint32_t ClassID() { \ - static uint32_t kClassID = GenBatchClassID(); \ - return kClassID; \ - } - class GrBatch : public GrNonAtomicRef { public: - GrBatch(uint32_t classID); + GrBatch(); ~GrBatch() override; virtual const char* name() const = 0; @@ -76,17 +69,10 @@ public: } /** - * Helper for safely down-casting to a GrBatch subclass + * Helper for down-casting to a GrBatch subclass */ - template <typename T> const T& cast() const { - SkASSERT(T::ClassID() == this->classID()); - return *static_cast<const T*>(this); - } - - template <typename T> T* cast() { - SkASSERT(T::ClassID() == this->classID()); - return static_cast<T*>(this); - } + template <typename T> const T& cast() const { return *static_cast<const T*>(this); } + template <typename T> T* cast() { return static_cast<T*>(this); } uint32_t classID() const { SkASSERT(kIllegalBatchID != fClassID); return fClassID; } @@ -110,6 +96,11 @@ public: virtual SkString dumpInfo() const = 0; protected: + template <typename PROC_SUBCLASS> void initClassID() { + static uint32_t kClassID = GenID(&gCurrBatchClassID); + fClassID = kClassID; + } + // NOTE, compute some bounds, even if extremely conservative. Do *NOT* setLargest on the bounds // rect because we outset it for dst copy textures void setBounds(const SkRect& newBounds) { fBounds = newBounds; } @@ -118,8 +109,6 @@ protected: return fBounds.joinPossiblyEmptyRect(otherBounds); } - static uint32_t GenBatchClassID() { return GenID(&gCurrBatchClassID); } - SkRect fBounds; private: @@ -129,7 +118,8 @@ private: virtual void onDraw(GrBatchFlushState*) = 0; static uint32_t GenID(int32_t* idCounter) { - // The atomic inc returns the old value not the incremented value. So we add + // fCurrProcessorClassID has been initialized to kIllegalProcessorClassID. 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(idCounter)) + 1; if (!id) { @@ -143,14 +133,13 @@ private: kIllegalBatchID = 0, }; + uint32_t fClassID; SkDEBUGCODE(bool fUsed;) - const uint32_t fClassID; #if GR_BATCH_SPEW - static uint32_t GenBatchID() { return GenID(&gCurrBatchUniqueID); } - const uint32_t fUniqueID; - static int32_t gCurrBatchUniqueID; + uint32_t fUniqueID; + static int32_t gCurrBatchUniqueID; #endif - static int32_t gCurrBatchClassID; + static int32_t gCurrBatchClassID; typedef GrNonAtomicRef INHERITED; }; |