Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(402)

Side by Side Diff: content/renderer/render_thread_impl.cc

Issue 2337913003: Fork cc::OutputSurface into cc::CompositorFrameSink. (Closed)
Patch Set: cfsfork: android-vulkan Created 4 years, 3 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « content/renderer/render_thread_impl.h ('k') | content/renderer/render_widget.h » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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 21 matching lines...) Expand all
32 #include "base/threading/thread_local.h" 32 #include "base/threading/thread_local.h"
33 #include "base/threading/thread_restrictions.h" 33 #include "base/threading/thread_restrictions.h"
34 #include "base/threading/thread_task_runner_handle.h" 34 #include "base/threading/thread_task_runner_handle.h"
35 #include "base/trace_event/trace_event.h" 35 #include "base/trace_event/trace_event.h"
36 #include "base/values.h" 36 #include "base/values.h"
37 #include "build/build_config.h" 37 #include "build/build_config.h"
38 #include "cc/base/histograms.h" 38 #include "cc/base/histograms.h"
39 #include "cc/base/switches.h" 39 #include "cc/base/switches.h"
40 #include "cc/blink/web_layer_impl.h" 40 #include "cc/blink/web_layer_impl.h"
41 #include "cc/output/buffer_to_texture_target_map.h" 41 #include "cc/output/buffer_to_texture_target_map.h"
42 #include "cc/output/compositor_frame_sink.h"
42 #include "cc/output/copy_output_request.h" 43 #include "cc/output/copy_output_request.h"
43 #include "cc/output/output_surface.h"
44 #include "cc/output/vulkan_in_process_context_provider.h" 44 #include "cc/output/vulkan_in_process_context_provider.h"
45 #include "cc/raster/task_graph_runner.h" 45 #include "cc/raster/task_graph_runner.h"
46 #include "cc/trees/layer_tree_host_common.h" 46 #include "cc/trees/layer_tree_host_common.h"
47 #include "cc/trees/layer_tree_settings.h" 47 #include "cc/trees/layer_tree_settings.h"
48 #include "components/memory_coordinator/child/child_memory_coordinator_impl.h" 48 #include "components/memory_coordinator/child/child_memory_coordinator_impl.h"
49 #include "content/child/appcache/appcache_dispatcher.h" 49 #include "content/child/appcache/appcache_dispatcher.h"
50 #include "content/child/appcache/appcache_frontend_impl.h" 50 #include "content/child/appcache/appcache_frontend_impl.h"
51 #include "content/child/blob_storage/blob_message_filter.h" 51 #include "content/child/blob_storage/blob_message_filter.h"
52 #include "content/child/child_discardable_shared_memory_manager.h" 52 #include "content/child/child_discardable_shared_memory_manager.h"
53 #include "content/child/child_gpu_memory_buffer_manager.h" 53 #include "content/child/child_gpu_memory_buffer_manager.h"
(...skipping 34 matching lines...) Expand 10 before | Expand all | Expand 10 after
88 #include "content/renderer/cache_storage/cache_storage_dispatcher.h" 88 #include "content/renderer/cache_storage/cache_storage_dispatcher.h"
89 #include "content/renderer/cache_storage/cache_storage_message_filter.h" 89 #include "content/renderer/cache_storage/cache_storage_message_filter.h"
90 #include "content/renderer/categorized_worker_pool.h" 90 #include "content/renderer/categorized_worker_pool.h"
91 #include "content/renderer/devtools/devtools_agent_filter.h" 91 #include "content/renderer/devtools/devtools_agent_filter.h"
92 #include "content/renderer/devtools/v8_sampling_profiler.h" 92 #include "content/renderer/devtools/v8_sampling_profiler.h"
93 #include "content/renderer/dom_storage/dom_storage_dispatcher.h" 93 #include "content/renderer/dom_storage/dom_storage_dispatcher.h"
94 #include "content/renderer/dom_storage/webstoragearea_impl.h" 94 #include "content/renderer/dom_storage/webstoragearea_impl.h"
95 #include "content/renderer/dom_storage/webstoragenamespace_impl.h" 95 #include "content/renderer/dom_storage/webstoragenamespace_impl.h"
96 #include "content/renderer/gpu/compositor_external_begin_frame_source.h" 96 #include "content/renderer/gpu/compositor_external_begin_frame_source.h"
97 #include "content/renderer/gpu/compositor_forwarding_message_filter.h" 97 #include "content/renderer/gpu/compositor_forwarding_message_filter.h"
98 #include "content/renderer/gpu/compositor_output_surface.h"
99 #include "content/renderer/gpu/frame_swap_message_queue.h" 98 #include "content/renderer/gpu/frame_swap_message_queue.h"
99 #include "content/renderer/gpu/renderer_compositor_frame_sink.h"
100 #include "content/renderer/input/input_event_filter.h" 100 #include "content/renderer/input/input_event_filter.h"
101 #include "content/renderer/input/input_handler_manager.h" 101 #include "content/renderer/input/input_handler_manager.h"
102 #include "content/renderer/input/main_thread_input_event_filter.h" 102 #include "content/renderer/input/main_thread_input_event_filter.h"
103 #include "content/renderer/media/audio_input_message_filter.h" 103 #include "content/renderer/media/audio_input_message_filter.h"
104 #include "content/renderer/media/audio_message_filter.h" 104 #include "content/renderer/media/audio_message_filter.h"
105 #include "content/renderer/media/audio_renderer_mixer_manager.h" 105 #include "content/renderer/media/audio_renderer_mixer_manager.h"
106 #include "content/renderer/media/media_stream_center.h" 106 #include "content/renderer/media/media_stream_center.h"
107 #include "content/renderer/media/midi_message_filter.h" 107 #include "content/renderer/media/midi_message_filter.h"
108 #include "content/renderer/media/render_media_client.h" 108 #include "content/renderer/media/render_media_client.h"
109 #include "content/renderer/media/renderer_gpu_video_accelerator_factories.h" 109 #include "content/renderer/media/renderer_gpu_video_accelerator_factories.h"
(...skipping 48 matching lines...) Expand 10 before | Expand all | Expand 10 after
158 #include "third_party/WebKit/public/web/WebSecurityPolicy.h" 158 #include "third_party/WebKit/public/web/WebSecurityPolicy.h"
159 #include "third_party/WebKit/public/web/WebView.h" 159 #include "third_party/WebKit/public/web/WebView.h"
160 #include "third_party/icu/source/i18n/unicode/timezone.h" 160 #include "third_party/icu/source/i18n/unicode/timezone.h"
161 #include "third_party/skia/include/core/SkGraphics.h" 161 #include "third_party/skia/include/core/SkGraphics.h"
162 #include "ui/base/layout.h" 162 #include "ui/base/layout.h"
163 #include "ui/base/ui_base_switches.h" 163 #include "ui/base/ui_base_switches.h"
164 164
165 #if defined(OS_ANDROID) 165 #if defined(OS_ANDROID)
166 #include <cpu-features.h> 166 #include <cpu-features.h>
167 #include "content/renderer/android/synchronous_compositor_filter.h" 167 #include "content/renderer/android/synchronous_compositor_filter.h"
168 #include "content/renderer/android/synchronous_compositor_output_surface.h" 168 #include "content/renderer/android/synchronous_compositor_frame_sink.h"
169 #include "content/renderer/media/android/renderer_demuxer_android.h" 169 #include "content/renderer/media/android/renderer_demuxer_android.h"
170 #include "content/renderer/media/android/stream_texture_factory.h" 170 #include "content/renderer/media/android/stream_texture_factory.h"
171 #include "media/base/android/media_codec_util.h" 171 #include "media/base/android/media_codec_util.h"
172 #endif 172 #endif
173 173
174 #if defined(OS_MACOSX) 174 #if defined(OS_MACOSX)
175 #include "base/mac/mac_util.h" 175 #include "base/mac/mac_util.h"
176 #include "content/renderer/theme_helper_mac.h" 176 #include "content/renderer/theme_helper_mac.h"
177 #include "content/renderer/webscrollbarbehavior_impl_mac.h" 177 #include "content/renderer/webscrollbarbehavior_impl_mac.h"
178 #endif 178 #endif
(...skipping 57 matching lines...) Expand 10 before | Expand all | Expand 10 after
236 #endif 236 #endif
237 const double kThrottledResourceRequestFlushPeriodS = 1. / 60.; 237 const double kThrottledResourceRequestFlushPeriodS = 1. / 60.;
238 238
239 // Maximum allocation size allowed for image scaling filters that 239 // Maximum allocation size allowed for image scaling filters that
240 // require pre-scaling. Skia will fallback to a filter that doesn't 240 // require pre-scaling. Skia will fallback to a filter that doesn't
241 // require pre-scaling if the default filter would require an 241 // require pre-scaling if the default filter would require an
242 // allocation that exceeds this limit. 242 // allocation that exceeds this limit.
243 const size_t kImageCacheSingleAllocationByteLimit = 64 * 1024 * 1024; 243 const size_t kImageCacheSingleAllocationByteLimit = 64 * 1024 * 1024;
244 244
245 // Unique identifier for each output surface created. 245 // Unique identifier for each output surface created.
246 uint32_t g_next_output_surface_id = 1; 246 uint32_t g_next_compositor_frame_sink_id = 1;
247 247
248 // Keep the global RenderThreadImpl in a TLS slot so it is impossible to access 248 // Keep the global RenderThreadImpl in a TLS slot so it is impossible to access
249 // incorrectly from the wrong thread. 249 // incorrectly from the wrong thread.
250 base::LazyInstance<base::ThreadLocalPointer<RenderThreadImpl> > 250 base::LazyInstance<base::ThreadLocalPointer<RenderThreadImpl> >
251 lazy_tls = LAZY_INSTANCE_INITIALIZER; 251 lazy_tls = LAZY_INSTANCE_INITIALIZER;
252 252
253 // v8::MemoryPressureLevel should correspond to base::MemoryPressureListener. 253 // v8::MemoryPressureLevel should correspond to base::MemoryPressureListener.
254 static_assert(static_cast<v8::MemoryPressureLevel>( 254 static_assert(static_cast<v8::MemoryPressureLevel>(
255 base::MemoryPressureListener::MEMORY_PRESSURE_LEVEL_NONE) == 255 base::MemoryPressureListener::MEMORY_PRESSURE_LEVEL_NONE) ==
256 v8::MemoryPressureLevel::kNone, "none level not align"); 256 v8::MemoryPressureLevel::kNone, "none level not align");
(...skipping 1534 matching lines...) Expand 10 before | Expand all | Expand 10 after
1791 } else { 1791 } else {
1792 #if defined(USE_AURA) 1792 #if defined(USE_AURA)
1793 gpu_channel_ = gpu_service_->EstablishGpuChannelSync(); 1793 gpu_channel_ = gpu_service_->EstablishGpuChannelSync();
1794 #else 1794 #else
1795 NOTREACHED(); 1795 NOTREACHED();
1796 #endif 1796 #endif
1797 } 1797 }
1798 return gpu_channel_; 1798 return gpu_channel_;
1799 } 1799 }
1800 1800
1801 std::unique_ptr<cc::OutputSurface> 1801 std::unique_ptr<cc::CompositorFrameSink>
1802 RenderThreadImpl::CreateCompositorOutputSurface( 1802 RenderThreadImpl::CreateCompositorFrameSink(
1803 bool use_software, 1803 bool use_software,
1804 int routing_id, 1804 int routing_id,
1805 scoped_refptr<FrameSwapMessageQueue> frame_swap_message_queue, 1805 scoped_refptr<FrameSwapMessageQueue> frame_swap_message_queue,
1806 const GURL& url) { 1806 const GURL& url) {
1807 const base::CommandLine& command_line = 1807 const base::CommandLine& command_line =
1808 *base::CommandLine::ForCurrentProcess(); 1808 *base::CommandLine::ForCurrentProcess();
1809 if (command_line.HasSwitch(switches::kDisableGpuCompositing)) 1809 if (command_line.HasSwitch(switches::kDisableGpuCompositing))
1810 use_software = true; 1810 use_software = true;
1811 1811
1812 #if defined(USE_AURA) 1812 #if defined(USE_AURA)
1813 if (GetMojoShellConnection() && !use_software && 1813 if (GetMojoShellConnection() && !use_software &&
1814 command_line.HasSwitch(switches::kUseMusInRenderer)) { 1814 command_line.HasSwitch(switches::kUseMusInRenderer)) {
1815 RenderWidgetMusConnection* connection = 1815 RenderWidgetMusConnection* connection =
1816 RenderWidgetMusConnection::GetOrCreate(routing_id); 1816 RenderWidgetMusConnection::GetOrCreate(routing_id);
1817 scoped_refptr<gpu::GpuChannelHost> gpu_channel_host = 1817 scoped_refptr<gpu::GpuChannelHost> gpu_channel_host =
1818 EstablishGpuChannelSync(); 1818 EstablishGpuChannelSync();
1819 return connection->CreateOutputSurface(std::move(gpu_channel_host)); 1819 return connection->CreateCompositorFrameSink(std::move(gpu_channel_host));
1820 } 1820 }
1821 #endif 1821 #endif
1822 1822
1823 uint32_t output_surface_id = g_next_output_surface_id++; 1823 uint32_t compositor_frame_sink_id = g_next_compositor_frame_sink_id++;
1824 1824
1825 if (command_line.HasSwitch(switches::kEnableVulkan)) { 1825 if (command_line.HasSwitch(switches::kEnableVulkan)) {
1826 scoped_refptr<cc::VulkanContextProvider> vulkan_context_provider = 1826 scoped_refptr<cc::VulkanContextProvider> vulkan_context_provider =
1827 cc::VulkanInProcessContextProvider::Create(); 1827 cc::VulkanInProcessContextProvider::Create();
1828 if (vulkan_context_provider) { 1828 if (vulkan_context_provider) {
1829 DCHECK(!layout_test_mode()); 1829 DCHECK(!layout_test_mode());
1830 return base::MakeUnique<CompositorOutputSurface>( 1830 return base::MakeUnique<RendererCompositorFrameSink>(
1831 routing_id, output_surface_id, 1831 routing_id, compositor_frame_sink_id,
1832 CreateExternalBeginFrameSource(routing_id), 1832 CreateExternalBeginFrameSource(routing_id),
1833 std::move(vulkan_context_provider), 1833 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::MakeUnique<CompositorOutputSurface>( 1855 return base::MakeUnique<RendererCompositorFrameSink>(
1856 routing_id, output_surface_id, 1856 routing_id, compositor_frame_sink_id,
1857 CreateExternalBeginFrameSource(routing_id), nullptr, nullptr, 1857 CreateExternalBeginFrameSource(routing_id), nullptr, nullptr,
1858 std::move(frame_swap_message_queue)); 1858 std::move(frame_swap_message_queue));
1859 } 1859 }
1860 1860
1861 scoped_refptr<ContextProviderCommandBuffer> worker_context_provider = 1861 scoped_refptr<ContextProviderCommandBuffer> worker_context_provider =
1862 SharedCompositorWorkerContextProvider(); 1862 SharedCompositorWorkerContextProvider();
1863 if (!worker_context_provider) { 1863 if (!worker_context_provider) {
1864 // Cause the compositor to wait and try again. 1864 // Cause the compositor to wait and try again.
1865 return nullptr; 1865 return nullptr;
1866 } 1866 }
(...skipping 24 matching lines...) Expand all
1891 share_context = nullptr; 1891 share_context = nullptr;
1892 1892
1893 scoped_refptr<ContextProviderCommandBuffer> context_provider( 1893 scoped_refptr<ContextProviderCommandBuffer> context_provider(
1894 new ContextProviderCommandBuffer( 1894 new ContextProviderCommandBuffer(
1895 gpu_channel_host, gpu::GPU_STREAM_DEFAULT, 1895 gpu_channel_host, gpu::GPU_STREAM_DEFAULT,
1896 gpu::GpuStreamPriority::NORMAL, gpu::kNullSurfaceHandle, url, 1896 gpu::GpuStreamPriority::NORMAL, gpu::kNullSurfaceHandle, url,
1897 automatic_flushes, support_locking, limits, attributes, share_context, 1897 automatic_flushes, support_locking, limits, attributes, share_context,
1898 command_buffer_metrics::RENDER_COMPOSITOR_CONTEXT)); 1898 command_buffer_metrics::RENDER_COMPOSITOR_CONTEXT));
1899 1899
1900 if (layout_test_deps_) { 1900 if (layout_test_deps_) {
1901 return layout_test_deps_->CreateOutputSurface( 1901 return layout_test_deps_->CreateCompositorFrameSink(
1902 routing_id, std::move(gpu_channel_host), std::move(context_provider), 1902 routing_id, std::move(gpu_channel_host), std::move(context_provider),
1903 std::move(worker_context_provider), this); 1903 std::move(worker_context_provider), this);
1904 } 1904 }
1905 1905
1906 #if defined(OS_ANDROID) 1906 #if defined(OS_ANDROID)
1907 if (sync_compositor_message_filter_) { 1907 if (sync_compositor_message_filter_) {
1908 return base::MakeUnique<SynchronousCompositorOutputSurface>( 1908 return base::MakeUnique<SynchronousCompositorFrameSink>(
1909 std::move(context_provider), std::move(worker_context_provider), 1909 std::move(context_provider), std::move(worker_context_provider),
1910 routing_id, output_surface_id, 1910 routing_id, compositor_frame_sink_id,
1911 CreateExternalBeginFrameSource(routing_id), 1911 CreateExternalBeginFrameSource(routing_id),
1912 sync_compositor_message_filter_.get(), 1912 sync_compositor_message_filter_.get(),
1913 std::move(frame_swap_message_queue)); 1913 std::move(frame_swap_message_queue));
1914 } 1914 }
1915 #endif 1915 #endif
1916 return base::WrapUnique(new CompositorOutputSurface( 1916 return base::WrapUnique(new RendererCompositorFrameSink(
1917 routing_id, output_surface_id, CreateExternalBeginFrameSource(routing_id), 1917 routing_id, compositor_frame_sink_id,
1918 std::move(context_provider), std::move(worker_context_provider), 1918 CreateExternalBeginFrameSource(routing_id), std::move(context_provider),
1919 std::move(frame_swap_message_queue))); 1919 std::move(worker_context_provider), std::move(frame_swap_message_queue)));
1920 } 1920 }
1921 1921
1922 std::unique_ptr<cc::SwapPromise> 1922 std::unique_ptr<cc::SwapPromise>
1923 RenderThreadImpl::RequestCopyOfOutputForLayoutTest( 1923 RenderThreadImpl::RequestCopyOfOutputForLayoutTest(
1924 int32_t routing_id, 1924 int32_t routing_id,
1925 std::unique_ptr<cc::CopyOutputRequest> request) { 1925 std::unique_ptr<cc::CopyOutputRequest> request) {
1926 DCHECK(layout_test_deps_); 1926 DCHECK(layout_test_deps_);
1927 return layout_test_deps_->RequestCopyOfOutput(routing_id, std::move(request)); 1927 return layout_test_deps_->RequestCopyOfOutput(routing_id, std::move(request));
1928 } 1928 }
1929 1929
(...skipping 314 matching lines...) Expand 10 before | Expand all | Expand 10 after
2244 if (blink::mainThreadIsolate()) { 2244 if (blink::mainThreadIsolate()) {
2245 blink::mainThreadIsolate()->MemoryPressureNotification( 2245 blink::mainThreadIsolate()->MemoryPressureNotification(
2246 v8::MemoryPressureLevel::kCritical); 2246 v8::MemoryPressureLevel::kCritical);
2247 blink::MemoryPressureNotificationToWorkerThreadIsolates( 2247 blink::MemoryPressureNotificationToWorkerThreadIsolates(
2248 v8::MemoryPressureLevel::kCritical); 2248 v8::MemoryPressureLevel::kCritical);
2249 } 2249 }
2250 } 2250 }
2251 2251
2252 2252
2253 } // namespace content 2253 } // namespace content
OLDNEW
« no previous file with comments | « content/renderer/render_thread_impl.h ('k') | content/renderer/render_widget.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698