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

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

Issue 2833773005: Pause drawing webvr when the App button is pressed (Closed)
Patch Set: make UiBrowserInterface a raw ptr 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
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 190 matching lines...) Expand 10 before | Expand all | Expand 10 after
201 g_instance = nullptr; 201 g_instance = nullptr;
202 } 202 }
203 203
204 void VrShell::PostToGlThreadWhenReady(const base::Closure& task) { 204 void VrShell::PostToGlThreadWhenReady(const base::Closure& task) {
205 // TODO(mthiesse): Remove this blocking wait. Queue up events if thread isn't 205 // TODO(mthiesse): Remove this blocking wait. Queue up events if thread isn't
206 // finished starting? 206 // finished starting?
207 gl_thread_->WaitUntilThreadStarted(); 207 gl_thread_->WaitUntilThreadStarted();
208 gl_thread_->task_runner()->PostTask(FROM_HERE, task); 208 gl_thread_->task_runner()->PostTask(FROM_HERE, task);
209 } 209 }
210 210
211 void VrShell::SetContentPaused(bool paused) { 211 void VrShell::OnContentPaused(bool paused) {
212 if (content_paused_ == paused) 212 if (!vr_shell_enabled_)
213 return; 213 return;
214 content_paused_ = paused;
215 214
216 if (!delegate_provider_->device_provider()) 215 if (!delegate_provider_->device_provider())
217 return; 216 return;
218 217
219 // TODO(mthiesse): The page is no longer visible when in menu mode. We 218 // TODO(mthiesse): The page is no longer visible when in menu mode. We
220 // should unfocus or otherwise let it know it's hidden. 219 // should unfocus or otherwise let it know it's hidden.
221 if (paused) { 220 if (paused)
222 delegate_provider_->device_provider()->Device()->OnBlur(); 221 delegate_provider_->device_provider()->Device()->OnBlur();
223 } else { 222 else
224 delegate_provider_->device_provider()->Device()->OnFocus(); 223 delegate_provider_->device_provider()->Device()->OnFocus();
225 }
226 } 224 }
227 225
228 void VrShell::OnTriggerEvent(JNIEnv* env, const JavaParamRef<jobject>& obj) { 226 void VrShell::OnTriggerEvent(JNIEnv* env, const JavaParamRef<jobject>& obj) {
229 gl_thread_->task_runner()->PostTask( 227 gl_thread_->task_runner()->PostTask(
230 FROM_HERE, 228 FROM_HERE,
231 base::Bind(&VrShellGl::OnTriggerEvent, gl_thread_->GetVrShellGl())); 229 base::Bind(&VrShellGl::OnTriggerEvent, gl_thread_->GetVrShellGl()));
232 } 230 }
233 231
234 void VrShell::OnPause(JNIEnv* env, const JavaParamRef<jobject>& obj) { 232 void VrShell::OnPause(JNIEnv* env, const JavaParamRef<jobject>& obj) {
235 gl_thread_->task_runner()->PostTask( 233 gl_thread_->task_runner()->PostTask(
(...skipping 159 matching lines...) Expand 10 before | Expand all | Expand 10 after
395 393
396 void VrShell::GvrDelegateReady() { 394 void VrShell::GvrDelegateReady() {
397 delegate_provider_->SetPresentingDelegate(this, gvr_api_); 395 delegate_provider_->SetPresentingDelegate(this, gvr_api_);
398 } 396 }
399 397
400 void VrShell::AppButtonGesturePerformed(UiInterface::Direction direction) { 398 void VrShell::AppButtonGesturePerformed(UiInterface::Direction direction) {
401 if (vr_shell_enabled_) 399 if (vr_shell_enabled_)
402 ui_->HandleAppButtonGesturePerformed(direction); 400 ui_->HandleAppButtonGesturePerformed(direction);
403 } 401 }
404 402
405 void VrShell::AppButtonPressed() {
406 if (vr_shell_enabled_)
407 ui_->HandleAppButtonClicked();
408 }
409
410 void VrShell::ContentPhysicalBoundsChanged(JNIEnv* env, 403 void VrShell::ContentPhysicalBoundsChanged(JNIEnv* env,
411 const JavaParamRef<jobject>& object, 404 const JavaParamRef<jobject>& object,
412 jint width, 405 jint width,
413 jint height, 406 jint height,
414 jfloat dpr) { 407 jfloat dpr) {
415 TRACE_EVENT0("gpu", "VrShell::ContentPhysicalBoundsChanged"); 408 TRACE_EVENT0("gpu", "VrShell::ContentPhysicalBoundsChanged");
416 // TODO(acondor): Set the device scale factor for font rendering on the 409 // TODO(acondor): Set the device scale factor for font rendering on the
417 // VR Shell textures. 410 // VR Shell textures.
418 PostToGlThreadWhenReady(base::Bind(&VrShellGl::ContentPhysicalBoundsChanged, 411 PostToGlThreadWhenReady(base::Bind(&VrShellGl::ContentPhysicalBoundsChanged,
419 gl_thread_->GetVrShellGl(), width, 412 gl_thread_->GetVrShellGl(), width,
420 height)); 413 height));
421 compositor_->SetWindowBounds(gfx::Size(width, height)); 414 compositor_->SetWindowBounds(gfx::Size(width, height));
422 } 415 }
423 416
417 // Note that the following code is obsolete and is here as reference for the
418 // actions that need to be implemented natively.
424 void VrShell::DoUiAction(const UiAction action, 419 void VrShell::DoUiAction(const UiAction action,
425 const base::DictionaryValue* arguments) { 420 const base::DictionaryValue* arguments) {
426 // Actions that can be handled natively. 421 // Actions that can be handled natively.
427 switch (action) { 422 switch (action) {
428 case SET_CONTENT_PAUSED: {
429 bool paused;
430 CHECK(arguments->GetBoolean("paused", &paused));
431 SetContentPaused(paused);
432 return;
433 }
434 case HISTORY_BACK: 423 case HISTORY_BACK:
435 if (web_contents_ && web_contents_->IsFullscreen()) { 424 if (web_contents_ && web_contents_->IsFullscreen()) {
436 web_contents_->ExitFullscreen(false); 425 web_contents_->ExitFullscreen(false);
437 return; 426 return;
438 } 427 }
439 // Otherwise handle in java. 428 // Otherwise handle in java.
440 break; 429 break;
441 case EXIT_PRESENT: 430 case EXIT_PRESENT:
442 delegate_provider_->ExitWebVRPresent(); 431 delegate_provider_->ExitWebVRPresent();
443 return; 432 return;
(...skipping 121 matching lines...) Expand 10 before | Expand all | Expand 10 after
565 jboolean for_web_vr, 554 jboolean for_web_vr,
566 jlong gvr_api, 555 jlong gvr_api,
567 jboolean reprojected_rendering) { 556 jboolean reprojected_rendering) {
568 return reinterpret_cast<intptr_t>(new VrShell( 557 return reinterpret_cast<intptr_t>(new VrShell(
569 env, obj, reinterpret_cast<ui::WindowAndroid*>(window_android), 558 env, obj, reinterpret_cast<ui::WindowAndroid*>(window_android),
570 for_web_vr, VrShellDelegate::GetNativeVrShellDelegate(env, delegate), 559 for_web_vr, VrShellDelegate::GetNativeVrShellDelegate(env, delegate),
571 reinterpret_cast<gvr_context*>(gvr_api), reprojected_rendering)); 560 reinterpret_cast<gvr_context*>(gvr_api), reprojected_rendering));
572 } 561 }
573 562
574 } // namespace vr_shell 563 } // namespace vr_shell
OLDNEW
« no previous file with comments | « chrome/browser/android/vr_shell/vr_shell.h ('k') | chrome/browser/android/vr_shell/vr_shell_gl.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698