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