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

Side by Side Diff: device/vr/vr_display_impl.cc

Issue 2584343002: WIP: working copy-no-compositor path
Patch Set: StatTracker destructor, delete old magic numbers, mojo export Created 3 years, 11 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
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 <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
11 namespace device { 11 namespace device {
12 12
13 VRDisplayImpl::VRDisplayImpl(device::VRDevice* device, VRServiceImpl* service) 13 VRDisplayImpl::VRDisplayImpl(device::VRDevice* device, VRServiceImpl* service)
14 : binding_(this), 14 : binding_(this),
15 device_(device), 15 device_(device),
16 service_(service), 16 service_(service),
17 weak_ptr_factory_(this) { 17 weak_ptr_factory_(this) {
18 VLOG(1) << __FUNCTION__ << ": this=" << (void*)this << " device=" << device << " service=" << service;
18 mojom::VRDisplayInfoPtr display_info = device->GetVRDevice(); 19 mojom::VRDisplayInfoPtr display_info = device->GetVRDevice();
19 if (service->client()) { 20 if (service->client()) {
20 service->client()->OnDisplayConnected(binding_.CreateInterfacePtrAndBind(), 21 service->client()->OnDisplayConnected(binding_.CreateInterfacePtrAndBind(),
21 mojo::MakeRequest(&client_), 22 mojo::MakeRequest(&client_),
22 std::move(display_info)); 23 std::move(display_info));
23 } 24 }
24 } 25 }
25 26
26 VRDisplayImpl::~VRDisplayImpl() { 27 VRDisplayImpl::~VRDisplayImpl() {
28 VLOG(1) << __FUNCTION__ << ": this=" << (void*)this << " destructor";
27 device_->RemoveDisplay(this); 29 device_->RemoveDisplay(this);
28 } 30 }
29 31
30 void VRDisplayImpl::GetPose(const GetPoseCallback& callback) { 32 void VRDisplayImpl::GetPose(mojom::VRPoseClientPtr pose_client) {
31 if (!device_->IsAccessAllowed(this)) { 33 if (!device_->IsAccessAllowed(this)) {
32 callback.Run(nullptr); 34 pose_client->OnPoseReceived(nullptr);
33 return; 35 return;
34 } 36 }
35 37
36 callback.Run(device_->GetPose()); 38 pose_client->OnPoseReceived(device_->GetPose());
37 } 39 }
38 40
39 void VRDisplayImpl::ResetPose() { 41 void VRDisplayImpl::ResetPose() {
40 if (!device_->IsAccessAllowed(this)) 42 if (!device_->IsAccessAllowed(this))
41 return; 43 return;
42 44
43 device_->ResetPose(); 45 device_->ResetPose();
44 } 46 }
45 47
46 void VRDisplayImpl::RequestPresent(bool secure_origin, 48 void VRDisplayImpl::RequestPresent(bool secure_origin,
(...skipping 16 matching lines...) Expand all
63 device_->SetSecureOrigin(secure_origin); 65 device_->SetSecureOrigin(secure_origin);
64 } 66 }
65 callback.Run(success); 67 callback.Run(success);
66 } 68 }
67 69
68 void VRDisplayImpl::ExitPresent() { 70 void VRDisplayImpl::ExitPresent() {
69 if (device_->CheckPresentingDisplay(this)) 71 if (device_->CheckPresentingDisplay(this))
70 device_->ExitPresent(); 72 device_->ExitPresent();
71 } 73 }
72 74
73 void VRDisplayImpl::SubmitFrame(mojom::VRPosePtr pose) { 75 void VRDisplayImpl::SubmitFrame(int32_t surface_handle,
74 if (!device_->CheckPresentingDisplay(this)) 76 mojom::VRPosePtr pose,
77 const SubmitFrameCallback& callback) {
78 if (!device_->CheckPresentingDisplay(this)) {
79 VLOG(1) << ": no presenting service, running callback";
80 callback.Run(0, pose ? pose->poseIndex : 0, -1.0);
75 return; 81 return;
76 device_->SubmitFrame(std::move(pose)); 82 }
83 device_->SubmitFrame(surface_handle, std::move(pose), std::move(callback));
77 } 84 }
78 85
79 void VRDisplayImpl::UpdateLayerBounds(mojom::VRLayerBoundsPtr left_bounds, 86 void VRDisplayImpl::UpdateLayerBounds(mojom::VRLayerBoundsPtr left_bounds,
80 mojom::VRLayerBoundsPtr right_bounds) { 87 mojom::VRLayerBoundsPtr right_bounds) {
81 if (!device_->IsAccessAllowed(this)) 88 if (!device_->CheckPresentingDisplay(this))
82 return; 89 return;
83 90
84 device_->UpdateLayerBounds(std::move(left_bounds), std::move(right_bounds)); 91 device_->UpdateLayerBounds(std::move(left_bounds), std::move(right_bounds));
85 } 92 }
93
94 void VRDisplayImpl::GetSurfaceHandle(int32_t width, int32_t height,
95 const GetSurfaceHandleCallback& callback) {
96 if (!device_->CheckPresentingDisplay(this))
97 return;
98
99 device_->GetSurfaceHandle(width, height, callback);
86 } 100 }
101 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698