LCOV - code coverage report
Current view: top level - gfx/vr - VRDisplayClient.cpp (source / functions) Hit Total Coverage
Test: output.info Lines: 0 57 0.0 %
Date: 2017-07-14 16:53:18 Functions: 0 14 0.0 %
Legend: Lines: hit not hit

          Line data    Source code
       1             : /* -*- Mode: C++; tab-width: 20; indent-tabs-mode: nil; c-basic-offset: 2 -*-
       2             :  * This Source Code Form is subject to the terms of the Mozilla Public
       3             :  * License, v. 2.0. If a copy of the MPL was not distributed with this
       4             :  * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
       5             : 
       6             : #include <math.h>
       7             : 
       8             : #include "prlink.h"
       9             : #include "prenv.h"
      10             : #include "gfxPrefs.h"
      11             : #include "nsString.h"
      12             : #include "mozilla/Preferences.h"
      13             : #include "mozilla/Unused.h"
      14             : #include "nsServiceManagerUtils.h"
      15             : #include "nsIScreenManager.h"
      16             : 
      17             : #ifdef XP_WIN
      18             : #include "../layers/d3d11/CompositorD3D11.h"
      19             : #endif
      20             : 
      21             : #include "VRDisplayClient.h"
      22             : #include "VRDisplayPresentation.h"
      23             : #include "VRManagerChild.h"
      24             : #include "VRLayerChild.h"
      25             : 
      26             : using namespace mozilla;
      27             : using namespace mozilla::gfx;
      28             : 
      29           0 : VRDisplayClient::VRDisplayClient(const VRDisplayInfo& aDisplayInfo)
      30             :   : mDisplayInfo(aDisplayInfo)
      31             :   , bLastEventWasMounted(false)
      32             :   , bLastEventWasPresenting(false)
      33             :   , mPresentationCount(0)
      34           0 :   , mLastEventFrameId(0)
      35             : {
      36           0 :   MOZ_COUNT_CTOR(VRDisplayClient);
      37           0 : }
      38             : 
      39           0 : VRDisplayClient::~VRDisplayClient() {
      40           0 :   MOZ_COUNT_DTOR(VRDisplayClient);
      41           0 : }
      42             : 
      43             : void
      44           0 : VRDisplayClient::UpdateDisplayInfo(const VRDisplayInfo& aDisplayInfo)
      45             : {
      46           0 :   mDisplayInfo = aDisplayInfo;
      47           0 :   FireEvents();
      48           0 : }
      49             : 
      50             : already_AddRefed<VRDisplayPresentation>
      51           0 : VRDisplayClient::BeginPresentation(const nsTArray<mozilla::dom::VRLayer>& aLayers,
      52             :                                    uint32_t aGroup)
      53             : {
      54           0 :   ++mPresentationCount;
      55           0 :   RefPtr<VRDisplayPresentation> presentation = new VRDisplayPresentation(this, aLayers, aGroup);
      56           0 :   return presentation.forget();
      57             : }
      58             : 
      59             : void
      60           0 : VRDisplayClient::PresentationDestroyed()
      61             : {
      62           0 :   --mPresentationCount;
      63           0 : }
      64             : 
      65             : void
      66           0 : VRDisplayClient::ZeroSensor()
      67             : {
      68           0 :   VRManagerChild *vm = VRManagerChild::Get();
      69           0 :   vm->SendResetSensor(mDisplayInfo.mDisplayID);
      70           0 : }
      71             : 
      72             : void
      73           0 : VRDisplayClient::SetGroupMask(uint32_t aGroupMask)
      74             : {
      75           0 :   VRManagerChild *vm = VRManagerChild::Get();
      76           0 :   vm->SendSetGroupMask(mDisplayInfo.mDisplayID, aGroupMask);
      77           0 : }
      78             : 
      79             : void
      80           0 : VRDisplayClient::FireEvents()
      81             : {
      82           0 :   VRManagerChild *vm = VRManagerChild::Get();
      83             :   // Only fire these events for non-chrome VR sessions
      84           0 :   bool isPresenting = (mDisplayInfo.mPresentingGroups & kVRGroupContent) != 0;
      85             : 
      86             :   // Check if we need to trigger onVRDisplayPresentChange event
      87           0 :   if (bLastEventWasPresenting != isPresenting) {
      88           0 :     bLastEventWasPresenting = isPresenting;
      89           0 :     vm->FireDOMVRDisplayPresentChangeEvent(mDisplayInfo.mDisplayID);
      90             :   }
      91             : 
      92             :   // Check if we need to trigger onvrdisplayactivate event
      93           0 :   if (!bLastEventWasMounted && mDisplayInfo.mIsMounted) {
      94           0 :     bLastEventWasMounted = true;
      95           0 :     if (gfxPrefs::VRAutoActivateEnabled()) {
      96           0 :       vm->FireDOMVRDisplayMountedEvent(mDisplayInfo.mDisplayID);
      97             :     }
      98             :   }
      99             : 
     100             :   // Check if we need to trigger onvrdisplaydeactivate event
     101           0 :   if (bLastEventWasMounted && !mDisplayInfo.mIsMounted) {
     102           0 :     bLastEventWasMounted = false;
     103           0 :     if (gfxPrefs::VRAutoActivateEnabled()) {
     104           0 :       vm->FireDOMVRDisplayUnmountedEvent(mDisplayInfo.mDisplayID);
     105             :     }
     106             :   }
     107             : 
     108             :   // Check if we need to trigger VRDisplay.requestAnimationFrame
     109           0 :   if (mLastEventFrameId != mDisplayInfo.mFrameId) {
     110           0 :     mLastEventFrameId = mDisplayInfo.mFrameId;
     111           0 :     vm->RunFrameRequestCallbacks();
     112             :   }
     113           0 : }
     114             : 
     115             : VRHMDSensorState
     116           0 : VRDisplayClient::GetSensorState()
     117             : {
     118           0 :   return mDisplayInfo.GetSensorState();
     119             : }
     120             : 
     121             : bool
     122           0 : VRDisplayClient::GetIsConnected() const
     123             : {
     124           0 :   return mDisplayInfo.GetIsConnected();
     125             : }
     126             : 
     127             : void
     128           0 : VRDisplayClient::NotifyDisconnected()
     129             : {
     130           0 :   mDisplayInfo.mIsConnected = false;
     131           0 : }
     132             : 
     133             : void
     134           0 : VRDisplayClient::UpdateSubmitFrameResult(const VRSubmitFrameResultInfo& aResult)
     135             : {
     136           0 :   mSubmitFrameResult = aResult;
     137           0 : }
     138             : 
     139             : void
     140           0 : VRDisplayClient::GetSubmitFrameResult(VRSubmitFrameResultInfo& aResult)
     141             : {
     142           0 :   aResult = mSubmitFrameResult;
     143           0 : }

Generated by: LCOV version 1.13