Chromium Code Reviews| 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/memory/ptr_util.h" | 13 #include "base/memory/ptr_util.h" |
| 14 #include "base/metrics/histogram_macros.h" | 14 #include "base/metrics/histogram_macros.h" |
| 15 #include "base/profiler/scoped_tracker.h" | 15 #include "base/profiler/scoped_tracker.h" |
| 16 #include "base/single_thread_task_runner.h" | 16 #include "base/single_thread_task_runner.h" |
| 17 #include "base/threading/simple_thread.h" | 17 #include "base/threading/simple_thread.h" |
| 18 #include "base/threading/thread.h" | 18 #include "base/threading/thread.h" |
| 19 #include "base/threading/thread_task_runner_handle.h" | 19 #include "base/threading/thread_task_runner_handle.h" |
| 20 #include "build/build_config.h" | 20 #include "build/build_config.h" |
| 21 #include "cc/base/histograms.h" | 21 #include "cc/base/histograms.h" |
| 22 #include "cc/base/switches.h" | |
| 22 #include "cc/output/texture_mailbox_deleter.h" | 23 #include "cc/output/texture_mailbox_deleter.h" |
| 23 #include "cc/output/vulkan_in_process_context_provider.h" | 24 #include "cc/output/vulkan_in_process_context_provider.h" |
| 24 #include "cc/raster/single_thread_task_graph_runner.h" | 25 #include "cc/raster/single_thread_task_graph_runner.h" |
| 25 #include "cc/raster/task_graph_runner.h" | 26 #include "cc/raster/task_graph_runner.h" |
| 26 #include "cc/scheduler/begin_frame_source.h" | 27 #include "cc/scheduler/begin_frame_source.h" |
| 27 #include "cc/scheduler/delay_based_time_source.h" | 28 #include "cc/scheduler/delay_based_time_source.h" |
| 28 #include "cc/surfaces/direct_compositor_frame_sink.h" | 29 #include "cc/surfaces/direct_compositor_frame_sink.h" |
| 29 #include "cc/surfaces/display.h" | 30 #include "cc/surfaces/display.h" |
| 30 #include "cc/surfaces/display_scheduler.h" | 31 #include "cc/surfaces/display_scheduler.h" |
| 31 #include "cc/surfaces/surface_manager.h" | 32 #include "cc/surfaces/surface_manager.h" |
| (...skipping 18 matching lines...) Expand all Loading... | |
| 50 #include "gpu/command_buffer/common/mailbox.h" | 51 #include "gpu/command_buffer/common/mailbox.h" |
| 51 #include "gpu/ipc/client/gpu_channel_host.h" | 52 #include "gpu/ipc/client/gpu_channel_host.h" |
| 52 #include "gpu/ipc/host/gpu_memory_buffer_support.h" | 53 #include "gpu/ipc/host/gpu_memory_buffer_support.h" |
| 53 #include "gpu/vulkan/features.h" | 54 #include "gpu/vulkan/features.h" |
| 54 #include "services/service_manager/runner/common/client_util.h" | 55 #include "services/service_manager/runner/common/client_util.h" |
| 55 #include "services/ui/public/cpp/gpu/context_provider_command_buffer.h" | 56 #include "services/ui/public/cpp/gpu/context_provider_command_buffer.h" |
| 56 #include "third_party/khronos/GLES2/gl2.h" | 57 #include "third_party/khronos/GLES2/gl2.h" |
| 57 #include "ui/compositor/compositor.h" | 58 #include "ui/compositor/compositor.h" |
| 58 #include "ui/compositor/compositor_constants.h" | 59 #include "ui/compositor/compositor_constants.h" |
| 59 #include "ui/compositor/compositor_switches.h" | 60 #include "ui/compositor/compositor_switches.h" |
| 61 #include "ui/compositor/compositor_util.h" | |
| 60 #include "ui/compositor/layer.h" | 62 #include "ui/compositor/layer.h" |
| 63 #include "ui/display/display_switches.h" | |
| 61 #include "ui/display/types/display_snapshot.h" | 64 #include "ui/display/types/display_snapshot.h" |
| 62 #include "ui/gfx/geometry/size.h" | 65 #include "ui/gfx/geometry/size.h" |
| 63 #include "ui/gfx/switches.h" | 66 #include "ui/gfx/switches.h" |
| 64 #include "ui/gl/gl_switches.h" | 67 #include "ui/gl/gl_switches.h" |
| 65 | 68 |
| 66 #if defined(USE_AURA) | 69 #if defined(USE_AURA) |
| 67 #include "content/public/common/service_manager_connection.h" | 70 #include "content/public/common/service_manager_connection.h" |
| 68 #include "ui/aura/window_tree_host.h" | 71 #include "ui/aura/window_tree_host.h" |
| 69 #endif | 72 #endif |
| 70 | 73 |
| (...skipping 137 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 208 if (command_line->HasSwitch(switches::kDisableGpuVsync)) { | 211 if (command_line->HasSwitch(switches::kDisableGpuVsync)) { |
| 209 std::string display_vsync_string = | 212 std::string display_vsync_string = |
| 210 command_line->GetSwitchValueASCII(switches::kDisableGpuVsync); | 213 command_line->GetSwitchValueASCII(switches::kDisableGpuVsync); |
| 211 // See comments in gl_switches about this flag. The browser compositor | 214 // See comments in gl_switches about this flag. The browser compositor |
| 212 // is only unthrottled when "gpu" or no switch value is passed, as it | 215 // is only unthrottled when "gpu" or no switch value is passed, as it |
| 213 // is driven directly by the display compositor. | 216 // is driven directly by the display compositor. |
| 214 if (display_vsync_string != "beginframe") { | 217 if (display_vsync_string != "beginframe") { |
| 215 disable_display_vsync_ = true; | 218 disable_display_vsync_ = true; |
| 216 } | 219 } |
| 217 } | 220 } |
| 221 renderer_settings_ = ui::CreateRendererSettings(&gpu::GetImageTextureTarget); | |
|
danakj
2017/05/12 14:21:37
you could do this as a constructor initialization
Alex Z.
2017/05/12 14:37:49
Done.
| |
| 218 | 222 |
| 219 task_graph_runner_->Start("CompositorTileWorker1", | 223 task_graph_runner_->Start("CompositorTileWorker1", |
| 220 base::SimpleThread::Options()); | 224 base::SimpleThread::Options()); |
| 221 #if defined(OS_WIN) | 225 #if defined(OS_WIN) |
| 222 software_backing_.reset(new OutputDeviceBacking); | 226 software_backing_.reset(new OutputDeviceBacking); |
| 223 #endif | 227 #endif |
| 224 } | 228 } |
| 225 | 229 |
| 226 GpuProcessTransportFactory::~GpuProcessTransportFactory() { | 230 GpuProcessTransportFactory::~GpuProcessTransportFactory() { |
| 227 DCHECK(per_compositor_data_.empty()); | 231 DCHECK(per_compositor_data_.empty()); |
| (...skipping 366 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 594 compositor->widget()); | 598 compositor->widget()); |
| 595 #endif | 599 #endif |
| 596 | 600 |
| 597 std::unique_ptr<cc::DisplayScheduler> scheduler(new cc::DisplayScheduler( | 601 std::unique_ptr<cc::DisplayScheduler> scheduler(new cc::DisplayScheduler( |
| 598 compositor->task_runner().get(), | 602 compositor->task_runner().get(), |
| 599 display_output_surface->capabilities().max_frames_pending)); | 603 display_output_surface->capabilities().max_frames_pending)); |
| 600 | 604 |
| 601 // The Display owns and uses the |display_output_surface| created above. | 605 // The Display owns and uses the |display_output_surface| created above. |
| 602 data->display = base::MakeUnique<cc::Display>( | 606 data->display = base::MakeUnique<cc::Display>( |
| 603 display_compositor::HostSharedBitmapManager::current(), | 607 display_compositor::HostSharedBitmapManager::current(), |
| 604 GetGpuMemoryBufferManager(), compositor->GetRendererSettings(), | 608 GetGpuMemoryBufferManager(), renderer_settings_, |
| 605 compositor->frame_sink_id(), begin_frame_source, | 609 compositor->frame_sink_id(), begin_frame_source, |
| 606 std::move(display_output_surface), std::move(scheduler), | 610 std::move(display_output_surface), std::move(scheduler), |
| 607 base::MakeUnique<cc::TextureMailboxDeleter>( | 611 base::MakeUnique<cc::TextureMailboxDeleter>( |
| 608 compositor->task_runner().get())); | 612 compositor->task_runner().get())); |
| 609 // Note that we are careful not to destroy prior BeginFrameSource objects | 613 // Note that we are careful not to destroy prior BeginFrameSource objects |
| 610 // until we have reset |data->display|. | 614 // until we have reset |data->display|. |
| 611 data->synthetic_begin_frame_source = std::move(synthetic_begin_frame_source); | 615 data->synthetic_begin_frame_source = std::move(synthetic_begin_frame_source); |
| 612 data->gpu_vsync_begin_frame_source = std::move(gpu_vsync_begin_frame_source); | 616 data->gpu_vsync_begin_frame_source = std::move(gpu_vsync_begin_frame_source); |
| 613 | 617 |
| 614 // The |delegated_output_surface| is given back to the compositor, it | 618 // The |delegated_output_surface| is given back to the compositor, it |
| (...skipping 73 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 688 #if defined(OS_WIN) | 692 #if defined(OS_WIN) |
| 689 gfx::RenderingWindowManager::GetInstance()->UnregisterParent( | 693 gfx::RenderingWindowManager::GetInstance()->UnregisterParent( |
| 690 compositor->widget()); | 694 compositor->widget()); |
| 691 #endif | 695 #endif |
| 692 } | 696 } |
| 693 | 697 |
| 694 double GpuProcessTransportFactory::GetRefreshRate() const { | 698 double GpuProcessTransportFactory::GetRefreshRate() const { |
| 695 return 60.0; | 699 return 60.0; |
| 696 } | 700 } |
| 697 | 701 |
| 698 uint32_t GpuProcessTransportFactory::GetImageTextureTarget( | |
| 699 gfx::BufferFormat format, | |
| 700 gfx::BufferUsage usage) { | |
| 701 return gpu::GetImageTextureTarget(format, usage); | |
| 702 } | |
| 703 | |
| 704 gpu::GpuMemoryBufferManager* | 702 gpu::GpuMemoryBufferManager* |
| 705 GpuProcessTransportFactory::GetGpuMemoryBufferManager() { | 703 GpuProcessTransportFactory::GetGpuMemoryBufferManager() { |
| 706 return gpu_channel_factory_->GetGpuMemoryBufferManager(); | 704 return gpu_channel_factory_->GetGpuMemoryBufferManager(); |
| 707 } | 705 } |
| 708 | 706 |
| 709 cc::TaskGraphRunner* GpuProcessTransportFactory::GetTaskGraphRunner() { | 707 cc::TaskGraphRunner* GpuProcessTransportFactory::GetTaskGraphRunner() { |
| 710 return task_graph_runner_.get(); | 708 return task_graph_runner_.get(); |
| 711 } | 709 } |
| 712 | 710 |
| 713 ui::ContextFactory* GpuProcessTransportFactory::GetContextFactory() { | 711 ui::ContextFactory* GpuProcessTransportFactory::GetContextFactory() { |
| (...skipping 82 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 796 PerCompositorDataMap::iterator it = per_compositor_data_.find(compositor); | 794 PerCompositorDataMap::iterator it = per_compositor_data_.find(compositor); |
| 797 if (it == per_compositor_data_.end()) | 795 if (it == per_compositor_data_.end()) |
| 798 return; | 796 return; |
| 799 PerCompositorData* data = it->second.get(); | 797 PerCompositorData* data = it->second.get(); |
| 800 DCHECK(data); | 798 DCHECK(data); |
| 801 data->output_is_secure = secure; | 799 data->output_is_secure = secure; |
| 802 if (data->display) | 800 if (data->display) |
| 803 data->display->SetOutputIsSecure(secure); | 801 data->display->SetOutputIsSecure(secure); |
| 804 } | 802 } |
| 805 | 803 |
| 804 const cc::RendererSettings& GpuProcessTransportFactory::GetRendererSettings() | |
| 805 const { | |
| 806 return renderer_settings_; | |
| 807 } | |
| 808 | |
| 806 void GpuProcessTransportFactory::AddObserver( | 809 void GpuProcessTransportFactory::AddObserver( |
| 807 ui::ContextFactoryObserver* observer) { | 810 ui::ContextFactoryObserver* observer) { |
| 808 observer_list_.AddObserver(observer); | 811 observer_list_.AddObserver(observer); |
| 809 } | 812 } |
| 810 | 813 |
| 811 void GpuProcessTransportFactory::RemoveObserver( | 814 void GpuProcessTransportFactory::RemoveObserver( |
| 812 ui::ContextFactoryObserver* observer) { | 815 ui::ContextFactoryObserver* observer) { |
| 813 observer_list_.RemoveObserver(observer); | 816 observer_list_.RemoveObserver(observer); |
| 814 } | 817 } |
| 815 | 818 |
| (...skipping 134 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 950 shared_vulkan_context_provider_ = | 953 shared_vulkan_context_provider_ = |
| 951 cc::VulkanInProcessContextProvider::Create(); | 954 cc::VulkanInProcessContextProvider::Create(); |
| 952 } | 955 } |
| 953 | 956 |
| 954 shared_vulkan_context_provider_initialized_ = true; | 957 shared_vulkan_context_provider_initialized_ = true; |
| 955 } | 958 } |
| 956 return shared_vulkan_context_provider_; | 959 return shared_vulkan_context_provider_; |
| 957 } | 960 } |
| 958 | 961 |
| 959 } // namespace content | 962 } // namespace content |
| OLD | NEW |