gfx/vr/VRDeviceProxyOrientationFallBack.h
author Gerald Squelart <gsquelart@mozilla.com>
Sun, 27 Mar 2016 19:57:25 +1100
changeset 323692 f0bcd999646ef34545e9c48d206ea8504b468d8c
parent 321399 32de5c14d7f8dd8563c3f6fd807ede191c1f254e
permissions -rw-r--r--
Bug 1259985 - Add missing return after null-check - r=jya a=lizzard MozReview-Commit-ID: 138NM9xTmVA

/* -*- 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() override;
  virtual VRHMDSensorState GetImmediateSensorState() 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 */