Greg Daniel | 4684f82 | 2018-03-08 15:27:36 -0500 | [diff] [blame] | 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 "GrUninstantiateProxyTracker.h" |
| 9 | |
| 10 | #include "GrSurfaceProxy.h" |
| 11 | #include "GrSurfaceProxyPriv.h" |
| 12 | |
| 13 | void GrUninstantiateProxyTracker::addProxy(GrSurfaceProxy* proxy) { |
| 14 | #ifdef SK_DEBUG |
| 15 | using LazyType = GrSurfaceProxy::LazyInstantiationType; |
| 16 | SkASSERT(LazyType::kUninstantiate == proxy->priv().lazyInstantiationType()); |
| 17 | for (int i = 0; i < fProxies.count(); ++i) { |
Robert Phillips | e4aae34 | 2018-03-14 10:26:57 -0400 | [diff] [blame] | 18 | SkASSERT(proxy != fProxies[i].get()); |
Greg Daniel | 4684f82 | 2018-03-08 15:27:36 -0500 | [diff] [blame] | 19 | } |
| 20 | #endif |
Robert Phillips | e4aae34 | 2018-03-14 10:26:57 -0400 | [diff] [blame] | 21 | fProxies.push_back(sk_ref_sp(proxy)); |
Greg Daniel | 4684f82 | 2018-03-08 15:27:36 -0500 | [diff] [blame] | 22 | } |
| 23 | |
| 24 | void GrUninstantiateProxyTracker::uninstantiateAllProxies() { |
| 25 | for (int i = 0; i < fProxies.count(); ++i) { |
Robert Phillips | e4aae34 | 2018-03-14 10:26:57 -0400 | [diff] [blame] | 26 | GrSurfaceProxy* proxy = fProxies[i].get(); |
Greg Daniel | 4684f82 | 2018-03-08 15:27:36 -0500 | [diff] [blame] | 27 | SkASSERT(proxy->priv().isSafeToUninstantiate()); |
| 28 | proxy->deInstantiate(); |
| 29 | } |
Robert Phillips | e4aae34 | 2018-03-14 10:26:57 -0400 | [diff] [blame] | 30 | |
| 31 | fProxies.reset(); |
Greg Daniel | 4684f82 | 2018-03-08 15:27:36 -0500 | [diff] [blame] | 32 | } |