blob: 9870617f24e9ba4169a52ce27012414106770abb [file] [log] [blame]
Brian Salomon876a0172019-03-08 11:12:14 -05001/*
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
13void 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
24void 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}