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

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

Issue 2384593002: Encode frame number in pixel data for pose sync (Closed)
Patch Set: Frame pose sync: fix oscillating off-by-one Created 4 years, 3 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
Index: chrome/browser/android/vr_shell/vr_shell.cc
diff --git a/chrome/browser/android/vr_shell/vr_shell.cc b/chrome/browser/android/vr_shell/vr_shell.cc
index c81d27c609d415b0d5647747ae1897dd094e13cc..d8b72a5c37e3517e548154478e8f7604116184b6 100644
--- a/chrome/browser/android/vr_shell/vr_shell.cc
+++ b/chrome/browser/android/vr_shell/vr_shell.cc
@@ -274,6 +274,23 @@ void VrShell::UpdateController(const gvr::Vec3f& forward_vector) {
}
}
+void VrShell::SetGvrPoseForWebVr(gvr::Mat4f pose, int32_t frameNumStarted) {
+ int mod = POSE_QUEUE_SIZE;
+ webvr_head_pose_[(frameNumStarted % mod + mod) % mod] = pose;
bajones 2016/10/02 20:55:23 Is there a reason this isn't simply frameNumStarte
klausw 2016/10/02 21:25:50 Yes, I've been using a signed int32_t where the mo
klausw 2016/10/04 00:40:41 Changed to use uint32_t which simplifies this.
+ webvr_newest_pose_num_ = frameNumStarted;
+}
+
+int32_t GetPixelEncodedFrameNumber() {
+ // Read the frame number encoded in a bottom left pixel as color values.
+ // See also third_party/WebKit/Source/modules/vr/VRDisplay.cpp which
+ // encodes the frame number, and device/vr/android/gvr/gvr_device.cc
+ // which tracks poses.
+ uint8_t pixels[4];
+ //glReadBuffer(GL_BACK); // crashes, null function pointer?!
bajones 2016/10/02 20:55:23 This function is only available in OpenGL ES 3.0 a
klausw 2016/10/02 21:25:50 Good to know, and it does seem to work as expected
klausw 2016/10/04 00:40:41 Comment updated.
+ glReadPixels(0, 0, 1, 1, GL_RGBA, GL_UNSIGNED_BYTE, pixels);
+ return pixels[0] | (pixels[1] << 8) | (pixels[2] << 16);
+}
+
void VrShell::DrawFrame(JNIEnv* env, const JavaParamRef<jobject>& obj) {
buffer_viewport_list_->SetToRecommendedBufferViewports();
@@ -291,6 +308,14 @@ void VrShell::DrawFrame(JNIEnv* env, const JavaParamRef<jobject>& obj) {
if (!webvr_secure_origin_) {
DrawWebVrOverlay(target_time.monotonic_system_time_nanos);
}
+
+ int32_t webvr_pose_frame = GetPixelEncodedFrameNumber();
+ // LOG << "klausw: newest_pose=" << webvr_newest_pose_num_ <<
+ // " pixel=" << webvr_pose_frame <<
+ // "(" << webvr_pose_frame - webvr_newest_pose_num_ << ")";
+
+ int mod = POSE_QUEUE_SIZE;
+ head_pose = webvr_head_pose_[(webvr_pose_frame % mod + mod) % mod];
} else {
DrawVrShell(head_pose);
}

Powered by Google App Engine
This is Rietveld 408576698