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 38 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
49 GvrDelegate* delegate = GetGvrDelegate(); | 49 GvrDelegate* delegate = GetGvrDelegate(); |
50 if (delegate) | 50 if (delegate) |
51 delegate->SetWebVRSecureOrigin(secure_origin_); | 51 delegate->SetWebVRSecureOrigin(secure_origin_); |
52 } | 52 } |
53 | 53 |
54 void GvrDevice::ExitPresent() { | 54 void GvrDevice::ExitPresent() { |
55 gvr_provider_->ExitPresent(); | 55 gvr_provider_->ExitPresent(); |
56 OnExitPresent(); | 56 OnExitPresent(); |
57 } | 57 } |
58 | 58 |
59 void GvrDevice::SubmitFrame(mojom::VRPosePtr pose) { | 59 void GvrDevice::SubmitFrame(int16_t frame_index, |
| 60 const gpu::Mailbox& mailbox, |
| 61 const gpu::SyncToken& sync_token, |
| 62 mojom::VRSubmitFrameClientPtr submit_client) { |
60 GvrDelegate* delegate = GetGvrDelegate(); | 63 GvrDelegate* delegate = GetGvrDelegate(); |
61 if (delegate) | 64 if (delegate) { |
62 delegate->SubmitWebVRFrame(); | 65 delegate->SubmitWebVRFrame(frame_index, mailbox, sync_token, |
| 66 std::move(submit_client)); |
| 67 } |
63 } | 68 } |
64 | 69 |
65 void GvrDevice::UpdateLayerBounds(int16_t frame_index, | 70 void GvrDevice::UpdateLayerBounds(int16_t frame_index, |
66 mojom::VRLayerBoundsPtr left_bounds, | 71 mojom::VRLayerBoundsPtr left_bounds, |
67 mojom::VRLayerBoundsPtr right_bounds) { | 72 mojom::VRLayerBoundsPtr right_bounds, |
| 73 int16_t source_width, |
| 74 int16_t source_height) { |
68 GvrDelegate* delegate = GetGvrDelegate(); | 75 GvrDelegate* delegate = GetGvrDelegate(); |
69 if (!delegate) | 76 if (!delegate) |
70 return; | 77 return; |
71 | 78 |
72 gvr::Rectf left_gvr_bounds; | 79 gvr::Rectf left_gvr_bounds; |
73 left_gvr_bounds.left = left_bounds->left; | 80 left_gvr_bounds.left = left_bounds->left; |
74 left_gvr_bounds.top = 1.0f - left_bounds->top; | 81 left_gvr_bounds.top = 1.0f - left_bounds->top; |
75 left_gvr_bounds.right = left_bounds->left + left_bounds->width; | 82 left_gvr_bounds.right = left_bounds->left + left_bounds->width; |
76 left_gvr_bounds.bottom = 1.0f - (left_bounds->top + left_bounds->height); | 83 left_gvr_bounds.bottom = 1.0f - (left_bounds->top + left_bounds->height); |
77 | 84 |
78 gvr::Rectf right_gvr_bounds; | 85 gvr::Rectf right_gvr_bounds; |
79 right_gvr_bounds.left = right_bounds->left; | 86 right_gvr_bounds.left = right_bounds->left; |
80 right_gvr_bounds.top = 1.0f - right_bounds->top; | 87 right_gvr_bounds.top = 1.0f - right_bounds->top; |
81 right_gvr_bounds.right = right_bounds->left + right_bounds->width; | 88 right_gvr_bounds.right = right_bounds->left + right_bounds->width; |
82 right_gvr_bounds.bottom = 1.0f - (right_bounds->top + right_bounds->height); | 89 right_gvr_bounds.bottom = 1.0f - (right_bounds->top + right_bounds->height); |
83 | 90 |
| 91 gvr::Sizei source_size = {source_width, source_height}; |
84 delegate->UpdateWebVRTextureBounds(frame_index, left_gvr_bounds, | 92 delegate->UpdateWebVRTextureBounds(frame_index, left_gvr_bounds, |
85 right_gvr_bounds); | 93 right_gvr_bounds, source_size); |
86 } | 94 } |
87 | 95 |
88 void GvrDevice::GetVRVSyncProvider(mojom::VRVSyncProviderRequest request) { | 96 void GvrDevice::GetVRVSyncProvider(mojom::VRVSyncProviderRequest request) { |
89 GvrDelegate* delegate = GetGvrDelegate(); | 97 GvrDelegate* delegate = GetGvrDelegate(); |
90 if (delegate) | 98 if (delegate) |
91 delegate->OnVRVsyncProviderRequest(std::move(request)); | 99 delegate->OnVRVsyncProviderRequest(std::move(request)); |
92 } | 100 } |
93 | 101 |
94 void GvrDevice::OnDelegateChanged() { | 102 void GvrDevice::OnDelegateChanged() { |
95 GvrDelegate* delegate = GetGvrDelegate(); | 103 GvrDelegate* delegate = GetGvrDelegate(); |
96 if (!delegate || !delegate->SupportsPresentation()) | 104 if (!delegate || !delegate->SupportsPresentation()) |
97 OnExitPresent(); | 105 OnExitPresent(); |
98 // Notify the clients that this device has changed | 106 // Notify the clients that this device has changed |
99 if (delegate) | 107 if (delegate) |
100 delegate->SetWebVRSecureOrigin(secure_origin_); | 108 delegate->SetWebVRSecureOrigin(secure_origin_); |
101 | 109 |
102 OnChanged(); | 110 OnChanged(); |
103 } | 111 } |
104 | 112 |
105 GvrDelegate* GvrDevice::GetGvrDelegate() { | 113 GvrDelegate* GvrDevice::GetGvrDelegate() { |
106 GvrDelegateProvider* delegate_provider = GvrDelegateProvider::GetInstance(); | 114 GvrDelegateProvider* delegate_provider = GvrDelegateProvider::GetInstance(); |
107 if (delegate_provider) | 115 if (delegate_provider) |
108 return delegate_provider->GetDelegate(); | 116 return delegate_provider->GetDelegate(); |
109 return nullptr; | 117 return nullptr; |
110 } | 118 } |
111 | 119 |
112 } // namespace device | 120 } // namespace device |
OLD | NEW |