xref: /aosp_15_r20/external/skia/src/gpu/graphite/GpuWorkSubmission.h (revision c8dee2aa9b3f27cf6c858bd81872bdeb2c07ed17)
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_GpuWorkSubmission_DEFINED
9 #define skgpu_graphite_GpuWorkSubmission_DEFINED
10 
11 #include "include/core/SkRefCnt.h"
12 
13 #include <memory>
14 
15 namespace skgpu::graphite {
16 class CommandBuffer;
17 class SharedContext;
18 class QueueManager;
19 
20 class GpuWorkSubmission {
21 public:
22     virtual ~GpuWorkSubmission();
23 
24     bool isFinished(const SharedContext* sharedContext);
25     void waitUntilFinished(const SharedContext* sharedContext);
26 
27 protected:
commandBuffer()28     CommandBuffer* commandBuffer() { return fCommandBuffer.get(); }
29 
30     GpuWorkSubmission(std::unique_ptr<CommandBuffer> cmdBuffer, QueueManager* queueManager);
31 
32 private:
33     virtual bool onIsFinished(const SharedContext* sharedContext) = 0;
34     virtual void onWaitUntilFinished(const SharedContext* sharedContext) = 0;
35 
36     std::unique_ptr<CommandBuffer> fCommandBuffer;
37     sk_sp<SkRefCnt> fOutstandingAsyncMapCounter;
38     QueueManager* fQueueManager;
39 };
40 
41 } // namespace skgpu::graphite
42 
43 #endif // skgpu_graphite_GpuWorkSubmission_DEFINED
44