Source code

Revision control

Other Tools

1
/* -*- Mode: C++; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
2
/* vim: set ts=8 sts=2 et sw=2 tw=80: */
3
/* This Source Code Form is subject to the terms of the Mozilla Public
4
* License, v. 2.0. If a copy of the MPL was not distributed with this
5
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */
6
7
#ifndef MOZILLA_GFX_LAYERS_SYNCOBJECT_H
8
#define MOZILLA_GFX_LAYERS_SYNCOBJECT_H
9
10
#include "mozilla/RefCounted.h"
11
12
struct ID3D11Device;
13
14
namespace mozilla {
15
namespace layers {
16
17
#ifdef XP_WIN
18
typedef void* SyncHandle;
19
#else
20
typedef uintptr_t SyncHandle;
21
#endif // XP_WIN
22
23
class SyncObjectHost : public RefCounted<SyncObjectHost> {
24
public:
25
MOZ_DECLARE_REFCOUNTED_VIRTUAL_TYPENAME(SyncObjectHost)
26
virtual ~SyncObjectHost() = default;
27
28
static already_AddRefed<SyncObjectHost> CreateSyncObjectHost(
29
#ifdef XP_WIN
30
ID3D11Device* aDevice = nullptr
31
#endif
32
);
33
34
virtual bool Init() = 0;
35
36
virtual SyncHandle GetSyncHandle() = 0;
37
38
// Return false for failed synchronization.
39
virtual bool Synchronize(bool aFallible = false) = 0;
40
41
protected:
42
SyncObjectHost() = default;
43
};
44
45
class SyncObjectClient : public external::AtomicRefCounted<SyncObjectClient> {
46
public:
47
MOZ_DECLARE_REFCOUNTED_VIRTUAL_TYPENAME(SyncObjectClient)
48
virtual ~SyncObjectClient() = default;
49
50
static already_AddRefed<SyncObjectClient> CreateSyncObjectClient(
51
SyncHandle aHandle
52
#ifdef XP_WIN
53
,
54
ID3D11Device* aDevice = nullptr
55
#endif
56
);
57
58
enum class SyncType {
59
D3D11,
60
};
61
62
virtual SyncType GetSyncType() = 0;
63
64
// Return false for failed synchronization.
65
virtual bool Synchronize(bool aFallible = false) = 0;
66
67
virtual bool IsSyncObjectValid() = 0;
68
69
protected:
70
SyncObjectClient() = default;
71
};
72
73
} // namespace layers
74
} // namespace mozilla
75
76
#endif // MOZILLA_GFX_LAYERS_SYNCOBJECT_H