| OLD | NEW |
| 1 // Copyright 2014 The Chromium Authors. All rights reserved. | 1 // Copyright 2014 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 "content/browser/compositor/gpu_process_transport_factory.h" | 5 #include "content/browser/compositor/gpu_process_transport_factory.h" |
| 6 | 6 |
| 7 #include <string> | 7 #include <string> |
| 8 #include <utility> | 8 #include <utility> |
| 9 | 9 |
| 10 #include "base/bind.h" | 10 #include "base/bind.h" |
| (...skipping 42 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 53 #include "gpu/command_buffer/common/mailbox.h" | 53 #include "gpu/command_buffer/common/mailbox.h" |
| 54 #include "gpu/ipc/client/gpu_channel_host.h" | 54 #include "gpu/ipc/client/gpu_channel_host.h" |
| 55 #include "third_party/khronos/GLES2/gl2.h" | 55 #include "third_party/khronos/GLES2/gl2.h" |
| 56 #include "ui/compositor/compositor.h" | 56 #include "ui/compositor/compositor.h" |
| 57 #include "ui/compositor/compositor_constants.h" | 57 #include "ui/compositor/compositor_constants.h" |
| 58 #include "ui/compositor/compositor_switches.h" | 58 #include "ui/compositor/compositor_switches.h" |
| 59 #include "ui/compositor/layer.h" | 59 #include "ui/compositor/layer.h" |
| 60 #include "ui/gfx/geometry/size.h" | 60 #include "ui/gfx/geometry/size.h" |
| 61 | 61 |
| 62 #if defined(MOJO_RUNNER_CLIENT) | 62 #if defined(MOJO_RUNNER_CLIENT) |
| 63 #include "components/mus/common/gpu_service.h" |
| 64 #include "content/browser/compositor/mus_browser_compositor_output_surface.h" |
| 65 #include "content/public/common/mojo_shell_connection.h" |
| 63 #include "services/shell/runner/common/client_util.h" | 66 #include "services/shell/runner/common/client_util.h" |
| 64 #endif | 67 #endif |
| 65 | 68 |
| 66 #if defined(OS_WIN) | 69 #if defined(OS_WIN) |
| 67 #include "content/browser/compositor/software_output_device_win.h" | 70 #include "content/browser/compositor/software_output_device_win.h" |
| 68 #include "ui/gfx/win/rendering_window_manager.h" | 71 #include "ui/gfx/win/rendering_window_manager.h" |
| 69 #elif defined(USE_OZONE) | 72 #elif defined(USE_OZONE) |
| 70 #include "components/display_compositor/compositor_overlay_candidate_validator_o
zone.h" | 73 #include "components/display_compositor/compositor_overlay_candidate_validator_o
zone.h" |
| 71 #include "content/browser/compositor/software_output_device_ozone.h" | 74 #include "content/browser/compositor/software_output_device_ozone.h" |
| 72 #include "ui/ozone/public/overlay_candidates_ozone.h" | 75 #include "ui/ozone/public/overlay_candidates_ozone.h" |
| (...skipping 69 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 142 gpu::SharedMemoryLimits(), attributes, shared_context_provider, type)); | 145 gpu::SharedMemoryLimits(), attributes, shared_context_provider, type)); |
| 143 } | 146 } |
| 144 | 147 |
| 145 #if defined(OS_MACOSX) | 148 #if defined(OS_MACOSX) |
| 146 bool IsCALayersDisabledFromCommandLine() { | 149 bool IsCALayersDisabledFromCommandLine() { |
| 147 base::CommandLine* command_line = base::CommandLine::ForCurrentProcess(); | 150 base::CommandLine* command_line = base::CommandLine::ForCurrentProcess(); |
| 148 return command_line->HasSwitch(switches::kDisableMacOverlays); | 151 return command_line->HasSwitch(switches::kDisableMacOverlays); |
| 149 } | 152 } |
| 150 #endif | 153 #endif |
| 151 | 154 |
| 155 bool IsUsingMus() { |
| 156 #if defined(MOJO_RUNNER_CLIENT) |
| 157 return shell::ShellIsRemote(); |
| 158 #else |
| 159 return false = false; |
| 160 #endif |
| 161 } |
| 162 |
| 152 } // namespace | 163 } // namespace |
| 153 | 164 |
| 154 namespace content { | 165 namespace content { |
| 155 | 166 |
| 156 struct GpuProcessTransportFactory::PerCompositorData { | 167 struct GpuProcessTransportFactory::PerCompositorData { |
| 157 gpu::SurfaceHandle surface_handle = gpu::kNullSurfaceHandle; | 168 gpu::SurfaceHandle surface_handle = gpu::kNullSurfaceHandle; |
| 158 BrowserCompositorOutputSurface* display_output_surface = nullptr; | 169 BrowserCompositorOutputSurface* display_output_surface = nullptr; |
| 159 cc::SyntheticBeginFrameSource* begin_frame_source = nullptr; | 170 cc::SyntheticBeginFrameSource* begin_frame_source = nullptr; |
| 160 ReflectorImpl* reflector = nullptr; | 171 ReflectorImpl* reflector = nullptr; |
| 161 std::unique_ptr<cc::Display> display; | 172 std::unique_ptr<cc::Display> display; |
| (...skipping 86 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 248 new display_compositor::CompositorOverlayCandidateValidatorAndroid()); | 259 new display_compositor::CompositorOverlayCandidateValidatorAndroid()); |
| 249 #endif | 260 #endif |
| 250 | 261 |
| 251 return validator; | 262 return validator; |
| 252 } | 263 } |
| 253 | 264 |
| 254 static bool ShouldCreateGpuOutputSurface(ui::Compositor* compositor) { | 265 static bool ShouldCreateGpuOutputSurface(ui::Compositor* compositor) { |
| 255 #if defined(MOJO_RUNNER_CLIENT) | 266 #if defined(MOJO_RUNNER_CLIENT) |
| 256 // Chrome running as a mojo app currently can only use software compositing. | 267 // Chrome running as a mojo app currently can only use software compositing. |
| 257 // TODO(rjkroege): http://crbug.com/548451 | 268 // TODO(rjkroege): http://crbug.com/548451 |
| 258 if (shell::ShellIsRemote()) { | 269 if (shell::ShellIsRemote() && !mus::GpuService::UseChromeGpuCommandBuffer()) |
| 259 return false; | 270 return false; |
| 260 } | |
| 261 #endif | 271 #endif |
| 262 | 272 |
| 263 #if defined(OS_CHROMEOS) | 273 #if defined(OS_CHROMEOS) |
| 264 // Software fallback does not happen on Chrome OS. | 274 // Software fallback does not happen on Chrome OS. |
| 265 return true; | 275 return true; |
| 266 #endif | 276 #endif |
| 267 | 277 |
| 268 #if defined(OS_WIN) | 278 #if defined(OS_WIN) |
| 269 if (::GetProp(compositor->widget(), kForceSoftwareCompositor) && | 279 if (::GetProp(compositor->widget(), kForceSoftwareCompositor) && |
| 270 ::RemoveProp(compositor->widget(), kForceSoftwareCompositor)) | 280 ::RemoveProp(compositor->widget(), kForceSoftwareCompositor)) |
| (...skipping 15 matching lines...) Expand all Loading... |
| 286 data->display_output_surface = nullptr; | 296 data->display_output_surface = nullptr; |
| 287 data->begin_frame_source = nullptr; | 297 data->begin_frame_source = nullptr; |
| 288 } | 298 } |
| 289 | 299 |
| 290 #if defined(OS_WIN) | 300 #if defined(OS_WIN) |
| 291 gfx::RenderingWindowManager::GetInstance()->UnregisterParent( | 301 gfx::RenderingWindowManager::GetInstance()->UnregisterParent( |
| 292 compositor->widget()); | 302 compositor->widget()); |
| 293 #endif | 303 #endif |
| 294 | 304 |
| 295 const bool use_vulkan = static_cast<bool>(SharedVulkanContextProvider()); | 305 const bool use_vulkan = static_cast<bool>(SharedVulkanContextProvider()); |
| 296 | 306 const bool use_mus = IsUsingMus(); |
| 297 const bool create_gpu_output_surface = | 307 const bool create_gpu_output_surface = |
| 298 ShouldCreateGpuOutputSurface(compositor.get()); | 308 ShouldCreateGpuOutputSurface(compositor.get()); |
| 299 if (create_gpu_output_surface && !use_vulkan) { | 309 if (create_gpu_output_surface && !use_vulkan) { |
| 300 BrowserGpuChannelHostFactory::instance()->EstablishGpuChannel( | 310 base::Closure callback( |
| 301 CAUSE_FOR_GPU_LAUNCH_SHARED_WORKER_THREAD_CONTEXT, | |
| 302 base::Bind(&GpuProcessTransportFactory::EstablishedGpuChannel, | 311 base::Bind(&GpuProcessTransportFactory::EstablishedGpuChannel, |
| 303 callback_factory_.GetWeakPtr(), compositor, | 312 callback_factory_.GetWeakPtr(), compositor, |
| 304 create_gpu_output_surface, 0)); | 313 create_gpu_output_surface, 0)); |
| 314 if (!use_mus) { |
| 315 BrowserGpuChannelHostFactory::instance()->EstablishGpuChannel( |
| 316 CAUSE_FOR_GPU_LAUNCH_SHARED_WORKER_THREAD_CONTEXT, callback); |
| 317 #if defined(MOJO_RUNNER_CLIENT) |
| 318 } else { |
| 319 mus::GpuService::GetInstance()->EstablishGpuChannel(callback); |
| 320 #endif |
| 321 } |
| 305 } else { | 322 } else { |
| 306 EstablishedGpuChannel(compositor, create_gpu_output_surface, 0); | 323 EstablishedGpuChannel(compositor, create_gpu_output_surface, 0); |
| 307 } | 324 } |
| 308 } | 325 } |
| 309 | 326 |
| 310 void GpuProcessTransportFactory::EstablishedGpuChannel( | 327 void GpuProcessTransportFactory::EstablishedGpuChannel( |
| 311 base::WeakPtr<ui::Compositor> compositor, | 328 base::WeakPtr<ui::Compositor> compositor, |
| 312 bool create_gpu_output_surface, | 329 bool create_gpu_output_surface, |
| 313 int num_attempts) { | 330 int num_attempts) { |
| 314 if (!compositor) | 331 if (!compositor) |
| (...skipping 16 matching lines...) Expand all Loading... |
| 331 create_gpu_output_surface = false; | 348 create_gpu_output_surface = false; |
| 332 } | 349 } |
| 333 | 350 |
| 334 #if defined(OS_WIN) | 351 #if defined(OS_WIN) |
| 335 gfx::RenderingWindowManager::GetInstance()->RegisterParent( | 352 gfx::RenderingWindowManager::GetInstance()->RegisterParent( |
| 336 compositor->widget()); | 353 compositor->widget()); |
| 337 #endif | 354 #endif |
| 338 | 355 |
| 339 scoped_refptr<cc::VulkanInProcessContextProvider> vulkan_context_provider = | 356 scoped_refptr<cc::VulkanInProcessContextProvider> vulkan_context_provider = |
| 340 SharedVulkanContextProvider(); | 357 SharedVulkanContextProvider(); |
| 341 | 358 const bool use_mus = IsUsingMus(); |
| 342 scoped_refptr<ContextProviderCommandBuffer> context_provider; | 359 scoped_refptr<ContextProviderCommandBuffer> context_provider; |
| 343 if (create_gpu_output_surface && !vulkan_context_provider) { | 360 if (create_gpu_output_surface && !vulkan_context_provider) { |
| 344 // Try to reuse existing worker context provider. | 361 // Try to reuse existing worker context provider. |
| 345 if (shared_worker_context_provider_) { | 362 if (shared_worker_context_provider_) { |
| 346 bool lost; | 363 bool lost; |
| 347 { | 364 { |
| 348 // Note: If context is lost, we delete reference after releasing the | 365 // Note: If context is lost, we delete reference after releasing the |
| 349 // lock. | 366 // lock. |
| 350 base::AutoLock lock(*shared_worker_context_provider_->GetLock()); | 367 base::AutoLock lock(*shared_worker_context_provider_->GetLock()); |
| 351 lost = shared_worker_context_provider_->ContextGL() | 368 lost = shared_worker_context_provider_->ContextGL() |
| 352 ->GetGraphicsResetStatusKHR() != GL_NO_ERROR; | 369 ->GetGraphicsResetStatusKHR() != GL_NO_ERROR; |
| 353 } | 370 } |
| 354 if (lost) | 371 if (lost) |
| 355 shared_worker_context_provider_ = nullptr; | 372 shared_worker_context_provider_ = nullptr; |
| 356 } | 373 } |
| 357 | 374 |
| 358 scoped_refptr<gpu::GpuChannelHost> gpu_channel_host; | 375 scoped_refptr<gpu::GpuChannelHost> gpu_channel_host; |
| 359 if (GpuDataManagerImpl::GetInstance()->CanUseGpuBrowserCompositor()) { | 376 if (GpuDataManagerImpl::GetInstance()->CanUseGpuBrowserCompositor()) { |
| 360 // We attempted to do EstablishGpuChannel already, so we just use | 377 // We attempted to do EstablishGpuChannel already, so we just use |
| 361 // GetGpuChannel() instead of EstablishGpuChannelSync(). | 378 // GetGpuChannel() instead of EstablishGpuChannelSync(). |
| 362 gpu_channel_host = | 379 if (!use_mus) { |
| 363 BrowserGpuChannelHostFactory::instance()->GetGpuChannel(); | 380 gpu_channel_host = |
| 381 BrowserGpuChannelHostFactory::instance()->GetGpuChannel(); |
| 382 #if defined(MOJO_RUNNER_CLIENT) |
| 383 } else { |
| 384 gpu_channel_host = mus::GpuService::GetInstance()->GetGpuChannel(); |
| 385 #endif |
| 386 } |
| 364 } | 387 } |
| 365 | 388 |
| 366 if (!gpu_channel_host) { | 389 if (!gpu_channel_host) { |
| 367 shared_worker_context_provider_ = nullptr; | 390 shared_worker_context_provider_ = nullptr; |
| 368 } else { | 391 } else { |
| 369 if (!shared_worker_context_provider_) { | 392 if (!shared_worker_context_provider_) { |
| 370 const bool support_locking = true; | 393 const bool support_locking = true; |
| 371 shared_worker_context_provider_ = CreateContextCommon( | 394 shared_worker_context_provider_ = CreateContextCommon( |
| 372 gpu_channel_host, gpu::kNullSurfaceHandle, support_locking, nullptr, | 395 gpu_channel_host, gpu::kNullSurfaceHandle, support_locking, nullptr, |
| 373 command_buffer_metrics::BROWSER_WORKER_CONTEXT); | 396 command_buffer_metrics::BROWSER_WORKER_CONTEXT); |
| 374 // TODO(vadimt): Remove ScopedTracker below once crbug.com/125248 is | 397 // TODO(vadimt): Remove ScopedTracker below once crbug.com/125248 is |
| 375 // fixed. Tracking time in BindToCurrentThread. | 398 // fixed. Tracking time in BindToCurrentThread. |
| 376 tracked_objects::ScopedTracker tracking_profile( | 399 tracked_objects::ScopedTracker tracking_profile( |
| 377 FROM_HERE_WITH_EXPLICIT_FUNCTION( | 400 FROM_HERE_WITH_EXPLICIT_FUNCTION( |
| 378 "125248" | 401 "125248" |
| 379 " GpuProcessTransportFactory::EstablishedGpuChannel" | 402 " GpuProcessTransportFactory::EstablishedGpuChannel" |
| 380 "::Worker")); | 403 "::Worker")); |
| 381 if (!shared_worker_context_provider_->BindToCurrentThread()) | 404 if (!shared_worker_context_provider_->BindToCurrentThread()) |
| 382 shared_worker_context_provider_ = nullptr; | 405 shared_worker_context_provider_ = nullptr; |
| 383 } | 406 } |
| 384 | 407 |
| 385 // The |context_provider| is used for both the browser compositor and the | 408 // The |context_provider| is used for both the browser compositor and the |
| 386 // display compositor. It shares resources with the worker context, so if | 409 // display compositor. It shares resources with the worker context, so if |
| 387 // we failed to make a worker context, just start over and try again. | 410 // we failed to make a worker context, just start over and try again. |
| 388 if (shared_worker_context_provider_) { | 411 if (shared_worker_context_provider_) { |
| 389 bool support_locking = false; | 412 bool support_locking = false; |
| 413 // For mus, we create offscreen context. |
| 390 context_provider = CreateContextCommon( | 414 context_provider = CreateContextCommon( |
| 391 std::move(gpu_channel_host), data->surface_handle, support_locking, | 415 std::move(gpu_channel_host), |
| 392 shared_worker_context_provider_.get(), | 416 use_mus ? gpu::kNullSurfaceHandle : data->surface_handle, |
| 417 support_locking, shared_worker_context_provider_.get(), |
| 393 command_buffer_metrics::DISPLAY_COMPOSITOR_ONSCREEN_CONTEXT); | 418 command_buffer_metrics::DISPLAY_COMPOSITOR_ONSCREEN_CONTEXT); |
| 394 // TODO(vadimt): Remove ScopedTracker below once crbug.com/125248 is | 419 // TODO(vadimt): Remove ScopedTracker below once crbug.com/125248 is |
| 395 // fixed. Tracking time in BindToCurrentThread. | 420 // fixed. Tracking time in BindToCurrentThread. |
| 396 tracked_objects::ScopedTracker tracking_profile( | 421 tracked_objects::ScopedTracker tracking_profile( |
| 397 FROM_HERE_WITH_EXPLICIT_FUNCTION( | 422 FROM_HERE_WITH_EXPLICIT_FUNCTION( |
| 398 "125248" | 423 "125248" |
| 399 " GpuProcessTransportFactory::EstablishedGpuChannel" | 424 " GpuProcessTransportFactory::EstablishedGpuChannel" |
| 400 "::Compositor")); | 425 "::Compositor")); |
| 401 #if defined(OS_MACOSX) | 426 #if defined(OS_MACOSX) |
| 402 // On Mac, GpuCommandBufferMsg_SwapBuffersCompleted must be handled in | 427 // On Mac, GpuCommandBufferMsg_SwapBuffersCompleted must be handled in |
| 403 // a nested message loop during resize. | 428 // a nested message loop during resize. |
| 404 context_provider->SetDefaultTaskRunner( | 429 context_provider->SetDefaultTaskRunner( |
| 405 ui::WindowResizeHelperMac::Get()->task_runner()); | 430 ui::WindowResizeHelperMac::Get()->task_runner()); |
| 406 #endif | 431 #endif |
| 407 if (!context_provider->BindToCurrentThread()) | 432 if (!context_provider->BindToCurrentThread()) |
| 408 context_provider = nullptr; | 433 context_provider = nullptr; |
| 409 } | 434 } |
| 410 } | 435 } |
| 411 | 436 |
| 412 bool created_gpu_browser_compositor = | 437 bool created_gpu_browser_compositor = |
| 413 !!context_provider && !!shared_worker_context_provider_; | 438 !!context_provider && !!shared_worker_context_provider_; |
| 414 | 439 |
| 415 UMA_HISTOGRAM_BOOLEAN("Aura.CreatedGpuBrowserCompositor", | 440 UMA_HISTOGRAM_BOOLEAN("Aura.CreatedGpuBrowserCompositor", |
| 416 created_gpu_browser_compositor); | 441 created_gpu_browser_compositor); |
| 417 | 442 |
| 418 if (!created_gpu_browser_compositor) { | 443 if (!created_gpu_browser_compositor) { |
| 419 // Try again. | 444 // Try again. |
| 420 BrowserGpuChannelHostFactory::instance()->EstablishGpuChannel( | 445 base::Closure callback( |
| 421 CAUSE_FOR_GPU_LAUNCH_SHARED_WORKER_THREAD_CONTEXT, | |
| 422 base::Bind(&GpuProcessTransportFactory::EstablishedGpuChannel, | 446 base::Bind(&GpuProcessTransportFactory::EstablishedGpuChannel, |
| 423 callback_factory_.GetWeakPtr(), compositor, | 447 callback_factory_.GetWeakPtr(), compositor, |
| 424 create_gpu_output_surface, num_attempts + 1)); | 448 create_gpu_output_surface, num_attempts + 1)); |
| 449 if (!use_mus) { |
| 450 BrowserGpuChannelHostFactory::instance()->EstablishGpuChannel( |
| 451 CAUSE_FOR_GPU_LAUNCH_SHARED_WORKER_THREAD_CONTEXT, callback); |
| 452 #if defined(MOJO_RUNNER_CLIENT) |
| 453 } else { |
| 454 mus::GpuService::GetInstance()->EstablishGpuChannel(callback); |
| 455 #endif |
| 456 } |
| 425 return; | 457 return; |
| 426 } | 458 } |
| 427 } | 459 } |
| 428 | 460 |
| 429 std::unique_ptr<cc::SyntheticBeginFrameSource> begin_frame_source; | 461 std::unique_ptr<cc::SyntheticBeginFrameSource> begin_frame_source; |
| 430 if (!compositor->GetRendererSettings().disable_display_vsync) { | 462 if (!compositor->GetRendererSettings().disable_display_vsync) { |
| 431 begin_frame_source.reset(new cc::DelayBasedBeginFrameSource( | 463 begin_frame_source.reset(new cc::DelayBasedBeginFrameSource( |
| 432 base::MakeUnique<cc::DelayBasedTimeSource>( | 464 base::MakeUnique<cc::DelayBasedTimeSource>( |
| 433 compositor->task_runner().get()))); | 465 compositor->task_runner().get()))); |
| 434 } else { | 466 } else { |
| (...skipping 48 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 483 compositor->vsync_manager(), begin_frame_source.get(), | 515 compositor->vsync_manager(), begin_frame_source.get(), |
| 484 CreateOverlayCandidateValidator(compositor->widget()), | 516 CreateOverlayCandidateValidator(compositor->widget()), |
| 485 GL_TEXTURE_2D, GL_RGB, | 517 GL_TEXTURE_2D, GL_RGB, |
| 486 BrowserGpuMemoryBufferManager::current())); | 518 BrowserGpuMemoryBufferManager::current())); |
| 487 #endif | 519 #endif |
| 488 } else { | 520 } else { |
| 489 std::unique_ptr<display_compositor::CompositorOverlayCandidateValidator> | 521 std::unique_ptr<display_compositor::CompositorOverlayCandidateValidator> |
| 490 validator; | 522 validator; |
| 491 #if !defined(OS_MACOSX) | 523 #if !defined(OS_MACOSX) |
| 492 // Overlays are only supported on surfaceless output surfaces on Mac. | 524 // Overlays are only supported on surfaceless output surfaces on Mac. |
| 493 validator = CreateOverlayCandidateValidator(compositor->widget()); | 525 if (!use_mus) |
| 526 validator = CreateOverlayCandidateValidator(compositor->widget()); |
| 494 #endif | 527 #endif |
| 495 display_output_surface = | 528 if (!use_mus) { |
| 496 base::WrapUnique(new GpuBrowserCompositorOutputSurface( | 529 display_output_surface = |
| 497 context_provider, compositor->vsync_manager(), | 530 base::WrapUnique(new GpuBrowserCompositorOutputSurface( |
| 498 begin_frame_source.get(), std::move(validator))); | 531 context_provider, compositor->vsync_manager(), |
| 532 begin_frame_source.get(), std::move(validator))); |
| 533 #if defined(MOJO_RUNNER_CLIENT) |
| 534 } else { |
| 535 display_output_surface = |
| 536 base::WrapUnique(new MusBrowserCompositorOutputSurface( |
| 537 data->surface_handle, context_provider, |
| 538 compositor->vsync_manager(), begin_frame_source.get(), |
| 539 std::move(validator))); |
| 540 #endif |
| 541 } |
| 499 } | 542 } |
| 500 } | 543 } |
| 501 } | 544 } |
| 502 | 545 |
| 503 data->display_output_surface = display_output_surface.get(); | 546 data->display_output_surface = display_output_surface.get(); |
| 504 data->begin_frame_source = begin_frame_source.get(); | 547 data->begin_frame_source = begin_frame_source.get(); |
| 505 if (data->reflector) | 548 if (data->reflector) |
| 506 data->reflector->OnSourceSurfaceReady(data->display_output_surface); | 549 data->reflector->OnSourceSurfaceReady(data->display_output_surface); |
| 507 | 550 |
| 508 #if defined(OS_WIN) | 551 #if defined(OS_WIN) |
| (...skipping 201 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 710 } | 753 } |
| 711 #endif | 754 #endif |
| 712 | 755 |
| 713 scoped_refptr<cc::ContextProvider> | 756 scoped_refptr<cc::ContextProvider> |
| 714 GpuProcessTransportFactory::SharedMainThreadContextProvider() { | 757 GpuProcessTransportFactory::SharedMainThreadContextProvider() { |
| 715 if (shared_main_thread_contexts_) | 758 if (shared_main_thread_contexts_) |
| 716 return shared_main_thread_contexts_; | 759 return shared_main_thread_contexts_; |
| 717 | 760 |
| 718 if (!GpuDataManagerImpl::GetInstance()->CanUseGpuBrowserCompositor()) | 761 if (!GpuDataManagerImpl::GetInstance()->CanUseGpuBrowserCompositor()) |
| 719 return nullptr; | 762 return nullptr; |
| 720 scoped_refptr<gpu::GpuChannelHost> gpu_channel_host( | 763 |
| 721 BrowserGpuChannelHostFactory::instance()->EstablishGpuChannelSync( | 764 const bool use_mus = IsUsingMus(); |
| 722 CAUSE_FOR_GPU_LAUNCH_BROWSER_SHARED_MAIN_THREAD_CONTEXT)); | 765 scoped_refptr<gpu::GpuChannelHost> gpu_channel_host; |
| 766 if (!use_mus) { |
| 767 gpu_channel_host = |
| 768 BrowserGpuChannelHostFactory::instance()->EstablishGpuChannelSync( |
| 769 CAUSE_FOR_GPU_LAUNCH_BROWSER_SHARED_MAIN_THREAD_CONTEXT); |
| 770 } else { |
| 771 gpu_channel_host = |
| 772 mus::GpuService::GetInstance()->EstablishGpuChannelSync(); |
| 773 } |
| 774 |
| 723 if (!gpu_channel_host) | 775 if (!gpu_channel_host) |
| 724 return nullptr; | 776 return nullptr; |
| 725 | 777 |
| 726 // We need a separate context from the compositor's so that skia and gl_helper | 778 // We need a separate context from the compositor's so that skia and gl_helper |
| 727 // don't step on each other. | 779 // don't step on each other. |
| 728 bool support_locking = false; | 780 bool support_locking = false; |
| 729 shared_main_thread_contexts_ = CreateContextCommon( | 781 shared_main_thread_contexts_ = CreateContextCommon( |
| 730 std::move(gpu_channel_host), gpu::kNullSurfaceHandle, support_locking, | 782 std::move(gpu_channel_host), gpu::kNullSurfaceHandle, support_locking, |
| 731 nullptr, command_buffer_metrics::BROWSER_OFFSCREEN_MAINTHREAD_CONTEXT); | 783 nullptr, command_buffer_metrics::BROWSER_OFFSCREEN_MAINTHREAD_CONTEXT); |
| 732 shared_main_thread_contexts_->SetLostContextCallback(base::Bind( | 784 shared_main_thread_contexts_->SetLostContextCallback(base::Bind( |
| (...skipping 71 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 804 shared_vulkan_context_provider_ = | 856 shared_vulkan_context_provider_ = |
| 805 cc::VulkanInProcessContextProvider::Create(); | 857 cc::VulkanInProcessContextProvider::Create(); |
| 806 } | 858 } |
| 807 | 859 |
| 808 shared_vulkan_context_provider_initialized_ = true; | 860 shared_vulkan_context_provider_initialized_ = true; |
| 809 } | 861 } |
| 810 return shared_vulkan_context_provider_; | 862 return shared_vulkan_context_provider_; |
| 811 } | 863 } |
| 812 | 864 |
| 813 } // namespace content | 865 } // namespace content |
| OLD | NEW |