gfx/vr/VRDisplayClient.h
author Ethan Glasser-Camp <eglassercamp@mozilla.com>
Mon, 05 Sep 2016 13:18:25 -0400
changeset 313090 9377cc9dc164dcadcd76c881484617310a461161
parent 309340 7b1349cb7487ce1b03a6f91c016315f9e8fdd0ec
child 332233 c57f055716dd63bef3b20a2b67b8dbfc3c7c4d58
permissions -rw-r--r--
Bug 1300591 - Update Kinto.js to v4.0.4, r=MattN MozReview-Commit-ID: B5pB3AmjjAL

/* -*- Mode: C++; tab-width: 20; indent-tabs-mode: nil; c-basic-offset: 2 -*-
 * 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 GFX_VR_DISPLAY_CLIENT_H
#define GFX_VR_DISPLAY_CLIENT_H

#include "nsIScreen.h"
#include "nsCOMPtr.h"
#include "mozilla/RefPtr.h"
#include "mozilla/dom/VRDisplayBinding.h"

#include "gfxVR.h"

namespace mozilla {
namespace gfx {
class VRDisplayPresentation;
class VRManagerChild;

class VRDisplayClient
{
public:
  NS_INLINE_DECL_THREADSAFE_REFCOUNTING(VRDisplayClient)

  explicit VRDisplayClient(const VRDisplayInfo& aDisplayInfo);

  void UpdateDisplayInfo(const VRDisplayInfo& aDisplayInfo);

  const VRDisplayInfo& GetDisplayInfo() const { return mDisplayInfo; }
  virtual VRHMDSensorState GetSensorState();
  virtual VRHMDSensorState GetImmediateSensorState();

  virtual void ZeroSensor();

  already_AddRefed<VRDisplayPresentation> BeginPresentation(const nsTArray<dom::VRLayer>& aLayers);
  void PresentationDestroyed();

  void NotifyVsync();
  void NotifyVRVsync();

  bool GetIsConnected() const;
  bool GetIsPresenting() const;

  void NotifyDisconnected();

protected:
  virtual ~VRDisplayClient();

  VRDisplayInfo mDisplayInfo;

  bool bLastEventWasPresenting;

  TimeStamp mLastVSyncTime;
  int mPresentationCount;
};

} // namespace gfx
} // namespace mozilla

#endif /* GFX_VR_DISPLAY_CLIENT_H */