Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(76)

Side by Side Diff: device/vr/android/gvr/gvr_device.cc

Issue 2738683002: WebVR compositor bypass via BrowserMain context + mailbox (Closed)
Patch Set: Less hacked up version Created 3 years, 9 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « device/vr/android/gvr/gvr_device.h ('k') | device/vr/test/fake_vr_device.h » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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
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::MailboxHolder& mailbox,
61 mojom::VRSubmitFrameClientPtr submit_client) {
60 GvrDelegate* delegate = GetGvrDelegate(); 62 GvrDelegate* delegate = GetGvrDelegate();
61 if (delegate) 63 if (delegate) {
62 delegate->SubmitWebVRFrame(); 64 delegate->SubmitWebVRFrame(frame_index, mailbox, std::move(submit_client));
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 = GvrDelegateProvider::GetInstance();
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
OLDNEW
« no previous file with comments | « device/vr/android/gvr/gvr_device.h ('k') | device/vr/test/fake_vr_device.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698