diff --git a/gn/gpu.gni b/gn/gpu.gni index fbc976b70d..362dac86a2 100644 --- a/gn/gpu.gni +++ b/gn/gpu.gni @@ -186,6 +186,7 @@ skia_gpu_sources = [ "$_src/gpu/GrTextureOpList.cpp", "$_src/gpu/GrTextureOpList.h", "$_src/gpu/GrTextureProxyCacheAccess.h", + "$_src/gpu/GrTextureProxyPriv.h", "$_src/gpu/GrTracing.h", "$_src/gpu/GrTestUtils.cpp", "$_src/gpu/GrTestUtils.h", diff --git a/include/private/GrSurfaceProxy.h b/include/private/GrSurfaceProxy.h index fcb839c1fe..0c65055611 100644 --- a/include/private/GrSurfaceProxy.h +++ b/include/private/GrSurfaceProxy.h @@ -332,8 +332,8 @@ public: SkDEBUGCODE(void validate(GrContext*) const;) // Provides access to functions that aren't part of the public API. - GrSurfaceProxyPriv priv(); - const GrSurfaceProxyPriv priv() const; + inline GrSurfaceProxyPriv priv(); + inline const GrSurfaceProxyPriv priv() const; protected: // Deferred version diff --git a/include/private/GrTextureProxy.h b/include/private/GrTextureProxy.h index 4c36ad7815..8e72eaddb9 100644 --- a/include/private/GrTextureProxy.h +++ b/include/private/GrTextureProxy.h @@ -15,6 +15,7 @@ class GrCaps; class GrResourceCache; class GrResourceProvider; class GrTextureOpList; +class GrTextureProxyPriv; // This class delays the acquisition of textures until they are actually required class GrTextureProxy : virtual public GrSurfaceProxy { @@ -62,6 +63,10 @@ public: inline CacheAccess cacheAccess(); inline const CacheAccess cacheAccess() const; + // Provides access to special purpose functions. + GrTextureProxyPriv texPriv(); + const GrTextureProxyPriv texPriv() const; + protected: friend class GrSurfaceProxy; // for ctors diff --git a/src/gpu/GrTextureProxyPriv.h b/src/gpu/GrTextureProxyPriv.h new file mode 100644 index 0000000000..c3ddb9460c --- /dev/null +++ b/src/gpu/GrTextureProxyPriv.h @@ -0,0 +1,39 @@ +/* + * Copyright 2017 Google Inc. + * + * Use of this source code is governed by a BSD-style license that can be + * found in the LICENSE file. + */ + +#ifndef GrTextureProxyPriv_DEFINED +#define GrTextureProxyPriv_DEFINED + +#include "GrTextureProxy.h" + +/** + * This class hides the more specialized capabilities of GrTextureProxy. + */ +class GrTextureProxyPriv { +public: + +private: + explicit GrTextureProxyPriv(GrTextureProxy* textureProxy) : fTextureProxy(textureProxy) {} + GrTextureProxyPriv(const GrTextureProxyPriv&) {} // unimpl + GrTextureProxyPriv& operator=(const GrTextureProxyPriv&); // unimpl + + // No taking addresses of this type. + const GrTextureProxyPriv* operator&() const; + GrTextureProxyPriv* operator&(); + + GrTextureProxy* fTextureProxy; + + friend class GrTextureProxy; // to construct/copy this type. +}; + +inline GrTextureProxyPriv GrTextureProxy::texPriv() { return GrTextureProxyPriv(this); } + +inline const GrTextureProxyPriv GrTextureProxy::texPriv() const { + return GrTextureProxyPriv(const_cast(this)); +} + +#endif