| OLD | NEW |
| 1 // Copyright 2016 The Chromium Authors. All rights reserved. | 1 // Copyright 2016 The Chromium Authors. All rights reserved. |
| 2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
| 3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
| 4 | 4 |
| 5 #ifndef DEVICE_VR_VR_DISPLAY_IMPL_H | 5 #ifndef DEVICE_VR_VR_DISPLAY_IMPL_H |
| 6 #define DEVICE_VR_VR_DISPLAY_IMPL_H | 6 #define DEVICE_VR_VR_DISPLAY_IMPL_H |
| 7 | 7 |
| 8 #include <memory> | 8 #include <memory> |
| 9 | 9 |
| 10 #include "base/macros.h" | 10 #include "base/macros.h" |
| 11 #include "base/memory/weak_ptr.h" | 11 #include "base/memory/weak_ptr.h" |
| 12 #include "device/vr/vr_device.h" | 12 #include "device/vr/vr_device.h" |
| 13 #include "device/vr/vr_export.h" | 13 #include "device/vr/vr_export.h" |
| 14 #include "device/vr/vr_service.mojom.h" | 14 #include "device/vr/vr_service.mojom.h" |
| 15 #include "mojo/public/cpp/bindings/binding.h" | 15 #include "mojo/public/cpp/bindings/binding.h" |
| 16 | 16 |
| 17 namespace device { | 17 namespace device { |
| 18 | 18 |
| 19 class VRServiceImpl; | 19 class VRServiceImpl; |
| 20 | 20 |
| 21 // Browser process representation of a VRDevice within a WebVR site session |
| 22 // (see VRServiceImpl). VRDisplayImpl receives/sends VR device events |
| 23 // from/to mojom::VRDisplayClient (the render process representation of a VR |
| 24 // device). |
| 25 // VRDisplayImpl objects are owned by their respective VRServiceImpl instances. |
| 21 class VRDisplayImpl : public mojom::VRDisplay { | 26 class VRDisplayImpl : public mojom::VRDisplay { |
| 22 public: | 27 public: |
| 23 VRDisplayImpl(device::VRDevice* device, VRServiceImpl* service); | 28 VRDisplayImpl(device::VRDevice* device, |
| 29 VRServiceImpl* service, |
| 30 mojom::VRServiceClient* service_client, |
| 31 mojom::VRDisplayInfoPtr display_info); |
| 24 ~VRDisplayImpl() override; | 32 ~VRDisplayImpl() override; |
| 25 | 33 |
| 26 mojom::VRDisplayClient* client() { return client_.get(); } | 34 virtual void OnChanged(mojom::VRDisplayInfoPtr vr_device_info); |
| 35 virtual void OnExitPresent(); |
| 36 virtual void OnBlur(); |
| 37 virtual void OnFocus(); |
| 38 virtual void OnActivate(mojom::VRDisplayEventReason reason); |
| 39 virtual void OnDeactivate(mojom::VRDisplayEventReason reason); |
| 27 | 40 |
| 28 private: | 41 private: |
| 29 friend class VRDisplayImplTest; | 42 friend class VRDisplayImplTest; |
| 30 friend class VRServiceImpl; | 43 friend class VRServiceImpl; |
| 31 | 44 |
| 32 void ResetPose() override; | 45 void ResetPose() override; |
| 33 | 46 |
| 34 void RequestPresent(bool secure_origin, | 47 void RequestPresent(bool secure_origin, |
| 35 mojom::VRSubmitFrameClientPtr submit_client, | 48 mojom::VRSubmitFrameClientPtr submit_client, |
| 36 const RequestPresentCallback& callback) override; | 49 const RequestPresentCallback& callback) override; |
| 37 void ExitPresent() override; | 50 void ExitPresent() override; |
| 38 void SubmitFrame(int16_t frame_index, | 51 void SubmitFrame(int16_t frame_index, |
| 39 const gpu::MailboxHolder& mailbox) override; | 52 const gpu::MailboxHolder& mailbox) override; |
| 40 | 53 |
| 41 void UpdateLayerBounds(int16_t frame_index, | 54 void UpdateLayerBounds(int16_t frame_index, |
| 42 mojom::VRLayerBoundsPtr left_bounds, | 55 mojom::VRLayerBoundsPtr left_bounds, |
| 43 mojom::VRLayerBoundsPtr right_bounds, | 56 mojom::VRLayerBoundsPtr right_bounds, |
| 44 int16_t source_width, | 57 int16_t source_width, |
| 45 int16_t source_height) override; | 58 int16_t source_height) override; |
| 46 void GetVRVSyncProvider(mojom::VRVSyncProviderRequest request) override; | 59 void GetVRVSyncProvider(mojom::VRVSyncProviderRequest request) override; |
| 47 | 60 |
| 48 void RequestPresentResult(const RequestPresentCallback& callback, | 61 void RequestPresentResult(const RequestPresentCallback& callback, |
| 49 bool secure_origin, | 62 bool secure_origin, |
| 50 bool success); | 63 bool success); |
| 51 | 64 |
| 52 void OnVRDisplayInfoCreated(mojom::VRDisplayInfoPtr display_info); | |
| 53 | |
| 54 mojo::Binding<mojom::VRDisplay> binding_; | 65 mojo::Binding<mojom::VRDisplay> binding_; |
| 55 mojom::VRDisplayClientPtr client_; | 66 mojom::VRDisplayClientPtr client_; |
| 56 device::VRDevice* device_; | 67 device::VRDevice* device_; |
| 57 VRServiceImpl* service_; | 68 VRServiceImpl* service_; |
| 58 | 69 |
| 59 base::WeakPtrFactory<VRDisplayImpl> weak_ptr_factory_; | 70 base::WeakPtrFactory<VRDisplayImpl> weak_ptr_factory_; |
| 60 }; | 71 }; |
| 61 | 72 |
| 62 } // namespace device | 73 } // namespace device |
| 63 | 74 |
| 64 #endif // DEVICE_VR_VR_DISPLAY_IMPL_H | 75 #endif // DEVICE_VR_VR_DISPLAY_IMPL_H |
| OLD | NEW |