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 #if defined(SKIA_DFX_FOR_RECORD_VKIMAGE) || defined(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 #if defined(SKIA_DFX_FOR_RECORD_VKIMAGE) || defined(SKIA_DFX_FOR_OHOS) GrSurfaceProxyPriv(GrSurfaceProxy * proxy)52 explicit GrSurfaceProxyPriv(GrSurfaceProxy* proxy) : 53 fProxy(proxy) 54 #ifdef SKIA_DFX_FOR_RECORD_VKIMAGE 55 , nodeId(ParallelDebug::GetNodeId()) 56 #endif 57 #ifdef SKIA_DFX_FOR_OHOS 58 , fRealAllocProxy(RealAllocConfig::GetRealAllocStatus()) 59 #endif 60 {}; 61 #else 62 explicit GrSurfaceProxyPriv(GrSurfaceProxy* proxy) : fProxy(proxy) {}; 63 #endif 64 65 // Required until C++17 copy elision 66 GrSurfaceProxyPriv(const GrSurfaceProxyPriv&) = default; 67 GrSurfaceProxyPriv& operator=(const GrSurfaceProxyPriv&) = delete; 68 69 // No taking addresses of this type. 70 const GrSurfaceProxyPriv* operator&() const; 71 GrSurfaceProxyPriv* operator&(); 72 73 GrSurfaceProxy* fProxy; 74 #ifdef SKIA_DFX_FOR_RECORD_VKIMAGE 75 uint64_t nodeId; 76 #endif 77 #ifdef SKIA_DFX_FOR_OHOS 78 // OH ISSUE: proxy resources real alloc status 79 bool fRealAllocProxy = false; 80 #endif 81 82 friend class GrSurfaceProxy; // to construct/copy this type. 83 }; 84 priv()85inline GrSurfaceProxyPriv GrSurfaceProxy::priv() { return GrSurfaceProxyPriv(this); } 86 priv()87inline const GrSurfaceProxyPriv GrSurfaceProxy::priv () const { // NOLINT(readability-const-return-type) 88 return GrSurfaceProxyPriv(const_cast<GrSurfaceProxy*>(this)); 89 } 90 91 #endif 92