blob: 0efb995a3578f86ae8fbeaf347a0bc7a6897229a [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
Mike Kleinc0bd9f92019-04-23 12:05:21 -050011#include "include/gpu/GrContextThreadSafeProxy.h"
Brian Salomon52aacd62018-05-10 12:57:17 -040012
Hal Canary02eefbe2019-06-26 13:54:14 -040013#include "src/gpu/GrCaps.h"
14
Brian Salomon52aacd62018-05-10 12:57:17 -040015/**
16 * Class that adds methods to GrContextThreadSafeProxy that are only intended for use internal to
17 * Skia. This class is purely a privileged window into GrContextThreadSafeProxy. It should never
18 * have additional data members or virtual methods.
19 */
20class GrContextThreadSafeProxyPriv {
21public:
Robert Phillipsc1541ae2019-02-04 12:05:37 -050022 // from GrContext_Base
23 uint32_t contextID() const { return fProxy->contextID(); }
Brian Salomon52aacd62018-05-10 12:57:17 -040024
Robert Phillipsfe0963c2019-02-07 13:25:07 -050025 bool matches(GrContext_Base* candidate) const { return fProxy->matches(candidate); }
26
Robert Phillipsc1541ae2019-02-04 12:05:37 -050027 const GrContextOptions& options() const { return fProxy->options(); }
28
Robert Phillipsbb606772019-02-04 17:50:57 -050029 const GrCaps* caps() const { return fProxy->caps(); }
30 sk_sp<const GrCaps> refCaps() const { return fProxy->refCaps(); }
Robert Phillipsc1541ae2019-02-04 12:05:37 -050031
Robert Phillipsbb606772019-02-04 17:50:57 -050032 // GrContextThreadSafeProxyPriv
33 static sk_sp<GrContextThreadSafeProxy> Make(GrBackendApi,
34 const GrContextOptions&,
35 uint32_t contextID,
Brian Osman7b1678a2019-12-16 09:17:25 -050036 sk_sp<const GrCaps>);
Brian Salomon52aacd62018-05-10 12:57:17 -040037
38private:
39 explicit GrContextThreadSafeProxyPriv(GrContextThreadSafeProxy* proxy) : fProxy(proxy) {}
40 GrContextThreadSafeProxyPriv(const GrContextThreadSafeProxy&) = delete;
41 GrContextThreadSafeProxyPriv& operator=(const GrContextThreadSafeProxyPriv&) = delete;
42
43 // No taking addresses of this type.
44 const GrContextThreadSafeProxyPriv* operator&() const = delete;
45 GrContextThreadSafeProxyPriv* operator&() = delete;
46
47 GrContextThreadSafeProxy* fProxy;
48
49 friend class GrContextThreadSafeProxy; // to construct/copy this type.
50};
51
52inline GrContextThreadSafeProxyPriv GrContextThreadSafeProxy::priv() {
53 return GrContextThreadSafeProxyPriv(this);
54}
55
56inline const GrContextThreadSafeProxyPriv GrContextThreadSafeProxy::priv() const {
57 return GrContextThreadSafeProxyPriv(const_cast<GrContextThreadSafeProxy*>(this));
58}
59
60#endif