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

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: Address comments 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 214 matching lines...) Expand 10 before | Expand all | Expand 10 after
225 return {size.width(), size.height()}; 225 return {size.width(), size.height()};
226 } 226 }
227 227
228 void VrShell::SetWebVRSecureOrigin(bool secure_origin) { 228 void VrShell::SetWebVRSecureOrigin(bool secure_origin) {
229 // TODO(cjgrant): Align this state with the logic that drives the omnibox. 229 // TODO(cjgrant): Align this state with the logic that drives the omnibox.
230 html_interface_->SetWebVRSecureOrigin(secure_origin); 230 html_interface_->SetWebVRSecureOrigin(secure_origin);
231 } 231 }
232 232
233 void VrShell::SubmitWebVRFrame() {} 233 void VrShell::SubmitWebVRFrame() {}
234 234
235 void VrShell::UpdateWebVRTextureBounds(const gvr::Rectf& left_bounds, 235 void VrShell::UpdateWebVRTextureBounds(int16_t frame_index,
236 const gvr::Rectf& left_bounds,
236 const gvr::Rectf& right_bounds) { 237 const gvr::Rectf& right_bounds) {
237 PostToGlThreadWhenReady(base::Bind(&VrShellGl::UpdateWebVRTextureBounds, 238 PostToGlThreadWhenReady(base::Bind(&VrShellGl::UpdateWebVRTextureBounds,
238 gl_thread_->GetVrShellGl(), left_bounds, 239 gl_thread_->GetVrShellGl(), frame_index,
239 right_bounds)); 240 left_bounds, right_bounds));
240 } 241 }
241 242
242 // TODO(mthiesse): Do not expose GVR API outside of GL thread. 243 // TODO(mthiesse): Do not expose GVR API outside of GL thread.
243 // It's not thread-safe. 244 // It's not thread-safe.
244 gvr::GvrApi* VrShell::gvr_api() { 245 gvr::GvrApi* VrShell::gvr_api() {
245 if (gl_thread_->GetVrShellGlUnsafe()) { 246 if (gl_thread_->GetVrShellGlUnsafe()) {
246 return gl_thread_->GetVrShellGlUnsafe()->gvr_api(); 247 return gl_thread_->GetVrShellGlUnsafe()->gvr_api();
247 } 248 }
248 CHECK(false); 249 CHECK(false);
249 return nullptr; 250 return nullptr;
(...skipping 153 matching lines...) Expand 10 before | Expand all | Expand 10 after
403 JNIEnv* env = base::android::AttachCurrentThread(); 404 JNIEnv* env = base::android::AttachCurrentThread();
404 Java_VrShellImpl_setContentCssSize(env, j_vr_shell_.obj(), width, height, 405 Java_VrShellImpl_setContentCssSize(env, j_vr_shell_.obj(), width, height,
405 dpr); 406 dpr);
406 } 407 }
407 408
408 void VrShell::SetUiCssSize(float width, float height, float dpr) { 409 void VrShell::SetUiCssSize(float width, float height, float dpr) {
409 JNIEnv* env = base::android::AttachCurrentThread(); 410 JNIEnv* env = base::android::AttachCurrentThread();
410 Java_VrShellImpl_setUiCssSize(env, j_vr_shell_.obj(), width, height, dpr); 411 Java_VrShellImpl_setUiCssSize(env, j_vr_shell_.obj(), width, height, dpr);
411 } 412 }
412 413
413 device::mojom::VRPosePtr VrShell::VRPosePtrFromGvrPose(gvr::Mat4f head_mat, 414 device::mojom::VRPosePtr VrShell::VRPosePtrFromGvrPose(gvr::Mat4f head_mat) {
414 uint32_t pose_index) {
415 device::mojom::VRPosePtr pose = device::mojom::VRPose::New(); 415 device::mojom::VRPosePtr pose = device::mojom::VRPose::New();
416 416
417 pose->timestamp = base::Time::Now().ToJsTime(); 417 pose->timestamp = base::Time::Now().ToJsTime();
418
419 pose->poseIndex = pose_index;
420 pose->orientation.emplace(4); 418 pose->orientation.emplace(4);
421 419
422 gfx::Transform inv_transform( 420 gfx::Transform inv_transform(
423 head_mat.m[0][0], head_mat.m[0][1], head_mat.m[0][2], head_mat.m[0][3], 421 head_mat.m[0][0], head_mat.m[0][1], head_mat.m[0][2], head_mat.m[0][3],
424 head_mat.m[1][0], head_mat.m[1][1], head_mat.m[1][2], head_mat.m[1][3], 422 head_mat.m[1][0], head_mat.m[1][1], head_mat.m[1][2], head_mat.m[1][3],
425 head_mat.m[2][0], head_mat.m[2][1], head_mat.m[2][2], head_mat.m[2][3], 423 head_mat.m[2][0], head_mat.m[2][1], head_mat.m[2][2], head_mat.m[2][3],
426 head_mat.m[3][0], head_mat.m[3][1], head_mat.m[3][2], head_mat.m[3][3]); 424 head_mat.m[3][0], head_mat.m[3][1], head_mat.m[3][2], head_mat.m[3][3]);
427 425
428 gfx::Transform transform; 426 gfx::Transform transform;
429 if (inv_transform.GetInverse(&transform)) { 427 if (inv_transform.GetInverse(&transform)) {
(...skipping 28 matching lines...) Expand all
458 return reinterpret_cast<intptr_t>(new VrShell( 456 return reinterpret_cast<intptr_t>(new VrShell(
459 env, obj, content::WebContents::FromJavaWebContents(content_web_contents), 457 env, obj, content::WebContents::FromJavaWebContents(content_web_contents),
460 reinterpret_cast<ui::WindowAndroid*>(content_window_android), 458 reinterpret_cast<ui::WindowAndroid*>(content_window_android),
461 content::WebContents::FromJavaWebContents(ui_web_contents), 459 content::WebContents::FromJavaWebContents(ui_web_contents),
462 reinterpret_cast<ui::WindowAndroid*>(ui_window_android), 460 reinterpret_cast<ui::WindowAndroid*>(ui_window_android),
463 for_web_vr, VrShellDelegate::GetNativeDelegate(env, delegate), 461 for_web_vr, VrShellDelegate::GetNativeDelegate(env, delegate),
464 reinterpret_cast<gvr_context*>(gvr_api), reprojected_rendering)); 462 reinterpret_cast<gvr_context*>(gvr_api), reprojected_rendering));
465 } 463 }
466 464
467 } // namespace vr_shell 465 } // namespace vr_shell
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698