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

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

Issue 2894903002: VR: Fix invalidation race viewing native pages. (Closed)
Patch Set: Address comments Created 3 years, 7 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
« no previous file with comments | « chrome/browser/android/vr_shell/vr_shell.h ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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 <string> 9 #include <string>
10 #include <utility> 10 #include <utility>
(...skipping 394 matching lines...) Expand 10 before | Expand all | Expand 10 after
405 WaitForGlThread(); 405 WaitForGlThread();
406 PostToGlThread( 406 PostToGlThread(
407 FROM_HERE, 407 FROM_HERE,
408 base::Bind(&VrShellGl::SetSubmitClient, gl_thread_->GetVrShellGl(), 408 base::Bind(&VrShellGl::SetSubmitClient, gl_thread_->GetVrShellGl(),
409 base::Passed(submit_client.PassInterface()))); 409 base::Passed(submit_client.PassInterface())));
410 } 410 }
411 411
412 base::android::ScopedJavaGlobalRef<jobject> VrShell::TakeContentSurface( 412 base::android::ScopedJavaGlobalRef<jobject> VrShell::TakeContentSurface(
413 JNIEnv* env, 413 JNIEnv* env,
414 const JavaParamRef<jobject>& obj) { 414 const JavaParamRef<jobject>& obj) {
415 if (!content_surface_) {
416 return base::android::ScopedJavaGlobalRef<jobject>(env, nullptr);
417 }
418 taken_surface_ = true;
415 compositor_->SurfaceChanged(nullptr); 419 compositor_->SurfaceChanged(nullptr);
416 base::android::ScopedJavaGlobalRef<jobject> surface(env, content_surface_); 420 base::android::ScopedJavaGlobalRef<jobject> surface(env, content_surface_);
417 content_surface_ = nullptr; 421 content_surface_ = nullptr;
418 return surface; 422 return surface;
419 } 423 }
420 424
421 void VrShell::RestoreContentSurface(JNIEnv* env, 425 void VrShell::RestoreContentSurface(JNIEnv* env,
422 const JavaParamRef<jobject>& obj) { 426 const JavaParamRef<jobject>& obj) {
427 // Don't try to restore the surface if we haven't successfully taken it yet.
428 if (!taken_surface_)
429 return;
430 taken_surface_ = false;
423 WaitForGlThread(); 431 WaitForGlThread();
424 PostToGlThread(FROM_HERE, base::Bind(&VrShellGl::CreateContentSurface, 432 PostToGlThread(FROM_HERE, base::Bind(&VrShellGl::CreateContentSurface,
425 gl_thread_->GetVrShellGl())); 433 gl_thread_->GetVrShellGl()));
426 } 434 }
427 435
428 void VrShell::SetHistoryButtonsEnabled(JNIEnv* env, 436 void VrShell::SetHistoryButtonsEnabled(JNIEnv* env,
429 const JavaParamRef<jobject>& obj, 437 const JavaParamRef<jobject>& obj,
430 jboolean can_go_back, 438 jboolean can_go_back,
431 jboolean can_go_forward) { 439 jboolean can_go_forward) {
432 ui_->SetHistoryButtonsEnabled(can_go_back, can_go_forward); 440 ui_->SetHistoryButtonsEnabled(can_go_back, can_go_forward);
433 } 441 }
434 442
435 void VrShell::ContentSurfaceChanged(jobject surface) { 443 void VrShell::ContentSurfaceChanged(jobject surface) {
436 content_surface_ = surface; 444 content_surface_ = surface;
437 compositor_->SurfaceChanged(surface);
438 JNIEnv* env = base::android::AttachCurrentThread(); 445 JNIEnv* env = base::android::AttachCurrentThread();
439 Java_VrShellImpl_contentSurfaceChanged(env, j_vr_shell_.obj()); 446 Java_VrShellImpl_contentSurfaceChanged(env, j_vr_shell_.obj());
447 compositor_->SurfaceChanged(content_surface_);
440 } 448 }
441 449
442 void VrShell::GvrDelegateReady() { 450 void VrShell::GvrDelegateReady() {
443 delegate_provider_->SetPresentingDelegate(this, gvr_api_); 451 delegate_provider_->SetPresentingDelegate(this, gvr_api_);
444 } 452 }
445 453
446 void VrShell::OnPhysicalBackingSizeChanged( 454 void VrShell::OnPhysicalBackingSizeChanged(
447 JNIEnv* env, 455 JNIEnv* env,
448 const JavaParamRef<jobject>& obj, 456 const JavaParamRef<jobject>& obj,
449 const JavaParamRef<jobject>& jweb_contents, 457 const JavaParamRef<jobject>& jweb_contents,
(...skipping 200 matching lines...) Expand 10 before | Expand all | Expand 10 after
650 jlong gvr_api, 658 jlong gvr_api,
651 jboolean reprojected_rendering) { 659 jboolean reprojected_rendering) {
652 return reinterpret_cast<intptr_t>(new VrShell( 660 return reinterpret_cast<intptr_t>(new VrShell(
653 env, obj, reinterpret_cast<ui::WindowAndroid*>(window_android), 661 env, obj, reinterpret_cast<ui::WindowAndroid*>(window_android),
654 for_web_vr, in_cct, 662 for_web_vr, in_cct,
655 VrShellDelegate::GetNativeVrShellDelegate(env, delegate), 663 VrShellDelegate::GetNativeVrShellDelegate(env, delegate),
656 reinterpret_cast<gvr_context*>(gvr_api), reprojected_rendering)); 664 reinterpret_cast<gvr_context*>(gvr_api), reprojected_rendering));
657 } 665 }
658 666
659 } // namespace vr_shell 667 } // namespace vr_shell
OLDNEW
« no previous file with comments | « chrome/browser/android/vr_shell/vr_shell.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698