| Index: src/gpu/GrNonAtomicRef.h
|
| diff --git a/src/gpu/GrNonAtomicRef.h b/src/gpu/GrNonAtomicRef.h
|
| index efa2881c5f49a34cd553ccb291b4c638277b7745..e1503bcf06e16936e463e79d243f3db7b1739203 100644
|
| --- a/src/gpu/GrNonAtomicRef.h
|
| +++ b/src/gpu/GrNonAtomicRef.h
|
| @@ -15,15 +15,18 @@
|
| * A simple non-atomic ref used in the GrBackend when we don't want to pay for the overhead of a
|
| * threadsafe ref counted object
|
| */
|
| -class GrNonAtomicRef : public SkNoncopyable {
|
| +template<typename TSubclass> class GrNonAtomicRef : public SkNoncopyable {
|
| public:
|
| GrNonAtomicRef() : fRefCnt(1) {}
|
| - virtual ~GrNonAtomicRef() {
|
| +
|
| +#ifdef SK_DEBUG
|
| + ~GrNonAtomicRef() {
|
| // fRefCnt can be one when a subclass is created statically
|
| SkASSERT((0 == fRefCnt || 1 == fRefCnt));
|
| // Set to invalid values.
|
| - SkDEBUGCODE(fRefCnt = -10;)
|
| + fRefCnt = -10;
|
| }
|
| +#endif
|
|
|
| void ref() const {
|
| // Once the ref cnt reaches zero it should never be ref'ed again.
|
| @@ -35,7 +38,7 @@ public:
|
| SkASSERT(fRefCnt > 0);
|
| --fRefCnt;
|
| if (0 == fRefCnt) {
|
| - delete this;
|
| + GrTDeleteNonAtomicRef(static_cast<const TSubclass*>(this));
|
| return;
|
| }
|
| }
|
| @@ -46,4 +49,8 @@ private:
|
| typedef SkNoncopyable INHERITED;
|
| };
|
|
|
| +template<typename T> inline void GrTDeleteNonAtomicRef(const T* ref) {
|
| + delete ref;
|
| +}
|
| +
|
| #endif
|
|
|