Debian Codegraph @

src/gpu/ganesh/gl/GrGLFinishCallbacks.h

raw
1 /*
2 * Copyright 2020 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 GrGLFinishCallbacks_DEFINED
9 #define GrGLFinishCallbacks_DEFINED
10
11 #include "include/gpu/ganesh/gl/GrGLTypes.h"
12 #include "src/gpu/RefCntedCallback.h"
13
14 #include <list>
15
16 class GrGLGpu;
17
18 /**
19 * Maintains a list of callbacks to be called when work on the GPU is complete.
20 */
21
22 class GrGLFinishCallbacks {
23 public:
24 GrGLFinishCallbacks(GrGLGpu* gpu);
25 ~GrGLFinishCallbacks();
26
27 /**
28 * Call all the callbacks in the list. This will block until all work is done.
29 *
30 * @param doDelete delete the contained fence object.
31 */
32 void callAll(bool doDelete);
33
34 /**
35 * Add a new callback to the list.
36 *
37 * @param finishedProc The function to call when GPU work is complete.
38 * @param finishedContext The context object to pass back to the callback.
39 * @param timerQuery A timer query to get the result from when finished.
40 */
41 void add(skgpu::AutoCallback, GrGLint timerQeury = 0);
42
43 /**
44 * Check if any GPU work is complete, and call the associated callbacks.
45 * This call is non-blocking.
46 */
47 void check();
48
49 /**
50 * Returns true if the callback list is empty.
51 */
52 bool empty() const { return fCallbacks.empty(); }
53
54 private:
55 struct FinishCallback {
56 skgpu::AutoCallback fCallback;
57 GrGLsync fSync;
58 GrGLint fTimerQuery;
59 };
60
61 GrGLGpu* fGpu;
62 std::list<FinishCallback> fCallbacks;
63 };
64
65 #endif // GrGLFinishCallbacks