| OLD | NEW |
| 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 201 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 212 // that IO is allowed to prevent jank, but there shouldn't be any concerns | 212 // that IO is allowed to prevent jank, but there shouldn't be any concerns |
| 213 // regarding jank in this case, because we're switching from 3D to 2D, | 213 // regarding jank in this case, because we're switching from 3D to 2D, |
| 214 // adding/removing a bunch of Java views, and probably changing device | 214 // adding/removing a bunch of Java views, and probably changing device |
| 215 // orientation here. | 215 // orientation here. |
| 216 base::ThreadRestrictions::ScopedAllowIO allow_io; | 216 base::ThreadRestrictions::ScopedAllowIO allow_io; |
| 217 gl_thread_.reset(); | 217 gl_thread_.reset(); |
| 218 } | 218 } |
| 219 g_instance = nullptr; | 219 g_instance = nullptr; |
| 220 } | 220 } |
| 221 | 221 |
| 222 void VrShell::PostToGlThreadWhenReady(const base::Closure& task) { | 222 void VrShell::WaitForGlThread() { |
| 223 // TODO(mthiesse): Remove this blocking wait. Queue up events if thread isn't | 223 if (thread_started_) |
| 224 // finished starting? | 224 return; |
| 225 // TODO(mthiesse): Remove this blocking wait. Queue up events on the thread |
| 226 // object, rather than on the weak ptr initialized after the thread is |
| 227 // started. |
| 225 gl_thread_->WaitUntilThreadStarted(); | 228 gl_thread_->WaitUntilThreadStarted(); |
| 226 gl_thread_->task_runner()->PostTask(FROM_HERE, task); | 229 thread_started_ = true; |
| 230 } |
| 231 |
| 232 void VrShell::PostToGlThread(const tracked_objects::Location& from_here, |
| 233 const base::Closure& task) { |
| 234 DCHECK(thread_started_); |
| 235 gl_thread_->task_runner()->PostTask(from_here, task); |
| 227 } | 236 } |
| 228 | 237 |
| 229 void VrShell::OnContentPaused(bool paused) { | 238 void VrShell::OnContentPaused(bool paused) { |
| 230 if (!vr_shell_enabled_) | 239 if (!vr_shell_enabled_) |
| 231 return; | 240 return; |
| 232 | 241 |
| 233 if (!delegate_provider_->device_provider()) | 242 if (!delegate_provider_->device_provider()) |
| 234 return; | 243 return; |
| 235 | 244 |
| 236 // TODO(mthiesse): The page is no longer visible when in menu mode. We | 245 // TODO(mthiesse): The page is no longer visible when in menu mode. We |
| 237 // should unfocus or otherwise let it know it's hidden. | 246 // should unfocus or otherwise let it know it's hidden. |
| 238 if (paused) | 247 if (paused) |
| 239 delegate_provider_->device_provider()->Device()->OnBlur(); | 248 delegate_provider_->device_provider()->Device()->OnBlur(); |
| 240 else | 249 else |
| 241 delegate_provider_->device_provider()->Device()->OnFocus(); | 250 delegate_provider_->device_provider()->Device()->OnFocus(); |
| 242 } | 251 } |
| 243 | 252 |
| 244 void VrShell::NavigateBack() { | 253 void VrShell::NavigateBack() { |
| 245 JNIEnv* env = base::android::AttachCurrentThread(); | 254 JNIEnv* env = base::android::AttachCurrentThread(); |
| 246 Java_VrShellImpl_navigateBack(env, j_vr_shell_.obj()); | 255 Java_VrShellImpl_navigateBack(env, j_vr_shell_.obj()); |
| 247 } | 256 } |
| 248 | 257 |
| 249 void VrShell::OnTriggerEvent(JNIEnv* env, const JavaParamRef<jobject>& obj) { | 258 void VrShell::OnTriggerEvent(JNIEnv* env, const JavaParamRef<jobject>& obj) { |
| 250 gl_thread_->task_runner()->PostTask( | 259 WaitForGlThread(); |
| 251 FROM_HERE, | 260 PostToGlThread(FROM_HERE, base::Bind(&VrShellGl::OnTriggerEvent, |
| 252 base::Bind(&VrShellGl::OnTriggerEvent, gl_thread_->GetVrShellGl())); | 261 gl_thread_->GetVrShellGl())); |
| 253 } | 262 } |
| 254 | 263 |
| 255 void VrShell::OnPause(JNIEnv* env, const JavaParamRef<jobject>& obj) { | 264 void VrShell::OnPause(JNIEnv* env, const JavaParamRef<jobject>& obj) { |
| 256 gl_thread_->task_runner()->PostTask( | 265 WaitForGlThread(); |
| 257 FROM_HERE, base::Bind(&VrShellGl::OnPause, gl_thread_->GetVrShellGl())); | 266 PostToGlThread(FROM_HERE, |
| 267 base::Bind(&VrShellGl::OnPause, gl_thread_->GetVrShellGl())); |
| 258 | 268 |
| 259 // exit vr session | 269 // exit vr session |
| 260 if (metrics_helper_) | 270 if (metrics_helper_) |
| 261 metrics_helper_->SetVRActive(false); | 271 metrics_helper_->SetVRActive(false); |
| 262 SetIsInVR(web_contents_, false); | 272 SetIsInVR(web_contents_, false); |
| 263 } | 273 } |
| 264 | 274 |
| 265 void VrShell::OnResume(JNIEnv* env, const JavaParamRef<jobject>& obj) { | 275 void VrShell::OnResume(JNIEnv* env, const JavaParamRef<jobject>& obj) { |
| 266 gl_thread_->task_runner()->PostTask( | 276 WaitForGlThread(); |
| 267 FROM_HERE, base::Bind(&VrShellGl::OnResume, gl_thread_->GetVrShellGl())); | 277 PostToGlThread(FROM_HERE, |
| 278 base::Bind(&VrShellGl::OnResume, gl_thread_->GetVrShellGl())); |
| 268 | 279 |
| 269 if (metrics_helper_) | 280 if (metrics_helper_) |
| 270 metrics_helper_->SetVRActive(true); | 281 metrics_helper_->SetVRActive(true); |
| 271 SetIsInVR(web_contents_, true); | 282 SetIsInVR(web_contents_, true); |
| 272 } | 283 } |
| 273 | 284 |
| 274 void VrShell::SetSurface(JNIEnv* env, | 285 void VrShell::SetSurface(JNIEnv* env, |
| 275 const JavaParamRef<jobject>& obj, | 286 const JavaParamRef<jobject>& obj, |
| 276 const JavaParamRef<jobject>& surface) { | 287 const JavaParamRef<jobject>& surface) { |
| 277 CHECK(!reprojected_rendering_); | 288 CHECK(!reprojected_rendering_); |
| 278 gfx::AcceleratedWidget window = | 289 gfx::AcceleratedWidget window = |
| 279 ANativeWindow_fromSurface(base::android::AttachCurrentThread(), surface); | 290 ANativeWindow_fromSurface(base::android::AttachCurrentThread(), surface); |
| 280 PostToGlThreadWhenReady(base::Bind(&VrShellGl::InitializeGl, | 291 WaitForGlThread(); |
| 281 gl_thread_->GetVrShellGl(), | 292 PostToGlThread(FROM_HERE, base::Bind(&VrShellGl::InitializeGl, |
| 282 base::Unretained(window))); | 293 gl_thread_->GetVrShellGl(), |
| 294 base::Unretained(window))); |
| 283 } | 295 } |
| 284 | 296 |
| 285 void VrShell::SetWebVrMode(JNIEnv* env, | 297 void VrShell::SetWebVrMode(JNIEnv* env, |
| 286 const JavaParamRef<jobject>& obj, | 298 const JavaParamRef<jobject>& obj, |
| 287 bool enabled) { | 299 bool enabled) { |
| 288 webvr_mode_ = enabled; | 300 webvr_mode_ = enabled; |
| 289 if (metrics_helper_) | 301 if (metrics_helper_) |
| 290 metrics_helper_->SetWebVREnabled(enabled); | 302 metrics_helper_->SetWebVREnabled(enabled); |
| 291 PostToGlThreadWhenReady(base::Bind(&VrShellGl::SetWebVrMode, | 303 WaitForGlThread(); |
| 292 gl_thread_->GetVrShellGl(), enabled)); | 304 PostToGlThread(FROM_HERE, base::Bind(&VrShellGl::SetWebVrMode, |
| 305 gl_thread_->GetVrShellGl(), enabled)); |
| 293 ui_->SetWebVrMode(enabled); | 306 ui_->SetWebVrMode(enabled); |
| 294 } | 307 } |
| 295 | 308 |
| 296 void VrShell::OnFullscreenChanged(bool enabled) { | 309 void VrShell::OnFullscreenChanged(bool enabled) { |
| 297 JNIEnv* env = base::android::AttachCurrentThread(); | 310 JNIEnv* env = base::android::AttachCurrentThread(); |
| 298 Java_VrShellImpl_onFullscreenChanged(env, j_vr_shell_.obj(), enabled); | 311 Java_VrShellImpl_onFullscreenChanged(env, j_vr_shell_.obj(), enabled); |
| 299 ui_->SetFullscreen(enabled); | 312 ui_->SetFullscreen(enabled); |
| 300 } | 313 } |
| 301 | 314 |
| 302 bool VrShell::GetWebVrMode(JNIEnv* env, const JavaParamRef<jobject>& obj) { | 315 bool VrShell::GetWebVrMode(JNIEnv* env, const JavaParamRef<jobject>& obj) { |
| (...skipping 42 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 345 ui_->RemoveTab(incognito, id); | 358 ui_->RemoveTab(incognito, id); |
| 346 } | 359 } |
| 347 | 360 |
| 348 void VrShell::SetWebVRSecureOrigin(bool secure_origin) { | 361 void VrShell::SetWebVRSecureOrigin(bool secure_origin) { |
| 349 ui_->SetWebVrSecureOrigin(secure_origin); | 362 ui_->SetWebVrSecureOrigin(secure_origin); |
| 350 } | 363 } |
| 351 | 364 |
| 352 void VrShell::SubmitWebVRFrame(int16_t frame_index, | 365 void VrShell::SubmitWebVRFrame(int16_t frame_index, |
| 353 const gpu::MailboxHolder& mailbox) { | 366 const gpu::MailboxHolder& mailbox) { |
| 354 TRACE_EVENT1("gpu", "SubmitWebVRFrame", "frame", frame_index); | 367 TRACE_EVENT1("gpu", "SubmitWebVRFrame", "frame", frame_index); |
| 355 | 368 WaitForGlThread(); |
| 356 PostToGlThreadWhenReady(base::Bind(&VrShellGl::SubmitWebVRFrame, | 369 PostToGlThread(FROM_HERE, |
| 357 gl_thread_->GetVrShellGl(), frame_index, | 370 base::Bind(&VrShellGl::SubmitWebVRFrame, |
| 358 mailbox)); | 371 gl_thread_->GetVrShellGl(), frame_index, mailbox)); |
| 359 } | 372 } |
| 360 | 373 |
| 361 void VrShell::SubmitControllerModel(std::unique_ptr<VrControllerModel> model) { | 374 void VrShell::SubmitControllerModel(std::unique_ptr<VrControllerModel> model) { |
| 362 PostToGlThreadWhenReady(base::Bind(&VrShellGl::SetControllerModel, | 375 WaitForGlThread(); |
| 363 gl_thread_->GetVrShellGl(), | 376 PostToGlThread(FROM_HERE, |
| 364 base::Passed(&model))); | 377 base::Bind(&VrShellGl::SetControllerModel, |
| 378 gl_thread_->GetVrShellGl(), base::Passed(&model))); |
| 365 } | 379 } |
| 366 | 380 |
| 367 void VrShell::UpdateWebVRTextureBounds(int16_t frame_index, | 381 void VrShell::UpdateWebVRTextureBounds(int16_t frame_index, |
| 368 const gfx::RectF& left_bounds, | 382 const gfx::RectF& left_bounds, |
| 369 const gfx::RectF& right_bounds, | 383 const gfx::RectF& right_bounds, |
| 370 const gfx::Size& source_size) { | 384 const gfx::Size& source_size) { |
| 371 PostToGlThreadWhenReady(base::Bind(&VrShellGl::UpdateWebVRTextureBounds, | 385 WaitForGlThread(); |
| 372 gl_thread_->GetVrShellGl(), frame_index, | 386 PostToGlThread(FROM_HERE, base::Bind(&VrShellGl::UpdateWebVRTextureBounds, |
| 373 left_bounds, right_bounds, source_size)); | 387 gl_thread_->GetVrShellGl(), frame_index, |
| 388 left_bounds, right_bounds, source_size)); |
| 374 } | 389 } |
| 375 | 390 |
| 376 void VrShell::CreateVRDisplayInfo( | 391 void VrShell::CreateVRDisplayInfo( |
| 377 const base::Callback<void(device::mojom::VRDisplayInfoPtr)>& callback, | 392 const base::Callback<void(device::mojom::VRDisplayInfoPtr)>& callback, |
| 378 uint32_t device_id) { | 393 uint32_t device_id) { |
| 379 PostToGlThreadWhenReady(base::Bind(&VrShellGl::CreateVRDisplayInfo, | 394 WaitForGlThread(); |
| 380 gl_thread_->GetVrShellGl(), callback, | 395 PostToGlThread(FROM_HERE, |
| 381 device_id)); | 396 base::Bind(&VrShellGl::CreateVRDisplayInfo, |
| 397 gl_thread_->GetVrShellGl(), callback, device_id)); |
| 382 } | 398 } |
| 383 | 399 |
| 384 void VrShell::SetSubmitClient( | 400 void VrShell::SetSubmitClient( |
| 385 device::mojom::VRSubmitFrameClientPtr submit_client) { | 401 device::mojom::VRSubmitFrameClientPtr submit_client) { |
| 386 PostToGlThreadWhenReady( | 402 WaitForGlThread(); |
| 403 PostToGlThread( |
| 404 FROM_HERE, |
| 387 base::Bind(&VrShellGl::SetSubmitClient, gl_thread_->GetVrShellGl(), | 405 base::Bind(&VrShellGl::SetSubmitClient, gl_thread_->GetVrShellGl(), |
| 388 base::Passed(submit_client.PassInterface()))); | 406 base::Passed(submit_client.PassInterface()))); |
| 389 } | 407 } |
| 390 | 408 |
| 391 base::android::ScopedJavaGlobalRef<jobject> VrShell::TakeContentSurface( | 409 base::android::ScopedJavaGlobalRef<jobject> VrShell::TakeContentSurface( |
| 392 JNIEnv* env, | 410 JNIEnv* env, |
| 393 const JavaParamRef<jobject>& obj) { | 411 const JavaParamRef<jobject>& obj) { |
| 394 compositor_->SurfaceChanged(nullptr); | 412 compositor_->SurfaceChanged(nullptr); |
| 395 base::android::ScopedJavaGlobalRef<jobject> surface(env, content_surface_); | 413 base::android::ScopedJavaGlobalRef<jobject> surface(env, content_surface_); |
| 396 content_surface_ = nullptr; | 414 content_surface_ = nullptr; |
| 397 return surface; | 415 return surface; |
| 398 } | 416 } |
| 399 | 417 |
| 400 void VrShell::RestoreContentSurface(JNIEnv* env, | 418 void VrShell::RestoreContentSurface(JNIEnv* env, |
| 401 const JavaParamRef<jobject>& obj) { | 419 const JavaParamRef<jobject>& obj) { |
| 402 PostToGlThreadWhenReady( | 420 WaitForGlThread(); |
| 403 base::Bind(&VrShellGl::CreateContentSurface, gl_thread_->GetVrShellGl())); | 421 PostToGlThread(FROM_HERE, base::Bind(&VrShellGl::CreateContentSurface, |
| 422 gl_thread_->GetVrShellGl())); |
| 404 } | 423 } |
| 405 | 424 |
| 406 void VrShell::SetHistoryButtonsEnabled(JNIEnv* env, | 425 void VrShell::SetHistoryButtonsEnabled(JNIEnv* env, |
| 407 const JavaParamRef<jobject>& obj, | 426 const JavaParamRef<jobject>& obj, |
| 408 jboolean can_go_back, | 427 jboolean can_go_back, |
| 409 jboolean can_go_forward) { | 428 jboolean can_go_forward) { |
| 410 ui_->SetHistoryButtonsEnabled(can_go_back, can_go_forward); | 429 ui_->SetHistoryButtonsEnabled(can_go_back, can_go_forward); |
| 411 } | 430 } |
| 412 | 431 |
| 413 void VrShell::ContentSurfaceChanged(jobject surface) { | 432 void VrShell::ContentSurfaceChanged(jobject surface) { |
| (...skipping 18 matching lines...) Expand all Loading... |
| 432 gfx::Size size(width, height); | 451 gfx::Size size(width, height); |
| 433 web_contents->GetNativeView()->OnPhysicalBackingSizeChanged(size); | 452 web_contents->GetNativeView()->OnPhysicalBackingSizeChanged(size); |
| 434 } | 453 } |
| 435 | 454 |
| 436 void VrShell::ContentPhysicalBoundsChanged(JNIEnv* env, | 455 void VrShell::ContentPhysicalBoundsChanged(JNIEnv* env, |
| 437 const JavaParamRef<jobject>& object, | 456 const JavaParamRef<jobject>& object, |
| 438 jint width, | 457 jint width, |
| 439 jint height, | 458 jint height, |
| 440 jfloat dpr) { | 459 jfloat dpr) { |
| 441 TRACE_EVENT0("gpu", "VrShell::ContentPhysicalBoundsChanged"); | 460 TRACE_EVENT0("gpu", "VrShell::ContentPhysicalBoundsChanged"); |
| 461 WaitForGlThread(); |
| 442 // TODO(acondor): Set the device scale factor for font rendering on the | 462 // TODO(acondor): Set the device scale factor for font rendering on the |
| 443 // VR Shell textures. | 463 // VR Shell textures. |
| 444 PostToGlThreadWhenReady(base::Bind(&VrShellGl::ContentPhysicalBoundsChanged, | 464 PostToGlThread(FROM_HERE, |
| 445 gl_thread_->GetVrShellGl(), width, | 465 base::Bind(&VrShellGl::ContentPhysicalBoundsChanged, |
| 446 height)); | 466 gl_thread_->GetVrShellGl(), width, height)); |
| 447 compositor_->SetWindowBounds(gfx::Size(width, height)); | 467 compositor_->SetWindowBounds(gfx::Size(width, height)); |
| 448 } | 468 } |
| 449 | 469 |
| 450 // Note that the following code is obsolete and is here as reference for the | 470 // Note that the following code is obsolete and is here as reference for the |
| 451 // actions that need to be implemented natively. | 471 // actions that need to be implemented natively. |
| 452 void VrShell::DoUiAction(const UiAction action, | 472 void VrShell::DoUiAction(const UiAction action, |
| 453 const base::DictionaryValue* arguments) { | 473 const base::DictionaryValue* arguments) { |
| 454 // Actions that can be handled natively. | 474 // Actions that can be handled natively. |
| 455 switch (action) { | 475 switch (action) { |
| 456 default: | 476 default: |
| (...skipping 21 matching lines...) Expand all Loading... |
| 478 Java_VrShellImpl_reload(env, j_vr_shell_.obj()); | 498 Java_VrShellImpl_reload(env, j_vr_shell_.obj()); |
| 479 break; | 499 break; |
| 480 default: | 500 default: |
| 481 NOTREACHED(); | 501 NOTREACHED(); |
| 482 } | 502 } |
| 483 } | 503 } |
| 484 | 504 |
| 485 void VrShell::ContentFrameWasResized(bool width_changed) { | 505 void VrShell::ContentFrameWasResized(bool width_changed) { |
| 486 display::Display display = | 506 display::Display display = |
| 487 display::Screen::GetScreen()->GetDisplayNearestWindow(window_); | 507 display::Screen::GetScreen()->GetDisplayNearestWindow(window_); |
| 488 PostToGlThreadWhenReady( | 508 WaitForGlThread(); |
| 509 PostToGlThread( |
| 510 FROM_HERE, |
| 489 base::Bind(&VrShellGl::ContentBoundsChanged, gl_thread_->GetVrShellGl(), | 511 base::Bind(&VrShellGl::ContentBoundsChanged, gl_thread_->GetVrShellGl(), |
| 490 display.size().width(), display.size().height())); | 512 display.size().width(), display.size().height())); |
| 491 } | 513 } |
| 492 | 514 |
| 493 void VrShell::ContentWebContentsDestroyed() { | 515 void VrShell::ContentWebContentsDestroyed() { |
| 494 input_manager_.reset(); | 516 input_manager_.reset(); |
| 495 web_contents_ = nullptr; | 517 web_contents_ = nullptr; |
| 496 // TODO(mthiesse): Handle web contents being destroyed. | 518 // TODO(mthiesse): Handle web contents being destroyed. |
| 497 ForceExitVr(); | 519 ForceExitVr(); |
| 498 } | 520 } |
| (...skipping 18 matching lines...) Expand all Loading... |
| 517 } | 539 } |
| 518 | 540 |
| 519 void VrShell::ExitFullscreen() { | 541 void VrShell::ExitFullscreen() { |
| 520 if (web_contents_ && web_contents_->IsFullscreen()) { | 542 if (web_contents_ && web_contents_->IsFullscreen()) { |
| 521 web_contents_->ExitFullscreen(false); | 543 web_contents_->ExitFullscreen(false); |
| 522 } | 544 } |
| 523 } | 545 } |
| 524 | 546 |
| 525 void VrShell::OnVRVsyncProviderRequest( | 547 void VrShell::OnVRVsyncProviderRequest( |
| 526 device::mojom::VRVSyncProviderRequest request) { | 548 device::mojom::VRVSyncProviderRequest request) { |
| 527 PostToGlThreadWhenReady(base::Bind(&VrShellGl::OnRequest, | 549 WaitForGlThread(); |
| 528 gl_thread_->GetVrShellGl(), | 550 PostToGlThread(FROM_HERE, |
| 529 base::Passed(&request))); | 551 base::Bind(&VrShellGl::OnRequest, gl_thread_->GetVrShellGl(), |
| 552 base::Passed(&request))); |
| 530 } | 553 } |
| 531 | 554 |
| 532 void VrShell::UpdateVSyncInterval(int64_t timebase_nanos, | 555 void VrShell::UpdateVSyncInterval(int64_t timebase_nanos, |
| 533 double interval_seconds) { | 556 double interval_seconds) { |
| 534 PollMediaAccessFlag(); | 557 PollMediaAccessFlag(); |
| 535 PostToGlThreadWhenReady(base::Bind(&VrShellGl::UpdateVSyncInterval, | 558 WaitForGlThread(); |
| 536 gl_thread_->GetVrShellGl(), timebase_nanos, | 559 PostToGlThread(FROM_HERE, base::Bind(&VrShellGl::UpdateVSyncInterval, |
| 537 interval_seconds)); | 560 gl_thread_->GetVrShellGl(), |
| 561 timebase_nanos, interval_seconds)); |
| 538 } | 562 } |
| 539 | 563 |
| 540 void VrShell::PollMediaAccessFlag() { | 564 void VrShell::PollMediaAccessFlag() { |
| 541 poll_capturing_media_task_.Cancel(); | 565 poll_capturing_media_task_.Cancel(); |
| 542 | 566 |
| 543 poll_capturing_media_task_.Reset( | 567 poll_capturing_media_task_.Reset( |
| 544 base::Bind(&VrShell::PollMediaAccessFlag, base::Unretained(this))); | 568 base::Bind(&VrShell::PollMediaAccessFlag, base::Unretained(this))); |
| 545 main_thread_task_runner_->PostDelayedTask( | 569 main_thread_task_runner_->PostDelayedTask( |
| 546 FROM_HERE, poll_capturing_media_task_.callback(), | 570 FROM_HERE, poll_capturing_media_task_.callback(), |
| 547 poll_media_access_interval_); | 571 poll_media_access_interval_); |
| 548 | 572 |
| 549 scoped_refptr<MediaStreamCaptureIndicator> indicator = | 573 scoped_refptr<MediaStreamCaptureIndicator> indicator = |
| 550 MediaCaptureDevicesDispatcher::GetInstance() | 574 MediaCaptureDevicesDispatcher::GetInstance() |
| 551 ->GetMediaStreamCaptureIndicator(); | 575 ->GetMediaStreamCaptureIndicator(); |
| 552 bool is_capturing_audio = indicator->IsCapturingAudio(web_contents_); | 576 bool is_capturing_audio = indicator->IsCapturingAudio(web_contents_); |
| 553 if (is_capturing_audio != is_capturing_audio_) | 577 if (is_capturing_audio != is_capturing_audio_) { |
| 554 PostToGlThreadWhenReady(base::Bind(&VrShellGl::SetAudioCapturingWarning, | 578 WaitForGlThread(); |
| 555 gl_thread_->GetVrShellGl(), | 579 PostToGlThread(FROM_HERE, |
| 556 is_capturing_audio)); | 580 base::Bind(&VrShellGl::SetAudioCapturingWarning, |
| 581 gl_thread_->GetVrShellGl(), is_capturing_audio)); |
| 582 } |
| 557 is_capturing_audio_ = is_capturing_audio; | 583 is_capturing_audio_ = is_capturing_audio; |
| 558 | 584 |
| 559 bool is_capturing_video = indicator->IsCapturingVideo(web_contents_); | 585 bool is_capturing_video = indicator->IsCapturingVideo(web_contents_); |
| 560 if (is_capturing_video != is_capturing_video_) | 586 if (is_capturing_video != is_capturing_video_) { |
| 561 PostToGlThreadWhenReady(base::Bind(&VrShellGl::SetVideoCapturingWarning, | 587 WaitForGlThread(); |
| 562 gl_thread_->GetVrShellGl(), | 588 PostToGlThread(FROM_HERE, |
| 563 is_capturing_video)); | 589 base::Bind(&VrShellGl::SetVideoCapturingWarning, |
| 590 gl_thread_->GetVrShellGl(), is_capturing_video)); |
| 591 } |
| 564 is_capturing_video_ = is_capturing_video; | 592 is_capturing_video_ = is_capturing_video; |
| 565 | 593 |
| 566 bool is_capturing_screen = indicator->IsBeingMirrored(web_contents_); | 594 bool is_capturing_screen = indicator->IsBeingMirrored(web_contents_); |
| 567 if (is_capturing_screen != is_capturing_screen_) | 595 if (is_capturing_screen != is_capturing_screen_) { |
| 568 PostToGlThreadWhenReady(base::Bind(&VrShellGl::SetScreenCapturingWarning, | 596 WaitForGlThread(); |
| 569 gl_thread_->GetVrShellGl(), | 597 PostToGlThread(FROM_HERE, |
| 570 is_capturing_screen)); | 598 base::Bind(&VrShellGl::SetScreenCapturingWarning, |
| 599 gl_thread_->GetVrShellGl(), is_capturing_screen)); |
| 600 } |
| 571 is_capturing_screen_ = is_capturing_screen; | 601 is_capturing_screen_ = is_capturing_screen; |
| 572 } | 602 } |
| 573 | 603 |
| 574 void VrShell::SetContentCssSize(float width, float height, float dpr) { | 604 void VrShell::SetContentCssSize(float width, float height, float dpr) { |
| 575 JNIEnv* env = base::android::AttachCurrentThread(); | 605 JNIEnv* env = base::android::AttachCurrentThread(); |
| 576 Java_VrShellImpl_setContentCssSize(env, j_vr_shell_.obj(), width, height, | 606 Java_VrShellImpl_setContentCssSize(env, j_vr_shell_.obj(), width, height, |
| 577 dpr); | 607 dpr); |
| 578 } | 608 } |
| 579 | 609 |
| 580 void VrShell::ProcessContentGesture( | 610 void VrShell::ProcessContentGesture( |
| (...skipping 40 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 621 jlong gvr_api, | 651 jlong gvr_api, |
| 622 jboolean reprojected_rendering) { | 652 jboolean reprojected_rendering) { |
| 623 return reinterpret_cast<intptr_t>(new VrShell( | 653 return reinterpret_cast<intptr_t>(new VrShell( |
| 624 env, obj, reinterpret_cast<ui::WindowAndroid*>(window_android), | 654 env, obj, reinterpret_cast<ui::WindowAndroid*>(window_android), |
| 625 for_web_vr, in_cct, | 655 for_web_vr, in_cct, |
| 626 VrShellDelegate::GetNativeVrShellDelegate(env, delegate), | 656 VrShellDelegate::GetNativeVrShellDelegate(env, delegate), |
| 627 reinterpret_cast<gvr_context*>(gvr_api), reprojected_rendering)); | 657 reinterpret_cast<gvr_context*>(gvr_api), reprojected_rendering)); |
| 628 } | 658 } |
| 629 | 659 |
| 630 } // namespace vr_shell | 660 } // namespace vr_shell |
| OLD | NEW |