• 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 "src/gpu/GrSurfaceProxy.h"
12 
13 #include "src/gpu/GrResourceProvider.h"
14 
15 /** Class that adds methods to GrSurfaceProxy that are only intended for use internal to Skia.
16     This class is purely a privileged window into GrSurfaceProxy. It should never have additional
17     data members or virtual methods. */
18 class GrSurfaceProxyPriv {
19 public:
getProxyRefCnt()20     int32_t getProxyRefCnt() const { return fProxy->getProxyRefCnt(); }
21 
computeScratchKey(GrScratchKey * key)22     void computeScratchKey(GrScratchKey* key) const { return fProxy->computeScratchKey(key); }
23 
24     // Create a GrSurface-derived class that meets the requirements (i.e, desc, renderability)
25     // of the GrSurfaceProxy.
createSurface(GrResourceProvider * resourceProvider)26     sk_sp<GrSurface> createSurface(GrResourceProvider* resourceProvider) const {
27         return fProxy->createSurface(resourceProvider);
28     }
29 
30     // Assign this proxy the provided GrSurface as its backing surface
assign(sk_sp<GrSurface> surface)31     void assign(sk_sp<GrSurface> surface) { fProxy->assign(std::move(surface)); }
32 
33     // Don't abuse this call!!!!!!!
isExact()34     bool isExact() const { return SkBackingFit::kExact == fProxy->fFit; }
35 
36     // Don't. Just don't.
37     void exactify(bool allocatedCaseOnly);
38 
setLazySize(int width,int height)39     void setLazySize(int width, int height) { fProxy->setLazySize(width, height); }
40 
41     bool doLazyInstantiation(GrResourceProvider*);
42 
lazyInstantiationType()43     GrSurfaceProxy::LazyInstantiationType lazyInstantiationType() const {
44         return fProxy->fLazyInstantiationType;
45     }
46 
isSafeToDeinstantiate()47     bool isSafeToDeinstantiate() const {
48         return SkToBool(fProxy->fTarget) && SkToBool(fProxy->fLazyInstantiateCallback) &&
49                GrSurfaceProxy::LazyInstantiationType::kDeinstantiate == lazyInstantiationType();
50     }
51 
52     static bool SK_WARN_UNUSED_RESULT AttachStencilIfNeeded(GrResourceProvider*, GrSurface*,
53                                                             int minStencilSampleCount);
54 
ignoredByResourceAllocator()55     bool ignoredByResourceAllocator() const { return fProxy->ignoredByResourceAllocator(); }
setIgnoredByResourceAllocator()56     void setIgnoredByResourceAllocator() { fProxy->setIgnoredByResourceAllocator(); }
57 
58 private:
GrSurfaceProxyPriv(GrSurfaceProxy * proxy)59     explicit GrSurfaceProxyPriv(GrSurfaceProxy* proxy) : fProxy(proxy) {}
GrSurfaceProxyPriv(const GrSurfaceProxyPriv &)60     GrSurfaceProxyPriv(const GrSurfaceProxyPriv&) {} // unimpl
61     GrSurfaceProxyPriv& operator=(const GrSurfaceProxyPriv&); // unimpl
62 
63     // No taking addresses of this type.
64     const GrSurfaceProxyPriv* operator&() const;
65     GrSurfaceProxyPriv* operator&();
66 
67     GrSurfaceProxy* fProxy;
68 
69     friend class GrSurfaceProxy; // to construct/copy this type.
70 };
71 
priv()72 inline GrSurfaceProxyPriv GrSurfaceProxy::priv() { return GrSurfaceProxyPriv(this); }
73 
priv()74 inline const GrSurfaceProxyPriv GrSurfaceProxy::priv () const {
75     return GrSurfaceProxyPriv(const_cast<GrSurfaceProxy*>(this));
76 }
77 
78 #endif
79