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 "content/browser/compositor/mus_browser_compositor_output_surface.h" |
| 64 #include "content/public/common/mojo_shell_connection.h" |
63 #include "services/shell/runner/common/client_util.h" | 65 #include "services/shell/runner/common/client_util.h" |
| 66 #include "services/ui/common/gpu_service.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" |
73 #include "ui/ozone/public/overlay_manager_ozone.h" | 76 #include "ui/ozone/public/overlay_manager_ozone.h" |
(...skipping 20 matching lines...) Expand all Loading... |
94 #include "content/browser/compositor/vulkan_browser_compositor_output_surface.h" | 97 #include "content/browser/compositor/vulkan_browser_compositor_output_surface.h" |
95 #endif | 98 #endif |
96 | 99 |
97 using cc::ContextProvider; | 100 using cc::ContextProvider; |
98 using gpu::gles2::GLES2Interface; | 101 using gpu::gles2::GLES2Interface; |
99 | 102 |
100 namespace { | 103 namespace { |
101 | 104 |
102 const int kNumRetriesBeforeSoftwareFallback = 4; | 105 const int kNumRetriesBeforeSoftwareFallback = 4; |
103 | 106 |
| 107 bool IsUsingMus() { |
| 108 #if defined(MOJO_RUNNER_CLIENT) |
| 109 return shell::ShellIsRemote(); |
| 110 #else |
| 111 return false; |
| 112 #endif |
| 113 } |
| 114 |
104 scoped_refptr<content::ContextProviderCommandBuffer> CreateContextCommon( | 115 scoped_refptr<content::ContextProviderCommandBuffer> CreateContextCommon( |
105 scoped_refptr<gpu::GpuChannelHost> gpu_channel_host, | 116 scoped_refptr<gpu::GpuChannelHost> gpu_channel_host, |
106 gpu::SurfaceHandle surface_handle, | 117 gpu::SurfaceHandle surface_handle, |
| 118 bool need_alpha_channel, |
107 bool support_locking, | 119 bool support_locking, |
108 content::ContextProviderCommandBuffer* shared_context_provider, | 120 content::ContextProviderCommandBuffer* shared_context_provider, |
109 content::command_buffer_metrics::ContextType type) { | 121 content::command_buffer_metrics::ContextType type) { |
110 DCHECK( | 122 DCHECK( |
111 content::GpuDataManagerImpl::GetInstance()->CanUseGpuBrowserCompositor()); | 123 content::GpuDataManagerImpl::GetInstance()->CanUseGpuBrowserCompositor()); |
112 DCHECK(gpu_channel_host); | 124 DCHECK(gpu_channel_host); |
113 | 125 |
114 // This is called from a few places to create different contexts: | 126 // This is called from a few places to create different contexts: |
115 // - The shared main thread context (offscreen). | 127 // - The shared main thread context (offscreen). |
116 // - The compositor context, which is used by the browser compositor | 128 // - The compositor context, which is used by the browser compositor |
117 // (offscreen) for synchronization mostly, and by the display compositor | 129 // (offscreen) for synchronization mostly, and by the display compositor |
118 // (onscreen) for actual GL drawing. | 130 // (onscreen, except for with mus) for actual GL drawing. |
119 // - The compositor worker context (offscreen) used for GPU raster. | 131 // - The compositor worker context (offscreen) used for GPU raster. |
120 // So ask for capabilities needed by any of these cases (we can optimize by | 132 // So ask for capabilities needed by any of these cases (we can optimize by |
121 // branching on |surface_handle| being null if these needs diverge). | 133 // branching on |surface_handle| being null if these needs diverge). |
122 // | 134 // |
123 // The default framebuffer for an offscreen context is not used, so it does | 135 // The default framebuffer for an offscreen context is not used, so it does |
124 // not need alpha, stencil, depth, antialiasing. The display compositor does | 136 // not need alpha, stencil, depth, antialiasing. The display compositor does |
125 // not use these things either, so we can request nothing here. | 137 // not use these things either, so we can request nothing here. |
| 138 // The display compositor does not use these things either (except for alpha |
| 139 // when using mus for non-opaque ui that overlaps the system's window |
| 140 // borders), so we can request only that when needed. |
126 gpu::gles2::ContextCreationAttribHelper attributes; | 141 gpu::gles2::ContextCreationAttribHelper attributes; |
127 attributes.alpha_size = -1; | 142 attributes.alpha_size = need_alpha_channel ? 8 : -1; |
128 attributes.depth_size = 0; | 143 attributes.depth_size = 0; |
129 attributes.stencil_size = 0; | 144 attributes.stencil_size = 0; |
130 attributes.samples = 0; | 145 attributes.samples = 0; |
131 attributes.sample_buffers = 0; | 146 attributes.sample_buffers = 0; |
132 attributes.bind_generates_resource = false; | 147 attributes.bind_generates_resource = false; |
133 attributes.lose_context_when_out_of_memory = true; | 148 attributes.lose_context_when_out_of_memory = true; |
| 149 attributes.buffer_preserved = false; |
134 | 150 |
135 constexpr bool automatic_flushes = false; | 151 constexpr bool automatic_flushes = false; |
136 | 152 |
137 GURL url("chrome://gpu/GpuProcessTransportFactory::CreateContextCommon"); | 153 GURL url("chrome://gpu/GpuProcessTransportFactory::CreateContextCommon"); |
138 return make_scoped_refptr(new content::ContextProviderCommandBuffer( | 154 return make_scoped_refptr(new content::ContextProviderCommandBuffer( |
139 std::move(gpu_channel_host), gpu::GPU_STREAM_DEFAULT, | 155 std::move(gpu_channel_host), gpu::GPU_STREAM_DEFAULT, |
140 gpu::GpuStreamPriority::NORMAL, surface_handle, url, automatic_flushes, | 156 gpu::GpuStreamPriority::NORMAL, surface_handle, url, automatic_flushes, |
141 support_locking, gpu::SharedMemoryLimits(), attributes, | 157 support_locking, gpu::SharedMemoryLimits(), attributes, |
142 shared_context_provider, type)); | 158 shared_context_provider, type)); |
143 } | 159 } |
(...skipping 103 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
247 #elif defined(OS_ANDROID) | 263 #elif defined(OS_ANDROID) |
248 validator.reset( | 264 validator.reset( |
249 new display_compositor::CompositorOverlayCandidateValidatorAndroid()); | 265 new display_compositor::CompositorOverlayCandidateValidatorAndroid()); |
250 #endif | 266 #endif |
251 | 267 |
252 return validator; | 268 return validator; |
253 } | 269 } |
254 | 270 |
255 static bool ShouldCreateGpuOutputSurface(ui::Compositor* compositor) { | 271 static bool ShouldCreateGpuOutputSurface(ui::Compositor* compositor) { |
256 #if defined(MOJO_RUNNER_CLIENT) | 272 #if defined(MOJO_RUNNER_CLIENT) |
257 // Chrome running as a mojo app currently can only use software compositing. | 273 if (shell::ShellIsRemote() && !ui::GpuService::UseChromeGpuCommandBuffer()) |
258 // TODO(rjkroege): http://crbug.com/548451 | |
259 if (shell::ShellIsRemote()) { | |
260 return false; | 274 return false; |
261 } | |
262 #endif | 275 #endif |
263 | 276 |
264 #if defined(OS_CHROMEOS) | 277 #if defined(OS_CHROMEOS) |
265 // Software fallback does not happen on Chrome OS. | 278 // Software fallback does not happen on Chrome OS. |
266 return true; | 279 return true; |
267 #endif | 280 #endif |
268 | 281 |
269 #if defined(OS_WIN) | 282 #if defined(OS_WIN) |
270 if (::GetProp(compositor->widget(), kForceSoftwareCompositor) && | 283 if (::GetProp(compositor->widget(), kForceSoftwareCompositor) && |
271 ::RemoveProp(compositor->widget(), kForceSoftwareCompositor)) | 284 ::RemoveProp(compositor->widget(), kForceSoftwareCompositor)) |
(...skipping 15 matching lines...) Expand all Loading... |
287 data->display_output_surface = nullptr; | 300 data->display_output_surface = nullptr; |
288 data->begin_frame_source = nullptr; | 301 data->begin_frame_source = nullptr; |
289 } | 302 } |
290 | 303 |
291 #if defined(OS_WIN) | 304 #if defined(OS_WIN) |
292 gfx::RenderingWindowManager::GetInstance()->UnregisterParent( | 305 gfx::RenderingWindowManager::GetInstance()->UnregisterParent( |
293 compositor->widget()); | 306 compositor->widget()); |
294 #endif | 307 #endif |
295 | 308 |
296 const bool use_vulkan = static_cast<bool>(SharedVulkanContextProvider()); | 309 const bool use_vulkan = static_cast<bool>(SharedVulkanContextProvider()); |
297 | 310 const bool use_mus = IsUsingMus(); |
298 const bool create_gpu_output_surface = | 311 const bool create_gpu_output_surface = |
299 ShouldCreateGpuOutputSurface(compositor.get()); | 312 ShouldCreateGpuOutputSurface(compositor.get()); |
300 if (create_gpu_output_surface && !use_vulkan) { | 313 if (create_gpu_output_surface && !use_vulkan) { |
301 BrowserGpuChannelHostFactory::instance()->EstablishGpuChannel( | 314 base::Closure callback( |
302 CAUSE_FOR_GPU_LAUNCH_SHARED_WORKER_THREAD_CONTEXT, | |
303 base::Bind(&GpuProcessTransportFactory::EstablishedGpuChannel, | 315 base::Bind(&GpuProcessTransportFactory::EstablishedGpuChannel, |
304 callback_factory_.GetWeakPtr(), compositor, | 316 callback_factory_.GetWeakPtr(), compositor, |
305 create_gpu_output_surface, 0)); | 317 create_gpu_output_surface, 0)); |
| 318 if (!use_mus) { |
| 319 BrowserGpuChannelHostFactory::instance()->EstablishGpuChannel( |
| 320 CAUSE_FOR_GPU_LAUNCH_SHARED_WORKER_THREAD_CONTEXT, callback); |
| 321 } else { |
| 322 #if defined(MOJO_RUNNER_CLIENT) |
| 323 ui::GpuService::GetInstance()->EstablishGpuChannel(callback); |
| 324 #else |
| 325 NOTREACHED(); |
| 326 #endif |
| 327 } |
306 } else { | 328 } else { |
307 EstablishedGpuChannel(compositor, create_gpu_output_surface, 0); | 329 EstablishedGpuChannel(compositor, create_gpu_output_surface, 0); |
308 } | 330 } |
309 } | 331 } |
310 | 332 |
311 void GpuProcessTransportFactory::EstablishedGpuChannel( | 333 void GpuProcessTransportFactory::EstablishedGpuChannel( |
312 base::WeakPtr<ui::Compositor> compositor, | 334 base::WeakPtr<ui::Compositor> compositor, |
313 bool create_gpu_output_surface, | 335 bool create_gpu_output_surface, |
314 int num_attempts) { | 336 int num_attempts) { |
315 if (!compositor) | 337 if (!compositor) |
(...skipping 16 matching lines...) Expand all Loading... |
332 create_gpu_output_surface = false; | 354 create_gpu_output_surface = false; |
333 } | 355 } |
334 | 356 |
335 #if defined(OS_WIN) | 357 #if defined(OS_WIN) |
336 gfx::RenderingWindowManager::GetInstance()->RegisterParent( | 358 gfx::RenderingWindowManager::GetInstance()->RegisterParent( |
337 compositor->widget()); | 359 compositor->widget()); |
338 #endif | 360 #endif |
339 | 361 |
340 scoped_refptr<cc::VulkanInProcessContextProvider> vulkan_context_provider = | 362 scoped_refptr<cc::VulkanInProcessContextProvider> vulkan_context_provider = |
341 SharedVulkanContextProvider(); | 363 SharedVulkanContextProvider(); |
342 | 364 const bool use_mus = IsUsingMus(); |
343 scoped_refptr<ContextProviderCommandBuffer> context_provider; | 365 scoped_refptr<ContextProviderCommandBuffer> context_provider; |
344 if (create_gpu_output_surface && !vulkan_context_provider) { | 366 if (create_gpu_output_surface && !vulkan_context_provider) { |
345 // Try to reuse existing worker context provider. | 367 // Try to reuse existing worker context provider. |
346 if (shared_worker_context_provider_) { | 368 if (shared_worker_context_provider_) { |
347 bool lost; | 369 bool lost; |
348 { | 370 { |
349 // Note: If context is lost, we delete reference after releasing the | 371 // Note: If context is lost, we delete reference after releasing the |
350 // lock. | 372 // lock. |
351 base::AutoLock lock(*shared_worker_context_provider_->GetLock()); | 373 base::AutoLock lock(*shared_worker_context_provider_->GetLock()); |
352 lost = shared_worker_context_provider_->ContextGL() | 374 lost = shared_worker_context_provider_->ContextGL() |
353 ->GetGraphicsResetStatusKHR() != GL_NO_ERROR; | 375 ->GetGraphicsResetStatusKHR() != GL_NO_ERROR; |
354 } | 376 } |
355 if (lost) | 377 if (lost) |
356 shared_worker_context_provider_ = nullptr; | 378 shared_worker_context_provider_ = nullptr; |
357 } | 379 } |
358 | 380 |
359 scoped_refptr<gpu::GpuChannelHost> gpu_channel_host; | 381 scoped_refptr<gpu::GpuChannelHost> gpu_channel_host; |
360 if (GpuDataManagerImpl::GetInstance()->CanUseGpuBrowserCompositor()) { | 382 if (GpuDataManagerImpl::GetInstance()->CanUseGpuBrowserCompositor()) { |
361 // We attempted to do EstablishGpuChannel already, so we just use | 383 // We attempted to do EstablishGpuChannel already, so we just use |
362 // GetGpuChannel() instead of EstablishGpuChannelSync(). | 384 // GetGpuChannel() instead of EstablishGpuChannelSync(). |
363 gpu_channel_host = | 385 if (!use_mus) { |
364 BrowserGpuChannelHostFactory::instance()->GetGpuChannel(); | 386 gpu_channel_host = |
| 387 BrowserGpuChannelHostFactory::instance()->GetGpuChannel(); |
| 388 } else { |
| 389 #if defined(MOJO_RUNNER_CLIENT) |
| 390 gpu_channel_host = ui::GpuService::GetInstance()->GetGpuChannel(); |
| 391 #else |
| 392 NOTREACHED(); |
| 393 #endif |
| 394 } |
365 } | 395 } |
366 | 396 |
367 if (!gpu_channel_host) { | 397 if (!gpu_channel_host) { |
368 shared_worker_context_provider_ = nullptr; | 398 shared_worker_context_provider_ = nullptr; |
369 } else { | 399 } else { |
370 if (!shared_worker_context_provider_) { | 400 if (!shared_worker_context_provider_) { |
| 401 bool need_alpha_channel = false; |
371 const bool support_locking = true; | 402 const bool support_locking = true; |
372 shared_worker_context_provider_ = CreateContextCommon( | 403 shared_worker_context_provider_ = |
373 gpu_channel_host, gpu::kNullSurfaceHandle, support_locking, nullptr, | 404 CreateContextCommon(gpu_channel_host, gpu::kNullSurfaceHandle, |
374 command_buffer_metrics::BROWSER_WORKER_CONTEXT); | 405 need_alpha_channel, support_locking, nullptr, |
| 406 command_buffer_metrics::BROWSER_WORKER_CONTEXT); |
375 // TODO(vadimt): Remove ScopedTracker below once crbug.com/125248 is | 407 // TODO(vadimt): Remove ScopedTracker below once crbug.com/125248 is |
376 // fixed. Tracking time in BindToCurrentThread. | 408 // fixed. Tracking time in BindToCurrentThread. |
377 tracked_objects::ScopedTracker tracking_profile( | 409 tracked_objects::ScopedTracker tracking_profile( |
378 FROM_HERE_WITH_EXPLICIT_FUNCTION( | 410 FROM_HERE_WITH_EXPLICIT_FUNCTION( |
379 "125248" | 411 "125248" |
380 " GpuProcessTransportFactory::EstablishedGpuChannel" | 412 " GpuProcessTransportFactory::EstablishedGpuChannel" |
381 "::Worker")); | 413 "::Worker")); |
382 if (!shared_worker_context_provider_->BindToCurrentThread()) | 414 if (!shared_worker_context_provider_->BindToCurrentThread()) |
383 shared_worker_context_provider_ = nullptr; | 415 shared_worker_context_provider_ = nullptr; |
384 } | 416 } |
385 | 417 |
386 // The |context_provider| is used for both the browser compositor and the | 418 // The |context_provider| is used for both the browser compositor and the |
387 // display compositor. It shares resources with the worker context, so if | 419 // display compositor. It shares resources with the worker context, so if |
388 // we failed to make a worker context, just start over and try again. | 420 // we failed to make a worker context, just start over and try again. |
389 if (shared_worker_context_provider_) { | 421 if (shared_worker_context_provider_) { |
| 422 // For mus, we create an offscreen context for a mus window, and we will |
| 423 // use CommandBufferProxyImpl::TakeFrontBuffer() to take the context's |
| 424 // front buffer into a mailbox, insert a sync token, and send the |
| 425 // mailbox+sync to the ui service process. |
| 426 gpu::SurfaceHandle surface_handle = |
| 427 IsUsingMus() ? gpu::kNullSurfaceHandle : data->surface_handle; |
| 428 bool need_alpha_channel = IsUsingMus(); |
390 bool support_locking = false; | 429 bool support_locking = false; |
391 context_provider = CreateContextCommon( | 430 context_provider = CreateContextCommon( |
392 std::move(gpu_channel_host), data->surface_handle, support_locking, | 431 std::move(gpu_channel_host), surface_handle, need_alpha_channel, |
393 shared_worker_context_provider_.get(), | 432 support_locking, shared_worker_context_provider_.get(), |
394 command_buffer_metrics::DISPLAY_COMPOSITOR_ONSCREEN_CONTEXT); | 433 command_buffer_metrics::DISPLAY_COMPOSITOR_ONSCREEN_CONTEXT); |
395 // TODO(vadimt): Remove ScopedTracker below once crbug.com/125248 is | 434 // TODO(vadimt): Remove ScopedTracker below once crbug.com/125248 is |
396 // fixed. Tracking time in BindToCurrentThread. | 435 // fixed. Tracking time in BindToCurrentThread. |
397 tracked_objects::ScopedTracker tracking_profile( | 436 tracked_objects::ScopedTracker tracking_profile( |
398 FROM_HERE_WITH_EXPLICIT_FUNCTION( | 437 FROM_HERE_WITH_EXPLICIT_FUNCTION( |
399 "125248" | 438 "125248" |
400 " GpuProcessTransportFactory::EstablishedGpuChannel" | 439 " GpuProcessTransportFactory::EstablishedGpuChannel" |
401 "::Compositor")); | 440 "::Compositor")); |
402 #if defined(OS_MACOSX) | 441 #if defined(OS_MACOSX) |
403 // On Mac, GpuCommandBufferMsg_SwapBuffersCompleted must be handled in | 442 // On Mac, GpuCommandBufferMsg_SwapBuffersCompleted must be handled in |
404 // a nested message loop during resize. | 443 // a nested message loop during resize. |
405 context_provider->SetDefaultTaskRunner( | 444 context_provider->SetDefaultTaskRunner( |
406 ui::WindowResizeHelperMac::Get()->task_runner()); | 445 ui::WindowResizeHelperMac::Get()->task_runner()); |
407 #endif | 446 #endif |
408 if (!context_provider->BindToCurrentThread()) | 447 if (!context_provider->BindToCurrentThread()) |
409 context_provider = nullptr; | 448 context_provider = nullptr; |
410 } | 449 } |
411 } | 450 } |
412 | 451 |
413 bool created_gpu_browser_compositor = | 452 bool created_gpu_browser_compositor = |
414 !!context_provider && !!shared_worker_context_provider_; | 453 !!context_provider && !!shared_worker_context_provider_; |
415 | 454 |
416 UMA_HISTOGRAM_BOOLEAN("Aura.CreatedGpuBrowserCompositor", | 455 UMA_HISTOGRAM_BOOLEAN("Aura.CreatedGpuBrowserCompositor", |
417 created_gpu_browser_compositor); | 456 created_gpu_browser_compositor); |
418 | 457 |
419 if (!created_gpu_browser_compositor) { | 458 if (!created_gpu_browser_compositor) { |
420 // Try again. | 459 // Try again. |
421 BrowserGpuChannelHostFactory::instance()->EstablishGpuChannel( | 460 base::Closure callback( |
422 CAUSE_FOR_GPU_LAUNCH_SHARED_WORKER_THREAD_CONTEXT, | |
423 base::Bind(&GpuProcessTransportFactory::EstablishedGpuChannel, | 461 base::Bind(&GpuProcessTransportFactory::EstablishedGpuChannel, |
424 callback_factory_.GetWeakPtr(), compositor, | 462 callback_factory_.GetWeakPtr(), compositor, |
425 create_gpu_output_surface, num_attempts + 1)); | 463 create_gpu_output_surface, num_attempts + 1)); |
| 464 if (!use_mus) { |
| 465 BrowserGpuChannelHostFactory::instance()->EstablishGpuChannel( |
| 466 CAUSE_FOR_GPU_LAUNCH_SHARED_WORKER_THREAD_CONTEXT, callback); |
| 467 } else { |
| 468 #if defined(MOJO_RUNNER_CLIENT) |
| 469 ui::GpuService::GetInstance()->EstablishGpuChannel(callback); |
| 470 #else |
| 471 NOTREACHED(); |
| 472 #endif |
| 473 } |
426 return; | 474 return; |
427 } | 475 } |
428 } | 476 } |
429 | 477 |
430 std::unique_ptr<cc::SyntheticBeginFrameSource> begin_frame_source; | 478 std::unique_ptr<cc::SyntheticBeginFrameSource> begin_frame_source; |
431 if (!compositor->GetRendererSettings().disable_display_vsync) { | 479 if (!compositor->GetRendererSettings().disable_display_vsync) { |
432 begin_frame_source.reset(new cc::DelayBasedBeginFrameSource( | 480 begin_frame_source.reset(new cc::DelayBasedBeginFrameSource( |
433 base::MakeUnique<cc::DelayBasedTimeSource>( | 481 base::MakeUnique<cc::DelayBasedTimeSource>( |
434 compositor->task_runner().get()))); | 482 compositor->task_runner().get()))); |
435 } else { | 483 } else { |
(...skipping 48 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
484 compositor->vsync_manager(), begin_frame_source.get(), | 532 compositor->vsync_manager(), begin_frame_source.get(), |
485 CreateOverlayCandidateValidator(compositor->widget()), | 533 CreateOverlayCandidateValidator(compositor->widget()), |
486 GL_TEXTURE_2D, GL_RGB, | 534 GL_TEXTURE_2D, GL_RGB, |
487 BrowserGpuMemoryBufferManager::current())); | 535 BrowserGpuMemoryBufferManager::current())); |
488 #endif | 536 #endif |
489 } else { | 537 } else { |
490 std::unique_ptr<display_compositor::CompositorOverlayCandidateValidator> | 538 std::unique_ptr<display_compositor::CompositorOverlayCandidateValidator> |
491 validator; | 539 validator; |
492 #if !defined(OS_MACOSX) | 540 #if !defined(OS_MACOSX) |
493 // Overlays are only supported on surfaceless output surfaces on Mac. | 541 // Overlays are only supported on surfaceless output surfaces on Mac. |
494 validator = CreateOverlayCandidateValidator(compositor->widget()); | 542 if (!use_mus) |
| 543 validator = CreateOverlayCandidateValidator(compositor->widget()); |
495 #endif | 544 #endif |
496 display_output_surface = | 545 if (!use_mus) { |
497 base::WrapUnique(new GpuBrowserCompositorOutputSurface( | 546 display_output_surface = |
498 context_provider, compositor->vsync_manager(), | 547 base::WrapUnique(new GpuBrowserCompositorOutputSurface( |
499 begin_frame_source.get(), std::move(validator))); | 548 context_provider, compositor->vsync_manager(), |
| 549 begin_frame_source.get(), std::move(validator))); |
| 550 } else { |
| 551 #if defined(MOJO_RUNNER_CLIENT) |
| 552 display_output_surface = |
| 553 base::WrapUnique(new MusBrowserCompositorOutputSurface( |
| 554 data->surface_handle, context_provider, |
| 555 compositor->vsync_manager(), begin_frame_source.get(), |
| 556 std::move(validator))); |
| 557 #else |
| 558 NOTREACHED(); |
| 559 #endif |
| 560 } |
500 } | 561 } |
501 } | 562 } |
502 } | 563 } |
503 | 564 |
504 data->display_output_surface = display_output_surface.get(); | 565 data->display_output_surface = display_output_surface.get(); |
505 data->begin_frame_source = begin_frame_source.get(); | 566 data->begin_frame_source = begin_frame_source.get(); |
506 if (data->reflector) | 567 if (data->reflector) |
507 data->reflector->OnSourceSurfaceReady(data->display_output_surface); | 568 data->reflector->OnSourceSurfaceReady(data->display_output_surface); |
508 | 569 |
509 #if defined(OS_WIN) | 570 #if defined(OS_WIN) |
(...skipping 215 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
725 } | 786 } |
726 #endif | 787 #endif |
727 | 788 |
728 scoped_refptr<cc::ContextProvider> | 789 scoped_refptr<cc::ContextProvider> |
729 GpuProcessTransportFactory::SharedMainThreadContextProvider() { | 790 GpuProcessTransportFactory::SharedMainThreadContextProvider() { |
730 if (shared_main_thread_contexts_) | 791 if (shared_main_thread_contexts_) |
731 return shared_main_thread_contexts_; | 792 return shared_main_thread_contexts_; |
732 | 793 |
733 if (!GpuDataManagerImpl::GetInstance()->CanUseGpuBrowserCompositor()) | 794 if (!GpuDataManagerImpl::GetInstance()->CanUseGpuBrowserCompositor()) |
734 return nullptr; | 795 return nullptr; |
735 scoped_refptr<gpu::GpuChannelHost> gpu_channel_host( | 796 |
736 BrowserGpuChannelHostFactory::instance()->EstablishGpuChannelSync( | 797 const bool use_mus = IsUsingMus(); |
737 CAUSE_FOR_GPU_LAUNCH_BROWSER_SHARED_MAIN_THREAD_CONTEXT)); | 798 scoped_refptr<gpu::GpuChannelHost> gpu_channel_host; |
| 799 if (!use_mus) { |
| 800 gpu_channel_host = |
| 801 BrowserGpuChannelHostFactory::instance()->EstablishGpuChannelSync( |
| 802 CAUSE_FOR_GPU_LAUNCH_BROWSER_SHARED_MAIN_THREAD_CONTEXT); |
| 803 } else { |
| 804 #if defined(MOJO_RUNNER_CLIENT) |
| 805 gpu_channel_host = ui::GpuService::GetInstance()->EstablishGpuChannelSync(); |
| 806 #else |
| 807 NOTREACHED(); |
| 808 #endif |
| 809 } |
| 810 |
738 if (!gpu_channel_host) | 811 if (!gpu_channel_host) |
739 return nullptr; | 812 return nullptr; |
740 | 813 |
741 // We need a separate context from the compositor's so that skia and gl_helper | 814 // We need a separate context from the compositor's so that skia and gl_helper |
742 // don't step on each other. | 815 // don't step on each other. |
| 816 bool need_alpha_channel = false; |
743 bool support_locking = false; | 817 bool support_locking = false; |
744 shared_main_thread_contexts_ = CreateContextCommon( | 818 shared_main_thread_contexts_ = CreateContextCommon( |
745 std::move(gpu_channel_host), gpu::kNullSurfaceHandle, support_locking, | 819 std::move(gpu_channel_host), gpu::kNullSurfaceHandle, need_alpha_channel, |
746 nullptr, command_buffer_metrics::BROWSER_OFFSCREEN_MAINTHREAD_CONTEXT); | 820 support_locking, nullptr, |
| 821 command_buffer_metrics::BROWSER_OFFSCREEN_MAINTHREAD_CONTEXT); |
747 shared_main_thread_contexts_->SetLostContextCallback(base::Bind( | 822 shared_main_thread_contexts_->SetLostContextCallback(base::Bind( |
748 &GpuProcessTransportFactory::OnLostMainThreadSharedContextInsideCallback, | 823 &GpuProcessTransportFactory::OnLostMainThreadSharedContextInsideCallback, |
749 callback_factory_.GetWeakPtr())); | 824 callback_factory_.GetWeakPtr())); |
750 // TODO(vadimt): Remove ScopedTracker below once crbug.com/125248 is | 825 // TODO(vadimt): Remove ScopedTracker below once crbug.com/125248 is |
751 // fixed. Tracking time in BindToCurrentThread. | 826 // fixed. Tracking time in BindToCurrentThread. |
752 tracked_objects::ScopedTracker tracking_profile( | 827 tracked_objects::ScopedTracker tracking_profile( |
753 FROM_HERE_WITH_EXPLICIT_FUNCTION( | 828 FROM_HERE_WITH_EXPLICIT_FUNCTION( |
754 "125248" | 829 "125248" |
755 " GpuProcessTransportFactory::SharedMainThreadContextProvider")); | 830 " GpuProcessTransportFactory::SharedMainThreadContextProvider")); |
756 if (!shared_main_thread_contexts_->BindToCurrentThread()) | 831 if (!shared_main_thread_contexts_->BindToCurrentThread()) |
(...skipping 62 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
819 shared_vulkan_context_provider_ = | 894 shared_vulkan_context_provider_ = |
820 cc::VulkanInProcessContextProvider::Create(); | 895 cc::VulkanInProcessContextProvider::Create(); |
821 } | 896 } |
822 | 897 |
823 shared_vulkan_context_provider_initialized_ = true; | 898 shared_vulkan_context_provider_initialized_ = true; |
824 } | 899 } |
825 return shared_vulkan_context_provider_; | 900 return shared_vulkan_context_provider_; |
826 } | 901 } |
827 | 902 |
828 } // namespace content | 903 } // namespace content |
OLD | NEW |