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

          Line data    Source code
       1             : /* -*- Mode: C++; tab-width: 2; 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 "VRLayerChild.h"
       7             : #include "GLScreenBuffer.h"
       8             : #include "mozilla/layers/TextureClientSharedSurface.h"
       9             : #include "SharedSurface.h"                // for SharedSurface
      10             : #include "SharedSurfaceGL.h"              // for SharedSurface
      11             : #include "mozilla/layers/LayersMessages.h" // for TimedTexture
      12             : #include "nsICanvasRenderingContextInternal.h"
      13             : #include "mozilla/dom/HTMLCanvasElement.h"
      14             : 
      15             : namespace mozilla {
      16             : namespace gfx {
      17             : 
      18           0 : VRLayerChild::VRLayerChild(uint32_t aVRDisplayID, VRManagerChild* aVRManagerChild)
      19             :   : mVRDisplayID(aVRDisplayID)
      20             :   , mCanvasElement(nullptr)
      21             :   , mShSurfClient(nullptr)
      22             :   , mFront(nullptr)
      23           0 :   , mIPCOpen(true)
      24             : {
      25           0 : }
      26             : 
      27           0 : VRLayerChild::~VRLayerChild()
      28             : {
      29           0 :   if (mCanvasElement) {
      30           0 :     mCanvasElement->StopVRPresentation();
      31             :   }
      32             : 
      33           0 :   ClearSurfaces();
      34             : 
      35           0 :   MOZ_COUNT_DTOR(VRLayerChild);
      36           0 : }
      37             : 
      38             : void
      39           0 : VRLayerChild::Initialize(dom::HTMLCanvasElement* aCanvasElement)
      40             : {
      41           0 :   MOZ_ASSERT(aCanvasElement);
      42           0 :   mCanvasElement = aCanvasElement;
      43           0 :   mCanvasElement->StartVRPresentation();
      44             : 
      45           0 :   VRManagerChild *vrmc = VRManagerChild::Get();
      46           0 :   vrmc->RunFrameRequestCallbacks();
      47           0 : }
      48             : 
      49             : void
      50           0 : VRLayerChild::SubmitFrame()
      51             : {
      52           0 :   if (!mCanvasElement) {
      53           0 :     return;
      54             :   }
      55             : 
      56           0 :   mShSurfClient = mCanvasElement->GetVRFrame();
      57           0 :   if (!mShSurfClient) {
      58           0 :     return;
      59             :   }
      60             : 
      61           0 :   gl::SharedSurface* surf = mShSurfClient->Surf();
      62           0 :   if (surf->mType == gl::SharedSurfaceType::Basic) {
      63           0 :     gfxCriticalError() << "SharedSurfaceType::Basic not supported for WebVR";
      64           0 :     return;
      65             :   }
      66             : 
      67           0 :   mFront = mShSurfClient;
      68           0 :   mShSurfClient = nullptr;
      69             : 
      70           0 :   mFront->SetAddedToCompositableClient();
      71           0 :   VRManagerChild* vrmc = VRManagerChild::Get();
      72           0 :   mFront->SyncWithObject(vrmc->GetSyncObject());
      73           0 :   MOZ_ALWAYS_TRUE(mFront->InitIPDLActor(vrmc));
      74             : 
      75           0 :   SendSubmitFrame(mFront->GetIPDLActor());
      76             : }
      77             : 
      78             : bool
      79           0 : VRLayerChild::IsIPCOpen()
      80             : {
      81           0 :   return mIPCOpen;
      82             : }
      83             : 
      84             : void
      85           0 : VRLayerChild::ClearSurfaces()
      86             : {
      87           0 :   mFront = nullptr;
      88           0 :   mShSurfClient = nullptr;
      89           0 : }
      90             : 
      91             : void
      92           0 : VRLayerChild::ActorDestroy(ActorDestroyReason aWhy)
      93             : {
      94           0 :   mIPCOpen = false;
      95           0 : }
      96             : 
      97             : } // namespace gfx
      98             : } // namespace mozilla

Generated by: LCOV version 1.13