Flutter Engine
The Flutter Engine
Loading...
Searching...
No Matches
ContextPriv.h
Go to the documentation of this file.
1/*
2 * Copyright 2021 Google LLC
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 skgpu_graphite_ContextPriv_DEFINED
9#define skgpu_graphite_ContextPriv_DEFINED
10
14
15#if defined(GRAPHITE_TEST_UTILS)
17#endif
18
19namespace skgpu::graphite {
20
21class Caps;
22class GlobalCache;
23class RendererProvider;
25class ShaderCodeDictionary;
26
27/** Class that adds methods to Context that are only intended for use internal to Skia.
28 This class is purely a privileged window into Context. It should never have additional
29 data members or virtual methods. */
31public:
32 const Caps* caps() const { return fContext->fSharedContext->caps(); }
33
35 return fContext->fSharedContext->shaderCodeDictionary();
36 }
38 return fContext->fSharedContext->shaderCodeDictionary();
39 }
40 const GlobalCache* globalCache() const {
41 return fContext->fSharedContext->globalCache();
42 }
44 return fContext->fSharedContext->globalCache();
45 }
47 return fContext->fSharedContext->rendererProvider();
48 }
50 return fContext->fResourceProvider.get();
51 }
52
53#if defined(GRAPHITE_TEST_UTILS)
54 void startCapture() {
55 fContext->fQueueManager->startCapture();
56 }
57 void stopCapture() {
58 fContext->fQueueManager->stopCapture();
59 }
60
61 void deregisterRecorder(const Recorder*);
62
63 bool readPixels(const SkPixmap&,
64 const TextureProxy*,
65 const SkImageInfo& srcImageInfo,
66 int srcX, int srcY);
67
68 bool supportsPathRendererStrategy(PathRendererStrategy);
69#endif
70
71private:
72 friend class Context; // to construct/copy this type.
73
74 explicit ContextPriv(Context* context) : fContext(context) {}
75
76 ContextPriv& operator=(const ContextPriv&) = delete;
77
78 // No taking addresses of this type.
79 const ContextPriv* operator&() const;
81
83};
84
85inline ContextPriv Context::priv() { return ContextPriv(this); }
86
87// NOLINTNEXTLINE(readability-const-return-type)
88inline const ContextPriv Context::priv() const {
89 return ContextPriv(const_cast<Context *>(this));
90}
91
92// This class is friended by the Context and allows the backend ContextFactory functions to
93// trampoline through this to call the private Context ctor. We can't directly friend the factory
94// functions in Context because they are in a different namespace and we don't want to declare the
95// functions in Context.h
97public:
98 static std::unique_ptr<Context> MakeContext(sk_sp<SharedContext>,
99 std::unique_ptr<QueueManager>,
100 const ContextOptions&);
101};
102
103} // namespace skgpu::graphite
104
105#endif // skgpu_graphite_ContextPriv_DEFINED
std::enable_if_t< sknonstd::is_bitmask_enum< E >::value, E > constexpr operator&(E l, E r)
const Context & fContext
static std::unique_ptr< Context > MakeContext(sk_sp< SharedContext >, std::unique_ptr< QueueManager >, const ContextOptions &)
Definition Context.cpp:926
GlobalCache * globalCache()
Definition ContextPriv.h:43
const GlobalCache * globalCache() const
Definition ContextPriv.h:40
ShaderCodeDictionary * shaderCodeDictionary()
Definition ContextPriv.h:37
const RendererProvider * rendererProvider() const
Definition ContextPriv.h:46
const Caps * caps() const
Definition ContextPriv.h:32
ResourceProvider * resourceProvider() const
Definition ContextPriv.h:49
const ShaderCodeDictionary * shaderCodeDictionary() const
Definition ContextPriv.h:34
friend class ContextPriv
Definition Context.h:209