| 1 |
/* |
| 2 |
* Copyright 2023 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 GrBackendSemaphorePriv_DEFINED |
| 9 |
#define GrBackendSemaphorePriv_DEFINED |
| 10 |
|
| 11 |
#include "include/core/SkTypes.h" |
| 12 |
#include "include/gpu/ganesh/GrBackendSemaphore.h" |
| 13 |
|
| 14 |
enum class GrBackendApi : unsigned int; |
| 15 |
|
| 16 |
class GrBackendSemaphoreData { |
| 17 |
public: |
| 18 |
virtual ~GrBackendSemaphoreData(); |
| 19 |
|
| 20 |
#if defined(SK_DEBUG) |
| 21 |
virtual GrBackendApi type() const = 0; |
| 22 |
#endif |
| 23 |
protected: |
| 24 |
GrBackendSemaphoreData() = default; |
| 25 |
GrBackendSemaphoreData(const GrBackendSemaphoreData&) = default; |
| 26 |
|
| 27 |
using AnySemaphoreData = GrBackendSemaphore::AnySemaphoreData; |
| 28 |
|
| 29 |
private: |
| 30 |
friend class GrBackendSemaphore; |
| 31 |
virtual void copyTo(AnySemaphoreData&) const = 0; |
| 32 |
}; |
| 33 |
|
| 34 |
class GrBackendSemaphorePriv final { |
| 35 |
public: |
| 36 |
template <typename SemaphoreData> |
| 37 |
static GrBackendSemaphore MakeGrBackendSemaphore(GrBackendApi backend, |
| 38 |
const SemaphoreData& data) { |
| 39 |
return GrBackendSemaphore(backend, data); |
| 40 |
} |
| 41 |
|
| 42 |
static const GrBackendSemaphoreData* GetBackendData(const GrBackendSemaphore& sem) { |
| 43 |
return sem.fSemaphoreData.get(); |
| 44 |
} |
| 45 |
}; |
| 46 |
|
| 47 |
#endif |