2017-10-27 20:33:53 +03:00
|
|
|
/* -*- Mode: C++; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
|
|
|
|
/* vim: set ts=8 sts=2 et sw=2 tw=80: */
|
2015-01-14 02:37:00 +03:00
|
|
|
/* This Source Code Form is subject to the terms of the Mozilla Public
|
|
|
|
* License, v. 2.0. If a copy of the MPL was not distributed with this
|
|
|
|
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */
|
|
|
|
|
|
|
|
#ifndef mozilla_layout_ipc_VsyncChild_h
|
|
|
|
#define mozilla_layout_ipc_VsyncChild_h
|
|
|
|
|
|
|
|
#include "mozilla/layout/PVsyncChild.h"
|
2015-01-30 00:19:00 +03:00
|
|
|
#include "nsISupportsImpl.h"
|
2015-10-18 08:24:48 +03:00
|
|
|
#include "mozilla/RefPtr.h"
|
2015-01-14 02:37:00 +03:00
|
|
|
|
|
|
|
namespace mozilla {
|
|
|
|
|
|
|
|
class VsyncObserver;
|
|
|
|
|
|
|
|
namespace ipc {
|
|
|
|
class BackgroundChildImpl;
|
2015-07-13 18:25:42 +03:00
|
|
|
} // namespace ipc
|
2015-01-14 02:37:00 +03:00
|
|
|
|
|
|
|
namespace layout {
|
|
|
|
|
|
|
|
// The PVsyncChild actor receives a vsync event from the main process and
|
|
|
|
// delivers it to the child process. Currently this is restricted to the main
|
|
|
|
// thread only. The actor will stay alive until the process dies or its
|
|
|
|
// PVsyncParent actor dies.
|
2015-03-21 19:28:04 +03:00
|
|
|
class VsyncChild final : public PVsyncChild
|
2015-01-14 02:37:00 +03:00
|
|
|
{
|
2015-01-30 00:19:00 +03:00
|
|
|
NS_INLINE_DECL_REFCOUNTING(VsyncChild)
|
|
|
|
|
2015-01-14 02:37:00 +03:00
|
|
|
friend class mozilla::ipc::BackgroundChildImpl;
|
|
|
|
|
|
|
|
public:
|
|
|
|
// Hide the SendObserve/SendUnobserve in PVsyncChild. We add an flag
|
|
|
|
// mObservingVsync to handle the race problem of unobserving vsync event.
|
|
|
|
bool SendObserve();
|
|
|
|
bool SendUnobserve();
|
|
|
|
|
|
|
|
// Bind a VsyncObserver into VsyncChild after ipc channel connected.
|
|
|
|
void SetVsyncObserver(VsyncObserver* aVsyncObserver);
|
2016-11-10 12:01:51 +03:00
|
|
|
// GetVsyncRate is a getter for mVsyncRate which sends a requests to
|
|
|
|
// VsyncParent to retreive the hardware vsync rate if mVsyncRate
|
|
|
|
// hasn't already been set.
|
2015-11-06 19:20:58 +03:00
|
|
|
TimeDuration GetVsyncRate();
|
2016-11-10 12:01:51 +03:00
|
|
|
// VsyncRate is a getter for mVsyncRate which always returns
|
|
|
|
// mVsyncRate directly, potentially returning
|
|
|
|
// TimeDuration::Forever() if mVsyncRate hasn't been set by calling
|
|
|
|
// GetVsyncRate.
|
|
|
|
TimeDuration VsyncRate();
|
2015-01-14 02:37:00 +03:00
|
|
|
|
|
|
|
private:
|
|
|
|
VsyncChild();
|
|
|
|
virtual ~VsyncChild();
|
|
|
|
|
2016-11-15 06:26:00 +03:00
|
|
|
virtual mozilla::ipc::IPCResult RecvNotify(const TimeStamp& aVsyncTimestamp) override;
|
|
|
|
virtual mozilla::ipc::IPCResult RecvVsyncRate(const float& aVsyncRate) override;
|
2015-03-21 19:28:04 +03:00
|
|
|
virtual void ActorDestroy(ActorDestroyReason aActorDestroyReason) override;
|
2015-01-14 02:37:00 +03:00
|
|
|
|
|
|
|
bool mObservingVsync;
|
2015-01-30 00:19:00 +03:00
|
|
|
bool mIsShutdown;
|
2015-01-14 02:37:00 +03:00
|
|
|
|
|
|
|
// The content side vsync observer.
|
2015-10-18 08:24:48 +03:00
|
|
|
RefPtr<VsyncObserver> mObserver;
|
2015-11-06 19:20:58 +03:00
|
|
|
TimeDuration mVsyncRate;
|
2015-01-14 02:37:00 +03:00
|
|
|
};
|
|
|
|
|
|
|
|
} // namespace layout
|
2015-07-13 18:25:42 +03:00
|
|
|
} // namespace mozilla
|
2015-01-14 02:37:00 +03:00
|
|
|
|
|
|
|
#endif // mozilla_layout_ipc_VsyncChild_h
|