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" |
11 #include "base/command_line.h" | 11 #include "base/command_line.h" |
12 #include "base/location.h" | 12 #include "base/location.h" |
13 #include "base/metrics/histogram_macros.h" | 13 #include "base/metrics/histogram_macros.h" |
14 #include "base/profiler/scoped_tracker.h" | 14 #include "base/profiler/scoped_tracker.h" |
15 #include "base/single_thread_task_runner.h" | 15 #include "base/single_thread_task_runner.h" |
16 #include "base/threading/simple_thread.h" | 16 #include "base/threading/simple_thread.h" |
17 #include "base/threading/thread.h" | 17 #include "base/threading/thread.h" |
18 #include "base/threading/thread_task_runner_handle.h" | 18 #include "base/threading/thread_task_runner_handle.h" |
19 #include "build/build_config.h" | 19 #include "build/build_config.h" |
20 #include "cc/base/histograms.h" | 20 #include "cc/base/histograms.h" |
21 #include "cc/output/compositor_frame.h" | |
22 #include "cc/output/output_surface.h" | |
23 #include "cc/output/texture_mailbox_deleter.h" | 21 #include "cc/output/texture_mailbox_deleter.h" |
24 #include "cc/output/vulkan_in_process_context_provider.h" | 22 #include "cc/output/vulkan_in_process_context_provider.h" |
25 #include "cc/raster/single_thread_task_graph_runner.h" | 23 #include "cc/raster/single_thread_task_graph_runner.h" |
26 #include "cc/raster/task_graph_runner.h" | 24 #include "cc/raster/task_graph_runner.h" |
27 #include "cc/scheduler/begin_frame_source.h" | 25 #include "cc/scheduler/begin_frame_source.h" |
28 #include "cc/scheduler/delay_based_time_source.h" | 26 #include "cc/scheduler/delay_based_time_source.h" |
| 27 #include "cc/surfaces/direct_compositor_frame_sink.h" |
29 #include "cc/surfaces/display.h" | 28 #include "cc/surfaces/display.h" |
30 #include "cc/surfaces/display_scheduler.h" | 29 #include "cc/surfaces/display_scheduler.h" |
31 #include "cc/surfaces/surface_display_output_surface.h" | |
32 #include "cc/surfaces/surface_manager.h" | 30 #include "cc/surfaces/surface_manager.h" |
33 #include "components/display_compositor/compositor_overlay_candidate_validator.h
" | 31 #include "components/display_compositor/compositor_overlay_candidate_validator.h
" |
34 #include "components/display_compositor/gl_helper.h" | 32 #include "components/display_compositor/gl_helper.h" |
35 #include "content/browser/compositor/browser_compositor_output_surface.h" | 33 #include "content/browser/compositor/browser_compositor_output_surface.h" |
36 #include "content/browser/compositor/gpu_browser_compositor_output_surface.h" | 34 #include "content/browser/compositor/gpu_browser_compositor_output_surface.h" |
37 #include "content/browser/compositor/gpu_surfaceless_browser_compositor_output_s
urface.h" | 35 #include "content/browser/compositor/gpu_surfaceless_browser_compositor_output_s
urface.h" |
38 #include "content/browser/compositor/offscreen_browser_compositor_output_surface
.h" | 36 #include "content/browser/compositor/offscreen_browser_compositor_output_surface
.h" |
39 #include "content/browser/compositor/reflector_impl.h" | 37 #include "content/browser/compositor/reflector_impl.h" |
40 #include "content/browser/compositor/software_browser_compositor_output_surface.
h" | 38 #include "content/browser/compositor/software_browser_compositor_output_surface.
h" |
41 #include "content/browser/gpu/browser_gpu_memory_buffer_manager.h" | 39 #include "content/browser/gpu/browser_gpu_memory_buffer_manager.h" |
(...skipping 212 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
254 ca_layers_disabled)); | 252 ca_layers_disabled)); |
255 } | 253 } |
256 #elif defined(OS_ANDROID) | 254 #elif defined(OS_ANDROID) |
257 validator.reset( | 255 validator.reset( |
258 new display_compositor::CompositorOverlayCandidateValidatorAndroid()); | 256 new display_compositor::CompositorOverlayCandidateValidatorAndroid()); |
259 #endif | 257 #endif |
260 | 258 |
261 return validator; | 259 return validator; |
262 } | 260 } |
263 | 261 |
264 static bool ShouldCreateGpuOutputSurface(ui::Compositor* compositor) { | 262 static bool ShouldCreateGpuCompositorFrameSink(ui::Compositor* compositor) { |
265 #if defined(OS_CHROMEOS) | 263 #if defined(OS_CHROMEOS) |
266 // Software fallback does not happen on Chrome OS. | 264 // Software fallback does not happen on Chrome OS. |
267 return true; | 265 return true; |
268 #endif | 266 #endif |
269 if (IsUsingMus()) | 267 if (IsUsingMus()) |
270 return true; | 268 return true; |
271 | 269 |
272 #if defined(OS_WIN) | 270 #if defined(OS_WIN) |
273 if (::GetProp(compositor->widget(), kForceSoftwareCompositor) && | 271 if (::GetProp(compositor->widget(), kForceSoftwareCompositor) && |
274 ::RemoveProp(compositor->widget(), kForceSoftwareCompositor)) | 272 ::RemoveProp(compositor->widget(), kForceSoftwareCompositor)) |
275 return false; | 273 return false; |
276 #endif | 274 #endif |
277 | 275 |
278 return GpuDataManagerImpl::GetInstance()->CanUseGpuBrowserCompositor(); | 276 return GpuDataManagerImpl::GetInstance()->CanUseGpuBrowserCompositor(); |
279 } | 277 } |
280 | 278 |
281 void GpuProcessTransportFactory::CreateOutputSurface( | 279 void GpuProcessTransportFactory::CreateCompositorFrameSink( |
282 base::WeakPtr<ui::Compositor> compositor) { | 280 base::WeakPtr<ui::Compositor> compositor) { |
283 DCHECK(!!compositor); | 281 DCHECK(!!compositor); |
284 PerCompositorData* data = per_compositor_data_[compositor.get()].get(); | 282 PerCompositorData* data = per_compositor_data_[compositor.get()].get(); |
285 if (!data) { | 283 if (!data) { |
286 data = CreatePerCompositorData(compositor.get()); | 284 data = CreatePerCompositorData(compositor.get()); |
287 } else { | 285 } else { |
288 // TODO(danakj): We can destroy the |data->display| here when the compositor | 286 // TODO(danakj): We can destroy the |data->display| here when the compositor |
289 // destroys its OutputSurface before calling back here. | 287 // destroys its CompositorFrameSink before calling back here. |
290 data->display_output_surface = nullptr; | 288 data->display_output_surface = nullptr; |
291 data->begin_frame_source = nullptr; | 289 data->begin_frame_source = nullptr; |
292 } | 290 } |
293 | 291 |
294 #if defined(OS_WIN) | 292 #if defined(OS_WIN) |
295 gfx::RenderingWindowManager::GetInstance()->UnregisterParent( | 293 gfx::RenderingWindowManager::GetInstance()->UnregisterParent( |
296 compositor->widget()); | 294 compositor->widget()); |
297 #endif | 295 #endif |
298 | 296 |
299 const bool use_vulkan = static_cast<bool>(SharedVulkanContextProvider()); | 297 const bool use_vulkan = static_cast<bool>(SharedVulkanContextProvider()); |
300 const bool create_gpu_output_surface = | 298 const bool create_gpu_output_surface = |
301 ShouldCreateGpuOutputSurface(compositor.get()); | 299 ShouldCreateGpuCompositorFrameSink(compositor.get()); |
302 if (create_gpu_output_surface && !use_vulkan) { | 300 if (create_gpu_output_surface && !use_vulkan) { |
303 gpu::GpuChannelEstablishedCallback callback( | 301 gpu::GpuChannelEstablishedCallback callback( |
304 base::Bind(&GpuProcessTransportFactory::EstablishedGpuChannel, | 302 base::Bind(&GpuProcessTransportFactory::EstablishedGpuChannel, |
305 callback_factory_.GetWeakPtr(), compositor, | 303 callback_factory_.GetWeakPtr(), compositor, |
306 create_gpu_output_surface, 0)); | 304 create_gpu_output_surface, 0)); |
307 DCHECK(gpu_channel_factory_); | 305 DCHECK(gpu_channel_factory_); |
308 gpu_channel_factory_->EstablishGpuChannel(callback); | 306 gpu_channel_factory_->EstablishGpuChannel(callback); |
309 } else { | 307 } else { |
310 EstablishedGpuChannel(compositor, create_gpu_output_surface, 0, nullptr); | 308 EstablishedGpuChannel(compositor, create_gpu_output_surface, 0, nullptr); |
311 } | 309 } |
(...skipping 233 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
545 HostSharedBitmapManager::current(), | 543 HostSharedBitmapManager::current(), |
546 GetGpuMemoryBufferManager(), | 544 GetGpuMemoryBufferManager(), |
547 compositor->GetRendererSettings(), std::move(begin_frame_source), | 545 compositor->GetRendererSettings(), std::move(begin_frame_source), |
548 std::move(display_output_surface), std::move(scheduler), | 546 std::move(display_output_surface), std::move(scheduler), |
549 base::MakeUnique<cc::TextureMailboxDeleter>( | 547 base::MakeUnique<cc::TextureMailboxDeleter>( |
550 compositor->task_runner().get())); | 548 compositor->task_runner().get())); |
551 | 549 |
552 // The |delegated_output_surface| is given back to the compositor, it | 550 // The |delegated_output_surface| is given back to the compositor, it |
553 // delegates to the Display as its root surface. Importantly, it shares the | 551 // delegates to the Display as its root surface. Importantly, it shares the |
554 // same ContextProvider as the Display's output surface. | 552 // same ContextProvider as the Display's output surface. |
555 std::unique_ptr<cc::SurfaceDisplayOutputSurface> delegated_output_surface( | 553 auto compositor_frame_sink = |
556 vulkan_context_provider | 554 vulkan_context_provider |
557 ? new cc::SurfaceDisplayOutputSurface( | 555 ? base::MakeUnique<cc::DirectCompositorFrameSink>( |
558 surface_manager_.get(), compositor->surface_id_allocator(), | 556 surface_manager_.get(), compositor->surface_id_allocator(), |
559 data->display.get(), | 557 data->display.get(), |
560 static_cast<scoped_refptr<cc::VulkanContextProvider>>( | 558 static_cast<scoped_refptr<cc::VulkanContextProvider>>( |
561 vulkan_context_provider)) | 559 vulkan_context_provider)) |
562 : new cc::SurfaceDisplayOutputSurface( | 560 : base::MakeUnique<cc::DirectCompositorFrameSink>( |
563 surface_manager_.get(), compositor->surface_id_allocator(), | 561 surface_manager_.get(), compositor->surface_id_allocator(), |
564 data->display.get(), context_provider, | 562 data->display.get(), context_provider, |
565 shared_worker_context_provider_)); | 563 shared_worker_context_provider_); |
566 data->display->Resize(compositor->size()); | 564 data->display->Resize(compositor->size()); |
567 data->display->SetOutputIsSecure(data->output_is_secure); | 565 data->display->SetOutputIsSecure(data->output_is_secure); |
568 compositor->SetOutputSurface(std::move(delegated_output_surface)); | 566 compositor->SetCompositorFrameSink(std::move(compositor_frame_sink)); |
569 } | 567 } |
570 | 568 |
571 std::unique_ptr<ui::Reflector> GpuProcessTransportFactory::CreateReflector( | 569 std::unique_ptr<ui::Reflector> GpuProcessTransportFactory::CreateReflector( |
572 ui::Compositor* source_compositor, | 570 ui::Compositor* source_compositor, |
573 ui::Layer* target_layer) { | 571 ui::Layer* target_layer) { |
574 PerCompositorData* source_data = | 572 PerCompositorData* source_data = |
575 per_compositor_data_[source_compositor].get(); | 573 per_compositor_data_[source_compositor].get(); |
576 DCHECK(source_data); | 574 DCHECK(source_data); |
577 | 575 |
578 std::unique_ptr<ReflectorImpl> reflector( | 576 std::unique_ptr<ReflectorImpl> reflector( |
(...skipping 294 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
873 shared_vulkan_context_provider_ = | 871 shared_vulkan_context_provider_ = |
874 cc::VulkanInProcessContextProvider::Create(); | 872 cc::VulkanInProcessContextProvider::Create(); |
875 } | 873 } |
876 | 874 |
877 shared_vulkan_context_provider_initialized_ = true; | 875 shared_vulkan_context_provider_initialized_ = true; |
878 } | 876 } |
879 return shared_vulkan_context_provider_; | 877 return shared_vulkan_context_provider_; |
880 } | 878 } |
881 | 879 |
882 } // namespace content | 880 } // namespace content |
OLD | NEW |