OLD | NEW |
---|---|
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 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/renderer/render_thread_impl.h" | 5 #include "content/renderer/render_thread_impl.h" |
6 | 6 |
7 #include <algorithm> | 7 #include <algorithm> |
8 #include <limits> | 8 #include <limits> |
9 #include <map> | 9 #include <map> |
10 #include <utility> | 10 #include <utility> |
(...skipping 28 matching lines...) Expand all Loading... | |
39 #include "build/build_config.h" | 39 #include "build/build_config.h" |
40 #include "cc/base/histograms.h" | 40 #include "cc/base/histograms.h" |
41 #include "cc/base/switches.h" | 41 #include "cc/base/switches.h" |
42 #include "cc/blink/web_external_bitmap_impl.h" | 42 #include "cc/blink/web_external_bitmap_impl.h" |
43 #include "cc/blink/web_layer_impl.h" | 43 #include "cc/blink/web_layer_impl.h" |
44 #include "cc/output/output_surface.h" | 44 #include "cc/output/output_surface.h" |
45 #include "cc/output/vulkan_in_process_context_provider.h" | 45 #include "cc/output/vulkan_in_process_context_provider.h" |
46 #include "cc/raster/task_graph_runner.h" | 46 #include "cc/raster/task_graph_runner.h" |
47 #include "cc/trees/layer_tree_host_common.h" | 47 #include "cc/trees/layer_tree_host_common.h" |
48 #include "cc/trees/layer_tree_settings.h" | 48 #include "cc/trees/layer_tree_settings.h" |
49 #include "components/mus/common/gpu_service.h" | |
49 #include "components/scheduler/child/compositor_worker_scheduler.h" | 50 #include "components/scheduler/child/compositor_worker_scheduler.h" |
50 #include "components/scheduler/child/webthread_base.h" | 51 #include "components/scheduler/child/webthread_base.h" |
51 #include "components/scheduler/child/webthread_impl_for_worker_scheduler.h" | 52 #include "components/scheduler/child/webthread_impl_for_worker_scheduler.h" |
52 #include "components/scheduler/renderer/renderer_scheduler.h" | 53 #include "components/scheduler/renderer/renderer_scheduler.h" |
53 #include "content/child/appcache/appcache_dispatcher.h" | 54 #include "content/child/appcache/appcache_dispatcher.h" |
54 #include "content/child/appcache/appcache_frontend_impl.h" | 55 #include "content/child/appcache/appcache_frontend_impl.h" |
55 #include "content/child/blob_storage/blob_message_filter.h" | 56 #include "content/child/blob_storage/blob_message_filter.h" |
56 #include "content/child/child_discardable_shared_memory_manager.h" | 57 #include "content/child/child_discardable_shared_memory_manager.h" |
57 #include "content/child/child_gpu_memory_buffer_manager.h" | 58 #include "content/child/child_gpu_memory_buffer_manager.h" |
58 #include "content/child/child_histogram_message_filter.h" | 59 #include "content/child/child_histogram_message_filter.h" |
(...skipping 376 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
435 attributes.lose_context_when_out_of_memory = true; | 436 attributes.lose_context_when_out_of_memory = true; |
436 const bool automatic_flushes = false; | 437 const bool automatic_flushes = false; |
437 return make_scoped_refptr(new ContextProviderCommandBuffer( | 438 return make_scoped_refptr(new ContextProviderCommandBuffer( |
438 std::move(gpu_channel_host), stream_id, stream_priority, | 439 std::move(gpu_channel_host), stream_id, stream_priority, |
439 gpu::kNullSurfaceHandle, | 440 gpu::kNullSurfaceHandle, |
440 GURL("chrome://gpu/RenderThreadImpl::CreateOffscreenContext"), | 441 GURL("chrome://gpu/RenderThreadImpl::CreateOffscreenContext"), |
441 gl::PreferIntegratedGpu, automatic_flushes, support_locking, limits, | 442 gl::PreferIntegratedGpu, automatic_flushes, support_locking, limits, |
442 attributes, nullptr, type)); | 443 attributes, nullptr, type)); |
443 } | 444 } |
444 | 445 |
446 bool IsRunningInMash() { | |
447 const base::CommandLine* cmdline = base::CommandLine::ForCurrentProcess(); | |
448 return cmdline->HasSwitch(switches::kIsRunningInMash); | |
449 } | |
450 | |
445 } // namespace | 451 } // namespace |
446 | 452 |
447 // For measuring memory usage after each task. Behind a command line flag. | 453 // For measuring memory usage after each task. Behind a command line flag. |
448 class MemoryObserver : public base::MessageLoop::TaskObserver { | 454 class MemoryObserver : public base::MessageLoop::TaskObserver { |
449 public: | 455 public: |
450 MemoryObserver() {} | 456 MemoryObserver() {} |
451 ~MemoryObserver() override {} | 457 ~MemoryObserver() override {} |
452 | 458 |
453 void WillProcessTask(const base::PendingTask& pending_task) override {} | 459 void WillProcessTask(const base::PendingTask& pending_task) override {} |
454 | 460 |
(...skipping 167 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
622 #if defined(USE_EXTERNAL_POPUP_MENU) | 628 #if defined(USE_EXTERNAL_POPUP_MENU) |
623 // On Mac and Android Java UI, the select popups are rendered by the browser. | 629 // On Mac and Android Java UI, the select popups are rendered by the browser. |
624 blink::WebView::setUseExternalPopupMenus(true); | 630 blink::WebView::setUseExternalPopupMenus(true); |
625 #endif | 631 #endif |
626 | 632 |
627 lazy_tls.Pointer()->Set(this); | 633 lazy_tls.Pointer()->Set(this); |
628 | 634 |
629 // Register this object as the main thread. | 635 // Register this object as the main thread. |
630 ChildProcess::current()->set_main_thread(this); | 636 ChildProcess::current()->set_main_thread(this); |
631 | 637 |
638 #if defined(MOJO_SHELL_CLIENT) | |
639 if (IsRunningInMash()) { | |
640 auto shell_connection = MojoShellConnection::GetForProcess(); | |
danakj
2016/06/27 21:28:48
auto*
Peng
2016/06/30 19:30:52
Done.
| |
641 mus::GpuService::Initialize(shell_connection->GetConnector()); | |
642 } | |
643 #endif | |
644 | |
632 InitializeWebKit(resource_task_queue); | 645 InitializeWebKit(resource_task_queue); |
633 | 646 |
634 // In single process the single process is all there is. | 647 // In single process the single process is all there is. |
635 webkit_shared_timer_suspended_ = false; | 648 webkit_shared_timer_suspended_ = false; |
636 widget_count_ = 0; | 649 widget_count_ = 0; |
637 hidden_widget_count_ = 0; | 650 hidden_widget_count_ = 0; |
638 idle_notification_delay_in_ms_ = kInitialIdleHandlerDelayMs; | 651 idle_notification_delay_in_ms_ = kInitialIdleHandlerDelayMs; |
639 idle_notifications_to_skip_ = 0; | 652 idle_notifications_to_skip_ = 0; |
640 | 653 |
641 appcache_dispatcher_.reset( | 654 appcache_dispatcher_.reset( |
(...skipping 950 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
1592 RenderThreadImpl::GetCompositorMainThreadTaskRunner() { | 1605 RenderThreadImpl::GetCompositorMainThreadTaskRunner() { |
1593 return main_thread_compositor_task_runner_; | 1606 return main_thread_compositor_task_runner_; |
1594 } | 1607 } |
1595 | 1608 |
1596 scoped_refptr<base::SingleThreadTaskRunner> | 1609 scoped_refptr<base::SingleThreadTaskRunner> |
1597 RenderThreadImpl::GetCompositorImplThreadTaskRunner() { | 1610 RenderThreadImpl::GetCompositorImplThreadTaskRunner() { |
1598 return compositor_task_runner_; | 1611 return compositor_task_runner_; |
1599 } | 1612 } |
1600 | 1613 |
1601 gpu::GpuMemoryBufferManager* RenderThreadImpl::GetGpuMemoryBufferManager() { | 1614 gpu::GpuMemoryBufferManager* RenderThreadImpl::GetGpuMemoryBufferManager() { |
1602 return gpu_memory_buffer_manager(); | 1615 if (!IsRunningInMash()) { |
1616 return gpu_memory_buffer_manager(); | |
1617 } else { | |
1618 return mus::GpuService::GetInstance()->gpu_memory_buffer_manager(); | |
danakj
2016/06/27 21:28:48
Why isn't gpu_memory_buffer_manager() the mus one?
Peng
2016/06/30 19:30:52
Done.
Peng
2016/06/30 19:50:54
Yeah. Unfortunately, mus::GpuService has his own b
| |
1619 } | |
1603 } | 1620 } |
1604 | 1621 |
1605 scheduler::RendererScheduler* RenderThreadImpl::GetRendererScheduler() { | 1622 scheduler::RendererScheduler* RenderThreadImpl::GetRendererScheduler() { |
1606 return renderer_scheduler_.get(); | 1623 return renderer_scheduler_.get(); |
1607 } | 1624 } |
1608 | 1625 |
1609 std::unique_ptr<cc::BeginFrameSource> | 1626 std::unique_ptr<cc::BeginFrameSource> |
1610 RenderThreadImpl::CreateExternalBeginFrameSource(int routing_id) { | 1627 RenderThreadImpl::CreateExternalBeginFrameSource(int routing_id) { |
1611 return base::WrapUnique(new CompositorExternalBeginFrameSource( | 1628 return base::WrapUnique(new CompositorExternalBeginFrameSource( |
1612 compositor_message_filter_.get(), sync_message_filter(), routing_id)); | 1629 compositor_message_filter_.get(), sync_message_filter(), routing_id)); |
(...skipping 142 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
1755 TRACE_EVENT0("gpu", "RenderThreadImpl::EstablishGpuChannelSync"); | 1772 TRACE_EVENT0("gpu", "RenderThreadImpl::EstablishGpuChannelSync"); |
1756 | 1773 |
1757 if (gpu_channel_) { | 1774 if (gpu_channel_) { |
1758 // Do nothing if we already have a GPU channel or are already | 1775 // Do nothing if we already have a GPU channel or are already |
1759 // establishing one. | 1776 // establishing one. |
1760 if (!gpu_channel_->IsLost()) | 1777 if (!gpu_channel_->IsLost()) |
1761 return gpu_channel_; | 1778 return gpu_channel_; |
1762 | 1779 |
1763 // Recreate the channel if it has been lost. | 1780 // Recreate the channel if it has been lost. |
1764 gpu_channel_->DestroyChannel(); | 1781 gpu_channel_->DestroyChannel(); |
1765 gpu_channel_ = NULL; | 1782 gpu_channel_ = nullptr; |
1766 } | 1783 } |
1767 | 1784 |
1768 // Ask the browser for the channel name. | 1785 if (!IsRunningInMash()) { |
1769 int client_id = 0; | 1786 int client_id = 0; |
1770 IPC::ChannelHandle channel_handle; | 1787 IPC::ChannelHandle channel_handle; |
1771 gpu::GPUInfo gpu_info; | 1788 gpu::GPUInfo gpu_info; |
1772 if (!Send(new ChildProcessHostMsg_EstablishGpuChannel( | 1789 // Ask the browser for the channel name. |
1773 cause_for_gpu_launch, &client_id, &channel_handle, &gpu_info)) || | 1790 if (!Send(new ChildProcessHostMsg_EstablishGpuChannel( |
1791 cause_for_gpu_launch, &client_id, &channel_handle, &gpu_info)) || | |
1774 #if defined(OS_POSIX) | 1792 #if defined(OS_POSIX) |
1775 channel_handle.socket.fd == -1 || | 1793 channel_handle.socket.fd == -1 || |
1776 #endif | 1794 #endif |
1777 channel_handle.name.empty()) { | 1795 channel_handle.name.empty()) { |
1778 // Otherwise cancel the connection. | 1796 // Otherwise cancel the connection. |
1779 return NULL; | 1797 return NULL; |
danakj
2016/06/27 21:28:47
nullptr
Peng
2016/06/30 19:30:52
Done.
| |
1798 } | |
1799 GetContentClient()->SetGpuInfo(gpu_info); | |
1800 | |
1801 // Cache some variables that are needed on the compositor thread for our | |
1802 // implementation of GpuChannelHostFactory. | |
1803 io_thread_task_runner_ = ChildProcess::current()->io_task_runner(); | |
1804 | |
1805 gpu_channel_ = | |
1806 gpu::GpuChannelHost::Create(this, client_id, gpu_info, channel_handle, | |
1807 ChildProcess::current()->GetShutDownEvent(), | |
1808 gpu_memory_buffer_manager()); | |
1809 } else { | |
1810 gpu_channel_ = mus::GpuService::GetInstance()->EstablishGpuChannelSync(); | |
danakj
2016/06/27 21:28:48
Would it be possible to have a non-mash in-process
Peng
2016/06/30 19:30:52
It is possible. But currently some features are no
| |
1780 } | 1811 } |
1781 | |
1782 GetContentClient()->SetGpuInfo(gpu_info); | |
1783 | |
1784 // Cache some variables that are needed on the compositor thread for our | |
1785 // implementation of GpuChannelHostFactory. | |
1786 io_thread_task_runner_ = ChildProcess::current()->io_task_runner(); | |
1787 | |
1788 gpu_channel_ = gpu::GpuChannelHost::Create( | |
1789 this, client_id, gpu_info, channel_handle, | |
1790 ChildProcess::current()->GetShutDownEvent(), gpu_memory_buffer_manager()); | |
1791 return gpu_channel_; | 1812 return gpu_channel_; |
1792 } | 1813 } |
1793 | 1814 |
1794 std::unique_ptr<cc::OutputSurface> | 1815 std::unique_ptr<cc::OutputSurface> |
1795 RenderThreadImpl::CreateCompositorOutputSurface( | 1816 RenderThreadImpl::CreateCompositorOutputSurface( |
1796 bool use_software, | 1817 bool use_software, |
1797 int routing_id, | 1818 int routing_id, |
1798 scoped_refptr<FrameSwapMessageQueue> frame_swap_message_queue, | 1819 scoped_refptr<FrameSwapMessageQueue> frame_swap_message_queue, |
1799 const GURL& url) { | 1820 const GURL& url) { |
1800 const base::CommandLine& command_line = | 1821 const base::CommandLine& command_line = |
1801 *base::CommandLine::ForCurrentProcess(); | 1822 *base::CommandLine::ForCurrentProcess(); |
1802 if (command_line.HasSwitch(switches::kDisableGpuCompositing)) | 1823 if (command_line.HasSwitch(switches::kDisableGpuCompositing)) |
1803 use_software = true; | 1824 use_software = true; |
1804 | 1825 |
1805 #if defined(MOJO_SHELL_CLIENT) | 1826 #if defined(MOJO_SHELL_CLIENT) |
1806 auto shell_connection = MojoShellConnection::GetForProcess(); | 1827 auto shell_connection = MojoShellConnection::GetForProcess(); |
1807 if (shell_connection && !use_software && | 1828 if (shell_connection && !use_software && |
1808 command_line.HasSwitch(switches::kUseMusInRenderer)) { | 1829 command_line.HasSwitch(switches::kUseMusInRenderer)) { |
1809 mus::GpuService::Initialize(shell_connection->GetConnector()); | |
1810 RenderWidgetMusConnection* connection = | 1830 RenderWidgetMusConnection* connection = |
1811 RenderWidgetMusConnection::GetOrCreate(routing_id); | 1831 RenderWidgetMusConnection::GetOrCreate(routing_id); |
1812 return connection->CreateOutputSurface(); | 1832 return connection->CreateOutputSurface(); |
1813 } | 1833 } |
1814 #endif | 1834 #endif |
1815 | 1835 |
1816 uint32_t output_surface_id = g_next_output_surface_id++; | 1836 uint32_t output_surface_id = g_next_output_surface_id++; |
1817 | 1837 |
1818 if (command_line.HasSwitch(switches::kEnableVulkan)) { | 1838 if (command_line.HasSwitch(switches::kEnableVulkan)) { |
1819 scoped_refptr<cc::VulkanContextProvider> vulkan_context_provider = | 1839 scoped_refptr<cc::VulkanContextProvider> vulkan_context_provider = |
(...skipping 390 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
2210 v8_memory_pressure_level == v8::MemoryPressureLevel::kCritical) | 2230 v8_memory_pressure_level == v8::MemoryPressureLevel::kCritical) |
2211 v8_memory_pressure_level = v8::MemoryPressureLevel::kModerate; | 2231 v8_memory_pressure_level = v8::MemoryPressureLevel::kModerate; |
2212 | 2232 |
2213 blink::mainThreadIsolate()->MemoryPressureNotification( | 2233 blink::mainThreadIsolate()->MemoryPressureNotification( |
2214 v8_memory_pressure_level); | 2234 v8_memory_pressure_level); |
2215 blink::MemoryPressureNotificationToWorkerThreadIsolates( | 2235 blink::MemoryPressureNotificationToWorkerThreadIsolates( |
2216 v8_memory_pressure_level); | 2236 v8_memory_pressure_level); |
2217 } | 2237 } |
2218 | 2238 |
2219 } // namespace content | 2239 } // namespace content |
OLD | NEW |