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/renderer_webkitplatformsupport_impl.h" | 5 #include "content/renderer/renderer_webkitplatformsupport_impl.h" |
6 | 6 |
7 #include "base/command_line.h" | 7 #include "base/command_line.h" |
8 #include "base/files/file_path.h" | 8 #include "base/files/file_path.h" |
9 #include "base/lazy_instance.h" | 9 #include "base/lazy_instance.h" |
10 #include "base/logging.h" | 10 #include "base/logging.h" |
(...skipping 935 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
946 return createOffscreenGraphicsContext3D(attributes, NULL); | 946 return createOffscreenGraphicsContext3D(attributes, NULL); |
947 } | 947 } |
948 | 948 |
949 blink::WebGraphicsContext3D* | 949 blink::WebGraphicsContext3D* |
950 RendererWebKitPlatformSupportImpl::createOffscreenGraphicsContext3D( | 950 RendererWebKitPlatformSupportImpl::createOffscreenGraphicsContext3D( |
951 const blink::WebGraphicsContext3D::Attributes& attributes, | 951 const blink::WebGraphicsContext3D::Attributes& attributes, |
952 blink::WebGraphicsContext3D* share_context) { | 952 blink::WebGraphicsContext3D* share_context) { |
953 if (!RenderThreadImpl::current()) | 953 if (!RenderThreadImpl::current()) |
954 return NULL; | 954 return NULL; |
955 | 955 |
956 scoped_ptr<webkit::gpu::WebGraphicsContext3DImpl> context; | |
956 #if defined(OS_ANDROID) | 957 #if defined(OS_ANDROID) |
957 if (SynchronousCompositorFactory* factory = | 958 if (SynchronousCompositorFactory* factory = |
958 SynchronousCompositorFactory::GetInstance()) { | 959 SynchronousCompositorFactory::GetInstance()) { |
959 return factory->CreateOffscreenGraphicsContext3D(attributes); | 960 context.reset(factory->CreateOffscreenGraphicsContext3D(attributes)); |
961 } else | |
962 #endif | |
piman
2014/08/28 18:13:02
nit: this is a little hard to read (the interactio
| |
963 { | |
964 scoped_refptr<GpuChannelHost> gpu_channel_host( | |
965 RenderThreadImpl::current()->EstablishGpuChannelSync( | |
966 CAUSE_FOR_GPU_LAUNCH_WEBGRAPHICSCONTEXT3DCOMMANDBUFFERIMPL_INITIALIZ E)); | |
967 | |
968 WebGraphicsContext3DCommandBufferImpl::SharedMemoryLimits limits; | |
969 bool lose_context_when_out_of_memory = false; | |
970 context.reset(WebGraphicsContext3DCommandBufferImpl::CreateOffscreenContext( | |
971 gpu_channel_host.get(), | |
972 attributes, | |
973 lose_context_when_out_of_memory, | |
974 GURL(attributes.topDocumentURL), | |
975 limits, | |
976 static_cast<WebGraphicsContext3DCommandBufferImpl*>(share_context))); | |
960 } | 977 } |
961 #endif | 978 // Most likely the GPU process exited and the attempt to reconnect to it |
962 | 979 // failed. Need to try to restore the context again later. |
963 scoped_refptr<GpuChannelHost> gpu_channel_host( | 980 if (!context || !context->InitializeOnCurrentThread()) |
964 RenderThreadImpl::current()->EstablishGpuChannelSync( | 981 return NULL; |
965 CAUSE_FOR_GPU_LAUNCH_WEBGRAPHICSCONTEXT3DCOMMANDBUFFERIMPL_INITIALIZE) ); | 982 return context.release(); |
966 | |
967 WebGraphicsContext3DCommandBufferImpl::SharedMemoryLimits limits; | |
968 bool lose_context_when_out_of_memory = false; | |
969 return WebGraphicsContext3DCommandBufferImpl::CreateOffscreenContext( | |
970 gpu_channel_host.get(), | |
971 attributes, | |
972 lose_context_when_out_of_memory, | |
973 GURL(attributes.topDocumentURL), | |
974 limits, | |
975 static_cast<WebGraphicsContext3DCommandBufferImpl*>(share_context)); | |
976 } | 983 } |
977 | 984 |
978 //------------------------------------------------------------------------------ | 985 //------------------------------------------------------------------------------ |
979 | 986 |
980 blink::WebGraphicsContext3DProvider* RendererWebKitPlatformSupportImpl:: | 987 blink::WebGraphicsContext3DProvider* RendererWebKitPlatformSupportImpl:: |
981 createSharedOffscreenGraphicsContext3DProvider() { | 988 createSharedOffscreenGraphicsContext3DProvider() { |
982 scoped_refptr<webkit::gpu::ContextProviderWebContext> provider = | 989 scoped_refptr<webkit::gpu::ContextProviderWebContext> provider = |
983 RenderThreadImpl::current()->SharedMainThreadContextProvider(); | 990 RenderThreadImpl::current()->SharedMainThreadContextProvider(); |
984 if (!provider.get()) | 991 if (!provider.get()) |
985 return NULL; | 992 return NULL; |
(...skipping 188 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
1174 void RendererWebKitPlatformSupportImpl::MockBatteryStatusChangedForTesting( | 1181 void RendererWebKitPlatformSupportImpl::MockBatteryStatusChangedForTesting( |
1175 const blink::WebBatteryStatus& status) { | 1182 const blink::WebBatteryStatus& status) { |
1176 PlatformEventObserverBase* observer = | 1183 PlatformEventObserverBase* observer = |
1177 platform_event_observers_.Lookup(blink::WebPlatformEventBattery); | 1184 platform_event_observers_.Lookup(blink::WebPlatformEventBattery); |
1178 if (!observer) | 1185 if (!observer) |
1179 return; | 1186 return; |
1180 observer->SendFakeDataForTesting((void*)&status); | 1187 observer->SendFakeDataForTesting((void*)&status); |
1181 } | 1188 } |
1182 | 1189 |
1183 } // namespace content | 1190 } // namespace content |
OLD | NEW |