gfx/vr/VRDeviceProxyOrientationFallBack.h
author Mark Goodwin <mgoodwin@mozilla.com>
Mon, 01 Feb 2016 16:11:48 +0000
changeset 283075 75fe50edcf9aca16125fa9abf8011e6b36ba7634
parent 277855 03e3553c83beae1609ccf3415ec575568bef8c11
child 285063 32de5c14d7f8dd8563c3f6fd807ede191c1f254e
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_PROXY_ORIENTATION_FALLBACK_H
#define GFX_VR_PROXY_ORIENTATION_FALLBACK_H

#include "VRDeviceProxy.h"

#include "mozilla/HalSensor.h"
#include "mozilla/HalScreenConfiguration.h"

namespace mozilla {
namespace gfx {

class VRDeviceProxyOrientationFallBack : public VRDeviceProxy
                                       , public hal::ISensorObserver
                                       , public hal::ScreenConfigurationObserver
{
public:

  explicit VRDeviceProxyOrientationFallBack(const VRDeviceUpdate& aDeviceUpdate);

  virtual void ZeroSensor() override;
  virtual VRHMDSensorState GetSensorState(double timeOffset = 0.0) override;

  // ISensorObserver interface
  void Notify(const hal::SensorData& SensorData) override;
  // ScreenConfigurationObserver interface
  void Notify(const hal::ScreenConfiguration& ScreenConfiguration) override;


protected:
  virtual ~VRDeviceProxyOrientationFallBack();

  void StartSensorTracking();
  void StopSensorTracking();
  void ComputeStateFromLastSensor();

  uint32_t mOrient;
  Quaternion mScreenTransform;
  Quaternion mSensorZeroInverse;
  Quaternion mSavedLastSensor;
  double mSavedLastSensorTime;
  bool mNeedsSensorCompute;    // if we need to compute the state from mSavedLastSensor

  bool mTracking;
};

} // namespace gfx
} // namespace mozilla

#endif /* GFX_VR_PROXY_ORIENTATION_FALLBACK_H */