• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
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 
8 #ifndef GrTextureProxyCacheAccess_DEFINED
9 #define GrTextureProxyCacheAccess_DEFINED
10 
11 #include "src/gpu/GrTextureProxy.h"
12 
13 /**
14  * This class allows GrResourceCache increased privileged access to GrTextureProxy objects.
15  */
16 class GrTextureProxy::CacheAccess {
17 private:
setUniqueKey(GrProxyProvider * proxyProvider,const GrUniqueKey & key)18     void setUniqueKey(GrProxyProvider* proxyProvider, const GrUniqueKey& key) {
19         fTextureProxy->setUniqueKey(proxyProvider, key);
20     }
21 
clearUniqueKey()22     void clearUniqueKey() {
23         fTextureProxy->clearUniqueKey();
24     }
25 
CacheAccess(GrTextureProxy * textureProxy)26     explicit CacheAccess(GrTextureProxy* textureProxy) : fTextureProxy(textureProxy) {}
27     // Required until C++17 copy elision
28     CacheAccess(const CacheAccess&) = default;
29     CacheAccess& operator=(const CacheAccess&) = delete;
30 
31     // No taking addresses of this type.
32     const CacheAccess* operator&() const;
33     CacheAccess* operator&();
34 
35     GrTextureProxy* fTextureProxy;
36 
37     friend class GrTextureProxy;  // to construct/copy this type.
38     friend class GrProxyProvider; // to use this type
39 };
40 
cacheAccess()41 inline GrTextureProxy::CacheAccess GrTextureProxy::cacheAccess() { return CacheAccess(this); }
42 
cacheAccess()43 inline const GrTextureProxy::CacheAccess GrTextureProxy::cacheAccess() const {  // NOLINT(readability-const-return-type)
44     return CacheAccess(const_cast<GrTextureProxy*>(this));
45 }
46 
47 #endif
48