Brian Salomon | 52aacd6 | 2018-05-10 12:57:17 -0400 | [diff] [blame] | 1 | /* |
| 2 | * Copyright 2018 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 GrContextThreadSafeProxyPriv_DEFINED |
| 9 | #define GrContextThreadSafeProxyPriv_DEFINED |
| 10 | |
Robert Phillips | a0bc39d | 2019-01-29 13:14:47 -0500 | [diff] [blame] | 11 | #include "GrContextThreadSafeProxy.h" |
Brian Salomon | 52aacd6 | 2018-05-10 12:57:17 -0400 | [diff] [blame] | 12 | |
| 13 | /** |
| 14 | * Class that adds methods to GrContextThreadSafeProxy that are only intended for use internal to |
| 15 | * Skia. This class is purely a privileged window into GrContextThreadSafeProxy. It should never |
| 16 | * have additional data members or virtual methods. |
| 17 | */ |
| 18 | class GrContextThreadSafeProxyPriv { |
| 19 | public: |
Robert Phillips | c1541ae | 2019-02-04 12:05:37 -0500 | [diff] [blame] | 20 | // from GrContext_Base |
| 21 | uint32_t contextID() const { return fProxy->contextID(); } |
Brian Salomon | 52aacd6 | 2018-05-10 12:57:17 -0400 | [diff] [blame] | 22 | |
Robert Phillips | fe0963c | 2019-02-07 13:25:07 -0500 | [diff] [blame] | 23 | bool matches(GrContext_Base* candidate) const { return fProxy->matches(candidate); } |
| 24 | |
Robert Phillips | c1541ae | 2019-02-04 12:05:37 -0500 | [diff] [blame] | 25 | const GrContextOptions& options() const { return fProxy->options(); } |
| 26 | |
Robert Phillips | bb60677 | 2019-02-04 17:50:57 -0500 | [diff] [blame] | 27 | const GrCaps* caps() const { return fProxy->caps(); } |
| 28 | sk_sp<const GrCaps> refCaps() const { return fProxy->refCaps(); } |
Robert Phillips | c1541ae | 2019-02-04 12:05:37 -0500 | [diff] [blame] | 29 | |
Robert Phillips | bb60677 | 2019-02-04 17:50:57 -0500 | [diff] [blame] | 30 | sk_sp<GrSkSLFPFactoryCache> fpFactoryCache(); |
| 31 | |
| 32 | // GrContextThreadSafeProxyPriv |
| 33 | static sk_sp<GrContextThreadSafeProxy> Make(GrBackendApi, |
| 34 | const GrContextOptions&, |
| 35 | uint32_t contextID, |
| 36 | sk_sp<const GrCaps>, |
| 37 | sk_sp<GrSkSLFPFactoryCache>); |
Brian Salomon | 52aacd6 | 2018-05-10 12:57:17 -0400 | [diff] [blame] | 38 | |
| 39 | private: |
| 40 | explicit GrContextThreadSafeProxyPriv(GrContextThreadSafeProxy* proxy) : fProxy(proxy) {} |
| 41 | GrContextThreadSafeProxyPriv(const GrContextThreadSafeProxy&) = delete; |
| 42 | GrContextThreadSafeProxyPriv& operator=(const GrContextThreadSafeProxyPriv&) = delete; |
| 43 | |
| 44 | // No taking addresses of this type. |
| 45 | const GrContextThreadSafeProxyPriv* operator&() const = delete; |
| 46 | GrContextThreadSafeProxyPriv* operator&() = delete; |
| 47 | |
| 48 | GrContextThreadSafeProxy* fProxy; |
| 49 | |
| 50 | friend class GrContextThreadSafeProxy; // to construct/copy this type. |
| 51 | }; |
| 52 | |
| 53 | inline GrContextThreadSafeProxyPriv GrContextThreadSafeProxy::priv() { |
| 54 | return GrContextThreadSafeProxyPriv(this); |
| 55 | } |
| 56 | |
| 57 | inline const GrContextThreadSafeProxyPriv GrContextThreadSafeProxy::priv() const { |
| 58 | return GrContextThreadSafeProxyPriv(const_cast<GrContextThreadSafeProxy*>(this)); |
| 59 | } |
| 60 | |
| 61 | #endif |