blob: 20f64125f5838e785270d58528ce6129392e6afa [file] [log] [blame]
Robert Phillips757914d2017-01-25 15:48:30 -05001/*
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
Greg Danielf91aeb22019-06-18 09:58:02 -040011#include "src/gpu/GrSurfaceProxy.h"
Robert Phillips757914d2017-01-25 15:48:30 -050012
Mike Kleinc0bd9f92019-04-23 12:05:21 -050013#include "src/gpu/GrResourceProvider.h"
Robert Phillipsf8e25022017-11-08 15:24:31 -050014
Robert Phillips757914d2017-01-25 15:48:30 -050015/** 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. */
18class GrSurfaceProxyPriv {
19public:
Greg Danield51fa2f2020-01-22 16:53:38 -050020 void computeScratchKey(const GrCaps& caps, GrScratchKey* key) const {
21 return fProxy->computeScratchKey(caps, key);
22 }
Robert Phillips57aa3672017-07-21 11:38:13 -040023
Robert Phillips5af44de2017-07-18 14:49:38 -040024 // 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);
28 }
29
30 // Assign this proxy the provided GrSurface as its backing surface
31 void assign(sk_sp<GrSurface> surface) { fProxy->assign(std::move(surface)); }
32
Robert Phillips0ae6faa2017-03-21 16:22:00 -040033 // Don't abuse this call!!!!!!!
Robert Phillips40fd7c92017-01-30 08:06:27 -050034 bool isExact() const { return SkBackingFit::kExact == fProxy->fFit; }
35
Robert Phillips0ae6faa2017-03-21 16:22:00 -040036 // Don't. Just don't.
Robert Phillipse8976842019-08-09 08:27:26 -040037 void exactify(bool allocatedCaseOnly);
Robert Phillips0ae6faa2017-03-21 16:22:00 -040038
Brian Salomon9f2b86c2019-10-22 10:37:46 -040039 void setLazyDimensions(SkISize dimensions) { fProxy->setLazyDimensions(dimensions); }
Chris Daltonf91b7552019-04-29 16:21:18 -060040
Greg Danielbddcc952018-01-24 13:22:24 -050041 bool doLazyInstantiation(GrResourceProvider*);
Chris Dalton706a6ff2017-11-29 22:01:06 -070042
Robert Phillips757914d2017-01-25 15:48:30 -050043private:
44 explicit GrSurfaceProxyPriv(GrSurfaceProxy* proxy) : fProxy(proxy) {}
45 GrSurfaceProxyPriv(const GrSurfaceProxyPriv&) {} // unimpl
46 GrSurfaceProxyPriv& operator=(const GrSurfaceProxyPriv&); // unimpl
47
48 // No taking addresses of this type.
49 const GrSurfaceProxyPriv* operator&() const;
50 GrSurfaceProxyPriv* operator&();
51
52 GrSurfaceProxy* fProxy;
53
54 friend class GrSurfaceProxy; // to construct/copy this type.
55};
56
57inline GrSurfaceProxyPriv GrSurfaceProxy::priv() { return GrSurfaceProxyPriv(this); }
58
59inline const GrSurfaceProxyPriv GrSurfaceProxy::priv () const {
60 return GrSurfaceProxyPriv(const_cast<GrSurfaceProxy*>(this));
61}
62
63#endif