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