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 #include "VsyncBridgeParent.h"
7 #include "mozilla/ipc/Endpoint.h"
8 #include "mozilla/layers/CompositorBridgeParent.h"
9 #include "mozilla/layers/CompositorThread.h"
11 using mozilla::layers::CompositorBridgeParent
;
12 using mozilla::layers::CompositorThreadHolder
;
17 RefPtr
<VsyncBridgeParent
> VsyncBridgeParent::Start(
18 Endpoint
<PVsyncBridgeParent
>&& aEndpoint
) {
19 RefPtr
<VsyncBridgeParent
> parent
= new VsyncBridgeParent();
21 RefPtr
<Runnable
> task
= NewRunnableMethod
<Endpoint
<PVsyncBridgeParent
>&&>(
22 "gfx::VsyncBridgeParent::Open", parent
, &VsyncBridgeParent::Open
,
23 std::move(aEndpoint
));
24 layers::CompositorThread()->Dispatch(task
.forget());
29 VsyncBridgeParent::VsyncBridgeParent() : mOpen(false) {
30 MOZ_COUNT_CTOR(VsyncBridgeParent
);
31 mCompositorThreadRef
= CompositorThreadHolder::GetSingleton();
34 VsyncBridgeParent::~VsyncBridgeParent() { MOZ_COUNT_DTOR(VsyncBridgeParent
); }
36 void VsyncBridgeParent::Open(Endpoint
<PVsyncBridgeParent
>&& aEndpoint
) {
37 if (!aEndpoint
.Bind(this)) {
38 // We can't recover from this.
39 MOZ_CRASH("Failed to bind VsyncBridgeParent to endpoint");
44 mozilla::ipc::IPCResult
VsyncBridgeParent::RecvNotifyVsync(
45 const VsyncEvent
& aVsync
, const LayersId
& aLayersId
) {
46 CompositorBridgeParent::NotifyVsync(aVsync
, aLayersId
);
50 void VsyncBridgeParent::Shutdown() {
51 if (!CompositorThreadHolder::IsInCompositorThread()) {
52 layers::CompositorThread()->Dispatch(
53 NewRunnableMethod("gfx::VsyncBridgeParent::ShutdownImpl", this,
54 &VsyncBridgeParent::ShutdownImpl
));
61 void VsyncBridgeParent::ShutdownImpl() {
68 void VsyncBridgeParent::ActorDestroy(ActorDestroyReason aWhy
) {
70 mCompositorThreadRef
= nullptr;
74 } // namespace mozilla