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 GrSurfaceProxyPriv_DEFINED 9 #define GrSurfaceProxyPriv_DEFINED 10 11 #include "GrSurfaceProxy.h" 12 13 /** Class that adds methods to GrSurfaceProxy that are only intended for use internal to Skia. 14 This class is purely a privileged window into GrSurfaceProxy. It should never have additional 15 data members or virtual methods. */ 16 class GrSurfaceProxyPriv { 17 public: 18 // If the proxy is already instantiated, return its backing GrTexture; if not, 19 // return null peekTexture()20 const GrTexture* peekTexture() const { 21 return fProxy->fTarget ? fProxy->fTarget->asTexture() : nullptr; 22 } 23 24 // Beware! This call is only guaranteed to tell you if the proxy in question has 25 // any pending IO in its current state. It won't tell you about the IO state in the 26 // future when the proxy is actually used/instantiated. hasPendingIO()27 bool hasPendingIO() const { return fProxy->hasPendingIO(); } 28 29 // Don't abuse this call!!!!!!! isExact()30 bool isExact() const { return SkBackingFit::kExact == fProxy->fFit; } 31 32 // Don't. Just don't. 33 void exactify(); 34 35 private: GrSurfaceProxyPriv(GrSurfaceProxy * proxy)36 explicit GrSurfaceProxyPriv(GrSurfaceProxy* proxy) : fProxy(proxy) {} GrSurfaceProxyPriv(const GrSurfaceProxyPriv &)37 GrSurfaceProxyPriv(const GrSurfaceProxyPriv&) {} // unimpl 38 GrSurfaceProxyPriv& operator=(const GrSurfaceProxyPriv&); // unimpl 39 40 // No taking addresses of this type. 41 const GrSurfaceProxyPriv* operator&() const; 42 GrSurfaceProxyPriv* operator&(); 43 44 GrSurfaceProxy* fProxy; 45 46 friend class GrSurfaceProxy; // to construct/copy this type. 47 }; 48 priv()49inline GrSurfaceProxyPriv GrSurfaceProxy::priv() { return GrSurfaceProxyPriv(this); } 50 priv()51inline const GrSurfaceProxyPriv GrSurfaceProxy::priv () const { 52 return GrSurfaceProxyPriv(const_cast<GrSurfaceProxy*>(this)); 53 } 54 55 #endif 56