Deuninstantiate

Uninstantiated: a state of not being instantiated.

Deinstantiate: transition from instantiated to uninstantiated state.

Change-Id: Id7b6b295267674a9915f95105d73fabfcc3555de
Reviewed-on: https://skia-review.googlesource.com/c/175586
Reviewed-by: Greg Daniel <egdaniel@google.com>
Commit-Queue: Brian Salomon <bsalomon@google.com>
diff --git a/src/gpu/GrUninstantiateProxyTracker.cpp b/src/gpu/GrDeinstantiateProxyTracker.cpp
similarity index 65%
rename from src/gpu/GrUninstantiateProxyTracker.cpp
rename to src/gpu/GrDeinstantiateProxyTracker.cpp
index 2bd5e3d..9870617 100644
--- a/src/gpu/GrUninstantiateProxyTracker.cpp
+++ b/src/gpu/GrDeinstantiateProxyTracker.cpp
@@ -5,15 +5,15 @@
  * found in the LICENSE file.
  */
 
-#include "GrUninstantiateProxyTracker.h"
+#include "GrDeinstantiateProxyTracker.h"
 
 #include "GrSurfaceProxy.h"
 #include "GrSurfaceProxyPriv.h"
 
-void GrUninstantiateProxyTracker::addProxy(GrSurfaceProxy* proxy) {
+void GrDeinstantiateProxyTracker::addProxy(GrSurfaceProxy* proxy) {
 #ifdef SK_DEBUG
     using LazyType = GrSurfaceProxy::LazyInstantiationType;
-    SkASSERT(LazyType::kUninstantiate == proxy->priv().lazyInstantiationType());
+    SkASSERT(LazyType::kDeinstantiate == proxy->priv().lazyInstantiationType());
     for (int i = 0; i < fProxies.count(); ++i) {
         SkASSERT(proxy != fProxies[i].get());
     }
@@ -21,11 +21,11 @@
     fProxies.push_back(sk_ref_sp(proxy));
 }
 
-void GrUninstantiateProxyTracker::uninstantiateAllProxies() {
+void GrDeinstantiateProxyTracker::deinstantiateAllProxies() {
     for (int i = 0; i < fProxies.count(); ++i) {
         GrSurfaceProxy* proxy = fProxies[i].get();
-        SkASSERT(proxy->priv().isSafeToUninstantiate());
-        proxy->deInstantiate();
+        SkASSERT(proxy->priv().isSafeToDeinstantiate());
+        proxy->deinstantiate();
     }
 
     fProxies.reset();
diff --git a/src/gpu/GrDeinstantiateProxyTracker.h b/src/gpu/GrDeinstantiateProxyTracker.h
new file mode 100644
index 0000000..2555ab1
--- /dev/null
+++ b/src/gpu/GrDeinstantiateProxyTracker.h
@@ -0,0 +1,29 @@
+/*
+ * Copyright 2018 Google Inc.
+ *
+ * Use of this source code is governed by a BSD-style license that can be
+ * found in the LICENSE file.
+ */
+
+#ifndef GrDeinstantiateProxyTracker_DEFINED
+#define GrDeinstantiateProxyTracker_DEFINED
+
+#include "GrSurfaceProxy.h"
+#include "SkTArray.h"
+
+class GrDeinstantiateProxyTracker {
+public:
+    GrDeinstantiateProxyTracker() {}
+
+    // Adds a proxy which will be deinstantiated at the end of flush. The same proxy may not be
+    // added multiple times.
+    void addProxy(GrSurfaceProxy* proxy);
+
+    // Loops through all tracked proxies and deinstantiates them.
+    void deinstantiateAllProxies();
+
+private:
+    SkTArray<sk_sp<GrSurfaceProxy>> fProxies;
+};
+
+#endif
diff --git a/src/gpu/GrDrawOpAtlas.cpp b/src/gpu/GrDrawOpAtlas.cpp
index edfd3c2..add0601 100644
--- a/src/gpu/GrDrawOpAtlas.cpp
+++ b/src/gpu/GrDrawOpAtlas.cpp
@@ -593,7 +593,7 @@
     }
 
     // remove ref to the backing texture
-    fProxies[lastPageIndex]->deInstantiate();
+    fProxies[lastPageIndex]->deinstantiate();
     --fNumActivePages;
 }
 
diff --git a/src/gpu/GrDrawingManager.cpp b/src/gpu/GrDrawingManager.cpp
index 79e1684..b0143ae 100644
--- a/src/gpu/GrDrawingManager.cpp
+++ b/src/gpu/GrDrawingManager.cpp
@@ -284,7 +284,7 @@
 
     {
         GrResourceAllocator alloc(fContext->contextPriv().resourceProvider(),
-                                  flushState.uninstantiateProxyTracker());
+                                  flushState.deinstantiateProxyTracker());
         for (int i = 0; i < fDAG.numOpLists(); ++i) {
             if (fDAG.opList(i)) {
                 fDAG.opList(i)->gatherProxyIntervals(&alloc);
@@ -333,7 +333,7 @@
 
     GrSemaphoresSubmitted result = gpu->finishFlush(numSemaphores, backendSemaphores);
 
-    flushState.uninstantiateProxyTracker()->uninstantiateAllProxies();
+    flushState.deinstantiateProxyTracker()->deinstantiateAllProxies();
 
     // Give the cache a chance to purge resources that become purgeable due to flushing.
     if (flushed) {
diff --git a/src/gpu/GrOnFlushResourceProvider.cpp b/src/gpu/GrOnFlushResourceProvider.cpp
index bbf1029..2555c81 100644
--- a/src/gpu/GrOnFlushResourceProvider.cpp
+++ b/src/gpu/GrOnFlushResourceProvider.cpp
@@ -60,7 +60,7 @@
     auto resourceProvider = fDrawingMgr->getContext()->contextPriv().resourceProvider();
 
     if (GrSurfaceProxy::LazyState::kNot != proxy->lazyInstantiationState()) {
-        // DDL TODO: Decide if we ever plan to have these proxies use the GrUninstantiateTracker
+        // DDL TODO: Decide if we ever plan to have these proxies use the GrDeinstantiateTracker
         // to support unistantiating them at the end of a flush.
         return proxy->priv().doLazyInstantiation(resourceProvider);
     }
diff --git a/src/gpu/GrOpFlushState.h b/src/gpu/GrOpFlushState.h
index 1e44935..f963c69 100644
--- a/src/gpu/GrOpFlushState.h
+++ b/src/gpu/GrOpFlushState.h
@@ -12,7 +12,7 @@
 #include "GrAppliedClip.h"
 #include "GrBufferAllocPool.h"
 #include "GrDeferredUpload.h"
-#include "GrUninstantiateProxyTracker.h"
+#include "GrDeinstantiateProxyTracker.h"
 #include "SkArenaAlloc.h"
 #include "SkArenaAllocList.h"
 #include "ops/GrMeshDrawOp.h"
@@ -105,9 +105,7 @@
     // permissible).
     GrAtlasManager* atlasManager() const final;
 
-    GrUninstantiateProxyTracker* uninstantiateProxyTracker() {
-        return &fUninstantiateProxyTracker;
-    }
+    GrDeinstantiateProxyTracker* deinstantiateProxyTracker() { return &fDeinstantiateProxyTracker; }
 
 private:
     /** GrMeshDrawOp::Target override. */
@@ -164,8 +162,8 @@
     SkArenaAllocList<Draw>::Iter fCurrDraw;
     SkArenaAllocList<InlineUpload>::Iter fCurrUpload;
 
-    // Used to track the proxies that need to be uninstantiated after we finish a flush
-    GrUninstantiateProxyTracker fUninstantiateProxyTracker;
+    // Used to track the proxies that need to be deinstantiated after we finish a flush
+    GrDeinstantiateProxyTracker fDeinstantiateProxyTracker;
 };
 
 #endif
diff --git a/src/gpu/GrResourceAllocator.cpp b/src/gpu/GrResourceAllocator.cpp
index b495836..0f70894 100644
--- a/src/gpu/GrResourceAllocator.cpp
+++ b/src/gpu/GrResourceAllocator.cpp
@@ -7,6 +7,7 @@
 
 #include "GrResourceAllocator.h"
 
+#include "GrDeinstantiateProxyTracker.h"
 #include "GrGpuResourcePriv.h"
 #include "GrOpList.h"
 #include "GrRenderTargetProxy.h"
@@ -16,7 +17,6 @@
 #include "GrSurfaceProxy.h"
 #include "GrSurfaceProxyPriv.h"
 #include "GrTextureProxy.h"
-#include "GrUninstantiateProxyTracker.h"
 
 #if GR_TRACK_INTERVAL_CREATION
     #include <atomic>
@@ -109,8 +109,8 @@
         if (GrSurfaceProxy::LazyState::kNot != proxy->lazyInstantiationState()) {
             if (proxy->priv().doLazyInstantiation(fResourceProvider)) {
                 if (proxy->priv().lazyInstantiationType() ==
-                    GrSurfaceProxy::LazyInstantiationType::kUninstantiate) {
-                    fUninstantiateTracker->addProxy(proxy);
+                    GrSurfaceProxy::LazyInstantiationType::kDeinstantiate) {
+                    fDeinstantiateTracker->addProxy(proxy);
                 }
             }
         }
@@ -376,9 +376,9 @@
             if (!cur->proxy()->priv().doLazyInstantiation(fResourceProvider)) {
                 *outError = AssignError::kFailedProxyInstantiation;
             } else {
-                if (GrSurfaceProxy::LazyInstantiationType::kUninstantiate ==
+                if (GrSurfaceProxy::LazyInstantiationType::kDeinstantiate ==
                     cur->proxy()->priv().lazyInstantiationType()) {
-                    fUninstantiateTracker->addProxy(cur->proxy());
+                    fDeinstantiateTracker->addProxy(cur->proxy());
                 }
             }
         } else if (sk_sp<GrSurface> surface = this->findSurfaceFor(cur->proxy(), needsStencil)) {
diff --git a/src/gpu/GrResourceAllocator.h b/src/gpu/GrResourceAllocator.h
index c4d2343..ea1250f 100644
--- a/src/gpu/GrResourceAllocator.h
+++ b/src/gpu/GrResourceAllocator.h
@@ -16,8 +16,8 @@
 #include "SkTDynamicHash.h"
 #include "SkTMultiMap.h"
 
+class GrDeinstantiateProxyTracker;
 class GrResourceProvider;
-class GrUninstantiateProxyTracker;
 
 // Print out explicit allocation information
 #define GR_ALLOCATION_SPEW 0
@@ -42,8 +42,8 @@
  */
 class GrResourceAllocator {
 public:
-    GrResourceAllocator(GrResourceProvider* resourceProvider, GrUninstantiateProxyTracker* tracker)
-            : fResourceProvider(resourceProvider), fUninstantiateTracker(tracker) {}
+    GrResourceAllocator(GrResourceProvider* resourceProvider, GrDeinstantiateProxyTracker* tracker)
+            : fResourceProvider(resourceProvider), fDeinstantiateTracker(tracker) {}
 
     ~GrResourceAllocator();
 
@@ -212,7 +212,7 @@
     static const int kInitialArenaSize = 128 * sizeof(Interval);
 
     GrResourceProvider*          fResourceProvider;
-    GrUninstantiateProxyTracker* fUninstantiateTracker;
+    GrDeinstantiateProxyTracker* fDeinstantiateTracker;
     FreePoolMultiMap             fFreePool;          // Recently created/used GrSurfaces
     IntvlHash                    fIntvlHash;         // All the intervals, hashed by proxyID
 
diff --git a/src/gpu/GrSurfaceProxy.cpp b/src/gpu/GrSurfaceProxy.cpp
index ac650af..617f2aa 100644
--- a/src/gpu/GrSurfaceProxy.cpp
+++ b/src/gpu/GrSurfaceProxy.cpp
@@ -245,13 +245,12 @@
     return true;
 }
 
-void GrSurfaceProxy::deInstantiate() {
+void GrSurfaceProxy::deinstantiate() {
     SkASSERT(this->isInstantiated());
 
     this->release();
 }
 
-
 void GrSurfaceProxy::computeScratchKey(GrScratchKey* key) const {
     SkASSERT(LazyState::kFully != this->lazyInstantiationState());
     const GrRenderTargetProxy* rtp = this->asRenderTargetProxy();
diff --git a/src/gpu/GrSurfaceProxyPriv.h b/src/gpu/GrSurfaceProxyPriv.h
index ecddf58..a9076b8 100644
--- a/src/gpu/GrSurfaceProxyPriv.h
+++ b/src/gpu/GrSurfaceProxyPriv.h
@@ -60,10 +60,10 @@
         return fProxy->fLazyInstantiationType;
     }
 
-    bool isSafeToUninstantiate() const {
+    bool isSafeToDeinstantiate() const {
         return SkToBool(fProxy->fTarget) &&
                SkToBool(fProxy->fLazyInstantiateCallback) &&
-               GrSurfaceProxy::LazyInstantiationType::kUninstantiate == lazyInstantiationType();
+               GrSurfaceProxy::LazyInstantiationType::kDeinstantiate == lazyInstantiationType();
     }
 
     static bool SK_WARN_UNUSED_RESULT AttachStencilIfNeeded(GrResourceProvider*, GrSurface*,
diff --git a/src/gpu/GrUninstantiateProxyTracker.h b/src/gpu/GrUninstantiateProxyTracker.h
deleted file mode 100644
index 5245466..0000000
--- a/src/gpu/GrUninstantiateProxyTracker.h
+++ /dev/null
@@ -1,29 +0,0 @@
-/*
- * Copyright 2018 Google Inc.
- *
- * Use of this source code is governed by a BSD-style license that can be
- * found in the LICENSE file.
- */
-
-#ifndef GrUninstantiateProxyTracker_DEFINED
-#define GrUninstantiateProxyTracker_DEFINED
-
-#include "GrSurfaceProxy.h"
-#include "SkTArray.h"
-
-class GrUninstantiateProxyTracker {
-public:
-    GrUninstantiateProxyTracker() {}
-
-    // Adds a proxy which will be uninstantiated at the end of flush. The same proxy may not be
-    // added multiple times.
-    void addProxy(GrSurfaceProxy* proxy);
-
-    // Loops through all tracked proxies and uninstantiates them.
-    void uninstantiateAllProxies();
-
-private:
-    SkTArray<sk_sp<GrSurfaceProxy>> fProxies;
-};
-
-#endif