2 * Copyright 2017 Google Inc.
4 * Use of this source code is governed by a BSD-style license that can be
5 * found in the LICENSE file.
8 #ifndef GrTextureProxyCacheAccess_DEFINED
9 #define GrTextureProxyCacheAccess_DEFINED
11 #include "src/gpu/ganesh/GrTextureProxy.h"
14 * This class allows GrResourceCache increased privileged access to GrTextureProxy objects.
16 class GrTextureProxy::CacheAccess {
18 void setUniqueKey(GrProxyProvider* proxyProvider, const skgpu::UniqueKey& key) {
19 fTextureProxy->setUniqueKey(proxyProvider, key);
22 void clearUniqueKey() {
23 fTextureProxy->clearUniqueKey();
26 explicit CacheAccess(GrTextureProxy* textureProxy) : fTextureProxy(textureProxy) {}
27 CacheAccess& operator=(const CacheAccess&) = delete;
29 // No taking addresses of this type.
30 const CacheAccess* operator&() const;
31 CacheAccess* operator&();
33 GrTextureProxy* fTextureProxy;
35 friend class GrTextureProxy; // to construct/copy this type.
36 friend class GrProxyProvider; // to use this type
39 inline GrTextureProxy::CacheAccess GrTextureProxy::cacheAccess() { return CacheAccess(this); }
41 inline const GrTextureProxy::CacheAccess GrTextureProxy::cacheAccess() const { // NOLINT(readability-const-return-type)
42 return CacheAccess(const_cast<GrTextureProxy*>(this));