Update rive-cpp to 2.0 version
[platform/core/uifw/rive-tizen.git] / submodule / skia / src / gpu / ganesh / GrContextThreadSafeProxyPriv.h
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 #include "include/private/gpu/ganesh/GrContext_Base.h"
13
14 #include "src/gpu/ganesh/GrCaps.h"
15 #include "src/text/gpu/TextBlobRedrawCoordinator.h"
16
17 /**
18  * Class that adds methods to GrContextThreadSafeProxy that are only intended for use internal to
19  * Skia. This class is purely a privileged window into GrContextThreadSafeProxy. It should never
20  * have additional data members or virtual methods.
21  */
22 class GrContextThreadSafeProxyPriv {
23 public:
24     void init(sk_sp<const GrCaps>, sk_sp<GrThreadSafePipelineBuilder>) const;
25
26     bool matches(GrContext_Base* candidate) const {
27         return fProxy == candidate->threadSafeProxy().get();
28     }
29
30     GrBackend backend() const { return fProxy->fBackend; }
31     const GrContextOptions& options() const { return fProxy->fOptions; }
32     uint32_t contextID() const { return fProxy->fContextID; }
33
34     const GrCaps* caps() const { return fProxy->fCaps.get(); }
35     sk_sp<const GrCaps> refCaps() const { return fProxy->fCaps; }
36
37     sktext::gpu::TextBlobRedrawCoordinator* getTextBlobRedrawCoordinator() {
38         return fProxy->fTextBlobRedrawCoordinator.get();
39     }
40     const sktext::gpu::TextBlobRedrawCoordinator* getTextBlobRedrawCoordinator() const {
41         return fProxy->fTextBlobRedrawCoordinator.get();
42     }
43
44     GrThreadSafeCache* threadSafeCache() { return fProxy->fThreadSafeCache.get(); }
45     const GrThreadSafeCache* threadSafeCache() const { return fProxy->fThreadSafeCache.get(); }
46
47     void abandonContext() { fProxy->abandonContext(); }
48     bool abandoned() const { return fProxy->abandoned(); }
49
50     // GrContextThreadSafeProxyPriv
51     static sk_sp<GrContextThreadSafeProxy> Make(GrBackendApi, const GrContextOptions&);
52
53 private:
54     explicit GrContextThreadSafeProxyPriv(GrContextThreadSafeProxy* proxy) : fProxy(proxy) {}
55     GrContextThreadSafeProxyPriv& operator=(const GrContextThreadSafeProxyPriv&) = delete;
56
57     // No taking addresses of this type.
58     const GrContextThreadSafeProxyPriv* operator&() const = delete;
59     GrContextThreadSafeProxyPriv* operator&() = delete;
60
61     GrContextThreadSafeProxy* fProxy;
62
63     friend class GrContextThreadSafeProxy;  // to construct/copy this type.
64 };
65
66 inline GrContextThreadSafeProxyPriv GrContextThreadSafeProxy::priv() {
67     return GrContextThreadSafeProxyPriv(this);
68 }
69
70 inline const GrContextThreadSafeProxyPriv GrContextThreadSafeProxy::priv() const {  // NOLINT(readability-const-return-type)
71     return GrContextThreadSafeProxyPriv(const_cast<GrContextThreadSafeProxy*>(this));
72 }
73
74 #endif