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 "device/vr/android/gvr/gvr_device.h" | 5 #include "device/vr/android/gvr/gvr_device.h" |
6 | 6 |
7 #include <math.h> | 7 #include <math.h> |
8 #include <algorithm> | 8 #include <algorithm> |
9 | 9 |
10 #include "base/time/time.h" | 10 #include "base/time/time.h" |
(...skipping 22 matching lines...) Expand all Loading... |
33 callback.Run(mojom::VRDisplayInfoPtr(nullptr)); | 33 callback.Run(mojom::VRDisplayInfoPtr(nullptr)); |
34 } | 34 } |
35 } | 35 } |
36 | 36 |
37 void GvrDevice::ResetPose() { | 37 void GvrDevice::ResetPose() { |
38 GvrDelegate* delegate = GetGvrDelegate(); | 38 GvrDelegate* delegate = GetGvrDelegate(); |
39 if (delegate) | 39 if (delegate) |
40 delegate->ResetPose(); | 40 delegate->ResetPose(); |
41 } | 41 } |
42 | 42 |
43 void GvrDevice::RequestPresent(const base::Callback<void(bool)>& callback) { | 43 void GvrDevice::RequestPresent(mojom::VRSubmitFrameClientPtr submit_client, |
44 gvr_provider_->RequestPresent(callback); | 44 const base::Callback<void(bool)>& callback) { |
| 45 gvr_provider_->RequestPresent(std::move(submit_client), callback); |
45 } | 46 } |
46 | 47 |
47 void GvrDevice::SetSecureOrigin(bool secure_origin) { | 48 void GvrDevice::SetSecureOrigin(bool secure_origin) { |
48 secure_origin_ = secure_origin; | 49 secure_origin_ = secure_origin; |
49 GvrDelegate* delegate = GetGvrDelegate(); | 50 GvrDelegate* delegate = GetGvrDelegate(); |
50 if (delegate) | 51 if (delegate) |
51 delegate->SetWebVRSecureOrigin(secure_origin_); | 52 delegate->SetWebVRSecureOrigin(secure_origin_); |
52 } | 53 } |
53 | 54 |
54 void GvrDevice::ExitPresent() { | 55 void GvrDevice::ExitPresent() { |
55 gvr_provider_->ExitPresent(); | 56 gvr_provider_->ExitPresent(); |
56 OnExitPresent(); | 57 OnExitPresent(); |
57 } | 58 } |
58 | 59 |
59 void GvrDevice::SubmitFrame(mojom::VRPosePtr pose) { | 60 void GvrDevice::SubmitFrame(int16_t frame_index, |
| 61 const gpu::MailboxHolder& mailbox) { |
60 GvrDelegate* delegate = GetGvrDelegate(); | 62 GvrDelegate* delegate = GetGvrDelegate(); |
61 if (delegate) | 63 if (delegate) { |
62 delegate->SubmitWebVRFrame(); | 64 delegate->SubmitWebVRFrame(frame_index, mailbox); |
| 65 } |
63 } | 66 } |
64 | 67 |
65 void GvrDevice::UpdateLayerBounds(int16_t frame_index, | 68 void GvrDevice::UpdateLayerBounds(int16_t frame_index, |
66 mojom::VRLayerBoundsPtr left_bounds, | 69 mojom::VRLayerBoundsPtr left_bounds, |
67 mojom::VRLayerBoundsPtr right_bounds) { | 70 mojom::VRLayerBoundsPtr right_bounds, |
| 71 int16_t source_width, |
| 72 int16_t source_height) { |
68 GvrDelegate* delegate = GetGvrDelegate(); | 73 GvrDelegate* delegate = GetGvrDelegate(); |
69 if (!delegate) | 74 if (!delegate) |
70 return; | 75 return; |
71 | 76 |
72 gvr::Rectf left_gvr_bounds; | 77 gvr::Rectf left_gvr_bounds; |
73 left_gvr_bounds.left = left_bounds->left; | 78 left_gvr_bounds.left = left_bounds->left; |
74 left_gvr_bounds.top = 1.0f - left_bounds->top; | 79 left_gvr_bounds.top = 1.0f - left_bounds->top; |
75 left_gvr_bounds.right = left_bounds->left + left_bounds->width; | 80 left_gvr_bounds.right = left_bounds->left + left_bounds->width; |
76 left_gvr_bounds.bottom = 1.0f - (left_bounds->top + left_bounds->height); | 81 left_gvr_bounds.bottom = 1.0f - (left_bounds->top + left_bounds->height); |
77 | 82 |
78 gvr::Rectf right_gvr_bounds; | 83 gvr::Rectf right_gvr_bounds; |
79 right_gvr_bounds.left = right_bounds->left; | 84 right_gvr_bounds.left = right_bounds->left; |
80 right_gvr_bounds.top = 1.0f - right_bounds->top; | 85 right_gvr_bounds.top = 1.0f - right_bounds->top; |
81 right_gvr_bounds.right = right_bounds->left + right_bounds->width; | 86 right_gvr_bounds.right = right_bounds->left + right_bounds->width; |
82 right_gvr_bounds.bottom = 1.0f - (right_bounds->top + right_bounds->height); | 87 right_gvr_bounds.bottom = 1.0f - (right_bounds->top + right_bounds->height); |
83 | 88 |
| 89 gvr::Sizei source_size = {source_width, source_height}; |
84 delegate->UpdateWebVRTextureBounds(frame_index, left_gvr_bounds, | 90 delegate->UpdateWebVRTextureBounds(frame_index, left_gvr_bounds, |
85 right_gvr_bounds); | 91 right_gvr_bounds, source_size); |
86 } | 92 } |
87 | 93 |
88 void GvrDevice::GetVRVSyncProvider(mojom::VRVSyncProviderRequest request) { | 94 void GvrDevice::GetVRVSyncProvider(mojom::VRVSyncProviderRequest request) { |
89 GvrDelegate* delegate = GetGvrDelegate(); | 95 GvrDelegate* delegate = GetGvrDelegate(); |
90 if (delegate) | 96 if (delegate) |
91 delegate->OnVRVsyncProviderRequest(std::move(request)); | 97 delegate->OnVRVsyncProviderRequest(std::move(request)); |
92 } | 98 } |
93 | 99 |
94 void GvrDevice::OnDelegateChanged() { | 100 void GvrDevice::OnDelegateChanged() { |
95 GvrDelegate* delegate = GetGvrDelegate(); | 101 GvrDelegate* delegate = GetGvrDelegate(); |
96 if (!delegate || !delegate->SupportsPresentation()) | 102 if (!delegate || !delegate->SupportsPresentation()) |
97 OnExitPresent(); | 103 OnExitPresent(); |
98 // Notify the clients that this device has changed | 104 // Notify the clients that this device has changed |
99 if (delegate) | 105 if (delegate) |
100 delegate->SetWebVRSecureOrigin(secure_origin_); | 106 delegate->SetWebVRSecureOrigin(secure_origin_); |
101 | 107 |
102 OnChanged(); | 108 OnChanged(); |
103 } | 109 } |
104 | 110 |
105 GvrDelegate* GvrDevice::GetGvrDelegate() { | 111 GvrDelegate* GvrDevice::GetGvrDelegate() { |
106 GvrDelegateProvider* delegate_provider = GvrDelegateProvider::GetInstance(); | 112 GvrDelegateProvider* delegate_provider = gvr_provider_->GetDelegateProvider(); |
107 if (delegate_provider) | 113 if (delegate_provider) |
108 return delegate_provider->GetDelegate(); | 114 return delegate_provider->GetDelegate(); |
109 return nullptr; | 115 return nullptr; |
110 } | 116 } |
111 | 117 |
112 } // namespace device | 118 } // namespace device |
OLD | NEW |