Chromium Code Reviews| 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; | |
| 957 bool must_use_synchronous_factory = false; | |
|
dshwang
2014/08/29 07:06:35
Introduce this local variable, because Android web
| |
| 956 #if defined(OS_ANDROID) | 958 #if defined(OS_ANDROID) |
| 957 if (SynchronousCompositorFactory* factory = | 959 if (SynchronousCompositorFactory* factory = |
| 958 SynchronousCompositorFactory::GetInstance()) { | 960 SynchronousCompositorFactory::GetInstance()) { |
| 959 return factory->CreateOffscreenGraphicsContext3D(attributes); | 961 context.reset(factory->CreateOffscreenGraphicsContext3D(attributes)); |
| 962 must_use_synchronous_factory = true; | |
| 960 } | 963 } |
| 961 #endif | 964 #endif |
| 965 if (!must_use_synchronous_factory) { | |
| 966 scoped_refptr<GpuChannelHost> gpu_channel_host( | |
| 967 RenderThreadImpl::current()->EstablishGpuChannelSync( | |
| 968 CAUSE_FOR_GPU_LAUNCH_WEBGRAPHICSCONTEXT3DCOMMANDBUFFERIMPL_INITIALIZ E)); | |
| 962 | 969 |
| 963 scoped_refptr<GpuChannelHost> gpu_channel_host( | 970 WebGraphicsContext3DCommandBufferImpl::SharedMemoryLimits limits; |
| 964 RenderThreadImpl::current()->EstablishGpuChannelSync( | 971 bool lose_context_when_out_of_memory = false; |
| 965 CAUSE_FOR_GPU_LAUNCH_WEBGRAPHICSCONTEXT3DCOMMANDBUFFERIMPL_INITIALIZE) ); | 972 context.reset(WebGraphicsContext3DCommandBufferImpl::CreateOffscreenContext( |
| 966 | 973 gpu_channel_host.get(), |
| 967 WebGraphicsContext3DCommandBufferImpl::SharedMemoryLimits limits; | 974 attributes, |
| 968 bool lose_context_when_out_of_memory = false; | 975 lose_context_when_out_of_memory, |
| 969 return WebGraphicsContext3DCommandBufferImpl::CreateOffscreenContext( | 976 GURL(attributes.topDocumentURL), |
| 970 gpu_channel_host.get(), | 977 limits, |
| 971 attributes, | 978 static_cast<WebGraphicsContext3DCommandBufferImpl*>(share_context))); |
| 972 lose_context_when_out_of_memory, | 979 } |
| 973 GURL(attributes.topDocumentURL), | 980 // Most likely the GPU process exited and the attempt to reconnect to it |
| 974 limits, | 981 // failed. Need to try to restore the context again later. |
| 975 static_cast<WebGraphicsContext3DCommandBufferImpl*>(share_context)); | 982 if (!context || !context->InitializeOnCurrentThread()) |
| 983 return NULL; | |
| 984 return context.release(); | |
| 976 } | 985 } |
| 977 | 986 |
| 978 //------------------------------------------------------------------------------ | 987 //------------------------------------------------------------------------------ |
| 979 | 988 |
| 980 blink::WebGraphicsContext3DProvider* RendererWebKitPlatformSupportImpl:: | 989 blink::WebGraphicsContext3DProvider* RendererWebKitPlatformSupportImpl:: |
| 981 createSharedOffscreenGraphicsContext3DProvider() { | 990 createSharedOffscreenGraphicsContext3DProvider() { |
| 982 scoped_refptr<webkit::gpu::ContextProviderWebContext> provider = | 991 scoped_refptr<webkit::gpu::ContextProviderWebContext> provider = |
| 983 RenderThreadImpl::current()->SharedMainThreadContextProvider(); | 992 RenderThreadImpl::current()->SharedMainThreadContextProvider(); |
| 984 if (!provider.get()) | 993 if (!provider.get()) |
| 985 return NULL; | 994 return NULL; |
| (...skipping 188 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 1174 void RendererWebKitPlatformSupportImpl::MockBatteryStatusChangedForTesting( | 1183 void RendererWebKitPlatformSupportImpl::MockBatteryStatusChangedForTesting( |
| 1175 const blink::WebBatteryStatus& status) { | 1184 const blink::WebBatteryStatus& status) { |
| 1176 PlatformEventObserverBase* observer = | 1185 PlatformEventObserverBase* observer = |
| 1177 platform_event_observers_.Lookup(blink::WebPlatformEventBattery); | 1186 platform_event_observers_.Lookup(blink::WebPlatformEventBattery); |
| 1178 if (!observer) | 1187 if (!observer) |
| 1179 return; | 1188 return; |
| 1180 observer->SendFakeDataForTesting((void*)&status); | 1189 observer->SendFakeDataForTesting((void*)&status); |
| 1181 } | 1190 } |
| 1182 | 1191 |
| 1183 } // namespace content | 1192 } // namespace content |
| OLD | NEW |