Debian Codegraph @

src/gpu/graphite/RecordingPriv.h

raw
1 /*
2 * Copyright 2022 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_RecordingPriv_DEFINED
9 #define skgpu_graphite_RecordingPriv_DEFINED
10
11 #include "include/core/SkPoint.h"
12 #include "include/core/SkRefCnt.h" // IWYU pragma: keep
13 #include "include/gpu/graphite/Recording.h"
14
15 #include <cstdint>
16 #include <memory>
17
18 struct SkIRect;
19
20 namespace skgpu::graphite {
21
22 class CommandBuffer;
23 class Context;
24 class Resource;
25 class ResourceProvider;
26 class RuntimeEffectDictionary;
27 class ScratchResourceManager;
28 class Surface;
29 class TaskList;
30 class Texture;
31 class TextureProxy;
32
33 class RecordingPriv {
34 public:
35 TextureProxy* deferredTargetProxy();
36 const Texture* setupDeferredTarget(ResourceProvider*,
37 Surface* targetSurface,
38 SkIVector targetTranslation,
39 SkIRect targetClip);
40
41 bool hasVolatileLazyProxies() const;
42 bool instantiateVolatileLazyProxies(ResourceProvider*);
43 void deinstantiateVolatileLazyProxies();
44
45 bool hasNonVolatileLazyProxies() const;
46 bool instantiateNonVolatileLazyProxies(ResourceProvider*);
47
48 void setFailureResultForFinishedProcs();
49
50 bool prepareResources(ResourceProvider*,
51 ScratchResourceManager*,
52 sk_sp<const RuntimeEffectDictionary>);
53
54 bool addCommands(Context*,
55 CommandBuffer*,
56 const Texture* replayTarget,
57 SkIVector targetTranslation,
58 SkIRect targetClip);
59 // This will eventually lead to adding a Usage Ref on the CommandBuffer. For now that is fine
60 // since the only Resource's we are reffing here are Buffers. However, if we ever want to track
61 // Textures or GPU only Buffers as well, we should keep a second list for Refs that we want to
62 // put CommandBuffer refs on.
63 void addResourceRef(sk_sp<Resource> resource);
64
65 TaskList* taskList() { return fRecording->fRootTaskList.get(); }
66
67 uint32_t recorderID() const { return fRecording->fRecorderID; }
68 uint32_t uniqueID() const { return fRecording->fUniqueID; }
69
70 #if defined(GPU_TEST_UTILS)
71 bool isTargetProxyInstantiated() const;
72 int numVolatilePromiseImages() const;
73 int numNonVolatilePromiseImages() const;
74 bool hasTasks() const;
75 #endif
76
77 private:
78 explicit RecordingPriv(Recording* recorder) : fRecording(recorder) {}
79 RecordingPriv& operator=(const RecordingPriv&) = delete;
80
81 // No taking addresses of this type.
82 const RecordingPriv* operator&() const = delete;
83 RecordingPriv* operator&() = delete;
84
85 Recording* fRecording;
86
87 friend class Recording; // to construct/copy this type.
88 };
89
90 inline RecordingPriv Recording::priv() {
91 return RecordingPriv(this);
92 }
93
94 } // namespace skgpu::graphite
95
96 #endif // skgpu_graphite_RecordingPriv_DEFINED