blob: b3a4eab021f12498697c857dd13b526d5da809fa [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
11#include "GrContext.h"
12
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:
20 const GrContextOptions& contextOptions() { return fProxy->fOptions; }
21
22 const GrCaps* caps() const { return fProxy->fCaps.get(); }
23 sk_sp<const GrCaps> refCaps() const { return fProxy->fCaps; }
24 uint32_t contextUniqueID() const { return fProxy->fContextUniqueID; }
25 GrBackend backend() const { return fProxy->fBackend; }
Ethan Nicholas00543112018-07-31 09:44:36 -040026 sk_sp<GrSkSLFPFactoryCache> fpFactoryCache() const { return fProxy->fFPFactoryCache; }
Brian Salomon52aacd62018-05-10 12:57:17 -040027
28private:
29 explicit GrContextThreadSafeProxyPriv(GrContextThreadSafeProxy* proxy) : fProxy(proxy) {}
30 GrContextThreadSafeProxyPriv(const GrContextThreadSafeProxy&) = delete;
31 GrContextThreadSafeProxyPriv& operator=(const GrContextThreadSafeProxyPriv&) = delete;
32
33 // No taking addresses of this type.
34 const GrContextThreadSafeProxyPriv* operator&() const = delete;
35 GrContextThreadSafeProxyPriv* operator&() = delete;
36
37 GrContextThreadSafeProxy* fProxy;
38
39 friend class GrContextThreadSafeProxy; // to construct/copy this type.
40};
41
42inline GrContextThreadSafeProxyPriv GrContextThreadSafeProxy::priv() {
43 return GrContextThreadSafeProxyPriv(this);
44}
45
46inline const GrContextThreadSafeProxyPriv GrContextThreadSafeProxy::priv() const {
47 return GrContextThreadSafeProxyPriv(const_cast<GrContextThreadSafeProxy*>(this));
48}
49
50#endif