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

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

Issue 2056833002: WIP HW (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Rebase Created 4 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
« no previous file with comments | « content/public/common/content_switches.cc ('k') | ui/views/mus/window_tree_host_mus.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 28 matching lines...) Expand all
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 375 matching lines...) Expand 10 before | Expand all | Expand 10 after
434 attributes.lose_context_when_out_of_memory = true; 435 attributes.lose_context_when_out_of_memory = true;
435 const bool automatic_flushes = false; 436 const bool automatic_flushes = false;
436 return make_scoped_refptr(new ContextProviderCommandBuffer( 437 return make_scoped_refptr(new ContextProviderCommandBuffer(
437 std::move(gpu_channel_host), stream_id, stream_priority, 438 std::move(gpu_channel_host), stream_id, stream_priority,
438 gpu::kNullSurfaceHandle, 439 gpu::kNullSurfaceHandle,
439 GURL("chrome://gpu/RenderThreadImpl::CreateOffscreenContext"), 440 GURL("chrome://gpu/RenderThreadImpl::CreateOffscreenContext"),
440 gl::PreferIntegratedGpu, automatic_flushes, support_locking, limits, 441 gl::PreferIntegratedGpu, automatic_flushes, support_locking, limits,
441 attributes, nullptr, type)); 442 attributes, nullptr, type));
442 } 443 }
443 444
445 bool IsRunningInMojoShell() {
446 const base::CommandLine* cmdline = base::CommandLine::ForCurrentProcess();
447 return cmdline->HasSwitch(switches::kIsRunningInMojoShell);
448 }
449
444 } // namespace 450 } // namespace
445 451
446 // For measuring memory usage after each task. Behind a command line flag. 452 // For measuring memory usage after each task. Behind a command line flag.
447 class MemoryObserver : public base::MessageLoop::TaskObserver { 453 class MemoryObserver : public base::MessageLoop::TaskObserver {
448 public: 454 public:
449 MemoryObserver() {} 455 MemoryObserver() {}
450 ~MemoryObserver() override {} 456 ~MemoryObserver() override {}
451 457
452 void WillProcessTask(const base::PendingTask& pending_task) override {} 458 void WillProcessTask(const base::PendingTask& pending_task) override {}
453 459
(...skipping 1142 matching lines...) Expand 10 before | Expand all | Expand 10 after
1596 RenderThreadImpl::GetCompositorMainThreadTaskRunner() { 1602 RenderThreadImpl::GetCompositorMainThreadTaskRunner() {
1597 return main_thread_compositor_task_runner_; 1603 return main_thread_compositor_task_runner_;
1598 } 1604 }
1599 1605
1600 scoped_refptr<base::SingleThreadTaskRunner> 1606 scoped_refptr<base::SingleThreadTaskRunner>
1601 RenderThreadImpl::GetCompositorImplThreadTaskRunner() { 1607 RenderThreadImpl::GetCompositorImplThreadTaskRunner() {
1602 return compositor_task_runner_; 1608 return compositor_task_runner_;
1603 } 1609 }
1604 1610
1605 gpu::GpuMemoryBufferManager* RenderThreadImpl::GetGpuMemoryBufferManager() { 1611 gpu::GpuMemoryBufferManager* RenderThreadImpl::GetGpuMemoryBufferManager() {
1606 return gpu_memory_buffer_manager(); 1612 if (!IsRunningInMojoShell()) {
1613 return gpu_memory_buffer_manager();
1614 } else {
1615 return mus::GpuService::GetInstance()->gpu_memory_buffer_manager();
1616 }
1607 } 1617 }
1608 1618
1609 scheduler::RendererScheduler* RenderThreadImpl::GetRendererScheduler() { 1619 scheduler::RendererScheduler* RenderThreadImpl::GetRendererScheduler() {
1610 return renderer_scheduler_.get(); 1620 return renderer_scheduler_.get();
1611 } 1621 }
1612 1622
1613 std::unique_ptr<cc::BeginFrameSource> 1623 std::unique_ptr<cc::BeginFrameSource>
1614 RenderThreadImpl::CreateExternalBeginFrameSource(int routing_id) { 1624 RenderThreadImpl::CreateExternalBeginFrameSource(int routing_id) {
1615 return base::WrapUnique(new CompositorExternalBeginFrameSource( 1625 return base::WrapUnique(new CompositorExternalBeginFrameSource(
1616 compositor_message_filter_.get(), sync_message_filter(), routing_id)); 1626 compositor_message_filter_.get(), sync_message_filter(), routing_id));
(...skipping 142 matching lines...) Expand 10 before | Expand all | Expand 10 after
1759 TRACE_EVENT0("gpu", "RenderThreadImpl::EstablishGpuChannelSync"); 1769 TRACE_EVENT0("gpu", "RenderThreadImpl::EstablishGpuChannelSync");
1760 1770
1761 if (gpu_channel_) { 1771 if (gpu_channel_) {
1762 // Do nothing if we already have a GPU channel or are already 1772 // Do nothing if we already have a GPU channel or are already
1763 // establishing one. 1773 // establishing one.
1764 if (!gpu_channel_->IsLost()) 1774 if (!gpu_channel_->IsLost())
1765 return gpu_channel_; 1775 return gpu_channel_;
1766 1776
1767 // Recreate the channel if it has been lost. 1777 // Recreate the channel if it has been lost.
1768 gpu_channel_->DestroyChannel(); 1778 gpu_channel_->DestroyChannel();
1769 gpu_channel_ = NULL; 1779 gpu_channel_ = nullptr;
1770 } 1780 }
1771 1781
1772 // Ask the browser for the channel name. 1782 if (!IsRunningInMojoShell()) {
1773 int client_id = 0; 1783 int client_id = 0;
1774 IPC::ChannelHandle channel_handle; 1784 IPC::ChannelHandle channel_handle;
1775 gpu::GPUInfo gpu_info; 1785 gpu::GPUInfo gpu_info;
1776 if (!Send(new ChildProcessHostMsg_EstablishGpuChannel( 1786 // Ask the browser for the channel name.
1777 cause_for_gpu_launch, &client_id, &channel_handle, &gpu_info)) || 1787 if (!Send(new ChildProcessHostMsg_EstablishGpuChannel(
1788 cause_for_gpu_launch, &client_id, &channel_handle, &gpu_info)) ||
1778 #if defined(OS_POSIX) 1789 #if defined(OS_POSIX)
1779 channel_handle.socket.fd == -1 || 1790 channel_handle.socket.fd == -1 ||
1780 #endif 1791 #endif
1781 channel_handle.name.empty()) { 1792 channel_handle.name.empty()) {
1782 // Otherwise cancel the connection. 1793 // Otherwise cancel the connection.
1783 return NULL; 1794 return NULL;
1795 }
1796 GetContentClient()->SetGpuInfo(gpu_info);
1797
1798 // Cache some variables that are needed on the compositor thread for our
1799 // implementation of GpuChannelHostFactory.
1800 io_thread_task_runner_ = ChildProcess::current()->io_task_runner();
1801
1802 gpu_channel_ =
1803 gpu::GpuChannelHost::Create(this, client_id, gpu_info, channel_handle,
1804 ChildProcess::current()->GetShutDownEvent(),
1805 gpu_memory_buffer_manager());
1806 } else {
1807 gpu_channel_ = mus::GpuService::GetInstance()->EstablishGpuChannelSync(
1808 MojoShellConnection::GetForProcess()->GetConnector());
1784 } 1809 }
1785
1786 GetContentClient()->SetGpuInfo(gpu_info);
1787
1788 // Cache some variables that are needed on the compositor thread for our
1789 // implementation of GpuChannelHostFactory.
1790 io_thread_task_runner_ = ChildProcess::current()->io_task_runner();
1791
1792 gpu_channel_ = gpu::GpuChannelHost::Create(
1793 this, client_id, gpu_info, channel_handle,
1794 ChildProcess::current()->GetShutDownEvent(), gpu_memory_buffer_manager());
1795 return gpu_channel_; 1810 return gpu_channel_;
1796 } 1811 }
1797 1812
1798 std::unique_ptr<cc::OutputSurface> 1813 std::unique_ptr<cc::OutputSurface>
1799 RenderThreadImpl::CreateCompositorOutputSurface( 1814 RenderThreadImpl::CreateCompositorOutputSurface(
1800 bool use_software, 1815 bool use_software,
1801 int routing_id, 1816 int routing_id,
1802 scoped_refptr<FrameSwapMessageQueue> frame_swap_message_queue, 1817 scoped_refptr<FrameSwapMessageQueue> frame_swap_message_queue,
1803 const GURL& url) { 1818 const GURL& url) {
1804 const base::CommandLine& command_line = 1819 const base::CommandLine& command_line =
(...skipping 407 matching lines...) Expand 10 before | Expand all | Expand 10 after
2212 v8_memory_pressure_level == v8::MemoryPressureLevel::kCritical) 2227 v8_memory_pressure_level == v8::MemoryPressureLevel::kCritical)
2213 v8_memory_pressure_level = v8::MemoryPressureLevel::kModerate; 2228 v8_memory_pressure_level = v8::MemoryPressureLevel::kModerate;
2214 2229
2215 blink::mainThreadIsolate()->MemoryPressureNotification( 2230 blink::mainThreadIsolate()->MemoryPressureNotification(
2216 v8_memory_pressure_level); 2231 v8_memory_pressure_level);
2217 blink::MemoryPressureNotificationToWorkerThreadIsolates( 2232 blink::MemoryPressureNotificationToWorkerThreadIsolates(
2218 v8_memory_pressure_level); 2233 v8_memory_pressure_level);
2219 } 2234 }
2220 2235
2221 } // namespace content 2236 } // namespace content
OLDNEW
« no previous file with comments | « content/public/common/content_switches.cc ('k') | ui/views/mus/window_tree_host_mus.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698