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
11#include "include/gpu/GrContextThreadSafeProxy.h"
12
13#include "src/gpu/GrCaps.h"
14
15/**
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:
22 // from GrContext_Base
23 uint32_t contextID() const { return fProxy->contextID(); }
24
25 bool matches(GrContext_Base* candidate) const { return fProxy->matches(candidate); }
26
27 const GrContextOptions& options() const { return fProxy->options(); }
28
29 const GrCaps* caps() const { return fProxy->caps(); }
30 sk_sp<const GrCaps> refCaps() const { return fProxy->refCaps(); }
31
32 // GrContextThreadSafeProxyPriv
33 static sk_sp<GrContextThreadSafeProxy> Make(GrBackendApi,
34 const GrContextOptions&,
35 uint32_t contextID,
36 sk_sp<const GrCaps>);
37
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
61