Debian Codegraph @

src/gpu/ganesh/GrSurfaceProxyPriv.h

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