Flutter Engine
The Flutter Engine
GrBackendSemaphore.h
Go to the documentation of this file.
1/*
2 * Copyright 2017 Google Inc.
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 GrBackendSemaphore_DEFINED
9#define GrBackendSemaphore_DEFINED
10
11#include "include/gpu/GrTypes.h" // IWYU pragma: keep
14
15#ifdef SK_DIRECT3D
17#endif
18
19#include <cstddef>
20
22
23/**
24 * Wrapper class for passing into and receiving data from Ganesh about a backend semaphore object.
25 */
27public:
28 // The GrBackendSemaphore cannot be used until either init* is called, which will set the
29 // appropriate GrBackend.
33 GrBackendSemaphore& operator=(const GrBackendSemaphore&);
34
35#ifdef SK_DIRECT3D
36 void initDirect3D(const GrD3DFenceInfo& info) {
37 fBackend = GrBackendApi::kDirect3D;
38 this->assignD3DFenceInfo(info);
39 fIsInitialized = true;
40 }
41#endif
42
43 bool isInitialized() const { return fIsInitialized; }
44 GrBackendApi backend() const { return fBackend; }
45
46#ifdef SK_DIRECT3D
47 bool getD3DFenceInfo(GrD3DFenceInfo* outInfo) const;
48#endif
49
50private:
53 // Size determined by looking at the GrBackendSemaphoreData subclasses, then
54 // guessing-and-checking. Compiler will complain if this is too small - in that case,
55 // just increase the number.
56 inline constexpr static size_t kMaxSubclassSize = 24;
58
59 template <typename SemaphoreData>
60 GrBackendSemaphore(GrBackendApi api, SemaphoreData data) : fBackend(api), fIsInitialized(true) {
61 fSemaphoreData.emplace<SemaphoreData>(data);
62 }
63
64#ifdef SK_DIRECT3D
65 void assignD3DFenceInfo(const GrD3DFenceInfo& info);
66#endif
67
68 GrBackendApi fBackend;
69 AnySemaphoreData fSemaphoreData;
70
71 union {
72 void* fPlaceholder; // TODO(293490566)
73#ifdef SK_DIRECT3D
74 GrD3DFenceInfo* fD3DFenceInfo;
75#endif
76 };
77 bool fIsInitialized;
78};
79
80#endif
static void info(const char *fmt,...) SK_PRINTF_LIKE(1
Definition: DM.cpp:213
GrBackendApi
Definition: GrTypes.h:95
#define SK_API
Definition: SkAPI.h:35
GrBackendSemaphore::AnySemaphoreData AnySemaphoreData
GrBackendApi backend() const
bool isInitialized() const
std::shared_ptr< const fml::Mapping > data
Definition: texture_gles.cc:63