blob: 4da021dd3f5656bbd995e8c863c43be8f350ae93 [file] [log] [blame]
Brian Salomon52aacd62018-05-10 12:57:17 -04001/*
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 Phillipsa0bc39d2019-01-29 13:14:47 -050011#include "GrContextThreadSafeProxy.h"
Brian Salomon52aacd62018-05-10 12:57:17 -040012
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 */
18class GrContextThreadSafeProxyPriv {
19public:
Robert Phillipsc1541ae2019-02-04 12:05:37 -050020 // from GrContext_Base
21 uint32_t contextID() const { return fProxy->contextID(); }
Brian Salomon52aacd62018-05-10 12:57:17 -040022
Robert Phillipsfe0963c2019-02-07 13:25:07 -050023 bool matches(GrContext_Base* candidate) const { return fProxy->matches(candidate); }
24
Robert Phillipsc1541ae2019-02-04 12:05:37 -050025 const GrContextOptions& options() const { return fProxy->options(); }
26
Robert Phillipsbb606772019-02-04 17:50:57 -050027 const GrCaps* caps() const { return fProxy->caps(); }
28 sk_sp<const GrCaps> refCaps() const { return fProxy->refCaps(); }
Robert Phillipsc1541ae2019-02-04 12:05:37 -050029
Robert Phillipsbb606772019-02-04 17:50:57 -050030 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 Salomon52aacd62018-05-10 12:57:17 -040038
39private:
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
53inline GrContextThreadSafeProxyPriv GrContextThreadSafeProxy::priv() {
54 return GrContextThreadSafeProxyPriv(this);
55}
56
57inline const GrContextThreadSafeProxyPriv GrContextThreadSafeProxy::priv() const {
58 return GrContextThreadSafeProxyPriv(const_cast<GrContextThreadSafeProxy*>(this));
59}
60
61#endif