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 1094 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1105 scoped_refptr<media::GpuVideoAcceleratorFactories> | 1105 scoped_refptr<media::GpuVideoAcceleratorFactories> |
1106 RenderThreadImpl::GetGpuFactories() { | 1106 RenderThreadImpl::GetGpuFactories() { |
1107 DCHECK(IsMainThread()); | 1107 DCHECK(IsMainThread()); |
1108 | 1108 |
1109 scoped_refptr<GpuChannelHost> gpu_channel_host = GetGpuChannel(); | 1109 scoped_refptr<GpuChannelHost> gpu_channel_host = GetGpuChannel(); |
1110 const CommandLine* cmd_line = CommandLine::ForCurrentProcess(); | 1110 const CommandLine* cmd_line = CommandLine::ForCurrentProcess(); |
1111 scoped_refptr<media::GpuVideoAcceleratorFactories> gpu_factories; | 1111 scoped_refptr<media::GpuVideoAcceleratorFactories> gpu_factories; |
1112 scoped_refptr<base::MessageLoopProxy> media_loop_proxy = | 1112 scoped_refptr<base::MessageLoopProxy> media_loop_proxy = |
1113 GetMediaThreadMessageLoopProxy(); | 1113 GetMediaThreadMessageLoopProxy(); |
1114 if (!cmd_line->HasSwitch(switches::kDisableAcceleratedVideoDecode)) { | 1114 if (!cmd_line->HasSwitch(switches::kDisableAcceleratedVideoDecode)) { |
1115 if (!gpu_va_context_provider_ || | 1115 if (!gpu_va_context_provider_.get() || |
1116 gpu_va_context_provider_->DestroyedOnMainThread()) { | 1116 gpu_va_context_provider_->DestroyedOnMainThread()) { |
1117 if (!gpu_channel_host) { | 1117 if (!gpu_channel_host.get()) { |
1118 gpu_channel_host = EstablishGpuChannelSync( | 1118 gpu_channel_host = EstablishGpuChannelSync( |
1119 CAUSE_FOR_GPU_LAUNCH_WEBGRAPHICSCONTEXT3DCOMMANDBUFFERIMPL_INITIALIZ
E); | 1119 CAUSE_FOR_GPU_LAUNCH_WEBGRAPHICSCONTEXT3DCOMMANDBUFFERIMPL_INITIALIZ
E); |
1120 } | 1120 } |
1121 blink::WebGraphicsContext3D::Attributes attributes; | 1121 blink::WebGraphicsContext3D::Attributes attributes; |
1122 bool lose_context_when_out_of_memory = false; | 1122 bool lose_context_when_out_of_memory = false; |
1123 gpu_va_context_provider_ = ContextProviderCommandBuffer::Create( | 1123 gpu_va_context_provider_ = ContextProviderCommandBuffer::Create( |
1124 make_scoped_ptr( | 1124 make_scoped_ptr( |
1125 WebGraphicsContext3DCommandBufferImpl::CreateOffscreenContext( | 1125 WebGraphicsContext3DCommandBufferImpl::CreateOffscreenContext( |
1126 gpu_channel_host.get(), | 1126 gpu_channel_host.get(), |
1127 attributes, | 1127 attributes, |
1128 lose_context_when_out_of_memory, | 1128 lose_context_when_out_of_memory, |
1129 GURL("chrome://gpu/RenderThreadImpl::GetGpuVDAContext3D"), | 1129 GURL("chrome://gpu/RenderThreadImpl::GetGpuVDAContext3D"), |
1130 WebGraphicsContext3DCommandBufferImpl::SharedMemoryLimits(), | 1130 WebGraphicsContext3DCommandBufferImpl::SharedMemoryLimits(), |
1131 NULL)), | 1131 NULL)), |
1132 "GPU-VideoAccelerator-Offscreen"); | 1132 "GPU-VideoAccelerator-Offscreen"); |
1133 } | 1133 } |
1134 } | 1134 } |
1135 if (gpu_va_context_provider_) { | 1135 if (gpu_va_context_provider_.get()) { |
1136 gpu_factories = RendererGpuVideoAcceleratorFactories::Create( | 1136 gpu_factories = RendererGpuVideoAcceleratorFactories::Create( |
1137 gpu_channel_host, media_loop_proxy, gpu_va_context_provider_); | 1137 gpu_channel_host.get(), media_loop_proxy, gpu_va_context_provider_); |
1138 } | 1138 } |
1139 return gpu_factories; | 1139 return gpu_factories; |
1140 } | 1140 } |
1141 | 1141 |
1142 scoped_ptr<WebGraphicsContext3DCommandBufferImpl> | 1142 scoped_ptr<WebGraphicsContext3DCommandBufferImpl> |
1143 RenderThreadImpl::CreateOffscreenContext3d() { | 1143 RenderThreadImpl::CreateOffscreenContext3d() { |
1144 blink::WebGraphicsContext3D::Attributes attributes(GetOffscreenAttribs()); | 1144 blink::WebGraphicsContext3D::Attributes attributes(GetOffscreenAttribs()); |
1145 bool lose_context_when_out_of_memory = true; | 1145 bool lose_context_when_out_of_memory = true; |
1146 | 1146 |
1147 scoped_refptr<GpuChannelHost> gpu_channel_host(EstablishGpuChannelSync( | 1147 scoped_refptr<GpuChannelHost> gpu_channel_host(EstablishGpuChannelSync( |
1148 CAUSE_FOR_GPU_LAUNCH_WEBGRAPHICSCONTEXT3DCOMMANDBUFFERIMPL_INITIALIZE)); | 1148 CAUSE_FOR_GPU_LAUNCH_WEBGRAPHICSCONTEXT3DCOMMANDBUFFERIMPL_INITIALIZE)); |
1149 return make_scoped_ptr( | 1149 return make_scoped_ptr( |
1150 WebGraphicsContext3DCommandBufferImpl::CreateOffscreenContext( | 1150 WebGraphicsContext3DCommandBufferImpl::CreateOffscreenContext( |
1151 gpu_channel_host.get(), | 1151 gpu_channel_host.get(), |
1152 attributes, | 1152 attributes, |
1153 lose_context_when_out_of_memory, | 1153 lose_context_when_out_of_memory, |
1154 GURL("chrome://gpu/RenderThreadImpl::CreateOffscreenContext3d"), | 1154 GURL("chrome://gpu/RenderThreadImpl::CreateOffscreenContext3d"), |
1155 WebGraphicsContext3DCommandBufferImpl::SharedMemoryLimits(), | 1155 WebGraphicsContext3DCommandBufferImpl::SharedMemoryLimits(), |
1156 NULL)); | 1156 NULL)); |
1157 } | 1157 } |
1158 | 1158 |
1159 scoped_refptr<webkit::gpu::ContextProviderWebContext> | 1159 scoped_refptr<webkit::gpu::ContextProviderWebContext> |
1160 RenderThreadImpl::SharedMainThreadContextProvider() { | 1160 RenderThreadImpl::SharedMainThreadContextProvider() { |
1161 DCHECK(IsMainThread()); | 1161 DCHECK(IsMainThread()); |
1162 if (!shared_main_thread_contexts_ || | 1162 if (!shared_main_thread_contexts_.get() || |
1163 shared_main_thread_contexts_->DestroyedOnMainThread()) { | 1163 shared_main_thread_contexts_->DestroyedOnMainThread()) { |
1164 shared_main_thread_contexts_ = NULL; | 1164 shared_main_thread_contexts_ = NULL; |
1165 #if defined(OS_ANDROID) | 1165 #if defined(OS_ANDROID) |
1166 if (SynchronousCompositorFactory* factory = | 1166 if (SynchronousCompositorFactory* factory = |
1167 SynchronousCompositorFactory::GetInstance()) { | 1167 SynchronousCompositorFactory::GetInstance()) { |
1168 shared_main_thread_contexts_ = factory->CreateOffscreenContextProvider( | 1168 shared_main_thread_contexts_ = factory->CreateOffscreenContextProvider( |
1169 GetOffscreenAttribs(), "Offscreen-MainThread"); | 1169 GetOffscreenAttribs(), "Offscreen-MainThread"); |
1170 } | 1170 } |
1171 #endif | 1171 #endif |
1172 if (!shared_main_thread_contexts_) { | 1172 if (!shared_main_thread_contexts_.get()) { |
1173 shared_main_thread_contexts_ = ContextProviderCommandBuffer::Create( | 1173 shared_main_thread_contexts_ = ContextProviderCommandBuffer::Create( |
1174 CreateOffscreenContext3d(), "Offscreen-MainThread"); | 1174 CreateOffscreenContext3d(), "Offscreen-MainThread"); |
1175 } | 1175 } |
1176 if (shared_main_thread_contexts_ && | 1176 if (shared_main_thread_contexts_.get() && |
1177 !shared_main_thread_contexts_->BindToCurrentThread()) | 1177 !shared_main_thread_contexts_->BindToCurrentThread()) |
1178 shared_main_thread_contexts_ = NULL; | 1178 shared_main_thread_contexts_ = NULL; |
1179 } | 1179 } |
1180 return shared_main_thread_contexts_; | 1180 return shared_main_thread_contexts_; |
1181 } | 1181 } |
1182 | 1182 |
1183 AudioRendererMixerManager* RenderThreadImpl::GetAudioRendererMixerManager() { | 1183 AudioRendererMixerManager* RenderThreadImpl::GetAudioRendererMixerManager() { |
1184 if (!audio_renderer_mixer_manager_) { | 1184 if (!audio_renderer_mixer_manager_) { |
1185 audio_renderer_mixer_manager_.reset(new AudioRendererMixerManager( | 1185 audio_renderer_mixer_manager_.reset(new AudioRendererMixerManager( |
1186 GetAudioHardwareConfig())); | 1186 GetAudioHardwareConfig())); |
(...skipping 458 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1645 hidden_widget_count_--; | 1645 hidden_widget_count_--; |
1646 | 1646 |
1647 if (!GetContentClient()->renderer()->RunIdleHandlerWhenWidgetsHidden()) { | 1647 if (!GetContentClient()->renderer()->RunIdleHandlerWhenWidgetsHidden()) { |
1648 return; | 1648 return; |
1649 } | 1649 } |
1650 | 1650 |
1651 ScheduleIdleHandler(kLongIdleHandlerDelayMs); | 1651 ScheduleIdleHandler(kLongIdleHandlerDelayMs); |
1652 } | 1652 } |
1653 | 1653 |
1654 } // namespace content | 1654 } // namespace content |
OLD | NEW |