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 b1fe6a972ce10b6ccc885b556a1f2c98ab746918..2fddbd365bd72eb97117bbe3c12a7c20cb2c37be 100644 |
--- a/chrome/browser/android/vr_shell/vr_shell.cc |
+++ b/chrome/browser/android/vr_shell/vr_shell.cc |
@@ -32,6 +32,8 @@ |
#include "ui/base/page_transition_types.h" |
#include "ui/display/display.h" |
#include "ui/display/screen.h" |
+#include "ui/gfx/transform.h" |
+#include "ui/gfx/transform_util.h" |
using base::android::JavaParamRef; |
using base::android::JavaRef; |
@@ -275,15 +277,6 @@ void VrShell::OnLoadProgressChanged( |
html_interface_->SetLoadProgress(progress); |
} |
-void VrShell::SetGvrPoseForWebVr(const gvr::Mat4f& pose, uint32_t pose_num) { |
- GLThread* thread = static_cast<GLThread*>(gl_thread_.get()); |
- if (thread->IsRunning()) { |
- thread->task_runner()->PostTask( |
- FROM_HERE, base::Bind(&VrShellGl::SetGvrPoseForWebVr, |
- thread->GetVrShellGl(), pose, pose_num)); |
- } |
-} |
- |
void VrShell::SetWebVRRenderSurfaceSize(int width, int height) { |
// TODO(klausw,crbug.com/655722): Change the GVR render size and set the WebVR |
// render surface size. |
@@ -459,6 +452,21 @@ void VrShell::ForceExitVr() { |
delegate_->ForceExitVr(); |
} |
+void VrShell::OnVRVsyncProviderRequest( |
+ device::mojom::VRVSyncProviderRequest request) { |
+ GLThread* thread = static_cast<GLThread*>(gl_thread_.get()); |
dcheng
2017/01/14 11:22:53
Can gl_thread_ just be std::unique_ptr<GLThread>?
mthiesse
2017/01/16 20:52:57
Done, but this required moving GLThread to its own
|
+ PostToGlThreadWhenReady(base::Bind( |
+ &VrShellGl::OnRequest, thread->GetVrShellGl(), base::Passed(&request))); |
+} |
+ |
+void VrShell::UpdateVSyncInterval(long timebase_nanos, |
+ double interval_seconds) { |
+ GLThread* thread = static_cast<GLThread*>(gl_thread_.get()); |
+ PostToGlThreadWhenReady( |
+ base::Bind(&VrShellGl::UpdateVSyncInterval, |
+ thread->GetVrShellGl(), timebase_nanos, interval_seconds)); |
+} |
+ |
void VrShell::SetContentCssSize(float width, float height, float dpr) { |
JNIEnv* env = base::android::AttachCurrentThread(); |
Java_VrShellImpl_setContentCssSize(env, j_vr_shell_.obj(), width, height, |
@@ -470,6 +478,41 @@ void VrShell::SetUiCssSize(float width, float height, float dpr) { |
Java_VrShellImpl_setUiCssSize(env, j_vr_shell_.obj(), width, height, dpr); |
} |
+device::mojom::VRPosePtr VrShell::VRPosePtrFromGvrPose(gvr::Mat4f head_mat, |
+ uint32_t pose_index) { |
+ device::mojom::VRPosePtr pose = device::mojom::VRPose::New(); |
+ |
+ pose->timestamp = base::Time::Now().ToJsTime(); |
+ |
+ // Increment pose frame counter always, even if it's a faked pose. |
klausw
2017/01/13 21:04:36
Comment doesn't match code, I don't see any increm
mthiesse
2017/01/16 20:52:57
Done.
|
+ pose->poseIndex = pose_index; |
+ pose->orientation.emplace(4); |
+ |
+ gfx::Transform inv_transform( |
+ head_mat.m[0][0], head_mat.m[0][1], head_mat.m[0][2], head_mat.m[0][3], |
+ head_mat.m[1][0], head_mat.m[1][1], head_mat.m[1][2], head_mat.m[1][3], |
+ head_mat.m[2][0], head_mat.m[2][1], head_mat.m[2][2], head_mat.m[2][3], |
+ head_mat.m[3][0], head_mat.m[3][1], head_mat.m[3][2], head_mat.m[3][3]); |
+ |
+ gfx::Transform transform; |
+ if (inv_transform.GetInverse(&transform)) { |
+ gfx::DecomposedTransform decomposed_transform; |
+ gfx::DecomposeTransform(&decomposed_transform, transform); |
+ |
+ pose->orientation.value()[0] = decomposed_transform.quaternion[0]; |
+ pose->orientation.value()[1] = decomposed_transform.quaternion[1]; |
+ pose->orientation.value()[2] = decomposed_transform.quaternion[2]; |
+ pose->orientation.value()[3] = decomposed_transform.quaternion[3]; |
+ |
+ pose->position.emplace(3); |
+ pose->position.value()[0] = decomposed_transform.translate[0]; |
+ pose->position.value()[1] = decomposed_transform.translate[1]; |
+ pose->position.value()[2] = decomposed_transform.translate[2]; |
+ } |
+ |
+ return pose; |
+} |
+ |
// ---------------------------------------------------------------------------- |
// Native JNI methods |
// ---------------------------------------------------------------------------- |