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 966 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
977 scoped_refptr<media::GpuVideoAcceleratorFactories> gpu_factories; | 977 scoped_refptr<media::GpuVideoAcceleratorFactories> gpu_factories; |
978 scoped_refptr<base::MessageLoopProxy> media_loop_proxy = | 978 scoped_refptr<base::MessageLoopProxy> media_loop_proxy = |
979 GetMediaThreadMessageLoopProxy(); | 979 GetMediaThreadMessageLoopProxy(); |
980 if (!cmd_line->HasSwitch(switches::kDisableAcceleratedVideoDecode)) { | 980 if (!cmd_line->HasSwitch(switches::kDisableAcceleratedVideoDecode)) { |
981 if (!gpu_va_context_provider_ || | 981 if (!gpu_va_context_provider_ || |
982 gpu_va_context_provider_->DestroyedOnMainThread()) { | 982 gpu_va_context_provider_->DestroyedOnMainThread()) { |
983 if (!gpu_channel_host) { | 983 if (!gpu_channel_host) { |
984 gpu_channel_host = EstablishGpuChannelSync( | 984 gpu_channel_host = EstablishGpuChannelSync( |
985 CAUSE_FOR_GPU_LAUNCH_WEBGRAPHICSCONTEXT3DCOMMANDBUFFERIMPL_INITIALIZ
E); | 985 CAUSE_FOR_GPU_LAUNCH_WEBGRAPHICSCONTEXT3DCOMMANDBUFFERIMPL_INITIALIZ
E); |
986 } | 986 } |
| 987 blink::WebGraphicsContext3D::Attributes attributes; |
| 988 bool lose_context_when_out_of_memory = false; |
987 gpu_va_context_provider_ = ContextProviderCommandBuffer::Create( | 989 gpu_va_context_provider_ = ContextProviderCommandBuffer::Create( |
988 make_scoped_ptr( | 990 make_scoped_ptr( |
989 WebGraphicsContext3DCommandBufferImpl::CreateOffscreenContext( | 991 WebGraphicsContext3DCommandBufferImpl::CreateOffscreenContext( |
990 gpu_channel_host.get(), | 992 gpu_channel_host.get(), |
991 blink::WebGraphicsContext3D::Attributes(), | 993 attributes, |
| 994 lose_context_when_out_of_memory, |
992 GURL("chrome://gpu/RenderThreadImpl::GetGpuVDAContext3D"), | 995 GURL("chrome://gpu/RenderThreadImpl::GetGpuVDAContext3D"), |
993 WebGraphicsContext3DCommandBufferImpl::SharedMemoryLimits(), | 996 WebGraphicsContext3DCommandBufferImpl::SharedMemoryLimits(), |
994 NULL)), | 997 NULL)), |
995 "GPU-VideoAccelerator-Offscreen"); | 998 "GPU-VideoAccelerator-Offscreen"); |
996 } | 999 } |
997 } | 1000 } |
998 if (gpu_va_context_provider_) { | 1001 if (gpu_va_context_provider_) { |
999 gpu_factories = RendererGpuVideoAcceleratorFactories::Create( | 1002 gpu_factories = RendererGpuVideoAcceleratorFactories::Create( |
1000 gpu_channel_host, media_loop_proxy, gpu_va_context_provider_); | 1003 gpu_channel_host, media_loop_proxy, gpu_va_context_provider_); |
1001 } | 1004 } |
1002 return gpu_factories; | 1005 return gpu_factories; |
1003 } | 1006 } |
1004 | 1007 |
1005 scoped_ptr<WebGraphicsContext3DCommandBufferImpl> | 1008 scoped_ptr<WebGraphicsContext3DCommandBufferImpl> |
1006 RenderThreadImpl::CreateOffscreenContext3d() { | 1009 RenderThreadImpl::CreateOffscreenContext3d() { |
1007 blink::WebGraphicsContext3D::Attributes attributes; | 1010 blink::WebGraphicsContext3D::Attributes attributes; |
1008 attributes.shareResources = true; | 1011 attributes.shareResources = true; |
1009 attributes.depth = false; | 1012 attributes.depth = false; |
1010 attributes.stencil = false; | 1013 attributes.stencil = false; |
1011 attributes.antialias = false; | 1014 attributes.antialias = false; |
1012 attributes.noAutomaticFlushes = true; | 1015 attributes.noAutomaticFlushes = true; |
| 1016 bool lose_context_when_out_of_memory = true; |
1013 | 1017 |
1014 scoped_refptr<GpuChannelHost> gpu_channel_host(EstablishGpuChannelSync( | 1018 scoped_refptr<GpuChannelHost> gpu_channel_host(EstablishGpuChannelSync( |
1015 CAUSE_FOR_GPU_LAUNCH_WEBGRAPHICSCONTEXT3DCOMMANDBUFFERIMPL_INITIALIZE)); | 1019 CAUSE_FOR_GPU_LAUNCH_WEBGRAPHICSCONTEXT3DCOMMANDBUFFERIMPL_INITIALIZE)); |
1016 return make_scoped_ptr( | 1020 return make_scoped_ptr( |
1017 WebGraphicsContext3DCommandBufferImpl::CreateOffscreenContext( | 1021 WebGraphicsContext3DCommandBufferImpl::CreateOffscreenContext( |
1018 gpu_channel_host.get(), | 1022 gpu_channel_host.get(), |
1019 attributes, | 1023 attributes, |
| 1024 lose_context_when_out_of_memory, |
1020 GURL("chrome://gpu/RenderThreadImpl::CreateOffscreenContext3d"), | 1025 GURL("chrome://gpu/RenderThreadImpl::CreateOffscreenContext3d"), |
1021 WebGraphicsContext3DCommandBufferImpl::SharedMemoryLimits(), | 1026 WebGraphicsContext3DCommandBufferImpl::SharedMemoryLimits(), |
1022 NULL)); | 1027 NULL)); |
1023 } | 1028 } |
1024 | 1029 |
1025 scoped_refptr<cc::ContextProvider> | 1030 scoped_refptr<cc::ContextProvider> |
1026 RenderThreadImpl::OffscreenCompositorContextProvider() { | 1031 RenderThreadImpl::OffscreenCompositorContextProvider() { |
1027 DCHECK(IsMainThread()); | 1032 DCHECK(IsMainThread()); |
1028 | 1033 |
1029 #if defined(OS_ANDROID) | 1034 #if defined(OS_ANDROID) |
(...skipping 483 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1513 hidden_widget_count_--; | 1518 hidden_widget_count_--; |
1514 | 1519 |
1515 if (!GetContentClient()->renderer()->RunIdleHandlerWhenWidgetsHidden()) { | 1520 if (!GetContentClient()->renderer()->RunIdleHandlerWhenWidgetsHidden()) { |
1516 return; | 1521 return; |
1517 } | 1522 } |
1518 | 1523 |
1519 ScheduleIdleHandler(kLongIdleHandlerDelayMs); | 1524 ScheduleIdleHandler(kLongIdleHandlerDelayMs); |
1520 } | 1525 } |
1521 | 1526 |
1522 } // namespace content | 1527 } // namespace content |
OLD | NEW |