• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
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  */
20 class GrContextThreadSafeProxyPriv {
21 public:
22     // from GrContext_Base
contextID()23     uint32_t contextID() const { return fProxy->contextID(); }
24 
matches(GrContext_Base * candidate)25     bool matches(GrContext_Base* candidate) const { return fProxy->matches(candidate); }
26 
options()27     const GrContextOptions& options() const { return fProxy->options(); }
28 
caps()29     const GrCaps* caps() const { return fProxy->caps(); }
refCaps()30     sk_sp<const GrCaps> refCaps() const { return fProxy->refCaps(); }
31 
32     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>);
40 
41 private:
GrContextThreadSafeProxyPriv(GrContextThreadSafeProxy * proxy)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 
priv()55 inline GrContextThreadSafeProxyPriv GrContextThreadSafeProxy::priv() {
56     return GrContextThreadSafeProxyPriv(this);
57 }
58 
priv()59 inline const GrContextThreadSafeProxyPriv GrContextThreadSafeProxy::priv() const {
60     return GrContextThreadSafeProxyPriv(const_cast<GrContextThreadSafeProxy*>(this));
61 }
62 
63 #endif
64