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"
19 typedef RefPtr
<gfx::FileHandleWrapper
> SyncHandle
;
21 typedef uintptr_t SyncHandle
;
24 class SyncObjectHost
: public RefCounted
<SyncObjectHost
> {
26 MOZ_DECLARE_REFCOUNTED_VIRTUAL_TYPENAME(SyncObjectHost
)
27 virtual ~SyncObjectHost() = default;
30 static already_AddRefed
<SyncObjectHost
> CreateSyncObjectHost(
31 ID3D11Device
* aDevice
);
33 virtual bool Init() = 0;
35 virtual SyncHandle
GetSyncHandle() = 0;
37 // Return false for failed synchronization.
38 virtual bool Synchronize(bool aFallible
= false) = 0;
41 SyncObjectHost() = default;
44 class SyncObjectClient
: public external::AtomicRefCounted
<SyncObjectClient
> {
46 MOZ_DECLARE_REFCOUNTED_VIRTUAL_TYPENAME(SyncObjectClient
)
47 virtual ~SyncObjectClient() = default;
50 static already_AddRefed
<SyncObjectClient
> CreateSyncObjectClient(
51 SyncHandle aHandle
, ID3D11Device
* aDevice
);
53 static already_AddRefed
<SyncObjectClient
>
54 CreateSyncObjectClientForContentDevice(SyncHandle aHandle
);
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;
70 SyncObjectClient() = default;
74 } // namespace mozilla
76 #endif // MOZILLA_GFX_LAYERS_SYNCOBJECT_H