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 546 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
557 if (webkit_platform_support_) | 557 if (webkit_platform_support_) |
558 blink::shutdown(); | 558 blink::shutdown(); |
559 | 559 |
560 lazy_tls.Pointer()->Set(NULL); | 560 lazy_tls.Pointer()->Set(NULL); |
561 | 561 |
562 // TODO(port) | 562 // TODO(port) |
563 #if defined(OS_WIN) | 563 #if defined(OS_WIN) |
564 // Clean up plugin channels before this thread goes away. | 564 // Clean up plugin channels before this thread goes away. |
565 NPChannelBase::CleanupChannels(); | 565 NPChannelBase::CleanupChannels(); |
566 #endif | 566 #endif |
567 | |
568 // Leak shared contexts on other threads, as we can not get to the correct | |
569 // thread to destroy them. | |
570 if (offscreen_compositor_contexts_.get()) | |
571 offscreen_compositor_contexts_->set_leak_on_destroy(); | |
572 } | 567 } |
573 | 568 |
574 bool RenderThreadImpl::Send(IPC::Message* msg) { | 569 bool RenderThreadImpl::Send(IPC::Message* msg) { |
575 // Certain synchronous messages cannot always be processed synchronously by | 570 // Certain synchronous messages cannot always be processed synchronously by |
576 // the browser, e.g., putting up UI and waiting for the user. This could cause | 571 // the browser, e.g., putting up UI and waiting for the user. This could cause |
577 // a complete hang of Chrome if a windowed plug-in is trying to communicate | 572 // a complete hang of Chrome if a windowed plug-in is trying to communicate |
578 // with the renderer thread since the browser's UI thread could be stuck | 573 // with the renderer thread since the browser's UI thread could be stuck |
579 // (within a Windows API call) trying to synchronously communicate with the | 574 // (within a Windows API call) trying to synchronously communicate with the |
580 // plug-in. The remedy is to pump messages on this thread while the browser | 575 // plug-in. The remedy is to pump messages on this thread while the browser |
581 // is processing this request. This creates an opportunity for re-entrancy | 576 // is processing this request. This creates an opportunity for re-entrancy |
(...skipping 433 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1015 return make_scoped_ptr( | 1010 return make_scoped_ptr( |
1016 WebGraphicsContext3DCommandBufferImpl::CreateOffscreenContext( | 1011 WebGraphicsContext3DCommandBufferImpl::CreateOffscreenContext( |
1017 gpu_channel_host.get(), | 1012 gpu_channel_host.get(), |
1018 attributes, | 1013 attributes, |
1019 lose_context_when_out_of_memory, | 1014 lose_context_when_out_of_memory, |
1020 GURL("chrome://gpu/RenderThreadImpl::CreateOffscreenContext3d"), | 1015 GURL("chrome://gpu/RenderThreadImpl::CreateOffscreenContext3d"), |
1021 WebGraphicsContext3DCommandBufferImpl::SharedMemoryLimits(), | 1016 WebGraphicsContext3DCommandBufferImpl::SharedMemoryLimits(), |
1022 NULL)); | 1017 NULL)); |
1023 } | 1018 } |
1024 | 1019 |
1025 scoped_refptr<cc::ContextProvider> | |
1026 RenderThreadImpl::OffscreenCompositorContextProvider() { | |
1027 DCHECK(IsMainThread()); | |
1028 | |
1029 #if defined(OS_ANDROID) | |
1030 if (SynchronousCompositorFactory* factory = | |
1031 SynchronousCompositorFactory::GetInstance()) { | |
1032 if (compositor_message_loop_proxy_) | |
1033 return factory->GetOffscreenContextProviderForCompositorThread(); | |
1034 return factory->GetSharedOffscreenContextProviderForMainThread(); | |
1035 } | |
1036 #endif | |
1037 | |
1038 if (!offscreen_compositor_contexts_.get() || | |
1039 offscreen_compositor_contexts_->DestroyedOnMainThread()) { | |
1040 offscreen_compositor_contexts_ = ContextProviderCommandBuffer::Create( | |
1041 CreateOffscreenContext3d(), | |
1042 "Compositor-Offscreen"); | |
1043 } | |
1044 return offscreen_compositor_contexts_; | |
1045 } | |
1046 | |
1047 scoped_refptr<webkit::gpu::ContextProviderWebContext> | 1020 scoped_refptr<webkit::gpu::ContextProviderWebContext> |
1048 RenderThreadImpl::SharedMainThreadContextProvider() { | 1021 RenderThreadImpl::SharedMainThreadContextProvider() { |
1049 DCHECK(IsMainThread()); | 1022 DCHECK(IsMainThread()); |
1050 #if defined(OS_ANDROID) | 1023 #if defined(OS_ANDROID) |
1051 if (SynchronousCompositorFactory* factory = | 1024 if (SynchronousCompositorFactory* factory = |
1052 SynchronousCompositorFactory::GetInstance()) | 1025 SynchronousCompositorFactory::GetInstance()) |
1053 return factory->GetSharedOffscreenContextProviderForMainThread(); | 1026 return factory->GetSharedOffscreenContextProviderForMainThread(); |
1054 #endif | 1027 #endif |
1055 | 1028 |
1056 if (!shared_main_thread_contexts_ || | 1029 if (!shared_main_thread_contexts_ || |
1057 shared_main_thread_contexts_->DestroyedOnMainThread()) { | 1030 shared_main_thread_contexts_->DestroyedOnMainThread()) { |
1058 if (compositor_message_loop_proxy_) { | 1031 shared_main_thread_contexts_ = ContextProviderCommandBuffer::Create( |
1059 // In threaded compositing mode, we have to create a new ContextProvider | 1032 CreateOffscreenContext3d(), "Offscreen-MainThread"); |
1060 // to bind to the main thread since the compositor's is bound to the | |
1061 // compositor thread. | |
1062 shared_main_thread_contexts_ = | |
1063 ContextProviderCommandBuffer::Create(CreateOffscreenContext3d(), | |
1064 "Offscreen-MainThread"); | |
1065 } else { | |
1066 // In single threaded mode, we can use the same context provider. | |
1067 shared_main_thread_contexts_ = | |
1068 static_cast<ContextProviderCommandBuffer*>( | |
1069 OffscreenCompositorContextProvider().get()); | |
1070 } | |
1071 } | 1033 } |
1072 if (shared_main_thread_contexts_ && | 1034 if (shared_main_thread_contexts_ && |
1073 !shared_main_thread_contexts_->BindToCurrentThread()) | 1035 !shared_main_thread_contexts_->BindToCurrentThread()) |
1074 shared_main_thread_contexts_ = NULL; | 1036 shared_main_thread_contexts_ = NULL; |
1075 return shared_main_thread_contexts_; | 1037 return shared_main_thread_contexts_; |
1076 } | 1038 } |
1077 | 1039 |
1078 AudioRendererMixerManager* RenderThreadImpl::GetAudioRendererMixerManager() { | 1040 AudioRendererMixerManager* RenderThreadImpl::GetAudioRendererMixerManager() { |
1079 if (!audio_renderer_mixer_manager_) { | 1041 if (!audio_renderer_mixer_manager_) { |
1080 audio_renderer_mixer_manager_.reset(new AudioRendererMixerManager( | 1042 audio_renderer_mixer_manager_.reset(new AudioRendererMixerManager( |
(...skipping 438 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1519 hidden_widget_count_--; | 1481 hidden_widget_count_--; |
1520 | 1482 |
1521 if (!GetContentClient()->renderer()->RunIdleHandlerWhenWidgetsHidden()) { | 1483 if (!GetContentClient()->renderer()->RunIdleHandlerWhenWidgetsHidden()) { |
1522 return; | 1484 return; |
1523 } | 1485 } |
1524 | 1486 |
1525 ScheduleIdleHandler(kLongIdleHandlerDelayMs); | 1487 ScheduleIdleHandler(kLongIdleHandlerDelayMs); |
1526 } | 1488 } |
1527 | 1489 |
1528 } // namespace content | 1490 } // namespace content |
OLD | NEW |