xref: /aosp_15_r20/external/skia/src/gpu/ganesh/GrContextThreadSafeProxyPriv.h (revision c8dee2aa9b3f27cf6c858bd81872bdeb2c07ed17)
1*c8dee2aaSAndroid Build Coastguard Worker /*
2*c8dee2aaSAndroid Build Coastguard Worker  * Copyright 2018 Google Inc.
3*c8dee2aaSAndroid Build Coastguard Worker  *
4*c8dee2aaSAndroid Build Coastguard Worker  * Use of this source code is governed by a BSD-style license that can be
5*c8dee2aaSAndroid Build Coastguard Worker  * found in the LICENSE file.
6*c8dee2aaSAndroid Build Coastguard Worker  */
7*c8dee2aaSAndroid Build Coastguard Worker 
8*c8dee2aaSAndroid Build Coastguard Worker #ifndef GrContextThreadSafeProxyPriv_DEFINED
9*c8dee2aaSAndroid Build Coastguard Worker #define GrContextThreadSafeProxyPriv_DEFINED
10*c8dee2aaSAndroid Build Coastguard Worker 
11*c8dee2aaSAndroid Build Coastguard Worker #include "include/gpu/ganesh/GrContextThreadSafeProxy.h"
12*c8dee2aaSAndroid Build Coastguard Worker #include "include/private/gpu/ganesh/GrContext_Base.h"
13*c8dee2aaSAndroid Build Coastguard Worker 
14*c8dee2aaSAndroid Build Coastguard Worker #include "src/gpu/ganesh/GrCaps.h"
15*c8dee2aaSAndroid Build Coastguard Worker #include "src/text/gpu/TextBlobRedrawCoordinator.h"
16*c8dee2aaSAndroid Build Coastguard Worker 
17*c8dee2aaSAndroid Build Coastguard Worker /**
18*c8dee2aaSAndroid Build Coastguard Worker  * Class that adds methods to GrContextThreadSafeProxy that are only intended for use internal to
19*c8dee2aaSAndroid Build Coastguard Worker  * Skia. This class is purely a privileged window into GrContextThreadSafeProxy. It should never
20*c8dee2aaSAndroid Build Coastguard Worker  * have additional data members or virtual methods.
21*c8dee2aaSAndroid Build Coastguard Worker  */
22*c8dee2aaSAndroid Build Coastguard Worker class GrContextThreadSafeProxyPriv {
23*c8dee2aaSAndroid Build Coastguard Worker public:
24*c8dee2aaSAndroid Build Coastguard Worker     void init(sk_sp<const GrCaps>, sk_sp<GrThreadSafePipelineBuilder>) const;
25*c8dee2aaSAndroid Build Coastguard Worker 
matches(GrContext_Base * candidate)26*c8dee2aaSAndroid Build Coastguard Worker     bool matches(GrContext_Base* candidate) const {
27*c8dee2aaSAndroid Build Coastguard Worker         return fProxy == candidate->threadSafeProxy().get();
28*c8dee2aaSAndroid Build Coastguard Worker     }
29*c8dee2aaSAndroid Build Coastguard Worker 
backend()30*c8dee2aaSAndroid Build Coastguard Worker     GrBackend backend() const { return fProxy->fBackend; }
options()31*c8dee2aaSAndroid Build Coastguard Worker     const GrContextOptions& options() const { return fProxy->fOptions; }
contextID()32*c8dee2aaSAndroid Build Coastguard Worker     uint32_t contextID() const { return fProxy->fContextID; }
33*c8dee2aaSAndroid Build Coastguard Worker 
caps()34*c8dee2aaSAndroid Build Coastguard Worker     const GrCaps* caps() const { return fProxy->fCaps.get(); }
refCaps()35*c8dee2aaSAndroid Build Coastguard Worker     sk_sp<const GrCaps> refCaps() const { return fProxy->fCaps; }
36*c8dee2aaSAndroid Build Coastguard Worker 
getTextBlobRedrawCoordinator()37*c8dee2aaSAndroid Build Coastguard Worker     sktext::gpu::TextBlobRedrawCoordinator* getTextBlobRedrawCoordinator() {
38*c8dee2aaSAndroid Build Coastguard Worker         return fProxy->fTextBlobRedrawCoordinator.get();
39*c8dee2aaSAndroid Build Coastguard Worker     }
getTextBlobRedrawCoordinator()40*c8dee2aaSAndroid Build Coastguard Worker     const sktext::gpu::TextBlobRedrawCoordinator* getTextBlobRedrawCoordinator() const {
41*c8dee2aaSAndroid Build Coastguard Worker         return fProxy->fTextBlobRedrawCoordinator.get();
42*c8dee2aaSAndroid Build Coastguard Worker     }
43*c8dee2aaSAndroid Build Coastguard Worker 
threadSafeCache()44*c8dee2aaSAndroid Build Coastguard Worker     GrThreadSafeCache* threadSafeCache() { return fProxy->fThreadSafeCache.get(); }
threadSafeCache()45*c8dee2aaSAndroid Build Coastguard Worker     const GrThreadSafeCache* threadSafeCache() const { return fProxy->fThreadSafeCache.get(); }
46*c8dee2aaSAndroid Build Coastguard Worker 
abandonContext()47*c8dee2aaSAndroid Build Coastguard Worker     void abandonContext() { fProxy->abandonContext(); }
abandoned()48*c8dee2aaSAndroid Build Coastguard Worker     bool abandoned() const { return fProxy->abandoned(); }
49*c8dee2aaSAndroid Build Coastguard Worker 
50*c8dee2aaSAndroid Build Coastguard Worker     // GrContextThreadSafeProxyPriv
51*c8dee2aaSAndroid Build Coastguard Worker     static sk_sp<GrContextThreadSafeProxy> Make(GrBackendApi, const GrContextOptions&);
52*c8dee2aaSAndroid Build Coastguard Worker 
53*c8dee2aaSAndroid Build Coastguard Worker private:
GrContextThreadSafeProxyPriv(GrContextThreadSafeProxy * proxy)54*c8dee2aaSAndroid Build Coastguard Worker     explicit GrContextThreadSafeProxyPriv(GrContextThreadSafeProxy* proxy) : fProxy(proxy) {}
55*c8dee2aaSAndroid Build Coastguard Worker     GrContextThreadSafeProxyPriv& operator=(const GrContextThreadSafeProxyPriv&) = delete;
56*c8dee2aaSAndroid Build Coastguard Worker 
57*c8dee2aaSAndroid Build Coastguard Worker     // No taking addresses of this type.
58*c8dee2aaSAndroid Build Coastguard Worker     const GrContextThreadSafeProxyPriv* operator&() const = delete;
59*c8dee2aaSAndroid Build Coastguard Worker     GrContextThreadSafeProxyPriv* operator&() = delete;
60*c8dee2aaSAndroid Build Coastguard Worker 
61*c8dee2aaSAndroid Build Coastguard Worker     GrContextThreadSafeProxy* fProxy;
62*c8dee2aaSAndroid Build Coastguard Worker 
63*c8dee2aaSAndroid Build Coastguard Worker     friend class GrContextThreadSafeProxy;  // to construct/copy this type.
64*c8dee2aaSAndroid Build Coastguard Worker };
65*c8dee2aaSAndroid Build Coastguard Worker 
priv()66*c8dee2aaSAndroid Build Coastguard Worker inline GrContextThreadSafeProxyPriv GrContextThreadSafeProxy::priv() {
67*c8dee2aaSAndroid Build Coastguard Worker     return GrContextThreadSafeProxyPriv(this);
68*c8dee2aaSAndroid Build Coastguard Worker }
69*c8dee2aaSAndroid Build Coastguard Worker 
priv()70*c8dee2aaSAndroid Build Coastguard Worker inline const GrContextThreadSafeProxyPriv GrContextThreadSafeProxy::priv() const {  // NOLINT(readability-const-return-type)
71*c8dee2aaSAndroid Build Coastguard Worker     return GrContextThreadSafeProxyPriv(const_cast<GrContextThreadSafeProxy*>(this));
72*c8dee2aaSAndroid Build Coastguard Worker }
73*c8dee2aaSAndroid Build Coastguard Worker 
74*c8dee2aaSAndroid Build Coastguard Worker #endif
75