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

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

Issue 1317743002: cc: Implement shared worker contexts. (v1) (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: fix tear down Created 5 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.cc » ('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 <vector> 10 #include <vector>
(...skipping 825 matching lines...) Expand 10 before | Expand all | Expand 10 after
836 // RenderThreadImpl. 836 // RenderThreadImpl.
837 embedded_worker_dispatcher_.reset(); 837 embedded_worker_dispatcher_.reset();
838 838
839 // Ramp down IDB before we ramp down WebKit (and V8), since IDB classes might 839 // Ramp down IDB before we ramp down WebKit (and V8), since IDB classes might
840 // hold pointers to V8 objects (e.g., via pending requests). 840 // hold pointers to V8 objects (e.g., via pending requests).
841 main_thread_indexed_db_dispatcher_.reset(); 841 main_thread_indexed_db_dispatcher_.reset();
842 842
843 main_thread_compositor_task_runner_ = NULL; 843 main_thread_compositor_task_runner_ = NULL;
844 844
845 // Context providers must be released prior to destroying the GPU channel. 845 // Context providers must be released prior to destroying the GPU channel.
846 shared_worker_context_provider_ = nullptr;
846 gpu_va_context_provider_ = nullptr; 847 gpu_va_context_provider_ = nullptr;
847 shared_main_thread_contexts_ = nullptr; 848 shared_main_thread_contexts_ = nullptr;
848 849
849 if (gpu_channel_.get()) 850 if (gpu_channel_.get())
850 gpu_channel_->DestroyChannel(); 851 gpu_channel_->DestroyChannel();
851 852
852 // TODO(port) 853 // TODO(port)
853 #if defined(OS_WIN) 854 #if defined(OS_WIN)
854 // Clean up plugin channels before this thread goes away. 855 // Clean up plugin channels before this thread goes away.
855 NPChannelBase::CleanupChannels(); 856 NPChannelBase::CleanupChannels();
(...skipping 474 matching lines...) Expand 10 before | Expand all | Expand 10 after
1330 } 1331 }
1331 return NULL; 1332 return NULL;
1332 } 1333 }
1333 #endif 1334 #endif
1334 1335
1335 scoped_refptr<GpuChannelHost> gpu_channel_host = GetGpuChannel(); 1336 scoped_refptr<GpuChannelHost> gpu_channel_host = GetGpuChannel();
1336 scoped_refptr<media::GpuVideoAcceleratorFactories> gpu_factories; 1337 scoped_refptr<media::GpuVideoAcceleratorFactories> gpu_factories;
1337 scoped_refptr<base::SingleThreadTaskRunner> media_task_runner = 1338 scoped_refptr<base::SingleThreadTaskRunner> media_task_runner =
1338 GetMediaThreadTaskRunner(); 1339 GetMediaThreadTaskRunner();
1339 if (!gpu_va_context_provider_.get() || 1340 if (!gpu_va_context_provider_.get() ||
1340 gpu_va_context_provider_->DestroyedOnMainThread()) { 1341 gpu_va_context_provider_->HasBeenLostOnMainThread()) {
1341 if (!gpu_channel_host.get()) { 1342 if (!gpu_channel_host.get()) {
1342 gpu_channel_host = EstablishGpuChannelSync( 1343 gpu_channel_host = EstablishGpuChannelSync(
1343 CAUSE_FOR_GPU_LAUNCH_WEBGRAPHICSCONTEXT3DCOMMANDBUFFERIMPL_INITIALIZE) ; 1344 CAUSE_FOR_GPU_LAUNCH_WEBGRAPHICSCONTEXT3DCOMMANDBUFFERIMPL_INITIALIZE) ;
1344 } 1345 }
1345 blink::WebGraphicsContext3D::Attributes attributes; 1346 blink::WebGraphicsContext3D::Attributes attributes;
1346 bool lose_context_when_out_of_memory = false; 1347 bool lose_context_when_out_of_memory = false;
1347 gpu_va_context_provider_ = ContextProviderCommandBuffer::Create( 1348 gpu_va_context_provider_ = ContextProviderCommandBuffer::Create(
1348 make_scoped_ptr( 1349 make_scoped_ptr(
1349 WebGraphicsContext3DCommandBufferImpl::CreateOffscreenContext( 1350 WebGraphicsContext3DCommandBufferImpl::CreateOffscreenContext(
1350 gpu_channel_host.get(), attributes, 1351 gpu_channel_host.get(), attributes,
(...skipping 41 matching lines...) Expand 10 before | Expand all | Expand 10 after
1392 lose_context_when_out_of_memory, 1393 lose_context_when_out_of_memory,
1393 GURL("chrome://gpu/RenderThreadImpl::CreateOffscreenContext3d"), 1394 GURL("chrome://gpu/RenderThreadImpl::CreateOffscreenContext3d"),
1394 WebGraphicsContext3DCommandBufferImpl::SharedMemoryLimits(), 1395 WebGraphicsContext3DCommandBufferImpl::SharedMemoryLimits(),
1395 NULL)); 1396 NULL));
1396 } 1397 }
1397 1398
1398 scoped_refptr<cc_blink::ContextProviderWebContext> 1399 scoped_refptr<cc_blink::ContextProviderWebContext>
1399 RenderThreadImpl::SharedMainThreadContextProvider() { 1400 RenderThreadImpl::SharedMainThreadContextProvider() {
1400 DCHECK(IsMainThread()); 1401 DCHECK(IsMainThread());
1401 if (!shared_main_thread_contexts_.get() || 1402 if (!shared_main_thread_contexts_.get() ||
1402 shared_main_thread_contexts_->DestroyedOnMainThread()) { 1403 shared_main_thread_contexts_->HasBeenLostOnMainThread()) {
1403 shared_main_thread_contexts_ = NULL; 1404 shared_main_thread_contexts_ = NULL;
1404 #if defined(OS_ANDROID) 1405 #if defined(OS_ANDROID)
1405 SynchronousCompositorFactory* factory = 1406 SynchronousCompositorFactory* factory =
1406 SynchronousCompositorFactory::GetInstance(); 1407 SynchronousCompositorFactory::GetInstance();
1407 if (factory && factory->OverrideWithFactory()) { 1408 if (factory && factory->OverrideWithFactory()) {
1408 shared_main_thread_contexts_ = factory->CreateOffscreenContextProvider( 1409 shared_main_thread_contexts_ = factory->CreateOffscreenContextProvider(
1409 GetOffscreenAttribs(), "Offscreen-MainThread"); 1410 GetOffscreenAttribs(), "Offscreen-MainThread");
1410 } 1411 }
1411 #endif 1412 #endif
1412 if (!shared_main_thread_contexts_.get()) { 1413 if (!shared_main_thread_contexts_.get()) {
(...skipping 462 matching lines...) Expand 10 before | Expand all | Expand 10 after
1875 AddFilter(renderer_demuxer_.get()); 1876 AddFilter(renderer_demuxer_.get());
1876 #endif 1877 #endif
1877 } 1878 }
1878 return media_thread_->task_runner(); 1879 return media_thread_->task_runner();
1879 } 1880 }
1880 1881
1881 base::TaskRunner* RenderThreadImpl::GetWorkerTaskRunner() { 1882 base::TaskRunner* RenderThreadImpl::GetWorkerTaskRunner() {
1882 return raster_worker_pool_.get(); 1883 return raster_worker_pool_.get();
1883 } 1884 }
1884 1885
1886 scoped_refptr<ContextProviderCommandBuffer>
1887 RenderThreadImpl::SharedWorkerContextProvider() {
1888 DCHECK(IsMainThread());
1889 // Try to reuse existing shared worker context provider.
1890 if (shared_worker_context_provider_) {
1891 base::AutoLock lock(*shared_worker_context_provider_->GetLock());
1892 if (shared_worker_context_provider_->ContextGL()
1893 ->GetGraphicsResetStatusKHR() != GL_NO_ERROR) {
1894 shared_worker_context_provider_->Destroy();
1895 shared_worker_context_provider_ = nullptr;
1896 }
1897 }
1898 if (!shared_worker_context_provider_) {
1899 shared_worker_context_provider_ = ContextProviderCommandBuffer::Create(
1900 CreateOffscreenContext3d(), RENDER_WORKER_CONTEXT);
1901 if (shared_worker_context_provider_ &&
1902 !shared_worker_context_provider_->BindToCurrentThread())
1903 shared_worker_context_provider_ = nullptr;
1904 if (shared_worker_context_provider_)
1905 shared_worker_context_provider_->SetupLock();
1906 }
1907 return shared_worker_context_provider_;
1908 }
1909
1885 void RenderThreadImpl::SampleGamepads(blink::WebGamepads* data) { 1910 void RenderThreadImpl::SampleGamepads(blink::WebGamepads* data) {
1886 blink_platform_impl_->sampleGamepads(*data); 1911 blink_platform_impl_->sampleGamepads(*data);
1887 } 1912 }
1888 1913
1889 bool RenderThreadImpl::RendererIsHidden() const { 1914 bool RenderThreadImpl::RendererIsHidden() const {
1890 return widget_count_ > 0 && hidden_widget_count_ == widget_count_; 1915 return widget_count_ > 0 && hidden_widget_count_ == widget_count_;
1891 } 1916 }
1892 1917
1893 void RenderThreadImpl::WidgetCreated() { 1918 void RenderThreadImpl::WidgetCreated() {
1894 bool renderer_was_hidden = RendererIsHidden(); 1919 bool renderer_was_hidden = RendererIsHidden();
(...skipping 72 matching lines...) Expand 10 before | Expand all | Expand 10 after
1967 } 1992 }
1968 1993
1969 void RenderThreadImpl::PendingRenderFrameConnect::OnConnectionError() { 1994 void RenderThreadImpl::PendingRenderFrameConnect::OnConnectionError() {
1970 size_t erased = 1995 size_t erased =
1971 RenderThreadImpl::current()->pending_render_frame_connects_.erase( 1996 RenderThreadImpl::current()->pending_render_frame_connects_.erase(
1972 routing_id_); 1997 routing_id_);
1973 DCHECK_EQ(1u, erased); 1998 DCHECK_EQ(1u, erased);
1974 } 1999 }
1975 2000
1976 } // namespace content 2001 } // namespace content
OLDNEW
« no previous file with comments | « content/renderer/render_thread_impl.h ('k') | content/renderer/render_widget.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698