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

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

Issue 2923583002: Remove RendererCompositorFrameSink and use ClientCompositorFrameSink instead (Closed)
Patch Set: Created 3 years, 6 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
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 37 matching lines...) Expand 10 before | Expand all | Expand 10 after
48 #include "cc/output/buffer_to_texture_target_map.h" 48 #include "cc/output/buffer_to_texture_target_map.h"
49 #include "cc/output/compositor_frame_sink.h" 49 #include "cc/output/compositor_frame_sink.h"
50 #include "cc/output/copy_output_request.h" 50 #include "cc/output/copy_output_request.h"
51 #include "cc/output/vulkan_in_process_context_provider.h" 51 #include "cc/output/vulkan_in_process_context_provider.h"
52 #include "cc/raster/task_graph_runner.h" 52 #include "cc/raster/task_graph_runner.h"
53 #include "cc/trees/layer_tree_host_common.h" 53 #include "cc/trees/layer_tree_host_common.h"
54 #include "cc/trees/layer_tree_settings.h" 54 #include "cc/trees/layer_tree_settings.h"
55 #include "components/discardable_memory/client/client_discardable_shared_memory_ manager.h" 55 #include "components/discardable_memory/client/client_discardable_shared_memory_ manager.h"
56 #include "components/metrics/public/interfaces/single_sample_metrics.mojom.h" 56 #include "components/metrics/public/interfaces/single_sample_metrics.mojom.h"
57 #include "components/metrics/single_sample_metrics.h" 57 #include "components/metrics/single_sample_metrics.h"
58 #include "components/viz/client/client_compositor_frame_sink.h"
58 #include "content/child/appcache/appcache_dispatcher.h" 59 #include "content/child/appcache/appcache_dispatcher.h"
59 #include "content/child/appcache/appcache_frontend_impl.h" 60 #include "content/child/appcache/appcache_frontend_impl.h"
60 #include "content/child/blob_storage/blob_message_filter.h" 61 #include "content/child/blob_storage/blob_message_filter.h"
61 #include "content/child/child_histogram_message_filter.h" 62 #include "content/child/child_histogram_message_filter.h"
62 #include "content/child/child_resource_message_filter.h" 63 #include "content/child/child_resource_message_filter.h"
63 #include "content/child/db_message_filter.h" 64 #include "content/child/db_message_filter.h"
64 #include "content/child/indexed_db/indexed_db_dispatcher.h" 65 #include "content/child/indexed_db/indexed_db_dispatcher.h"
65 #include "content/child/memory/child_memory_coordinator_impl.h" 66 #include "content/child/memory/child_memory_coordinator_impl.h"
66 #include "content/child/resource_dispatcher.h" 67 #include "content/child/resource_dispatcher.h"
67 #include "content/child/resource_scheduling_filter.h" 68 #include "content/child/resource_scheduling_filter.h"
(...skipping 31 matching lines...) Expand 10 before | Expand all | Expand 10 after
99 #include "content/renderer/cache_storage/cache_storage_message_filter.h" 100 #include "content/renderer/cache_storage/cache_storage_message_filter.h"
100 #include "content/renderer/categorized_worker_pool.h" 101 #include "content/renderer/categorized_worker_pool.h"
101 #include "content/renderer/devtools/devtools_agent_filter.h" 102 #include "content/renderer/devtools/devtools_agent_filter.h"
102 #include "content/renderer/dom_storage/dom_storage_dispatcher.h" 103 #include "content/renderer/dom_storage/dom_storage_dispatcher.h"
103 #include "content/renderer/dom_storage/webstoragearea_impl.h" 104 #include "content/renderer/dom_storage/webstoragearea_impl.h"
104 #include "content/renderer/dom_storage/webstoragenamespace_impl.h" 105 #include "content/renderer/dom_storage/webstoragenamespace_impl.h"
105 #include "content/renderer/effective_connection_type_helper.h" 106 #include "content/renderer/effective_connection_type_helper.h"
106 #include "content/renderer/gpu/compositor_external_begin_frame_source.h" 107 #include "content/renderer/gpu/compositor_external_begin_frame_source.h"
107 #include "content/renderer/gpu/compositor_forwarding_message_filter.h" 108 #include "content/renderer/gpu/compositor_forwarding_message_filter.h"
108 #include "content/renderer/gpu/frame_swap_message_queue.h" 109 #include "content/renderer/gpu/frame_swap_message_queue.h"
109 #include "content/renderer/gpu/renderer_compositor_frame_sink.h"
110 #include "content/renderer/input/input_event_filter.h" 110 #include "content/renderer/input/input_event_filter.h"
111 #include "content/renderer/input/input_handler_manager.h" 111 #include "content/renderer/input/input_handler_manager.h"
112 #include "content/renderer/input/main_thread_input_event_filter.h" 112 #include "content/renderer/input/main_thread_input_event_filter.h"
113 #include "content/renderer/media/audio_input_message_filter.h" 113 #include "content/renderer/media/audio_input_message_filter.h"
114 #include "content/renderer/media/audio_message_filter.h" 114 #include "content/renderer/media/audio_message_filter.h"
115 #include "content/renderer/media/audio_renderer_mixer_manager.h" 115 #include "content/renderer/media/audio_renderer_mixer_manager.h"
116 #include "content/renderer/media/media_stream_center.h" 116 #include "content/renderer/media/media_stream_center.h"
117 #include "content/renderer/media/midi_message_filter.h" 117 #include "content/renderer/media/midi_message_filter.h"
118 #include "content/renderer/media/render_media_client.h" 118 #include "content/renderer/media/render_media_client.h"
119 #include "content/renderer/media/renderer_gpu_video_accelerator_factories.h" 119 #include "content/renderer/media/renderer_gpu_video_accelerator_factories.h"
(...skipping 292 matching lines...) Expand 10 before | Expand all | Expand 10 after
412 connector->BindInterface(mojom::kBrowserServiceName, std::move(request)); 412 connector->BindInterface(mojom::kBrowserServiceName, std::move(request));
413 return; 413 return;
414 } 414 }
415 415
416 task_runner->PostTask( 416 task_runner->PostTask(
417 FROM_HERE, 417 FROM_HERE,
418 base::Bind(&CreateSingleSampleMetricsProvider, std::move(task_runner), 418 base::Bind(&CreateSingleSampleMetricsProvider, std::move(task_runner),
419 connector, base::Passed(&request))); 419 connector, base::Passed(&request)));
420 } 420 }
421 421
422 class RendererLocalSurfaceIdProvider : public viz::LocalSurfaceIdProvider {
423 public:
424 const cc::LocalSurfaceId& GetLocalSurfaceIdForFrame(
425 const cc::CompositorFrame& frame) override {
426 auto new_surface_properties =
427 RenderWidgetSurfaceProperties::FromCompositorFrame(frame);
428 if (!local_surface_id_.is_valid() ||
429 new_surface_properties != surface_properties_) {
430 local_surface_id_ = local_surface_id_allocator_.GenerateId();
431 surface_properties_ = new_surface_properties;
432 }
433 return local_surface_id_;
434 }
435
436 private:
437 cc::LocalSurfaceIdAllocator local_surface_id_allocator_;
438 cc::LocalSurfaceId local_surface_id_;
439 RenderWidgetSurfaceProperties surface_properties_;
440 };
441
422 } // namespace 442 } // namespace
423 443
424 RenderThreadImpl::HistogramCustomizer::HistogramCustomizer() { 444 RenderThreadImpl::HistogramCustomizer::HistogramCustomizer() {
425 custom_histograms_.insert("V8.MemoryExternalFragmentationTotal"); 445 custom_histograms_.insert("V8.MemoryExternalFragmentationTotal");
426 custom_histograms_.insert("V8.MemoryHeapSampleTotalCommitted"); 446 custom_histograms_.insert("V8.MemoryHeapSampleTotalCommitted");
427 custom_histograms_.insert("V8.MemoryHeapSampleTotalUsed"); 447 custom_histograms_.insert("V8.MemoryHeapSampleTotalUsed");
428 custom_histograms_.insert("V8.MemoryHeapUsed"); 448 custom_histograms_.insert("V8.MemoryHeapUsed");
429 custom_histograms_.insert("V8.MemoryHeapCommitted"); 449 custom_histograms_.insert("V8.MemoryHeapCommitted");
430 } 450 }
431 451
(...skipping 1475 matching lines...) Expand 10 before | Expand all | Expand 10 after
1907 cc::mojom::MojoCompositorFrameSinkClientRequest client_request = 1927 cc::mojom::MojoCompositorFrameSinkClientRequest client_request =
1908 mojo::MakeRequest(&client); 1928 mojo::MakeRequest(&client);
1909 1929
1910 if (command_line.HasSwitch(switches::kEnableVulkan)) { 1930 if (command_line.HasSwitch(switches::kEnableVulkan)) {
1911 scoped_refptr<cc::VulkanContextProvider> vulkan_context_provider = 1931 scoped_refptr<cc::VulkanContextProvider> vulkan_context_provider =
1912 cc::VulkanInProcessContextProvider::Create(); 1932 cc::VulkanInProcessContextProvider::Create();
1913 if (vulkan_context_provider) { 1933 if (vulkan_context_provider) {
1914 DCHECK(!layout_test_mode()); 1934 DCHECK(!layout_test_mode());
1915 frame_sink_provider_->CreateForWidget(routing_id, std::move(sink_request), 1935 frame_sink_provider_->CreateForWidget(routing_id, std::move(sink_request),
1916 std::move(client)); 1936 std::move(client));
1917 callback.Run(base::MakeUnique<RendererCompositorFrameSink>( 1937 callback.Run(base::MakeUnique<viz::ClientCompositorFrameSink>(
1918 routing_id, std::move(synthetic_begin_frame_source), 1938 std::move(vulkan_context_provider),
1919 std::move(vulkan_context_provider), std::move(sink_info), 1939 std::move(synthetic_begin_frame_source), std::move(sink_info),
1920 std::move(client_request))); 1940 std::move(client_request),
1941 base::MakeUnique<RendererLocalSurfaceIdProvider>(),
1942 false /* enable_surface_synchroninzation */));
1921 return; 1943 return;
1922 } 1944 }
1923 } 1945 }
1924 1946
1925 // Create a gpu process channel and verify we want to use GPU compositing 1947 // Create a gpu process channel and verify we want to use GPU compositing
1926 // before creating any context providers. 1948 // before creating any context providers.
1927 scoped_refptr<gpu::GpuChannelHost> gpu_channel_host; 1949 scoped_refptr<gpu::GpuChannelHost> gpu_channel_host;
1928 if (!use_software) { 1950 if (!use_software) {
1929 gpu_channel_host = EstablishGpuChannelSync(); 1951 gpu_channel_host = EstablishGpuChannelSync();
1930 if (!gpu_channel_host) { 1952 if (!gpu_channel_host) {
1931 // Cause the compositor to wait and try again. 1953 // Cause the compositor to wait and try again.
1932 callback.Run(nullptr); 1954 callback.Run(nullptr);
1933 return; 1955 return;
1934 } 1956 }
1935 // We may get a valid channel, but with a software renderer. In that case, 1957 // We may get a valid channel, but with a software renderer. In that case,
1936 // disable GPU compositing. 1958 // disable GPU compositing.
1937 if (gpu_channel_host->gpu_info().software_rendering) 1959 if (gpu_channel_host->gpu_info().software_rendering)
1938 use_software = true; 1960 use_software = true;
1939 } 1961 }
1940 1962
1941 if (use_software) { 1963 if (use_software) {
1942 DCHECK(!layout_test_mode()); 1964 DCHECK(!layout_test_mode());
1943 frame_sink_provider_->CreateForWidget(routing_id, std::move(sink_request), 1965 frame_sink_provider_->CreateForWidget(routing_id, std::move(sink_request),
1944 std::move(client)); 1966 std::move(client));
1945 callback.Run(base::MakeUnique<RendererCompositorFrameSink>( 1967 callback.Run(base::MakeUnique<viz::ClientCompositorFrameSink>(
1946 routing_id, std::move(synthetic_begin_frame_source), nullptr, nullptr, 1968 nullptr, nullptr, nullptr, shared_bitmap_manager(),
1947 nullptr, shared_bitmap_manager(), std::move(sink_info), 1969 std::move(synthetic_begin_frame_source), std::move(sink_info),
1948 std::move(client_request))); 1970 std::move(client_request),
1971 base::MakeUnique<RendererLocalSurfaceIdProvider>(),
1972 false /* enable_surface_synchroninzation */));
1949 return; 1973 return;
1950 } 1974 }
1951 1975
1952 scoped_refptr<ui::ContextProviderCommandBuffer> worker_context_provider = 1976 scoped_refptr<ui::ContextProviderCommandBuffer> worker_context_provider =
1953 SharedCompositorWorkerContextProvider(); 1977 SharedCompositorWorkerContextProvider();
1954 if (!worker_context_provider) { 1978 if (!worker_context_provider) {
1955 // Cause the compositor to wait and try again. 1979 // Cause the compositor to wait and try again.
1956 callback.Run(nullptr); 1980 callback.Run(nullptr);
1957 return; 1981 return;
1958 } 1982 }
(...skipping 48 matching lines...) Expand 10 before | Expand all | Expand 10 after
2007 std::move(context_provider), std::move(worker_context_provider), 2031 std::move(context_provider), std::move(worker_context_provider),
2008 GetGpuMemoryBufferManager(), shared_bitmap_manager(), routing_id, 2032 GetGpuMemoryBufferManager(), shared_bitmap_manager(), routing_id,
2009 g_next_compositor_frame_sink_id++, std::move(begin_frame_source), 2033 g_next_compositor_frame_sink_id++, std::move(begin_frame_source),
2010 sync_compositor_message_filter_.get(), 2034 sync_compositor_message_filter_.get(),
2011 std::move(frame_swap_message_queue))); 2035 std::move(frame_swap_message_queue)));
2012 return; 2036 return;
2013 } 2037 }
2014 #endif 2038 #endif
2015 frame_sink_provider_->CreateForWidget(routing_id, std::move(sink_request), 2039 frame_sink_provider_->CreateForWidget(routing_id, std::move(sink_request),
2016 std::move(client)); 2040 std::move(client));
2017 callback.Run(base::WrapUnique(new RendererCompositorFrameSink( 2041 callback.Run(base::MakeUnique<viz::ClientCompositorFrameSink>(
2018 routing_id, std::move(synthetic_begin_frame_source),
2019 std::move(context_provider), std::move(worker_context_provider), 2042 std::move(context_provider), std::move(worker_context_provider),
2020 GetGpuMemoryBufferManager(), nullptr, std::move(sink_info), 2043 GetGpuMemoryBufferManager(), nullptr,
2021 std::move(client_request)))); 2044 std::move(synthetic_begin_frame_source), std::move(sink_info),
2045 std::move(client_request),
2046 base::MakeUnique<RendererLocalSurfaceIdProvider>(),
2047 false /* enable_surface_synchroninzation */));
2022 } 2048 }
2023 2049
2024 AssociatedInterfaceRegistry* 2050 AssociatedInterfaceRegistry*
2025 RenderThreadImpl::GetAssociatedInterfaceRegistry() { 2051 RenderThreadImpl::GetAssociatedInterfaceRegistry() {
2026 return &associated_interfaces_; 2052 return &associated_interfaces_;
2027 } 2053 }
2028 2054
2029 std::unique_ptr<cc::SwapPromise> 2055 std::unique_ptr<cc::SwapPromise>
2030 RenderThreadImpl::RequestCopyOfOutputForLayoutTest( 2056 RenderThreadImpl::RequestCopyOfOutputForLayoutTest(
2031 int32_t routing_id, 2057 int32_t routing_id,
(...skipping 438 matching lines...) Expand 10 before | Expand all | Expand 10 after
2470 } 2496 }
2471 } 2497 }
2472 2498
2473 void RenderThreadImpl::OnRendererInterfaceRequest( 2499 void RenderThreadImpl::OnRendererInterfaceRequest(
2474 mojom::RendererAssociatedRequest request) { 2500 mojom::RendererAssociatedRequest request) {
2475 DCHECK(!renderer_binding_.is_bound()); 2501 DCHECK(!renderer_binding_.is_bound());
2476 renderer_binding_.Bind(std::move(request)); 2502 renderer_binding_.Bind(std::move(request));
2477 } 2503 }
2478 2504
2479 } // namespace content 2505 } // namespace content
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698