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

Side by Side Diff: chrome/browser/android/vr_shell/vr_shell.cc

Issue 2612333002: Allow VRDisplay to specify which frame the layer bounds should be updated at. (Closed)
Patch Set: Finish implementaion Created 3 years, 11 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 unified diff | Download patch
OLDNEW
1 // Copyright 2016 The Chromium Authors. All rights reserved. 1 // Copyright 2016 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #include "chrome/browser/android/vr_shell/vr_shell.h" 5 #include "chrome/browser/android/vr_shell/vr_shell.h"
6 6
7 #include <android/native_window_jni.h> 7 #include <android/native_window_jni.h>
8 8
9 #include "base/metrics/histogram_macros.h" 9 #include "base/metrics/histogram_macros.h"
10 #include "base/threading/platform_thread.h" 10 #include "base/threading/platform_thread.h"
(...skipping 269 matching lines...) Expand 10 before | Expand all | Expand 10 after
280 return {size.width(), size.height()}; 280 return {size.width(), size.height()};
281 } 281 }
282 282
283 void VrShell::SetWebVRSecureOrigin(bool secure_origin) { 283 void VrShell::SetWebVRSecureOrigin(bool secure_origin) {
284 // TODO(cjgrant): Align this state with the logic that drives the omnibox. 284 // TODO(cjgrant): Align this state with the logic that drives the omnibox.
285 html_interface_->SetWebVRSecureOrigin(secure_origin); 285 html_interface_->SetWebVRSecureOrigin(secure_origin);
286 } 286 }
287 287
288 void VrShell::SubmitWebVRFrame() {} 288 void VrShell::SubmitWebVRFrame() {}
289 289
290 void VrShell::UpdateWebVRTextureBounds(const gvr::Rectf& left_bounds, 290 void VrShell::UpdateWebVRTextureBounds(int16_t frame_index,
291 const gvr::Rectf& left_bounds,
291 const gvr::Rectf& right_bounds) { 292 const gvr::Rectf& right_bounds) {
292 GLThread* thread = static_cast<GLThread*>(gl_thread_.get()); 293 GLThread* thread = static_cast<GLThread*>(gl_thread_.get());
293 PostToGlThreadWhenReady(base::Bind(&VrShellGl::UpdateWebVRTextureBounds, 294 PostToGlThreadWhenReady(base::Bind(&VrShellGl::UpdateWebVRTextureBounds,
294 thread->GetVrShellGl(), left_bounds, 295 thread->GetVrShellGl(), frame_index,
295 right_bounds)); 296 left_bounds, right_bounds));
296 } 297 }
297 298
298 // TODO(mthiesse): Do not expose GVR API outside of GL thread. 299 // TODO(mthiesse): Do not expose GVR API outside of GL thread.
299 // It's not thread-safe. 300 // It's not thread-safe.
300 gvr::GvrApi* VrShell::gvr_api() { 301 gvr::GvrApi* VrShell::gvr_api() {
301 GLThread* thread = static_cast<GLThread*>(gl_thread_.get()); 302 GLThread* thread = static_cast<GLThread*>(gl_thread_.get());
302 if (thread->GetVrShellGlUnsafe()) { 303 if (thread->GetVrShellGlUnsafe()) {
303 return thread->GetVrShellGlUnsafe()->gvr_api(); 304 return thread->GetVrShellGlUnsafe()->gvr_api();
304 } 305 }
305 CHECK(false); 306 CHECK(false);
(...skipping 158 matching lines...) Expand 10 before | Expand all | Expand 10 after
464 JNIEnv* env = base::android::AttachCurrentThread(); 465 JNIEnv* env = base::android::AttachCurrentThread();
465 Java_VrShellImpl_setContentCssSize(env, j_vr_shell_.obj(), width, height, 466 Java_VrShellImpl_setContentCssSize(env, j_vr_shell_.obj(), width, height,
466 dpr); 467 dpr);
467 } 468 }
468 469
469 void VrShell::SetUiCssSize(float width, float height, float dpr) { 470 void VrShell::SetUiCssSize(float width, float height, float dpr) {
470 JNIEnv* env = base::android::AttachCurrentThread(); 471 JNIEnv* env = base::android::AttachCurrentThread();
471 Java_VrShellImpl_setUiCssSize(env, j_vr_shell_.obj(), width, height, dpr); 472 Java_VrShellImpl_setUiCssSize(env, j_vr_shell_.obj(), width, height, dpr);
472 } 473 }
473 474
474 device::mojom::VRPosePtr VrShell::VRPosePtrFromGvrPose(gvr::Mat4f head_mat, 475 device::mojom::VRPosePtr VrShell::VRPosePtrFromGvrPose(gvr::Mat4f head_mat) {
475 uint32_t pose_index) {
476 device::mojom::VRPosePtr pose = device::mojom::VRPose::New(); 476 device::mojom::VRPosePtr pose = device::mojom::VRPose::New();
477 477
478 pose->timestamp = base::Time::Now().ToJsTime(); 478 pose->timestamp = base::Time::Now().ToJsTime();
479
480 // Increment pose frame counter always, even if it's a faked pose.
481 pose->poseIndex = pose_index;
482 pose->orientation.emplace(4); 479 pose->orientation.emplace(4);
483 480
484 gfx::Transform inv_transform( 481 gfx::Transform inv_transform(
485 head_mat.m[0][0], head_mat.m[0][1], head_mat.m[0][2], head_mat.m[0][3], 482 head_mat.m[0][0], head_mat.m[0][1], head_mat.m[0][2], head_mat.m[0][3],
486 head_mat.m[1][0], head_mat.m[1][1], head_mat.m[1][2], head_mat.m[1][3], 483 head_mat.m[1][0], head_mat.m[1][1], head_mat.m[1][2], head_mat.m[1][3],
487 head_mat.m[2][0], head_mat.m[2][1], head_mat.m[2][2], head_mat.m[2][3], 484 head_mat.m[2][0], head_mat.m[2][1], head_mat.m[2][2], head_mat.m[2][3],
488 head_mat.m[3][0], head_mat.m[3][1], head_mat.m[3][2], head_mat.m[3][3]); 485 head_mat.m[3][0], head_mat.m[3][1], head_mat.m[3][2], head_mat.m[3][3]);
489 486
490 gfx::Transform transform; 487 gfx::Transform transform;
491 if (inv_transform.GetInverse(&transform)) { 488 if (inv_transform.GetInverse(&transform)) {
(...skipping 28 matching lines...) Expand all
520 return reinterpret_cast<intptr_t>(new VrShell( 517 return reinterpret_cast<intptr_t>(new VrShell(
521 env, obj, content::WebContents::FromJavaWebContents(content_web_contents), 518 env, obj, content::WebContents::FromJavaWebContents(content_web_contents),
522 reinterpret_cast<ui::WindowAndroid*>(content_window_android), 519 reinterpret_cast<ui::WindowAndroid*>(content_window_android),
523 content::WebContents::FromJavaWebContents(ui_web_contents), 520 content::WebContents::FromJavaWebContents(ui_web_contents),
524 reinterpret_cast<ui::WindowAndroid*>(ui_window_android), 521 reinterpret_cast<ui::WindowAndroid*>(ui_window_android),
525 for_web_vr, VrShellDelegate::GetNativeDelegate(env, delegate), 522 for_web_vr, VrShellDelegate::GetNativeDelegate(env, delegate),
526 reinterpret_cast<gvr_context*>(gvr_api), reprojected_rendering)); 523 reinterpret_cast<gvr_context*>(gvr_api), reprojected_rendering));
527 } 524 }
528 525
529 } // namespace vr_shell 526 } // namespace vr_shell
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698