gfx/vr/VRManager.h
author Mark Goodwin <mgoodwin@mozilla.com>
Mon, 01 Feb 2016 16:11:48 +0000
changeset 283075 75fe50edcf9aca16125fa9abf8011e6b36ba7634
parent 277855 03e3553c83beae1609ccf3415ec575568bef8c11
child 301499 232a786cf87fb0f68f9bda6e9316515524d2ac8a
permissions -rw-r--r--
Bug 1244776 - Update moz-kinto-client.js to include recent Kinto.js changes r=rnewman Please see the Kinto.js PR for the storage adapter changes: https://github.com/Kinto/kinto.js/pull/303 Additions and changes to the Firefox storage adapter tests have been made accordingly.

/* -*- 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_MANAGER_H
#define GFX_VR_MANAGER_H

#include "nsAutoPtr.h"
#include "nsRefPtrHashtable.h"
#include "nsTArray.h"
#include "nsTHashtable.h"
#include "mozilla/TimeStamp.h"
#include "gfxVR.h"

namespace mozilla {
namespace gfx {

class VRManagerParent;
class VRHMDInfo;

class VRManager
{
  NS_INLINE_DECL_THREADSAFE_REFCOUNTING(mozilla::gfx::VRManager)

public:
  static void ManagerInit();
  static VRManager* Get();

  void AddVRManagerParent(VRManagerParent* aVRManagerParent);
  void RemoveVRManagerParent(VRManagerParent* aVRManagerParent);

  void NotifyVsync(const TimeStamp& aVsyncTimestamp);
  void RefreshVRDevices();
  RefPtr<gfx::VRHMDInfo> GetDevice(const uint32_t& aDeviceID);

protected:
  VRManager();
  ~VRManager();

private:

  void Init();
  void Destroy();

  void DispatchVRDeviceInfoUpdate();
  void DispatchVRDeviceSensorUpdate();

  typedef nsTHashtable<nsRefPtrHashKey<VRManagerParent>> VRManagerParentSet;
  VRManagerParentSet mVRManagerParents;

  typedef nsTArray<RefPtr<VRHMDManager>> VRHMDManagerArray;
  VRHMDManagerArray mManagers;

  typedef nsRefPtrHashtable<nsUint32HashKey, gfx::VRHMDInfo> VRHMDInfoHashMap;
  VRHMDInfoHashMap mVRDevices;

  Atomic<bool> mInitialized;

};

} // namespace gfx
} // namespace mozilla

#endif // GFX_VR_MANAGER_H