Bug 1882703 [wpt PR 44848] - Update wpt metadata, a=testonly
[gecko.git] / gfx / layers / SyncObject.h
blob14871c1bfad670595563dc80f3215aea612e65ae
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/gfx/FileHandleWrapper.h"
11 #include "mozilla/RefCounted.h"
13 struct ID3D11Device;
15 namespace mozilla {
16 namespace layers {
18 #ifdef XP_WIN
19 typedef RefPtr<gfx::FileHandleWrapper> SyncHandle;
20 #else
21 typedef uintptr_t SyncHandle;
22 #endif // XP_WIN
24 class SyncObjectHost : public RefCounted<SyncObjectHost> {
25 public:
26 MOZ_DECLARE_REFCOUNTED_VIRTUAL_TYPENAME(SyncObjectHost)
27 virtual ~SyncObjectHost() = default;
29 #ifdef XP_WIN
30 static already_AddRefed<SyncObjectHost> CreateSyncObjectHost(
31 ID3D11Device* aDevice);
32 #endif
33 virtual bool Init() = 0;
35 virtual SyncHandle GetSyncHandle() = 0;
37 // Return false for failed synchronization.
38 virtual bool Synchronize(bool aFallible = false) = 0;
40 protected:
41 SyncObjectHost() = default;
44 class SyncObjectClient : public external::AtomicRefCounted<SyncObjectClient> {
45 public:
46 MOZ_DECLARE_REFCOUNTED_VIRTUAL_TYPENAME(SyncObjectClient)
47 virtual ~SyncObjectClient() = default;
49 #ifdef XP_WIN
50 static already_AddRefed<SyncObjectClient> CreateSyncObjectClient(
51 SyncHandle aHandle, ID3D11Device* aDevice);
52 #endif
53 static already_AddRefed<SyncObjectClient>
54 CreateSyncObjectClientForContentDevice(SyncHandle aHandle);
56 enum class SyncType {
57 D3D11,
60 virtual SyncType GetSyncType() = 0;
62 // Return false for failed synchronization.
63 virtual bool Synchronize(bool aFallible = false) = 0;
65 virtual bool IsSyncObjectValid() = 0;
67 virtual void EnsureInitialized() = 0;
69 protected:
70 SyncObjectClient() = default;
73 } // namespace layers
74 } // namespace mozilla
76 #endif // MOZILLA_GFX_LAYERS_SYNCOBJECT_H