blob: 8e299c818001d96b5d4ef6e92c4ce4f38ed890ce [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; }
26
27private:
28 explicit GrContextThreadSafeProxyPriv(GrContextThreadSafeProxy* proxy) : fProxy(proxy) {}
29 GrContextThreadSafeProxyPriv(const GrContextThreadSafeProxy&) = delete;
30 GrContextThreadSafeProxyPriv& operator=(const GrContextThreadSafeProxyPriv&) = delete;
31
32 // No taking addresses of this type.
33 const GrContextThreadSafeProxyPriv* operator&() const = delete;
34 GrContextThreadSafeProxyPriv* operator&() = delete;
35
36 GrContextThreadSafeProxy* fProxy;
37
38 friend class GrContextThreadSafeProxy; // to construct/copy this type.
39};
40
41inline GrContextThreadSafeProxyPriv GrContextThreadSafeProxy::priv() {
42 return GrContextThreadSafeProxyPriv(this);
43}
44
45inline const GrContextThreadSafeProxyPriv GrContextThreadSafeProxy::priv() const {
46 return GrContextThreadSafeProxyPriv(const_cast<GrContextThreadSafeProxy*>(this));
47}
48
49#endif