GrDeinstantiateProxyTracker.cpp 948 B

1234567891011121314151617181920212223242526272829303132
  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. #include "src/gpu/GrDeinstantiateProxyTracker.h"
  8. #include "src/gpu/GrSurfaceProxy.h"
  9. #include "src/gpu/GrSurfaceProxyPriv.h"
  10. void GrDeinstantiateProxyTracker::addProxy(GrSurfaceProxy* proxy) {
  11. #ifdef SK_DEBUG
  12. using LazyType = GrSurfaceProxy::LazyInstantiationType;
  13. SkASSERT(LazyType::kDeinstantiate == proxy->priv().lazyInstantiationType());
  14. for (int i = 0; i < fProxies.count(); ++i) {
  15. SkASSERT(proxy != fProxies[i].get());
  16. }
  17. #endif
  18. fProxies.push_back(sk_ref_sp<GrSurfaceProxy>(proxy));
  19. }
  20. void GrDeinstantiateProxyTracker::deinstantiateAllProxies() {
  21. for (int i = 0; i < fProxies.count(); ++i) {
  22. GrSurfaceProxy* proxy = fProxies[i].get();
  23. SkASSERT(proxy->priv().isSafeToDeinstantiate());
  24. proxy->deinstantiate();
  25. }
  26. fProxies.reset();
  27. }