Flutter Engine
The Flutter Engine
Loading...
Searching...
No Matches
Recording.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_Recording_DEFINED
9#define skgpu_graphite_Recording_DEFINED
10
13
14#include <memory>
15#include <unordered_set>
16#include <vector>
17
18namespace skgpu {
19class RefCntedCallback;
20}
21
22namespace skgpu::graphite {
23
24class CommandBuffer;
25class RecordingPriv;
26class Resource;
28class TaskList;
29class Texture;
30class TextureInfo;
31class TextureProxy;
32
33class SK_API Recording final {
34public:
35 ~Recording();
36
38
39private:
40 friend class Recorder; // for ctor and LazyProxyData
41 friend class RecordingPriv;
42
43 // LazyProxyData is used if this recording should be replayed to a target that is provided on
44 // replay, and it handles the target proxy's instantiation with the provided target.
45 class LazyProxyData {
46 public:
47 LazyProxyData(const TextureInfo&);
48
49 TextureProxy* lazyProxy();
50 sk_sp<TextureProxy> refLazyProxy();
51
52 bool lazyInstantiate(ResourceProvider*, sk_sp<Texture>);
53
54 private:
55 sk_sp<Texture> fTarget;
56 sk_sp<TextureProxy> fTargetProxy;
57 };
58
59 struct ProxyHash {
60 std::size_t operator()(const sk_sp<TextureProxy>& proxy) const;
61 };
62
63 Recording(uint32_t uniqueID,
64 uint32_t recorderID,
65 std::unordered_set<sk_sp<TextureProxy>, ProxyHash>&& nonVolatileLazyProxies,
66 std::unordered_set<sk_sp<TextureProxy>, ProxyHash>&& volatileLazyProxies,
67 std::unique_ptr<LazyProxyData> targetProxyData,
69
70 bool addCommands(CommandBuffer*, ResourceProvider*);
71 void addResourceRef(sk_sp<Resource>);
72
73 // Used to verify ordering
74 uint32_t fUniqueID;
75 uint32_t fRecorderID;
76
77 // This is held by a pointer instead of being inline to allow TaskList to be forward declared.
78 std::unique_ptr<TaskList> fRootTaskList;
79 // We don't always take refs to all resources used by specific Tasks (e.g. a common buffer used
80 // for uploads). Instead we'll just hold onto one ref for those Resources outside the Tasks.
81 // Those refs are stored in the array here and will eventually be passed onto a CommandBuffer
82 // when the Recording adds its commands.
83 std::vector<sk_sp<Resource>> fExtraResourceRefs;
84
85 std::unordered_set<sk_sp<TextureProxy>, ProxyHash> fNonVolatileLazyProxies;
86 std::unordered_set<sk_sp<TextureProxy>, ProxyHash> fVolatileLazyProxies;
87
88 std::unique_ptr<LazyProxyData> fTargetProxyData;
89
91};
92
93} // namespace skgpu::graphite
94
95#endif // skgpu_graphite_Recording_DEFINED
#define SK_API
Definition SkAPI.h:35
FlPixelBufferTexturePrivate * priv