| 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 #include <utility> | 5 #include <utility> |
| 6 | 6 |
| 7 #include "base/bind.h" | 7 #include "base/bind.h" |
| 8 #include "device/vr/vr_device.h" | 8 #include "device/vr/vr_device.h" |
| 9 #include "device/vr/vr_service_impl.h" | 9 #include "device/vr/vr_service_impl.h" |
| 10 | 10 |
| (...skipping 23 matching lines...) Expand all Loading... |
| 34 } | 34 } |
| 35 | 35 |
| 36 void VRDisplayImpl::ResetPose() { | 36 void VRDisplayImpl::ResetPose() { |
| 37 if (!device_->IsAccessAllowed(this)) | 37 if (!device_->IsAccessAllowed(this)) |
| 38 return; | 38 return; |
| 39 | 39 |
| 40 device_->ResetPose(); | 40 device_->ResetPose(); |
| 41 } | 41 } |
| 42 | 42 |
| 43 void VRDisplayImpl::RequestPresent(bool secure_origin, | 43 void VRDisplayImpl::RequestPresent(bool secure_origin, |
| 44 mojom::VRSubmitFrameClientPtr submit_client, | |
| 45 const RequestPresentCallback& callback) { | 44 const RequestPresentCallback& callback) { |
| 46 if (!device_->IsAccessAllowed(this)) { | 45 if (!device_->IsAccessAllowed(this)) { |
| 47 callback.Run(false); | 46 callback.Run(false); |
| 48 return; | 47 return; |
| 49 } | 48 } |
| 50 | 49 |
| 51 device_->RequestPresent( | 50 device_->RequestPresent(base::Bind(&VRDisplayImpl::RequestPresentResult, |
| 52 std::move(submit_client), | 51 weak_ptr_factory_.GetWeakPtr(), callback, |
| 53 base::Bind(&VRDisplayImpl::RequestPresentResult, | 52 secure_origin)); |
| 54 weak_ptr_factory_.GetWeakPtr(), callback, secure_origin)); | |
| 55 } | 53 } |
| 56 | 54 |
| 57 void VRDisplayImpl::RequestPresentResult(const RequestPresentCallback& callback, | 55 void VRDisplayImpl::RequestPresentResult(const RequestPresentCallback& callback, |
| 58 bool secure_origin, | 56 bool secure_origin, |
| 59 bool success) { | 57 bool success) { |
| 60 if (success) { | 58 if (success) { |
| 61 device_->SetPresentingDisplay(this); | 59 device_->SetPresentingDisplay(this); |
| 62 device_->SetSecureOrigin(secure_origin); | 60 device_->SetSecureOrigin(secure_origin); |
| 63 } | 61 } |
| 64 callback.Run(success); | 62 callback.Run(success); |
| 65 } | 63 } |
| 66 | 64 |
| 67 void VRDisplayImpl::ExitPresent() { | 65 void VRDisplayImpl::ExitPresent() { |
| 68 if (device_->CheckPresentingDisplay(this)) | 66 if (device_->CheckPresentingDisplay(this)) |
| 69 device_->ExitPresent(); | 67 device_->ExitPresent(); |
| 70 } | 68 } |
| 71 | 69 |
| 72 void VRDisplayImpl::SubmitFrame(int16_t frame_index, | 70 void VRDisplayImpl::SubmitFrame(mojom::VRPosePtr pose) { |
| 73 const gpu::MailboxHolder& mailbox) { | |
| 74 if (!device_->CheckPresentingDisplay(this)) | 71 if (!device_->CheckPresentingDisplay(this)) |
| 75 return; | 72 return; |
| 76 device_->SubmitFrame(frame_index, mailbox); | 73 device_->SubmitFrame(std::move(pose)); |
| 77 } | 74 } |
| 78 | 75 |
| 79 void VRDisplayImpl::UpdateLayerBounds(int16_t frame_index, | 76 void VRDisplayImpl::UpdateLayerBounds(int16_t frame_index, |
| 80 mojom::VRLayerBoundsPtr left_bounds, | 77 mojom::VRLayerBoundsPtr left_bounds, |
| 81 mojom::VRLayerBoundsPtr right_bounds, | 78 mojom::VRLayerBoundsPtr right_bounds) { |
| 82 int16_t source_width, | |
| 83 int16_t source_height) { | |
| 84 if (!device_->IsAccessAllowed(this)) | 79 if (!device_->IsAccessAllowed(this)) |
| 85 return; | 80 return; |
| 86 | 81 |
| 87 device_->UpdateLayerBounds(frame_index, std::move(left_bounds), | 82 device_->UpdateLayerBounds(frame_index, std::move(left_bounds), |
| 88 std::move(right_bounds), source_width, | 83 std::move(right_bounds)); |
| 89 source_height); | |
| 90 } | 84 } |
| 91 | 85 |
| 92 void VRDisplayImpl::GetVRVSyncProvider(mojom::VRVSyncProviderRequest request) { | 86 void VRDisplayImpl::GetVRVSyncProvider(mojom::VRVSyncProviderRequest request) { |
| 93 if (!device_->IsAccessAllowed(this)) { | 87 if (!device_->IsAccessAllowed(this)) { |
| 94 return; | 88 return; |
| 95 } | 89 } |
| 96 device_->GetVRVSyncProvider(std::move(request)); | 90 device_->GetVRVSyncProvider(std::move(request)); |
| 97 } | 91 } |
| 98 } | 92 } |
| OLD | NEW |