Bug 1690340 - Part 2: Use the new naming for the developer tools menu items. r=jdescottes
[gecko.git] / gfx / layers / SyncObject.h
blob03590dd436947b749b22795aa6150f65a738b53a
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/. */
7 #ifndef MOZILLA_GFX_LAYERS_SYNCOBJECT_H
8 #define MOZILLA_GFX_LAYERS_SYNCOBJECT_H
10 #include "mozilla/RefCounted.h"
12 struct ID3D11Device;
14 namespace mozilla {
15 namespace layers {
17 #ifdef XP_WIN
18 typedef void* SyncHandle;
19 #else
20 typedef uintptr_t SyncHandle;
21 #endif // XP_WIN
23 class SyncObjectHost : public RefCounted<SyncObjectHost> {
24 public:
25 MOZ_DECLARE_REFCOUNTED_VIRTUAL_TYPENAME(SyncObjectHost)
26 virtual ~SyncObjectHost() = default;
28 #ifdef XP_WIN
29 static already_AddRefed<SyncObjectHost> CreateSyncObjectHost(
30 ID3D11Device* aDevice);
31 #endif
32 virtual bool Init() = 0;
34 virtual SyncHandle GetSyncHandle() = 0;
36 // Return false for failed synchronization.
37 virtual bool Synchronize(bool aFallible = false) = 0;
39 protected:
40 SyncObjectHost() = default;
43 class SyncObjectClient : public external::AtomicRefCounted<SyncObjectClient> {
44 public:
45 MOZ_DECLARE_REFCOUNTED_VIRTUAL_TYPENAME(SyncObjectClient)
46 virtual ~SyncObjectClient() = default;
48 #ifdef XP_WIN
49 static already_AddRefed<SyncObjectClient> CreateSyncObjectClient(
50 SyncHandle aHandle, ID3D11Device* aDevice);
51 #endif
52 static already_AddRefed<SyncObjectClient>
53 CreateSyncObjectClientForContentDevice(SyncHandle aHandle);
55 enum class SyncType {
56 D3D11,
59 virtual SyncType GetSyncType() = 0;
61 // Return false for failed synchronization.
62 virtual bool Synchronize(bool aFallible = false) = 0;
64 virtual bool IsSyncObjectValid() = 0;
66 virtual void EnsureInitialized() = 0;
68 protected:
69 SyncObjectClient() = default;
72 } // namespace layers
73 } // namespace mozilla
75 #endif // MOZILLA_GFX_LAYERS_SYNCOBJECT_H