blob: e96afeaa47b69f9d8dcded5b645369d5946b719f [file] [log] [blame]
// Copyright 2019 The Chromium Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
#ifndef DEVICE_VR_OPENXR_OPENXR_DEVICE_H_
#define DEVICE_VR_OPENXR_OPENXR_DEVICE_H_
#include <memory>
#include "base/macros.h"
#include "device/vr/public/mojom/vr_service.mojom.h"
#include "device/vr/vr_device_base.h"
#include "mojo/public/cpp/bindings/pending_receiver.h"
namespace device {
class OpenXrRenderLoop;
class DEVICE_VR_EXPORT OpenXrDevice
: public VRDeviceBase,
public mojom::XRSessionController,
public mojom::IsolatedXRGamepadProviderFactory,
public mojom::XRCompositorHost {
public:
OpenXrDevice();
~OpenXrDevice() override;
static bool IsHardwareAvailable();
static bool IsApiAvailable();
// VRDeviceBase
void RequestSession(
mojom::XRRuntimeSessionOptionsPtr options,
mojom::XRRuntime::RequestSessionCallback callback) override;
mojom::IsolatedXRGamepadProviderFactoryPtr BindGamepadFactory();
mojom::XRCompositorHostPtr BindCompositorHost();
private:
// XRSessionController
void SetFrameDataRestricted(bool restricted) override;
// mojom::IsolatedXRGamepadProviderFactory
void GetIsolatedXRGamepadProvider(
mojo::PendingReceiver<mojom::IsolatedXRGamepadProvider> provider_receiver)
override;
// XRCompositorHost
void CreateImmersiveOverlay(
mojo::PendingReceiver<mojom::ImmersiveOverlay> overlay_receiver) override;
void EnsureRenderLoop();
void OnRequestSessionResult(mojom::XRRuntime::RequestSessionCallback callback,
bool result,
mojom::XRSessionPtr session);
void OnPresentingControllerMojoConnectionError();
std::unique_ptr<OpenXrRenderLoop> render_loop_;
mojo::Binding<mojom::XRSessionController> exclusive_controller_binding_;
mojo::Binding<mojom::IsolatedXRGamepadProviderFactory>
gamepad_provider_factory_binding_;
mojo::PendingReceiver<mojom::IsolatedXRGamepadProvider> provider_receiver_;
mojo::Binding<mojom::XRCompositorHost> compositor_host_binding_;
mojo::PendingReceiver<mojom::ImmersiveOverlay> overlay_receiver_;
base::WeakPtrFactory<OpenXrDevice> weak_ptr_factory_;
DISALLOW_COPY_AND_ASSIGN(OpenXrDevice);
};
} // namespace device
#endif // DEVICE_VR_OPENXR_OPENXR_DEVICE_H_