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 "src/gpu/GrSurfaceProxy.h" 12 13 #include "src/gpu/GrResourceProvider.h" 14 15 /** Class that adds methods to GrSurfaceProxy that are only intended for use internal to Skia. 16 This class is purely a privileged window into GrSurfaceProxy. It should never have additional 17 data members or virtual methods. */ 18 class GrSurfaceProxyPriv { 19 public: computeScratchKey(GrScratchKey * key)20 void computeScratchKey(GrScratchKey* key) const { return fProxy->computeScratchKey(key); } 21 22 // Create a GrSurface-derived class that meets the requirements (i.e, desc, renderability) 23 // of the GrSurfaceProxy. createSurface(GrResourceProvider * resourceProvider)24 sk_sp<GrSurface> createSurface(GrResourceProvider* resourceProvider) const { 25 return fProxy->createSurface(resourceProvider); 26 } 27 28 // Assign this proxy the provided GrSurface as its backing surface assign(sk_sp<GrSurface> surface)29 void assign(sk_sp<GrSurface> surface) { fProxy->assign(std::move(surface)); } 30 31 // Don't abuse this call!!!!!!! isExact()32 bool isExact() const { return SkBackingFit::kExact == fProxy->fFit; } 33 34 // Don't. Just don't. 35 void exactify(bool allocatedCaseOnly); 36 setLazySize(int width,int height)37 void setLazySize(int width, int height) { fProxy->setLazySize(width, height); } 38 39 bool doLazyInstantiation(GrResourceProvider*); 40 41 42 static bool SK_WARN_UNUSED_RESULT AttachStencilIfNeeded(GrResourceProvider*, GrSurface*, 43 int minStencilSampleCount); 44 45 private: GrSurfaceProxyPriv(GrSurfaceProxy * proxy)46 explicit GrSurfaceProxyPriv(GrSurfaceProxy* proxy) : fProxy(proxy) {} GrSurfaceProxyPriv(const GrSurfaceProxyPriv &)47 GrSurfaceProxyPriv(const GrSurfaceProxyPriv&) {} // unimpl 48 GrSurfaceProxyPriv& operator=(const GrSurfaceProxyPriv&); // unimpl 49 50 // No taking addresses of this type. 51 const GrSurfaceProxyPriv* operator&() const; 52 GrSurfaceProxyPriv* operator&(); 53 54 GrSurfaceProxy* fProxy; 55 56 friend class GrSurfaceProxy; // to construct/copy this type. 57 }; 58 priv()59inline GrSurfaceProxyPriv GrSurfaceProxy::priv() { return GrSurfaceProxyPriv(this); } 60 priv()61inline const GrSurfaceProxyPriv GrSurfaceProxy::priv () const { 62 return GrSurfaceProxyPriv(const_cast<GrSurfaceProxy*>(this)); 63 } 64 65 #endif 66