2 * Copyright 2018 Google Inc.
4 * Use of this source code is governed by a BSD-style license that can be
5 * found in the LICENSE file.
8 #ifndef GrContextThreadSafeProxyPriv_DEFINED
9 #define GrContextThreadSafeProxyPriv_DEFINED
11 #include "include/gpu/GrContextThreadSafeProxy.h"
12 #include "include/private/gpu/ganesh/GrContext_Base.h"
14 #include "src/gpu/ganesh/GrCaps.h"
15 #include "src/text/gpu/TextBlobRedrawCoordinator.h"
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.
22 class GrContextThreadSafeProxyPriv {
24 void init(sk_sp<const GrCaps>, sk_sp<GrThreadSafePipelineBuilder>) const;
26 bool matches(GrContext_Base* candidate) const {
27 return fProxy == candidate->threadSafeProxy().get();
30 GrBackend backend() const { return fProxy->fBackend; }
31 const GrContextOptions& options() const { return fProxy->fOptions; }
32 uint32_t contextID() const { return fProxy->fContextID; }
34 const GrCaps* caps() const { return fProxy->fCaps.get(); }
35 sk_sp<const GrCaps> refCaps() const { return fProxy->fCaps; }
37 sktext::gpu::TextBlobRedrawCoordinator* getTextBlobRedrawCoordinator() {
38 return fProxy->fTextBlobRedrawCoordinator.get();
40 const sktext::gpu::TextBlobRedrawCoordinator* getTextBlobRedrawCoordinator() const {
41 return fProxy->fTextBlobRedrawCoordinator.get();
44 GrThreadSafeCache* threadSafeCache() { return fProxy->fThreadSafeCache.get(); }
45 const GrThreadSafeCache* threadSafeCache() const { return fProxy->fThreadSafeCache.get(); }
47 void abandonContext() { fProxy->abandonContext(); }
48 bool abandoned() const { return fProxy->abandoned(); }
50 // GrContextThreadSafeProxyPriv
51 static sk_sp<GrContextThreadSafeProxy> Make(GrBackendApi, const GrContextOptions&);
54 explicit GrContextThreadSafeProxyPriv(GrContextThreadSafeProxy* proxy) : fProxy(proxy) {}
55 GrContextThreadSafeProxyPriv& operator=(const GrContextThreadSafeProxyPriv&) = delete;
57 // No taking addresses of this type.
58 const GrContextThreadSafeProxyPriv* operator&() const = delete;
59 GrContextThreadSafeProxyPriv* operator&() = delete;
61 GrContextThreadSafeProxy* fProxy;
63 friend class GrContextThreadSafeProxy; // to construct/copy this type.
66 inline GrContextThreadSafeProxyPriv GrContextThreadSafeProxy::priv() {
67 return GrContextThreadSafeProxyPriv(this);
70 inline const GrContextThreadSafeProxyPriv GrContextThreadSafeProxy::priv() const { // NOLINT(readability-const-return-type)
71 return GrContextThreadSafeProxyPriv(const_cast<GrContextThreadSafeProxy*>(this));