1 /* 2 * Copyright 2018 Google Inc. 3 * 4 * Use of this source code is governed by a BSD-style license that can be 5 * found in the LICENSE file. 6 */ 7 8 #include "GrDeinstantiateProxyTracker.h" 9 10 #include "GrSurfaceProxy.h" 11 #include "GrSurfaceProxyPriv.h" 12 13 void GrDeinstantiateProxyTracker::addProxy(GrSurfaceProxy* proxy) { 14 #ifdef SK_DEBUG 15 using LazyType = GrSurfaceProxy::LazyInstantiationType; 16 SkASSERT(LazyType::kDeinstantiate == proxy->priv().lazyInstantiationType()); 17 for (int i = 0; i < fProxies.count(); ++i) { 18 SkASSERT(proxy != fProxies[i].get()); 19 } 20 #endif 21 fProxies.push_back(sk_ref_sp(proxy)); 22 } 23 24 void GrDeinstantiateProxyTracker::deinstantiateAllProxies() { 25 for (int i = 0; i < fProxies.count(); ++i) { 26 GrSurfaceProxy* proxy = fProxies[i].get(); 27 SkASSERT(proxy->priv().isSafeToDeinstantiate()); 28 proxy->deinstantiate(); 29 } 30 31 fProxies.reset(); 32 } 33