xref: /aosp_15_r20/external/skia/src/gpu/graphite/BackendSemaphorePriv.h (revision c8dee2aa9b3f27cf6c858bd81872bdeb2c07ed17)
1 /*
2  * Copyright 2024 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 #ifndef skgpu_graphite_BackendSemaphorePriv_DEFINED
8 #define skgpu_graphite_BackendSemaphorePriv_DEFINED
9 
10 #include "include/core/SkString.h"
11 #include "include/gpu/graphite/BackendSemaphore.h"
12 
13 #include <cstdint>
14 
15 namespace skgpu::graphite {
16 
17 class BackendSemaphoreData {
18 public:
19     virtual ~BackendSemaphoreData();
20 
21 #if defined(SK_DEBUG)
22     virtual skgpu::BackendApi type() const = 0;
23 #endif
24 protected:
25     BackendSemaphoreData() = default;
26     BackendSemaphoreData(const BackendSemaphoreData&) = default;
27 
28     using AnyBackendSemaphoreData = BackendSemaphore::AnyBackendSemaphoreData;
29 
30 private:
31     friend class BackendSemaphore;
32 
33     virtual void copyTo(AnyBackendSemaphoreData& dstData) const = 0;
34 };
35 
36 class BackendSemaphorePriv {
37 public:
38     template <typename SomeBackendSemaphoreData>
Make(BackendApi backend,const SomeBackendSemaphoreData & textureData)39     static BackendSemaphore Make(BackendApi backend, const SomeBackendSemaphoreData& textureData) {
40         return BackendSemaphore(backend, textureData);
41     }
42 
GetData(const BackendSemaphore & info)43     static const BackendSemaphoreData* GetData(const BackendSemaphore& info) {
44         return info.fSemaphoreData.get();
45     }
46 };
47 
48 }  // namespace skgpu::graphite
49 
50 #endif
51