Robert Phillips | 757914d | 2017-01-25 15:48:30 -0500 | [diff] [blame] | 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 | |
Greg Daniel | f91aeb2 | 2019-06-18 09:58:02 -0400 | [diff] [blame] | 11 | #include "src/gpu/GrSurfaceProxy.h" |
Robert Phillips | 757914d | 2017-01-25 15:48:30 -0500 | [diff] [blame] | 12 | |
Mike Klein | c0bd9f9 | 2019-04-23 12:05:21 -0500 | [diff] [blame] | 13 | #include "src/gpu/GrResourceProvider.h" |
Robert Phillips | f8e2502 | 2017-11-08 15:24:31 -0500 | [diff] [blame] | 14 | |
Robert Phillips | 757914d | 2017-01-25 15:48:30 -0500 | [diff] [blame] | 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: |
Robert Phillips | 57aa367 | 2017-07-21 11:38:13 -0400 | [diff] [blame] | 20 | void computeScratchKey(GrScratchKey* key) const { return fProxy->computeScratchKey(key); } |
| 21 | |
Robert Phillips | 5af44de | 2017-07-18 14:49:38 -0400 | [diff] [blame] | 22 | // Create a GrSurface-derived class that meets the requirements (i.e, desc, renderability) |
| 23 | // of the GrSurfaceProxy. |
| 24 | sk_sp<GrSurface> createSurface(GrResourceProvider* resourceProvider) const { |
| 25 | return fProxy->createSurface(resourceProvider); |
| 26 | } |
| 27 | |
| 28 | // Assign this proxy the provided GrSurface as its backing surface |
| 29 | void assign(sk_sp<GrSurface> surface) { fProxy->assign(std::move(surface)); } |
| 30 | |
Robert Phillips | 0ae6faa | 2017-03-21 16:22:00 -0400 | [diff] [blame] | 31 | // Don't abuse this call!!!!!!! |
Robert Phillips | 40fd7c9 | 2017-01-30 08:06:27 -0500 | [diff] [blame] | 32 | bool isExact() const { return SkBackingFit::kExact == fProxy->fFit; } |
| 33 | |
Robert Phillips | 0ae6faa | 2017-03-21 16:22:00 -0400 | [diff] [blame] | 34 | // Don't. Just don't. |
Robert Phillips | e897684 | 2019-08-09 08:27:26 -0400 | [diff] [blame] | 35 | void exactify(bool allocatedCaseOnly); |
Robert Phillips | 0ae6faa | 2017-03-21 16:22:00 -0400 | [diff] [blame] | 36 | |
Chris Dalton | f91b755 | 2019-04-29 16:21:18 -0600 | [diff] [blame] | 37 | void setLazySize(int width, int height) { fProxy->setLazySize(width, height); } |
| 38 | |
Greg Daniel | bddcc95 | 2018-01-24 13:22:24 -0500 | [diff] [blame] | 39 | bool doLazyInstantiation(GrResourceProvider*); |
Chris Dalton | 706a6ff | 2017-11-29 22:01:06 -0700 | [diff] [blame] | 40 | |
Brian Salomon | 876a017 | 2019-03-08 11:12:14 -0500 | [diff] [blame] | 41 | |
Robert Phillips | 01a9128 | 2018-07-26 08:03:04 -0400 | [diff] [blame] | 42 | static bool SK_WARN_UNUSED_RESULT AttachStencilIfNeeded(GrResourceProvider*, GrSurface*, |
Chris Dalton | effee20 | 2019-07-01 22:28:03 -0600 | [diff] [blame] | 43 | int minStencilSampleCount); |
Robert Phillips | eafd48a | 2017-11-16 07:52:08 -0500 | [diff] [blame] | 44 | |
Robert Phillips | 757914d | 2017-01-25 15:48:30 -0500 | [diff] [blame] | 45 | private: |
| 46 | explicit GrSurfaceProxyPriv(GrSurfaceProxy* proxy) : fProxy(proxy) {} |
| 47 | GrSurfaceProxyPriv(const GrSurfaceProxyPriv&) {} // unimpl |
| 48 | GrSurfaceProxyPriv& operator=(const GrSurfaceProxyPriv&); // unimpl |
| 49 | |
| 50 | // No taking addresses of this type. |
| 51 | const GrSurfaceProxyPriv* operator&() const; |
| 52 | GrSurfaceProxyPriv* operator&(); |
| 53 | |
| 54 | GrSurfaceProxy* fProxy; |
| 55 | |
| 56 | friend class GrSurfaceProxy; // to construct/copy this type. |
| 57 | }; |
| 58 | |
| 59 | inline GrSurfaceProxyPriv GrSurfaceProxy::priv() { return GrSurfaceProxyPriv(this); } |
| 60 | |
| 61 | inline const GrSurfaceProxyPriv GrSurfaceProxy::priv () const { |
| 62 | return GrSurfaceProxyPriv(const_cast<GrSurfaceProxy*>(this)); |
| 63 | } |
| 64 | |
| 65 | #endif |