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