Add reference base class to GrGpuResourcewith pending IO references.

BUG=skia:2889
R=robertphillips@google.com

Author: bsalomon@google.com

Review URL: https://codereview.chromium.org/533343002
diff --git a/src/gpu/GrGpuResource.cpp b/src/gpu/GrGpuResource.cpp
index bce7d2c..d29ab6d 100644
--- a/src/gpu/GrGpuResource.cpp
+++ b/src/gpu/GrGpuResource.cpp
@@ -11,6 +11,16 @@
 #include "GrResourceCache2.h"
 #include "GrGpu.h"
 
+GrGpuRef::~GrGpuRef() {
+    SkASSERT(0 == fRefCnt);
+    SkASSERT(0 == fPendingReads);
+    SkASSERT(0 == fPendingWrites);
+    // Set to invalid values.
+    SkDEBUGCODE(fRefCnt = fPendingReads = fPendingWrites = -10;)
+}
+
+///////////////////////////////////////////////////////////////////////////////
+
 static inline GrResourceCache2* get_resource_cache2(GrGpu* gpu) {
     SkASSERT(NULL != gpu);
     SkASSERT(NULL != gpu->getContext());
@@ -20,7 +30,6 @@
 
 GrGpuResource::GrGpuResource(GrGpu* gpu, bool isWrapped)
     : fGpu(gpu)
-    , fRefCnt(1)
     , fCacheEntry(NULL)
     , fUniqueID(CreateUniqueID())
     , fScratchKey(GrResourceKey::NullScratchKey()) {
@@ -36,7 +45,6 @@
 }
 
 GrGpuResource::~GrGpuResource() {
-    SkASSERT(0 == fRefCnt);
     // subclass should have released this.
     SkASSERT(this->wasDestroyed());
 }