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 "GrTextureProxy.h" 12 13/** 14 * This class allows GrResourceCache increased privileged access to GrTextureProxy objects. 15 */ 16class GrTextureProxy::CacheAccess { 17private: 18 void setUniqueKey(GrProxyProvider* proxyProvider, const GrUniqueKey& key) { 19 fTextureProxy->setUniqueKey(proxyProvider, key); 20 } 21 22 void clearUniqueKey() { 23 fTextureProxy->clearUniqueKey(); 24 } 25 26 explicit CacheAccess(GrTextureProxy* textureProxy) : fTextureProxy(textureProxy) {} 27 CacheAccess(const CacheAccess&) {} // unimpl 28 CacheAccess& operator=(const CacheAccess&); // unimpl 29 30 // No taking addresses of this type. 31 const CacheAccess* operator&() const; 32 CacheAccess* operator&(); 33 34 GrTextureProxy* fTextureProxy; 35 36 friend class GrTextureProxy; // to construct/copy this type. 37 friend class GrProxyProvider; // to use this type 38}; 39 40inline GrTextureProxy::CacheAccess GrTextureProxy::cacheAccess() { return CacheAccess(this); } 41 42inline const GrTextureProxy::CacheAccess GrTextureProxy::cacheAccess() const { 43 return CacheAccess(const_cast<GrTextureProxy*>(this)); 44} 45 46#endif 47