blob: 9f83e4bc38367d2b500d3e3c7761be86dbf842e4 [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 sk_sp<GrSkSLFPFactoryCache> fpFactoryCache();
33
34 // GrContextThreadSafeProxyPriv
35 static sk_sp<GrContextThreadSafeProxy> Make(GrBackendApi,
36 const GrContextOptions&,
37 uint32_t contextID,
38 sk_sp<const GrCaps>,
39 sk_sp<GrSkSLFPFactoryCache>);
Brian Salomon52aacd62018-05-10 12:57:17 -040040
41private:
42 explicit GrContextThreadSafeProxyPriv(GrContextThreadSafeProxy* proxy) : fProxy(proxy) {}
43 GrContextThreadSafeProxyPriv(const GrContextThreadSafeProxy&) = delete;
44 GrContextThreadSafeProxyPriv& operator=(const GrContextThreadSafeProxyPriv&) = delete;
45
46 // No taking addresses of this type.
47 const GrContextThreadSafeProxyPriv* operator&() const = delete;
48 GrContextThreadSafeProxyPriv* operator&() = delete;
49
50 GrContextThreadSafeProxy* fProxy;
51
52 friend class GrContextThreadSafeProxy; // to construct/copy this type.
53};
54
55inline GrContextThreadSafeProxyPriv GrContextThreadSafeProxy::priv() {
56 return GrContextThreadSafeProxyPriv(this);
57}
58
59inline const GrContextThreadSafeProxyPriv GrContextThreadSafeProxy::priv() const {
60 return GrContextThreadSafeProxyPriv(const_cast<GrContextThreadSafeProxy*>(this));
61}
62
63#endif