| 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 269 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 280 explicit WebThreadForCompositor(base::Thread::Options options) | 280 explicit WebThreadForCompositor(base::Thread::Options options) |
| 281 : WebThreadImplForWorkerScheduler("Compositor", options) { | 281 : WebThreadImplForWorkerScheduler("Compositor", options) { |
| 282 Init(); | 282 Init(); |
| 283 } | 283 } |
| 284 ~WebThreadForCompositor() override {} | 284 ~WebThreadForCompositor() override {} |
| 285 | 285 |
| 286 private: | 286 private: |
| 287 // WebThreadImplForWorkerScheduler: | 287 // WebThreadImplForWorkerScheduler: |
| 288 std::unique_ptr<blink::scheduler::WorkerScheduler> CreateWorkerScheduler() | 288 std::unique_ptr<blink::scheduler::WorkerScheduler> CreateWorkerScheduler() |
| 289 override { | 289 override { |
| 290 return base::WrapUnique( | 290 return base::MakeUnique<blink::scheduler::CompositorWorkerScheduler>( |
| 291 new blink::scheduler::CompositorWorkerScheduler(thread())); | 291 thread()); |
| 292 } | 292 } |
| 293 | 293 |
| 294 DISALLOW_COPY_AND_ASSIGN(WebThreadForCompositor); | 294 DISALLOW_COPY_AND_ASSIGN(WebThreadForCompositor); |
| 295 }; | 295 }; |
| 296 | 296 |
| 297 void* CreateHistogram( | 297 void* CreateHistogram( |
| 298 const char *name, int min, int max, size_t buckets) { | 298 const char *name, int min, int max, size_t buckets) { |
| 299 if (min <= 0) | 299 if (min <= 0) |
| 300 min = 1; | 300 min = 1; |
| 301 std::string histogram_name; | 301 std::string histogram_name; |
| (...skipping 1301 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1603 #endif | 1603 #endif |
| 1604 return gpu_memory_buffer_manager(); | 1604 return gpu_memory_buffer_manager(); |
| 1605 } | 1605 } |
| 1606 | 1606 |
| 1607 blink::scheduler::RendererScheduler* RenderThreadImpl::GetRendererScheduler() { | 1607 blink::scheduler::RendererScheduler* RenderThreadImpl::GetRendererScheduler() { |
| 1608 return renderer_scheduler_.get(); | 1608 return renderer_scheduler_.get(); |
| 1609 } | 1609 } |
| 1610 | 1610 |
| 1611 std::unique_ptr<cc::BeginFrameSource> | 1611 std::unique_ptr<cc::BeginFrameSource> |
| 1612 RenderThreadImpl::CreateExternalBeginFrameSource(int routing_id) { | 1612 RenderThreadImpl::CreateExternalBeginFrameSource(int routing_id) { |
| 1613 return base::WrapUnique(new CompositorExternalBeginFrameSource( | 1613 return base::MakeUnique<CompositorExternalBeginFrameSource>( |
| 1614 compositor_message_filter_.get(), sync_message_filter(), routing_id)); | 1614 compositor_message_filter_.get(), sync_message_filter(), routing_id); |
| 1615 } | 1615 } |
| 1616 | 1616 |
| 1617 cc::ImageSerializationProcessor* | 1617 cc::ImageSerializationProcessor* |
| 1618 RenderThreadImpl::GetImageSerializationProcessor() { | 1618 RenderThreadImpl::GetImageSerializationProcessor() { |
| 1619 return GetContentClient()->renderer()->GetImageSerializationProcessor(); | 1619 return GetContentClient()->renderer()->GetImageSerializationProcessor(); |
| 1620 } | 1620 } |
| 1621 | 1621 |
| 1622 cc::TaskGraphRunner* RenderThreadImpl::GetTaskGraphRunner() { | 1622 cc::TaskGraphRunner* RenderThreadImpl::GetTaskGraphRunner() { |
| 1623 return categorized_worker_pool_->GetTaskGraphRunner(); | 1623 return categorized_worker_pool_->GetTaskGraphRunner(); |
| 1624 } | 1624 } |
| (...skipping 197 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1822 } | 1822 } |
| 1823 #endif | 1823 #endif |
| 1824 | 1824 |
| 1825 uint32_t output_surface_id = g_next_output_surface_id++; | 1825 uint32_t output_surface_id = g_next_output_surface_id++; |
| 1826 | 1826 |
| 1827 if (command_line.HasSwitch(switches::kEnableVulkan)) { | 1827 if (command_line.HasSwitch(switches::kEnableVulkan)) { |
| 1828 scoped_refptr<cc::VulkanContextProvider> vulkan_context_provider = | 1828 scoped_refptr<cc::VulkanContextProvider> vulkan_context_provider = |
| 1829 cc::VulkanInProcessContextProvider::Create(); | 1829 cc::VulkanInProcessContextProvider::Create(); |
| 1830 if (vulkan_context_provider) { | 1830 if (vulkan_context_provider) { |
| 1831 DCHECK(!layout_test_mode()); | 1831 DCHECK(!layout_test_mode()); |
| 1832 return base::WrapUnique(new CompositorOutputSurface( | 1832 return base::MakeUnique<CompositorOutputSurface>( |
| 1833 routing_id, output_surface_id, std::move(vulkan_context_provider), | 1833 routing_id, output_surface_id, std::move(vulkan_context_provider), |
| 1834 std::move(frame_swap_message_queue))); | 1834 std::move(frame_swap_message_queue)); |
| 1835 } | 1835 } |
| 1836 } | 1836 } |
| 1837 | 1837 |
| 1838 // Create a gpu process channel and verify we want to use GPU compositing | 1838 // Create a gpu process channel and verify we want to use GPU compositing |
| 1839 // before creating any context providers. | 1839 // before creating any context providers. |
| 1840 scoped_refptr<gpu::GpuChannelHost> gpu_channel_host; | 1840 scoped_refptr<gpu::GpuChannelHost> gpu_channel_host; |
| 1841 if (!use_software) { | 1841 if (!use_software) { |
| 1842 gpu_channel_host = EstablishGpuChannelSync(); | 1842 gpu_channel_host = EstablishGpuChannelSync(); |
| 1843 if (!gpu_channel_host) { | 1843 if (!gpu_channel_host) { |
| 1844 // Cause the compositor to wait and try again. | 1844 // Cause the compositor to wait and try again. |
| 1845 return nullptr; | 1845 return nullptr; |
| 1846 } | 1846 } |
| 1847 // We may get a valid channel, but with a software renderer. In that case, | 1847 // We may get a valid channel, but with a software renderer. In that case, |
| 1848 // disable GPU compositing. | 1848 // disable GPU compositing. |
| 1849 if (gpu_channel_host->gpu_info().software_rendering) | 1849 if (gpu_channel_host->gpu_info().software_rendering) |
| 1850 use_software = true; | 1850 use_software = true; |
| 1851 } | 1851 } |
| 1852 | 1852 |
| 1853 if (use_software) { | 1853 if (use_software) { |
| 1854 DCHECK(!layout_test_mode()); | 1854 DCHECK(!layout_test_mode()); |
| 1855 return base::WrapUnique(new CompositorOutputSurface( | 1855 return base::MakeUnique<CompositorOutputSurface>( |
| 1856 routing_id, output_surface_id, nullptr, nullptr, | 1856 routing_id, output_surface_id, nullptr, nullptr, |
| 1857 std::move(frame_swap_message_queue))); | 1857 std::move(frame_swap_message_queue)); |
| 1858 } | 1858 } |
| 1859 | 1859 |
| 1860 scoped_refptr<ContextProviderCommandBuffer> worker_context_provider = | 1860 scoped_refptr<ContextProviderCommandBuffer> worker_context_provider = |
| 1861 SharedCompositorWorkerContextProvider(); | 1861 SharedCompositorWorkerContextProvider(); |
| 1862 if (!worker_context_provider) { | 1862 if (!worker_context_provider) { |
| 1863 // Cause the compositor to wait and try again. | 1863 // Cause the compositor to wait and try again. |
| 1864 return nullptr; | 1864 return nullptr; |
| 1865 } | 1865 } |
| 1866 | 1866 |
| 1867 // The renderer compositor context doesn't do a lot of stuff, so we don't | 1867 // The renderer compositor context doesn't do a lot of stuff, so we don't |
| (...skipping 29 matching lines...) Expand all Loading... |
| 1897 command_buffer_metrics::RENDER_COMPOSITOR_CONTEXT)); | 1897 command_buffer_metrics::RENDER_COMPOSITOR_CONTEXT)); |
| 1898 | 1898 |
| 1899 if (layout_test_deps_) { | 1899 if (layout_test_deps_) { |
| 1900 return layout_test_deps_->CreateOutputSurface( | 1900 return layout_test_deps_->CreateOutputSurface( |
| 1901 routing_id, std::move(gpu_channel_host), std::move(context_provider), | 1901 routing_id, std::move(gpu_channel_host), std::move(context_provider), |
| 1902 std::move(worker_context_provider), this); | 1902 std::move(worker_context_provider), this); |
| 1903 } | 1903 } |
| 1904 | 1904 |
| 1905 #if defined(OS_ANDROID) | 1905 #if defined(OS_ANDROID) |
| 1906 if (sync_compositor_message_filter_) { | 1906 if (sync_compositor_message_filter_) { |
| 1907 return base::WrapUnique(new SynchronousCompositorOutputSurface( | 1907 return base::MakeUnique<SynchronousCompositorOutputSurface>( |
| 1908 std::move(context_provider), std::move(worker_context_provider), | 1908 std::move(context_provider), std::move(worker_context_provider), |
| 1909 routing_id, output_surface_id, sync_compositor_message_filter_.get(), | 1909 routing_id, output_surface_id, sync_compositor_message_filter_.get(), |
| 1910 std::move(frame_swap_message_queue))); | 1910 std::move(frame_swap_message_queue)); |
| 1911 } | 1911 } |
| 1912 #endif | 1912 #endif |
| 1913 | 1913 |
| 1914 return base::WrapUnique(new CompositorOutputSurface( | 1914 return base::MakeUnique<CompositorOutputSurface>( |
| 1915 routing_id, output_surface_id, std::move(context_provider), | 1915 routing_id, output_surface_id, std::move(context_provider), |
| 1916 std::move(worker_context_provider), std::move(frame_swap_message_queue))); | 1916 std::move(worker_context_provider), std::move(frame_swap_message_queue)); |
| 1917 } | 1917 } |
| 1918 | 1918 |
| 1919 std::unique_ptr<cc::SwapPromise> | 1919 std::unique_ptr<cc::SwapPromise> |
| 1920 RenderThreadImpl::RequestCopyOfOutputForLayoutTest( | 1920 RenderThreadImpl::RequestCopyOfOutputForLayoutTest( |
| 1921 int32_t routing_id, | 1921 int32_t routing_id, |
| 1922 std::unique_ptr<cc::CopyOutputRequest> request) { | 1922 std::unique_ptr<cc::CopyOutputRequest> request) { |
| 1923 DCHECK(layout_test_deps_); | 1923 DCHECK(layout_test_deps_); |
| 1924 return layout_test_deps_->RequestCopyOfOutput(routing_id, std::move(request)); | 1924 return layout_test_deps_->RequestCopyOfOutput(routing_id, std::move(request)); |
| 1925 } | 1925 } |
| 1926 | 1926 |
| (...skipping 302 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2229 v8_memory_pressure_level == v8::MemoryPressureLevel::kCritical) | 2229 v8_memory_pressure_level == v8::MemoryPressureLevel::kCritical) |
| 2230 v8_memory_pressure_level = v8::MemoryPressureLevel::kModerate; | 2230 v8_memory_pressure_level = v8::MemoryPressureLevel::kModerate; |
| 2231 | 2231 |
| 2232 blink::mainThreadIsolate()->MemoryPressureNotification( | 2232 blink::mainThreadIsolate()->MemoryPressureNotification( |
| 2233 v8_memory_pressure_level); | 2233 v8_memory_pressure_level); |
| 2234 blink::MemoryPressureNotificationToWorkerThreadIsolates( | 2234 blink::MemoryPressureNotificationToWorkerThreadIsolates( |
| 2235 v8_memory_pressure_level); | 2235 v8_memory_pressure_level); |
| 2236 } | 2236 } |
| 2237 | 2237 |
| 2238 } // namespace content | 2238 } // namespace content |
| OLD | NEW |