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 <vector> | 10 #include <vector> |
(...skipping 557 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
568 | 568 |
569 AddFilter((new ServiceWorkerContextMessageFilter())->GetFilter()); | 569 AddFilter((new ServiceWorkerContextMessageFilter())->GetFilter()); |
570 | 570 |
571 GetContentClient()->renderer()->RenderThreadStarted(); | 571 GetContentClient()->renderer()->RenderThreadStarted(); |
572 | 572 |
573 InitSkiaEventTracer(); | 573 InitSkiaEventTracer(); |
574 | 574 |
575 const base::CommandLine& command_line = | 575 const base::CommandLine& command_line = |
576 *base::CommandLine::ForCurrentProcess(); | 576 *base::CommandLine::ForCurrentProcess(); |
577 | 577 |
578 is_impl_side_painting_enabled_ = | |
579 !command_line.HasSwitch(switches::kDisableImplSidePainting); | |
580 cc_blink::WebLayerImpl::SetImplSidePaintingEnabled( | |
581 is_impl_side_painting_enabled_); | |
582 | |
583 cc::LayerSettings layer_settings; | 578 cc::LayerSettings layer_settings; |
584 if (command_line.HasSwitch(switches::kEnableCompositorAnimationTimelines)) | 579 if (command_line.HasSwitch(switches::kEnableCompositorAnimationTimelines)) |
585 layer_settings.use_compositor_animation_timelines = true; | 580 layer_settings.use_compositor_animation_timelines = true; |
586 cc_blink::WebLayerImpl::SetLayerSettings(layer_settings); | 581 cc_blink::WebLayerImpl::SetLayerSettings(layer_settings); |
587 | 582 |
588 is_zero_copy_enabled_ = command_line.HasSwitch(switches::kEnableZeroCopy); | 583 is_zero_copy_enabled_ = command_line.HasSwitch(switches::kEnableZeroCopy); |
589 is_one_copy_enabled_ = !command_line.HasSwitch(switches::kDisableOneCopy); | 584 is_one_copy_enabled_ = !command_line.HasSwitch(switches::kDisableOneCopy); |
590 | 585 |
591 #if defined(OS_MACOSX) && !defined(OS_IOS) | 586 #if defined(OS_MACOSX) && !defined(OS_IOS) |
592 is_elastic_overscroll_enabled_ = base::mac::IsOSLionOrLater(); | 587 is_elastic_overscroll_enabled_ = base::mac::IsOSLionOrLater(); |
(...skipping 56 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
649 // been initialized by the Zygote before this instance became a Renderer. | 644 // been initialized by the Zygote before this instance became a Renderer. |
650 media::InitializeMediaLibrary(); | 645 media::InitializeMediaLibrary(); |
651 | 646 |
652 memory_pressure_listener_.reset(new base::MemoryPressureListener( | 647 memory_pressure_listener_.reset(new base::MemoryPressureListener( |
653 base::Bind(&RenderThreadImpl::OnMemoryPressure, base::Unretained(this)))); | 648 base::Bind(&RenderThreadImpl::OnMemoryPressure, base::Unretained(this)))); |
654 | 649 |
655 compositor_task_graph_runner_.reset(new cc::TaskGraphRunner); | 650 compositor_task_graph_runner_.reset(new cc::TaskGraphRunner); |
656 | 651 |
657 is_gather_pixel_refs_enabled_ = false; | 652 is_gather_pixel_refs_enabled_ = false; |
658 | 653 |
659 if (is_impl_side_painting_enabled_) { | 654 int num_raster_threads = 0; |
660 int num_raster_threads = 0; | 655 std::string string_value = |
661 std::string string_value = | 656 command_line.GetSwitchValueASCII(switches::kNumRasterThreads); |
662 command_line.GetSwitchValueASCII(switches::kNumRasterThreads); | 657 bool parsed_num_raster_threads = |
663 bool parsed_num_raster_threads = | 658 base::StringToInt(string_value, &num_raster_threads); |
664 base::StringToInt(string_value, &num_raster_threads); | 659 DCHECK(parsed_num_raster_threads) << string_value; |
665 DCHECK(parsed_num_raster_threads) << string_value; | 660 DCHECK_GT(num_raster_threads, 0); |
666 DCHECK_GT(num_raster_threads, 0); | |
667 | 661 |
668 // Note: Currently, gathering of pixel refs when using a single | 662 // Note: Currently, gathering of pixel refs when using a single |
669 // raster thread doesn't provide any benefit. This might change | 663 // raster thread doesn't provide any benefit. This might change |
670 // in the future but we avoid it for now to reduce the cost of | 664 // in the future but we avoid it for now to reduce the cost of |
671 // Picture::Create. | 665 // Picture::Create. |
672 is_gather_pixel_refs_enabled_ = num_raster_threads > 1; | 666 is_gather_pixel_refs_enabled_ = num_raster_threads > 1; |
673 | 667 |
674 base::SimpleThread::Options thread_options; | 668 base::SimpleThread::Options thread_options; |
675 #if defined(OS_ANDROID) || defined(OS_LINUX) | 669 #if defined(OS_ANDROID) || defined(OS_LINUX) |
676 if (!command_line.HasSwitch( | 670 if (!command_line.HasSwitch( |
677 switches::kUseNormalPriorityForTileTaskWorkerThreads)) { | 671 switches::kUseNormalPriorityForTileTaskWorkerThreads)) { |
678 thread_options.set_priority(base::ThreadPriority::BACKGROUND); | 672 thread_options.set_priority(base::ThreadPriority::BACKGROUND); |
679 } | 673 } |
680 #endif | 674 #endif |
681 while (compositor_raster_threads_.size() < | 675 while (compositor_raster_threads_.size() < |
682 static_cast<size_t>(num_raster_threads)) { | 676 static_cast<size_t>(num_raster_threads)) { |
683 scoped_ptr<CompositorRasterThread> raster_thread( | 677 scoped_ptr<CompositorRasterThread> raster_thread(new CompositorRasterThread( |
684 new CompositorRasterThread( | 678 compositor_task_graph_runner_.get(), |
685 compositor_task_graph_runner_.get(), | 679 base::StringPrintf("CompositorTileWorker%u", |
686 base::StringPrintf( | 680 static_cast<unsigned>( |
687 "CompositorTileWorker%u", | 681 compositor_raster_threads_.size() + 1)).c_str(), |
688 static_cast<unsigned>(compositor_raster_threads_.size() + 1)) | 682 thread_options)); |
689 .c_str(), | 683 raster_thread->Start(); |
690 thread_options)); | 684 compositor_raster_threads_.push_back(raster_thread.Pass()); |
691 raster_thread->Start(); | |
692 compositor_raster_threads_.push_back(raster_thread.Pass()); | |
693 } | |
694 } | 685 } |
695 | 686 |
696 // In single process, browser main loop set up the discardable memory | 687 // In single process, browser main loop set up the discardable memory |
697 // allocator. | 688 // allocator. |
698 if (!command_line.HasSwitch(switches::kSingleProcess)) { | 689 if (!command_line.HasSwitch(switches::kSingleProcess)) { |
699 base::DiscardableMemoryAllocator::SetInstance( | 690 base::DiscardableMemoryAllocator::SetInstance( |
700 ChildThreadImpl::discardable_shared_memory_manager()); | 691 ChildThreadImpl::discardable_shared_memory_manager()); |
701 } | 692 } |
702 | 693 |
703 service_registry()->AddService<RenderFrameSetup>( | 694 service_registry()->AddService<RenderFrameSetup>( |
(...skipping 409 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1113 devtools_agent_message_filter_ = new DevToolsAgentFilter(); | 1104 devtools_agent_message_filter_ = new DevToolsAgentFilter(); |
1114 AddFilter(devtools_agent_message_filter_.get()); | 1105 AddFilter(devtools_agent_message_filter_.get()); |
1115 | 1106 |
1116 v8_sampling_profiler_.reset(new V8SamplingProfiler()); | 1107 v8_sampling_profiler_.reset(new V8SamplingProfiler()); |
1117 | 1108 |
1118 if (GetContentClient()->renderer()->RunIdleHandlerWhenWidgetsHidden()) | 1109 if (GetContentClient()->renderer()->RunIdleHandlerWhenWidgetsHidden()) |
1119 ScheduleIdleHandler(kLongIdleHandlerDelayMs); | 1110 ScheduleIdleHandler(kLongIdleHandlerDelayMs); |
1120 | 1111 |
1121 cc_blink::SetSharedBitmapAllocationFunction(AllocateSharedBitmapFunction); | 1112 cc_blink::SetSharedBitmapAllocationFunction(AllocateSharedBitmapFunction); |
1122 | 1113 |
1123 // Limit use of the scaled image cache to when deferred image decoding is | |
1124 // enabled. | |
1125 if (!command_line.HasSwitch(switches::kEnableDeferredImageDecoding) && | |
1126 !is_impl_side_painting_enabled_) | |
1127 SkGraphics::SetResourceCacheTotalByteLimit(0u); | |
1128 | |
1129 SkGraphics::SetResourceCacheSingleAllocationByteLimit( | 1114 SkGraphics::SetResourceCacheSingleAllocationByteLimit( |
1130 kImageCacheSingleAllocationByteLimit); | 1115 kImageCacheSingleAllocationByteLimit); |
1131 | 1116 |
1132 if (command_line.HasSwitch(switches::kMemoryMetrics)) { | 1117 if (command_line.HasSwitch(switches::kMemoryMetrics)) { |
1133 memory_observer_.reset(new MemoryObserver()); | 1118 memory_observer_.reset(new MemoryObserver()); |
1134 message_loop()->AddTaskObserver(memory_observer_.get()); | 1119 message_loop()->AddTaskObserver(memory_observer_.get()); |
1135 } | 1120 } |
1136 | 1121 |
1137 if (command_line.HasSwitch(switches::kExplicitlyAllowedPorts)) { | 1122 if (command_line.HasSwitch(switches::kExplicitlyAllowedPorts)) { |
1138 std::string allowed_ports = | 1123 std::string allowed_ports = |
(...skipping 245 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1384 const base::string16& str) { | 1369 const base::string16& str) { |
1385 Send(new ViewHostMsg_PreCacheFontCharacters(log_font, str)); | 1370 Send(new ViewHostMsg_PreCacheFontCharacters(log_font, str)); |
1386 } | 1371 } |
1387 | 1372 |
1388 #endif // OS_WIN | 1373 #endif // OS_WIN |
1389 | 1374 |
1390 ServiceRegistry* RenderThreadImpl::GetServiceRegistry() { | 1375 ServiceRegistry* RenderThreadImpl::GetServiceRegistry() { |
1391 return service_registry(); | 1376 return service_registry(); |
1392 } | 1377 } |
1393 | 1378 |
1394 bool RenderThreadImpl::IsImplSidePaintingEnabled() { | |
1395 return is_impl_side_painting_enabled_; | |
1396 } | |
1397 | |
1398 bool RenderThreadImpl::IsGpuRasterizationForced() { | 1379 bool RenderThreadImpl::IsGpuRasterizationForced() { |
1399 return is_gpu_rasterization_forced_; | 1380 return is_gpu_rasterization_forced_; |
1400 } | 1381 } |
1401 | 1382 |
1402 bool RenderThreadImpl::IsGpuRasterizationEnabled() { | 1383 bool RenderThreadImpl::IsGpuRasterizationEnabled() { |
1403 return is_gpu_rasterization_enabled_; | 1384 return is_gpu_rasterization_enabled_; |
1404 } | 1385 } |
1405 | 1386 |
1406 int RenderThreadImpl::GetGpuRasterizationMSAASampleCount() { | 1387 int RenderThreadImpl::GetGpuRasterizationMSAASampleCount() { |
1407 return gpu_rasterization_msaa_sample_count_; | 1388 return gpu_rasterization_msaa_sample_count_; |
(...skipping 492 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1900 } | 1881 } |
1901 | 1882 |
1902 void RenderThreadImpl::PendingRenderFrameConnect::OnConnectionError() { | 1883 void RenderThreadImpl::PendingRenderFrameConnect::OnConnectionError() { |
1903 size_t erased = | 1884 size_t erased = |
1904 RenderThreadImpl::current()->pending_render_frame_connects_.erase( | 1885 RenderThreadImpl::current()->pending_render_frame_connects_.erase( |
1905 routing_id_); | 1886 routing_id_); |
1906 DCHECK_EQ(1u, erased); | 1887 DCHECK_EQ(1u, erased); |
1907 } | 1888 } |
1908 | 1889 |
1909 } // namespace content | 1890 } // namespace content |
OLD | NEW |