Coverage Report

Created: 2024-09-14 07:19

/src/skia/include/gpu/graphite/BackendSemaphore.h
Line
Count
Source (jump to first uncovered line)
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 skgpu_graphite_BackendSemaphore_DEFINED
9
#define skgpu_graphite_BackendSemaphore_DEFINED
10
11
#include "include/core/SkRefCnt.h"
12
#include "include/gpu/graphite/GraphiteTypes.h"
13
#include "include/private/base/SkAnySubclass.h"
14
15
namespace skgpu::graphite {
16
17
class BackendSemaphoreData;
18
19
class SK_API BackendSemaphore {
20
public:
21
    BackendSemaphore();
22
23
    BackendSemaphore(const BackendSemaphore&);
24
25
    ~BackendSemaphore();
26
27
    BackendSemaphore& operator=(const BackendSemaphore&);
28
29
0
    bool isValid() const { return fIsValid; }
30
0
    BackendApi backend() const { return fBackend; }
31
32
private:
33
    friend class BackendSemaphoreData;
34
    friend class BackendSemaphorePriv;
35
36
    // Size determined by looking at the BackendSemaphoreData subclasses, then
37
    // guessing-and-checking. Compiler will complain if this is too small - in that case, just
38
    // increase the number.
39
    inline constexpr static size_t kMaxSubclassSize = 24;
40
    using AnyBackendSemaphoreData = SkAnySubclass<BackendSemaphoreData, kMaxSubclassSize>;
41
42
    template <typename SomeBackendSemaphoreData>
43
    BackendSemaphore(BackendApi backend, const SomeBackendSemaphoreData& data)
44
0
            : fBackend(backend), fIsValid(true) {
45
0
        fSemaphoreData.emplace<SomeBackendSemaphoreData>(data);
46
0
    }
47
48
    BackendApi fBackend;
49
    AnyBackendSemaphoreData fSemaphoreData;
50
51
    bool fIsValid = false;
52
};
53
54
} // namespace skgpu::graphite
55
56
#endif // skgpu_graphite_BackendSemaphore_DEFINED
57