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

Side by Side Diff: content/browser/compositor/gpu_process_transport_factory.cc

Issue 2056833002: WIP HW (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Rebase Created 4 years, 6 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 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
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 175 matching lines...) Expand 10 before | Expand all | Expand 10 after
248 new display_compositor::CompositorOverlayCandidateValidatorAndroid()); 251 new display_compositor::CompositorOverlayCandidateValidatorAndroid());
249 #endif 252 #endif
250 253
251 return validator; 254 return validator;
252 } 255 }
253 256
254 static bool ShouldCreateGpuOutputSurface(ui::Compositor* compositor) { 257 static bool ShouldCreateGpuOutputSurface(ui::Compositor* compositor) {
255 #if defined(MOJO_RUNNER_CLIENT) 258 #if defined(MOJO_RUNNER_CLIENT)
256 // Chrome running as a mojo app currently can only use software compositing. 259 // Chrome running as a mojo app currently can only use software compositing.
257 // TODO(rjkroege): http://crbug.com/548451 260 // TODO(rjkroege): http://crbug.com/548451
258 if (shell::ShellIsRemote()) { 261 if (shell::ShellIsRemote())
259 return false; 262 return mus::GpuService::UseChromeGpuCommandBuffer();
260 }
261 #endif 263 #endif
262 264
263 #if defined(OS_CHROMEOS) 265 #if defined(OS_CHROMEOS)
264 // Software fallback does not happen on Chrome OS. 266 // Software fallback does not happen on Chrome OS.
265 return true; 267 return true;
266 #endif 268 #endif
267 269
268 #if defined(OS_WIN) 270 #if defined(OS_WIN)
269 if (::GetProp(compositor->widget(), kForceSoftwareCompositor) && 271 if (::GetProp(compositor->widget(), kForceSoftwareCompositor) &&
270 ::RemoveProp(compositor->widget(), kForceSoftwareCompositor)) 272 ::RemoveProp(compositor->widget(), kForceSoftwareCompositor))
(...skipping 15 matching lines...) Expand all
286 data->display_output_surface = nullptr; 288 data->display_output_surface = nullptr;
287 data->begin_frame_source = nullptr; 289 data->begin_frame_source = nullptr;
288 } 290 }
289 291
290 #if defined(OS_WIN) 292 #if defined(OS_WIN)
291 gfx::RenderingWindowManager::GetInstance()->UnregisterParent( 293 gfx::RenderingWindowManager::GetInstance()->UnregisterParent(
292 compositor->widget()); 294 compositor->widget());
293 #endif 295 #endif
294 296
295 const bool use_vulkan = static_cast<bool>(SharedVulkanContextProvider()); 297 const bool use_vulkan = static_cast<bool>(SharedVulkanContextProvider());
298 #if defined(MOJO_RUNNER_CLIENT)
299 const bool use_mus = shell::ShellIsRemote();
300 #else
301 const bool use_mus = false;
302 #endif
296 303
297 const bool create_gpu_output_surface = 304 const bool create_gpu_output_surface =
298 ShouldCreateGpuOutputSurface(compositor.get()); 305 ShouldCreateGpuOutputSurface(compositor.get());
299 if (create_gpu_output_surface && !use_vulkan) { 306 if (create_gpu_output_surface && !use_vulkan) {
300 BrowserGpuChannelHostFactory::instance()->EstablishGpuChannel( 307 base::Closure callback(
301 CAUSE_FOR_GPU_LAUNCH_SHARED_WORKER_THREAD_CONTEXT,
302 base::Bind(&GpuProcessTransportFactory::EstablishedGpuChannel, 308 base::Bind(&GpuProcessTransportFactory::EstablishedGpuChannel,
303 callback_factory_.GetWeakPtr(), compositor, 309 callback_factory_.GetWeakPtr(), compositor,
304 create_gpu_output_surface, 0)); 310 create_gpu_output_surface, 0));
311 if (!use_mus) {
312 BrowserGpuChannelHostFactory::instance()->EstablishGpuChannel(
313 CAUSE_FOR_GPU_LAUNCH_SHARED_WORKER_THREAD_CONTEXT, callback);
314 #if defined(MOJO_RUNNER_CLIENT)
315 } else {
316 auto connector = MojoShellConnection::GetForProcess()->GetConnector();
317 mus::GpuService::GetInstance()->EstablishGpuChannel(connector, callback);
318 #endif
319 }
305 } else { 320 } else {
306 EstablishedGpuChannel(compositor, create_gpu_output_surface, 0); 321 EstablishedGpuChannel(compositor, create_gpu_output_surface, 0);
307 } 322 }
308 } 323 }
309 324
310 void GpuProcessTransportFactory::EstablishedGpuChannel( 325 void GpuProcessTransportFactory::EstablishedGpuChannel(
311 base::WeakPtr<ui::Compositor> compositor, 326 base::WeakPtr<ui::Compositor> compositor,
312 bool create_gpu_output_surface, 327 bool create_gpu_output_surface,
313 int num_attempts) { 328 int num_attempts) {
314 if (!compositor) 329 if (!compositor)
(...skipping 16 matching lines...) Expand all
331 create_gpu_output_surface = false; 346 create_gpu_output_surface = false;
332 } 347 }
333 348
334 #if defined(OS_WIN) 349 #if defined(OS_WIN)
335 gfx::RenderingWindowManager::GetInstance()->RegisterParent( 350 gfx::RenderingWindowManager::GetInstance()->RegisterParent(
336 compositor->widget()); 351 compositor->widget());
337 #endif 352 #endif
338 353
339 scoped_refptr<cc::VulkanInProcessContextProvider> vulkan_context_provider = 354 scoped_refptr<cc::VulkanInProcessContextProvider> vulkan_context_provider =
340 SharedVulkanContextProvider(); 355 SharedVulkanContextProvider();
356 #if defined(MOJO_RUNNER_CLIENT)
357 const bool use_mus = shell::ShellIsRemote();
358 #else
359 const bool use_mus = false;
360 #endif
341 361
342 scoped_refptr<ContextProviderCommandBuffer> context_provider; 362 scoped_refptr<ContextProviderCommandBuffer> context_provider;
343 if (create_gpu_output_surface && !vulkan_context_provider) { 363 if (create_gpu_output_surface && !vulkan_context_provider) {
344 // Try to reuse existing worker context provider. 364 // Try to reuse existing worker context provider.
345 if (shared_worker_context_provider_) { 365 if (shared_worker_context_provider_) {
346 bool lost; 366 bool lost;
347 { 367 {
348 // Note: If context is lost, we delete reference after releasing the 368 // Note: If context is lost, we delete reference after releasing the
349 // lock. 369 // lock.
350 base::AutoLock lock(*shared_worker_context_provider_->GetLock()); 370 base::AutoLock lock(*shared_worker_context_provider_->GetLock());
351 lost = shared_worker_context_provider_->ContextGL() 371 lost = shared_worker_context_provider_->ContextGL()
352 ->GetGraphicsResetStatusKHR() != GL_NO_ERROR; 372 ->GetGraphicsResetStatusKHR() != GL_NO_ERROR;
353 } 373 }
354 if (lost) 374 if (lost)
355 shared_worker_context_provider_ = nullptr; 375 shared_worker_context_provider_ = nullptr;
356 } 376 }
357 377
358 scoped_refptr<gpu::GpuChannelHost> gpu_channel_host; 378 scoped_refptr<gpu::GpuChannelHost> gpu_channel_host;
359 if (GpuDataManagerImpl::GetInstance()->CanUseGpuBrowserCompositor()) { 379 if (GpuDataManagerImpl::GetInstance()->CanUseGpuBrowserCompositor()) {
360 // We attempted to do EstablishGpuChannel already, so we just use 380 // We attempted to do EstablishGpuChannel already, so we just use
361 // GetGpuChannel() instead of EstablishGpuChannelSync(). 381 // GetGpuChannel() instead of EstablishGpuChannelSync().
362 gpu_channel_host = 382 if (!use_mus) {
363 BrowserGpuChannelHostFactory::instance()->GetGpuChannel(); 383 gpu_channel_host =
384 BrowserGpuChannelHostFactory::instance()->GetGpuChannel();
385 #if defined(MOJO_RUNNER_CLIENT)
386 } else {
387 gpu_channel_host = mus::GpuService::GetInstance()->GetGpuChannel();
388 #endif
389 }
364 } 390 }
365 391
366 if (!gpu_channel_host) { 392 if (!gpu_channel_host) {
367 shared_worker_context_provider_ = nullptr; 393 shared_worker_context_provider_ = nullptr;
368 } else { 394 } else {
369 if (!shared_worker_context_provider_) { 395 if (!shared_worker_context_provider_) {
370 const bool support_locking = true; 396 const bool support_locking = true;
371 shared_worker_context_provider_ = CreateContextCommon( 397 shared_worker_context_provider_ = CreateContextCommon(
372 gpu_channel_host, gpu::kNullSurfaceHandle, support_locking, nullptr, 398 gpu_channel_host, gpu::kNullSurfaceHandle, support_locking, nullptr,
373 command_buffer_metrics::BROWSER_WORKER_CONTEXT); 399 command_buffer_metrics::BROWSER_WORKER_CONTEXT);
374 // TODO(vadimt): Remove ScopedTracker below once crbug.com/125248 is 400 // TODO(vadimt): Remove ScopedTracker below once crbug.com/125248 is
375 // fixed. Tracking time in BindToCurrentThread. 401 // fixed. Tracking time in BindToCurrentThread.
376 tracked_objects::ScopedTracker tracking_profile( 402 tracked_objects::ScopedTracker tracking_profile(
377 FROM_HERE_WITH_EXPLICIT_FUNCTION( 403 FROM_HERE_WITH_EXPLICIT_FUNCTION(
378 "125248" 404 "125248"
379 " GpuProcessTransportFactory::EstablishedGpuChannel" 405 " GpuProcessTransportFactory::EstablishedGpuChannel"
380 "::Worker")); 406 "::Worker"));
381 if (!shared_worker_context_provider_->BindToCurrentThread()) 407 if (!shared_worker_context_provider_->BindToCurrentThread())
382 shared_worker_context_provider_ = nullptr; 408 shared_worker_context_provider_ = nullptr;
383 } 409 }
384 410
385 // The |context_provider| is used for both the browser compositor and the 411 // The |context_provider| is used for both the browser compositor and the
386 // display compositor. It shares resources with the worker context, so if 412 // 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. 413 // we failed to make a worker context, just start over and try again.
388 if (shared_worker_context_provider_) { 414 if (shared_worker_context_provider_) {
389 bool support_locking = false; 415 bool support_locking = false;
416 // For mus, we create offscreen context.
390 context_provider = CreateContextCommon( 417 context_provider = CreateContextCommon(
391 std::move(gpu_channel_host), data->surface_handle, support_locking, 418 std::move(gpu_channel_host),
392 shared_worker_context_provider_.get(), 419 use_mus ? gpu::kNullSurfaceHandle : data->surface_handle,
420 support_locking, shared_worker_context_provider_.get(),
393 command_buffer_metrics::DISPLAY_COMPOSITOR_ONSCREEN_CONTEXT); 421 command_buffer_metrics::DISPLAY_COMPOSITOR_ONSCREEN_CONTEXT);
394 // TODO(vadimt): Remove ScopedTracker below once crbug.com/125248 is 422 // TODO(vadimt): Remove ScopedTracker below once crbug.com/125248 is
395 // fixed. Tracking time in BindToCurrentThread. 423 // fixed. Tracking time in BindToCurrentThread.
396 tracked_objects::ScopedTracker tracking_profile( 424 tracked_objects::ScopedTracker tracking_profile(
397 FROM_HERE_WITH_EXPLICIT_FUNCTION( 425 FROM_HERE_WITH_EXPLICIT_FUNCTION(
398 "125248" 426 "125248"
399 " GpuProcessTransportFactory::EstablishedGpuChannel" 427 " GpuProcessTransportFactory::EstablishedGpuChannel"
400 "::Compositor")); 428 "::Compositor"));
401 #if defined(OS_MACOSX) 429 #if defined(OS_MACOSX)
402 // On Mac, GpuCommandBufferMsg_SwapBuffersCompleted must be handled in 430 // On Mac, GpuCommandBufferMsg_SwapBuffersCompleted must be handled in
403 // a nested message loop during resize. 431 // a nested message loop during resize.
404 context_provider->SetDefaultTaskRunner( 432 context_provider->SetDefaultTaskRunner(
405 ui::WindowResizeHelperMac::Get()->task_runner()); 433 ui::WindowResizeHelperMac::Get()->task_runner());
406 #endif 434 #endif
407 if (!context_provider->BindToCurrentThread()) 435 if (!context_provider->BindToCurrentThread())
408 context_provider = nullptr; 436 context_provider = nullptr;
409 } 437 }
410 } 438 }
411 439
412 bool created_gpu_browser_compositor = 440 bool created_gpu_browser_compositor =
413 !!context_provider && !!shared_worker_context_provider_; 441 !!context_provider && !!shared_worker_context_provider_;
414 442
415 UMA_HISTOGRAM_BOOLEAN("Aura.CreatedGpuBrowserCompositor", 443 UMA_HISTOGRAM_BOOLEAN("Aura.CreatedGpuBrowserCompositor",
416 created_gpu_browser_compositor); 444 created_gpu_browser_compositor);
417 445
418 if (!created_gpu_browser_compositor) { 446 if (!created_gpu_browser_compositor) {
419 // Try again. 447 // Try again.
420 BrowserGpuChannelHostFactory::instance()->EstablishGpuChannel( 448 base::Closure callback(
421 CAUSE_FOR_GPU_LAUNCH_SHARED_WORKER_THREAD_CONTEXT,
422 base::Bind(&GpuProcessTransportFactory::EstablishedGpuChannel, 449 base::Bind(&GpuProcessTransportFactory::EstablishedGpuChannel,
423 callback_factory_.GetWeakPtr(), compositor, 450 callback_factory_.GetWeakPtr(), compositor,
424 create_gpu_output_surface, num_attempts + 1)); 451 create_gpu_output_surface, num_attempts + 1));
452 if (!use_mus) {
453 BrowserGpuChannelHostFactory::instance()->EstablishGpuChannel(
454 CAUSE_FOR_GPU_LAUNCH_SHARED_WORKER_THREAD_CONTEXT, callback);
455 #if defined(MOJO_RUNNER_CLIENT)
456 } else {
457 auto connector = MojoShellConnection::GetForProcess()->GetConnector();
458 mus::GpuService::GetInstance()->EstablishGpuChannel(connector,
459 callback);
460 #endif
461 }
425 return; 462 return;
426 } 463 }
427 } 464 }
428 465
429 std::unique_ptr<cc::SyntheticBeginFrameSource> begin_frame_source; 466 std::unique_ptr<cc::SyntheticBeginFrameSource> begin_frame_source;
430 if (!compositor->GetRendererSettings().disable_display_vsync) { 467 if (!compositor->GetRendererSettings().disable_display_vsync) {
431 begin_frame_source.reset(new cc::DelayBasedBeginFrameSource( 468 begin_frame_source.reset(new cc::DelayBasedBeginFrameSource(
432 base::MakeUnique<cc::DelayBasedTimeSource>( 469 base::MakeUnique<cc::DelayBasedTimeSource>(
433 compositor->task_runner().get()))); 470 compositor->task_runner().get())));
434 } else { 471 } else {
(...skipping 48 matching lines...) Expand 10 before | Expand all | Expand 10 after
483 compositor->vsync_manager(), begin_frame_source.get(), 520 compositor->vsync_manager(), begin_frame_source.get(),
484 CreateOverlayCandidateValidator(compositor->widget()), 521 CreateOverlayCandidateValidator(compositor->widget()),
485 GL_TEXTURE_2D, GL_RGB, 522 GL_TEXTURE_2D, GL_RGB,
486 BrowserGpuMemoryBufferManager::current())); 523 BrowserGpuMemoryBufferManager::current()));
487 #endif 524 #endif
488 } else { 525 } else {
489 std::unique_ptr<display_compositor::CompositorOverlayCandidateValidator> 526 std::unique_ptr<display_compositor::CompositorOverlayCandidateValidator>
490 validator; 527 validator;
491 #if !defined(OS_MACOSX) 528 #if !defined(OS_MACOSX)
492 // Overlays are only supported on surfaceless output surfaces on Mac. 529 // Overlays are only supported on surfaceless output surfaces on Mac.
493 validator = CreateOverlayCandidateValidator(compositor->widget()); 530 // validator = CreateOverlayCandidateValidator(compositor->widget());
494 #endif 531 #endif
495 display_output_surface = 532 if (!use_mus) {
496 base::WrapUnique(new GpuBrowserCompositorOutputSurface( 533 display_output_surface =
497 context_provider, compositor->vsync_manager(), 534 base::WrapUnique(new GpuBrowserCompositorOutputSurface(
498 begin_frame_source.get(), std::move(validator))); 535 context_provider, compositor->vsync_manager(),
536 begin_frame_source.get(), std::move(validator)));
537 #if defined(MOJO_RUNNER_CLIENT)
538 } else {
539 display_output_surface =
540 base::WrapUnique(new MusBrowserCompositorOutputSurface(
541 data->surface_handle, context_provider,
542 compositor->vsync_manager(), begin_frame_source.get(),
543 std::move(validator)));
544 #endif
545 }
499 } 546 }
500 } 547 }
501 } 548 }
502 549
503 data->display_output_surface = display_output_surface.get(); 550 data->display_output_surface = display_output_surface.get();
504 data->begin_frame_source = begin_frame_source.get(); 551 data->begin_frame_source = begin_frame_source.get();
505 if (data->reflector) 552 if (data->reflector)
506 data->reflector->OnSourceSurfaceReady(data->display_output_surface); 553 data->reflector->OnSourceSurfaceReady(data->display_output_surface);
507 554
508 #if defined(OS_WIN) 555 #if defined(OS_WIN)
509 gfx::RenderingWindowManager::GetInstance()->DoSetParentOnChild( 556 gfx::RenderingWindowManager::GetInstance()->DoSetParentOnChild(
510 compositor->widget()); 557 compositor->widget());
511 #endif 558 #endif
512 559
513 std::unique_ptr<cc::DisplayScheduler> scheduler(new cc::DisplayScheduler( 560 std::unique_ptr<cc::DisplayScheduler> scheduler(new cc::DisplayScheduler(
514 begin_frame_source.get(), compositor->task_runner().get(), 561 begin_frame_source.get(), compositor->task_runner().get(),
515 display_output_surface->capabilities().max_frames_pending)); 562 display_output_surface->capabilities().max_frames_pending));
516 563
517 // The Display owns and uses the |display_output_surface| created above. 564 if (!(use_mus && create_gpu_output_surface)) {
518 data->display = base::MakeUnique<cc::Display>( 565 // The Display owns and uses the |display_output_surface| created above.
519 surface_manager_.get(), HostSharedBitmapManager::current(), 566 data->display = base::MakeUnique<cc::Display>(
520 BrowserGpuMemoryBufferManager::current(), 567 surface_manager_.get(), HostSharedBitmapManager::current(),
521 compositor->GetRendererSettings(), 568 BrowserGpuMemoryBufferManager::current(),
522 compositor->surface_id_allocator()->id_namespace(), 569 compositor->GetRendererSettings(),
523 std::move(begin_frame_source), std::move(display_output_surface), 570 compositor->surface_id_allocator()->id_namespace(),
524 std::move(scheduler), base::MakeUnique<cc::TextureMailboxDeleter>( 571 std::move(begin_frame_source), std::move(display_output_surface),
525 compositor->task_runner().get())); 572 std::move(scheduler), base::MakeUnique<cc::TextureMailboxDeleter>(
573 compositor->task_runner().get()));
526 574
527 // The |delegated_output_surface| is given back to the compositor, it 575 // The |delegated_output_surface| is given back to the compositor, it
528 // delegates to the Display as its root surface. Importantly, it shares the 576 // delegates to the Display as its root surface. Importantly, it shares the
529 // same ContextProvider as the Display's output surface. 577 // same ContextProvider as the Display's output surface.
530 std::unique_ptr<cc::SurfaceDisplayOutputSurface> delegated_output_surface( 578 std::unique_ptr<cc::SurfaceDisplayOutputSurface> delegated_output_surface(
531 vulkan_context_provider 579 vulkan_context_provider
532 ? new cc::SurfaceDisplayOutputSurface( 580 ? new cc::SurfaceDisplayOutputSurface(
533 surface_manager_.get(), compositor->surface_id_allocator(), 581 surface_manager_.get(), compositor->surface_id_allocator(),
534 data->display.get(), 582 data->display.get(),
535 static_cast<scoped_refptr<cc::VulkanContextProvider>>( 583 static_cast<scoped_refptr<cc::VulkanContextProvider>>(
536 vulkan_context_provider)) 584 vulkan_context_provider))
537 : new cc::SurfaceDisplayOutputSurface( 585 : new cc::SurfaceDisplayOutputSurface(
538 surface_manager_.get(), compositor->surface_id_allocator(), 586 surface_manager_.get(), compositor->surface_id_allocator(),
539 data->display.get(), context_provider, 587 data->display.get(), context_provider,
540 shared_worker_context_provider_)); 588 shared_worker_context_provider_));
541 data->display->Resize(compositor->size()); 589 data->display->Resize(compositor->size());
542 data->display->SetOutputIsSecure(data->output_is_secure); 590 data->display->SetOutputIsSecure(data->output_is_secure);
543 compositor->SetOutputSurface(std::move(delegated_output_surface)); 591 compositor->SetOutputSurface(std::move(delegated_output_surface));
592 #if defined(MOJO_RUNNER_CLIENT)
593 } else {
594 compositor->SetOutputSurface(std::move(display_output_surface));
595 #endif
596 }
544 } 597 }
545 598
546 std::unique_ptr<ui::Reflector> GpuProcessTransportFactory::CreateReflector( 599 std::unique_ptr<ui::Reflector> GpuProcessTransportFactory::CreateReflector(
547 ui::Compositor* source_compositor, 600 ui::Compositor* source_compositor,
548 ui::Layer* target_layer) { 601 ui::Layer* target_layer) {
549 PerCompositorData* source_data = per_compositor_data_[source_compositor]; 602 PerCompositorData* source_data = per_compositor_data_[source_compositor];
550 DCHECK(source_data); 603 DCHECK(source_data);
551 604
552 std::unique_ptr<ReflectorImpl> reflector( 605 std::unique_ptr<ReflectorImpl> reflector(
553 new ReflectorImpl(source_compositor, target_layer)); 606 new ReflectorImpl(source_compositor, target_layer));
(...skipping 156 matching lines...) Expand 10 before | Expand all | Expand 10 after
710 } 763 }
711 #endif 764 #endif
712 765
713 scoped_refptr<cc::ContextProvider> 766 scoped_refptr<cc::ContextProvider>
714 GpuProcessTransportFactory::SharedMainThreadContextProvider() { 767 GpuProcessTransportFactory::SharedMainThreadContextProvider() {
715 if (shared_main_thread_contexts_) 768 if (shared_main_thread_contexts_)
716 return shared_main_thread_contexts_; 769 return shared_main_thread_contexts_;
717 770
718 if (!GpuDataManagerImpl::GetInstance()->CanUseGpuBrowserCompositor()) 771 if (!GpuDataManagerImpl::GetInstance()->CanUseGpuBrowserCompositor())
719 return nullptr; 772 return nullptr;
720 scoped_refptr<gpu::GpuChannelHost> gpu_channel_host( 773 scoped_refptr<gpu::GpuChannelHost> gpu_channel_host;
721 BrowserGpuChannelHostFactory::instance()->EstablishGpuChannelSync( 774
722 CAUSE_FOR_GPU_LAUNCH_BROWSER_SHARED_MAIN_THREAD_CONTEXT)); 775 #if defined(MOJO_RUNNER_CLIENT)
776 const bool use_mus = shell::ShellIsRemote();
777 #else
778 const bool use_mus = false;
779 #endif
780
781 if (!use_mus) {
782 gpu_channel_host =
783 BrowserGpuChannelHostFactory::instance()->EstablishGpuChannelSync(
784 CAUSE_FOR_GPU_LAUNCH_BROWSER_SHARED_MAIN_THREAD_CONTEXT);
785 } else {
786 auto connector = MojoShellConnection::GetForProcess()->GetConnector();
787 gpu_channel_host =
788 mus::GpuService::GetInstance()->EstablishGpuChannelSync(connector);
789 }
790
723 if (!gpu_channel_host) 791 if (!gpu_channel_host)
724 return nullptr; 792 return nullptr;
725 793
726 // We need a separate context from the compositor's so that skia and gl_helper 794 // We need a separate context from the compositor's so that skia and gl_helper
727 // don't step on each other. 795 // don't step on each other.
728 bool support_locking = false; 796 bool support_locking = false;
729 shared_main_thread_contexts_ = CreateContextCommon( 797 shared_main_thread_contexts_ = CreateContextCommon(
730 std::move(gpu_channel_host), gpu::kNullSurfaceHandle, support_locking, 798 std::move(gpu_channel_host), gpu::kNullSurfaceHandle, support_locking,
731 nullptr, command_buffer_metrics::BROWSER_OFFSCREEN_MAINTHREAD_CONTEXT); 799 nullptr, command_buffer_metrics::BROWSER_OFFSCREEN_MAINTHREAD_CONTEXT);
732 shared_main_thread_contexts_->SetLostContextCallback(base::Bind( 800 shared_main_thread_contexts_->SetLostContextCallback(base::Bind(
(...skipping 72 matching lines...) Expand 10 before | Expand all | Expand 10 after
805 shared_vulkan_context_provider_ = 873 shared_vulkan_context_provider_ =
806 cc::VulkanInProcessContextProvider::Create(); 874 cc::VulkanInProcessContextProvider::Create();
807 } 875 }
808 876
809 shared_vulkan_context_provider_initialized_ = true; 877 shared_vulkan_context_provider_initialized_ = true;
810 } 878 }
811 return shared_vulkan_context_provider_; 879 return shared_vulkan_context_provider_;
812 } 880 }
813 881
814 } // namespace content 882 } // namespace content
OLDNEW
« no previous file with comments | « content/browser/compositor/DEPS ('k') | content/browser/compositor/mus_browser_compositor_output_surface.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698