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

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

Issue 2396663002: Reland gvr upgrade (Closed)
Patch Set: Created 4 years, 2 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 e03f5c84fb28e62f071c7783c278b9c1dc64ae4d..b2348f26c8798986c3479c5dee4d861cbba3b9c8 100644
--- a/chrome/browser/android/vr_shell/vr_shell.cc
+++ b/chrome/browser/android/vr_shell/vr_shell.cc
@@ -220,7 +220,7 @@ void VrShell::InitializeGl(JNIEnv* env,
std::vector<gvr::BufferSpec> specs;
specs.push_back(gvr_api_->CreateBufferSpec());
render_size_ = specs[0].GetSize();
- swap_chain_.reset(new gvr::SwapChain(gvr_api_->CreateSwapchain(specs)));
+ swap_chain_.reset(new gvr::SwapChain(gvr_api_->CreateSwapChain(specs)));
vr_shell_renderer_.reset(new VrShellRenderer());
buffer_viewport_list_.reset(
@@ -347,31 +347,6 @@ void VrShell::UpdateController(const gvr::Vec3f& forward_vector) {
}
}
-void ApplyNeckModel(gvr::Mat4f& mat_forward) {
- // This assumes that the input matrix is a pure rotation matrix. The
- // input object_from_reference matrix has the inverse rotation of
- // the head rotation. Invert it (this is just a transpose).
- gvr::Mat4f mat = MatrixTranspose(mat_forward);
-
- // Position of the point between the eyes, relative to the neck pivot:
- const float kNeckHorizontalOffset = -0.080f; // meters in Z
- const float kNeckVerticalOffset = 0.075f; // meters in Y
-
- std::array<float, 4> neckOffset = {
- {0.0f, kNeckVerticalOffset, kNeckHorizontalOffset, 1.0f}};
-
- // Rotate eyes around neck pivot point.
- auto offset = MatrixVectorMul(mat, neckOffset);
-
- // Measure new position relative to original center of head, because
- // applying a neck model should not elevate the camera.
- offset[1] -= kNeckVerticalOffset;
-
- // Right-multiply the inverse translation onto the
- // object_from_reference_matrix.
- TranslateMRight(mat_forward, mat_forward, -offset[0], -offset[1], -offset[2]);
-}
-
void VrShell::DrawFrame(JNIEnv* env, const JavaParamRef<jobject>& obj) {
buffer_viewport_list_->SetToRecommendedBufferViewports();
@@ -380,7 +355,7 @@ void VrShell::DrawFrame(JNIEnv* env, const JavaParamRef<jobject>& obj) {
target_time.monotonic_system_time_nanos += kPredictionTimeWithoutVsyncNanos;
gvr::Mat4f head_pose =
- gvr_api_->GetHeadPoseInStartSpace(target_time);
+ gvr_api_->GetHeadSpaceFromStartSpaceRotation(target_time);
gvr::Vec3f position = GetTranslation(head_pose);
if (position.x == 0.0f && position.y == 0.0f && position.z == 0.0f) {
@@ -389,7 +364,7 @@ void VrShell::DrawFrame(JNIEnv* env, const JavaParamRef<jobject>& obj) {
// object_from_reference_matrix, we're not updating position_external.
// TODO: Not sure what object_from_reference_matrix is. The new api removed
// it. For now, removing it seems working fine.
- ApplyNeckModel(head_pose);
+ gvr_api_->ApplyNeckModel(head_pose, 1.0f);
}
// Bind back to the default framebuffer.
@@ -569,6 +544,7 @@ void VrShell::DrawWebVr() {
glDisable(GL_POLYGON_OFFSET_FILL);
// Don't need to clear, since we're drawing over the entire render target.
+ glClear(GL_COLOR_BUFFER_BIT);
glViewport(0, 0, render_size_.width, render_size_.height);
vr_shell_renderer_->GetWebVrRenderer()->Draw(content_texture_id_);

Powered by Google App Engine
This is Rietveld 408576698