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

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

Issue 2739973002: Revert of WebVR compositor bypass via BrowserMain context + mailbox (Closed)
Patch Set: 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/android/gvr/gvr_device_provider.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 22 matching lines...) Expand all
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(mojom::VRSubmitFrameClientPtr submit_client, 43 void GvrDevice::RequestPresent(const base::Callback<void(bool)>& callback) {
44 const base::Callback<void(bool)>& callback) { 44 gvr_provider_->RequestPresent(callback);
45 gvr_provider_->RequestPresent(std::move(submit_client), callback);
46 } 45 }
47 46
48 void GvrDevice::SetSecureOrigin(bool secure_origin) { 47 void GvrDevice::SetSecureOrigin(bool secure_origin) {
49 secure_origin_ = secure_origin; 48 secure_origin_ = secure_origin;
50 GvrDelegate* delegate = GetGvrDelegate(); 49 GvrDelegate* delegate = GetGvrDelegate();
51 if (delegate) 50 if (delegate)
52 delegate->SetWebVRSecureOrigin(secure_origin_); 51 delegate->SetWebVRSecureOrigin(secure_origin_);
53 } 52 }
54 53
55 void GvrDevice::ExitPresent() { 54 void GvrDevice::ExitPresent() {
56 gvr_provider_->ExitPresent(); 55 gvr_provider_->ExitPresent();
57 OnExitPresent(); 56 OnExitPresent();
58 } 57 }
59 58
60 void GvrDevice::SubmitFrame(int16_t frame_index, 59 void GvrDevice::SubmitFrame(mojom::VRPosePtr pose) {
61 const gpu::MailboxHolder& mailbox) {
62 GvrDelegate* delegate = GetGvrDelegate(); 60 GvrDelegate* delegate = GetGvrDelegate();
63 if (delegate) { 61 if (delegate)
64 delegate->SubmitWebVRFrame(frame_index, mailbox); 62 delegate->SubmitWebVRFrame();
65 }
66 } 63 }
67 64
68 void GvrDevice::UpdateLayerBounds(int16_t frame_index, 65 void GvrDevice::UpdateLayerBounds(int16_t frame_index,
69 mojom::VRLayerBoundsPtr left_bounds, 66 mojom::VRLayerBoundsPtr left_bounds,
70 mojom::VRLayerBoundsPtr right_bounds, 67 mojom::VRLayerBoundsPtr right_bounds) {
71 int16_t source_width,
72 int16_t source_height) {
73 GvrDelegate* delegate = GetGvrDelegate(); 68 GvrDelegate* delegate = GetGvrDelegate();
74 if (!delegate) 69 if (!delegate)
75 return; 70 return;
76 71
77 gvr::Rectf left_gvr_bounds; 72 gvr::Rectf left_gvr_bounds;
78 left_gvr_bounds.left = left_bounds->left; 73 left_gvr_bounds.left = left_bounds->left;
79 left_gvr_bounds.top = 1.0f - left_bounds->top; 74 left_gvr_bounds.top = 1.0f - left_bounds->top;
80 left_gvr_bounds.right = left_bounds->left + left_bounds->width; 75 left_gvr_bounds.right = left_bounds->left + left_bounds->width;
81 left_gvr_bounds.bottom = 1.0f - (left_bounds->top + left_bounds->height); 76 left_gvr_bounds.bottom = 1.0f - (left_bounds->top + left_bounds->height);
82 77
83 gvr::Rectf right_gvr_bounds; 78 gvr::Rectf right_gvr_bounds;
84 right_gvr_bounds.left = right_bounds->left; 79 right_gvr_bounds.left = right_bounds->left;
85 right_gvr_bounds.top = 1.0f - right_bounds->top; 80 right_gvr_bounds.top = 1.0f - right_bounds->top;
86 right_gvr_bounds.right = right_bounds->left + right_bounds->width; 81 right_gvr_bounds.right = right_bounds->left + right_bounds->width;
87 right_gvr_bounds.bottom = 1.0f - (right_bounds->top + right_bounds->height); 82 right_gvr_bounds.bottom = 1.0f - (right_bounds->top + right_bounds->height);
88 83
89 gvr::Sizei source_size = {source_width, source_height};
90 delegate->UpdateWebVRTextureBounds(frame_index, left_gvr_bounds, 84 delegate->UpdateWebVRTextureBounds(frame_index, left_gvr_bounds,
91 right_gvr_bounds, source_size); 85 right_gvr_bounds);
92 } 86 }
93 87
94 void GvrDevice::GetVRVSyncProvider(mojom::VRVSyncProviderRequest request) { 88 void GvrDevice::GetVRVSyncProvider(mojom::VRVSyncProviderRequest request) {
95 GvrDelegate* delegate = GetGvrDelegate(); 89 GvrDelegate* delegate = GetGvrDelegate();
96 if (delegate) 90 if (delegate)
97 delegate->OnVRVsyncProviderRequest(std::move(request)); 91 delegate->OnVRVsyncProviderRequest(std::move(request));
98 } 92 }
99 93
100 void GvrDevice::OnDelegateChanged() { 94 void GvrDevice::OnDelegateChanged() {
101 GvrDelegate* delegate = GetGvrDelegate(); 95 GvrDelegate* delegate = GetGvrDelegate();
102 if (!delegate || !delegate->SupportsPresentation()) 96 if (!delegate || !delegate->SupportsPresentation())
103 OnExitPresent(); 97 OnExitPresent();
104 // Notify the clients that this device has changed 98 // Notify the clients that this device has changed
105 if (delegate) 99 if (delegate)
106 delegate->SetWebVRSecureOrigin(secure_origin_); 100 delegate->SetWebVRSecureOrigin(secure_origin_);
107 101
108 OnChanged(); 102 OnChanged();
109 } 103 }
110 104
111 GvrDelegate* GvrDevice::GetGvrDelegate() { 105 GvrDelegate* GvrDevice::GetGvrDelegate() {
112 GvrDelegateProvider* delegate_provider = gvr_provider_->GetDelegateProvider(); 106 GvrDelegateProvider* delegate_provider = GvrDelegateProvider::GetInstance();
113 if (delegate_provider) 107 if (delegate_provider)
114 return delegate_provider->GetDelegate(); 108 return delegate_provider->GetDelegate();
115 return nullptr; 109 return nullptr;
116 } 110 }
117 111
118 } // namespace device 112 } // namespace device
OLDNEW
« no previous file with comments | « device/vr/android/gvr/gvr_device.h ('k') | device/vr/android/gvr/gvr_device_provider.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698