GrTextureProxyCacheAccess.h 1.3 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546
  1. /*
  2. * Copyright 2017 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. #ifndef GrTextureProxyCacheAccess_DEFINED
  8. #define GrTextureProxyCacheAccess_DEFINED
  9. #include "src/gpu/GrTextureProxy.h"
  10. /**
  11. * This class allows GrResourceCache increased privileged access to GrTextureProxy objects.
  12. */
  13. class GrTextureProxy::CacheAccess {
  14. private:
  15. void setUniqueKey(GrProxyProvider* proxyProvider, const GrUniqueKey& key) {
  16. fTextureProxy->setUniqueKey(proxyProvider, key);
  17. }
  18. void clearUniqueKey() {
  19. fTextureProxy->clearUniqueKey();
  20. }
  21. explicit CacheAccess(GrTextureProxy* textureProxy) : fTextureProxy(textureProxy) {}
  22. CacheAccess(const CacheAccess&) {} // unimpl
  23. CacheAccess& operator=(const CacheAccess&); // unimpl
  24. // No taking addresses of this type.
  25. const CacheAccess* operator&() const;
  26. CacheAccess* operator&();
  27. GrTextureProxy* fTextureProxy;
  28. friend class GrTextureProxy; // to construct/copy this type.
  29. friend class GrProxyProvider; // to use this type
  30. };
  31. inline GrTextureProxy::CacheAccess GrTextureProxy::cacheAccess() { return CacheAccess(this); }
  32. inline const GrTextureProxy::CacheAccess GrTextureProxy::cacheAccess() const {
  33. return CacheAccess(const_cast<GrTextureProxy*>(this));
  34. }
  35. #endif