2 * Copyright 2017 Google Inc.
4 * Use of this source code is governed by a BSD-style license that can be
5 * found in the LICENSE file.
8 #ifndef GrSurfaceProxyPriv_DEFINED
9 #define GrSurfaceProxyPriv_DEFINED
11 #include "src/gpu/ganesh/GrSurfaceProxy.h"
13 class GrResourceProvider;
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 {
20 void computeScratchKey(const GrCaps& caps, skgpu::ScratchKey* key) const {
21 return fProxy->computeScratchKey(caps, key);
24 // Create a GrSurface-derived class that meets the requirements (i.e, desc, renderability)
25 // of the GrSurfaceProxy.
26 sk_sp<GrSurface> createSurface(GrResourceProvider* resourceProvider) const {
27 return fProxy->createSurface(resourceProvider);
30 // Assign this proxy the provided GrSurface as its backing surface
31 void assign(sk_sp<GrSurface> surface) { fProxy->assign(std::move(surface)); }
33 // Don't abuse this call!!!!!!!
34 bool isExact() const { return SkBackingFit::kExact == fProxy->fFit; }
37 void exactify(bool allocatedCaseOnly);
39 void setLazyDimensions(SkISize dimensions) { fProxy->setLazyDimensions(dimensions); }
41 bool doLazyInstantiation(GrResourceProvider*);
43 void setIsDDLTarget() { fProxy->fIsDDLTarget = true; }
45 void setIsPromiseProxy() { fProxy->fIsPromiseProxy = true; }
48 explicit GrSurfaceProxyPriv(GrSurfaceProxy* proxy) : fProxy(proxy) {}
49 GrSurfaceProxyPriv& operator=(const GrSurfaceProxyPriv&) = delete;
51 // No taking addresses of this type.
52 const GrSurfaceProxyPriv* operator&() const;
53 GrSurfaceProxyPriv* operator&();
55 GrSurfaceProxy* fProxy;
57 friend class GrSurfaceProxy; // to construct/copy this type.
60 inline GrSurfaceProxyPriv GrSurfaceProxy::priv() { return GrSurfaceProxyPriv(this); }
62 inline const GrSurfaceProxyPriv GrSurfaceProxy::priv () const { // NOLINT(readability-const-return-type)
63 return GrSurfaceProxyPriv(const_cast<GrSurfaceProxy*>(this));