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

Unified Diff: chrome/browser/android/vr_shell/vr_controller.cc

Issue 2941293002: VR: Use more accurate timestamps for input events. (Closed)
Patch Set: Address comments Created 3 years, 6 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « chrome/browser/android/vr_shell/vr_controller.h ('k') | chrome/browser/android/vr_shell/vr_shell_gl.h » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: chrome/browser/android/vr_shell/vr_controller.cc
diff --git a/chrome/browser/android/vr_shell/vr_controller.cc b/chrome/browser/android/vr_shell/vr_controller.cc
index a628cb445f8e23d926fec8654bd90c7482067c0d..dbd5ea223f6e18ab5d34757ba2a090cebddbe9a4 100644
--- a/chrome/browser/android/vr_shell/vr_controller.cc
+++ b/chrome/browser/android/vr_shell/vr_controller.cc
@@ -10,7 +10,6 @@
#include "base/logging.h"
#include "base/memory/ptr_util.h"
-#include "base/time/time.h"
#include "cc/base/math_util.h"
#include "chrome/browser/android/vr_shell/elbow_model.h"
#include "third_party/WebKit/public/platform/WebGestureEvent.h"
@@ -49,6 +48,8 @@ constexpr int kMaxNumOfExtrapolations = 2;
// Distance from the center of the controller to start rendering the laser.
constexpr float kLaserStartDisplacement = 0.045;
+constexpr int microsPerNano = 1000;
+
void ClampTouchpadPosition(gfx::Vector2dF* position) {
position->set_x(cc::MathUtil::ClampToRange(position->x(), 0.0f, 1.0f));
position->set_y(cc::MathUtil::ClampToRange(position->y(), 0.0f, 1.0f));
@@ -141,6 +142,21 @@ float VrController::TouchPosY() {
return controller_state_->GetTouchPos().y;
}
+base::TimeTicks VrController::GetLastOrientationTimestamp() const {
+ return base::TimeTicks::FromInternalValue(
+ controller_state_->GetLastOrientationTimestamp() / microsPerNano);
+}
+
+base::TimeTicks VrController::GetLastTouchTimestamp() const {
+ return base::TimeTicks::FromInternalValue(
+ controller_state_->GetLastTouchTimestamp() / microsPerNano);
+}
+
+base::TimeTicks VrController::GetLastButtonTimestamp() const {
+ return base::TimeTicks::FromInternalValue(
+ controller_state_->GetLastButtonTimestamp() / microsPerNano);
+}
+
gfx::Quaternion VrController::Orientation() const {
const gvr::Quatf& orientation = controller_state_->GetOrientation();
return gfx::Quaternion(orientation.qx, orientation.qy, orientation.qz,
@@ -290,7 +306,7 @@ std::unique_ptr<GestureList> VrController::DetectGestures() {
void VrController::UpdateGestureFromTouchInfo(blink::WebGestureEvent* gesture) {
gesture->SetTimeStampSeconds(
- (base::TimeTicks::Now() - base::TimeTicks()).InSecondsF());
+ (GetLastTouchTimestamp() - base::TimeTicks()).InSecondsF());
switch (state_) {
// User has not put finger on touch pad.
case WAITING:
« no previous file with comments | « chrome/browser/android/vr_shell/vr_controller.h ('k') | chrome/browser/android/vr_shell/vr_shell_gl.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698