Chromium Code Reviews| Index: chrome/browser/android/vr_shell/non_presenting_gvr_delegate.cc |
| diff --git a/chrome/browser/android/vr_shell/non_presenting_gvr_delegate.cc b/chrome/browser/android/vr_shell/non_presenting_gvr_delegate.cc |
| index da7ec3f758e15f23ccd8dc0623cfdce7113a2ffe..36ab13acb57253da269cf466b5fcdf9505c29f2c 100644 |
| --- a/chrome/browser/android/vr_shell/non_presenting_gvr_delegate.cc |
| +++ b/chrome/browser/android/vr_shell/non_presenting_gvr_delegate.cc |
| @@ -56,8 +56,10 @@ NonPresentingGvrDelegate::OnSwitchToPresentingDelegate() { |
| void NonPresentingGvrDelegate::StopVSyncLoop() { |
| vsync_task_.Cancel(); |
| - if (!callback_.is_null()) |
| - callback_.Run(nullptr, base::TimeDelta()); |
| + if (!callback_.is_null()) { |
| + callback_.Run(nullptr, base::TimeDelta(), -1); |
|
dcheng
2017/01/27 09:41:33
One possibility (if you want) is base::ResetAndRet
mthiesse
2017/01/27 16:15:31
That works well, thanks!
|
| + callback_.Reset(); |
| + } |
| callback_.Reset(); |
| gvr_api_->PauseTracking(); |
| // If the loop is stopped, it's not considered to be paused. |
| @@ -94,7 +96,7 @@ void NonPresentingGvrDelegate::OnVSync() { |
| base::TimeDelta time = intervals * vsync_interval_; |
| if (!callback_.is_null()) { |
| - callback_.Run(GetPose(), time); |
| + SendVSync(time, callback_); |
| callback_.Reset(); |
| } else { |
| pending_vsync_ = true; |
| @@ -113,7 +115,7 @@ void NonPresentingGvrDelegate::GetVSync(const GetVSyncCallback& callback) { |
| return; |
| } |
| pending_vsync_ = false; |
| - callback.Run(GetPose(), pending_time_); |
| + SendVSync(pending_time_, callback); |
| } |
| void NonPresentingGvrDelegate::UpdateVSyncInterval(long timebase_nanos, |
| @@ -124,17 +126,14 @@ void NonPresentingGvrDelegate::UpdateVSyncInterval(long timebase_nanos, |
| StartVSyncLoop(); |
| } |
| -device::mojom::VRPosePtr NonPresentingGvrDelegate::GetPose() { |
| +void NonPresentingGvrDelegate::SendVSync(base::TimeDelta time, |
| + const GetVSyncCallback& callback) { |
| gvr::ClockTimePoint target_time = gvr::GvrApi::GetTimePointNow(); |
| target_time.monotonic_system_time_nanos += kPredictionTimeWithoutVsyncNanos; |
| - gvr::Mat4f head_mat = |
| - gvr_api_->GetHeadSpaceFromStartSpaceRotation(target_time); |
| - head_mat = gvr_api_->ApplyNeckModel(head_mat, 1.0f); |
| - |
| - uint32_t pose_index = pose_index_++; |
| - |
| - return VrShell::VRPosePtrFromGvrPose(head_mat, pose_index); |
| + gvr::Mat4f head_mat = gvr_api_->ApplyNeckModel( |
| + gvr_api_->GetHeadSpaceFromStartSpaceRotation(target_time), 1.0f); |
| + callback.Run(VrShell::VRPosePtrFromGvrPose(head_mat), time, -1); |
| } |
| } // namespace vr_shell |