| 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 63 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 74 #include "third_party/WebKit/public/platform/WebPluginListBuilder.h" | 74 #include "third_party/WebKit/public/platform/WebPluginListBuilder.h" |
| 75 #include "third_party/WebKit/public/platform/WebURL.h" | 75 #include "third_party/WebKit/public/platform/WebURL.h" |
| 76 #include "third_party/WebKit/public/platform/WebVector.h" | 76 #include "third_party/WebKit/public/platform/WebVector.h" |
| 77 #include "ui/gfx/color_profile.h" | 77 #include "ui/gfx/color_profile.h" |
| 78 #include "url/gurl.h" | 78 #include "url/gurl.h" |
| 79 #include "webkit/common/gpu/context_provider_web_context.h" | 79 #include "webkit/common/gpu/context_provider_web_context.h" |
| 80 | 80 |
| 81 #if defined(OS_ANDROID) | 81 #if defined(OS_ANDROID) |
| 82 #include "content/renderer/android/synchronous_compositor_factory.h" | 82 #include "content/renderer/android/synchronous_compositor_factory.h" |
| 83 #include "content/renderer/media/android/audio_decoder_android.h" | 83 #include "content/renderer/media/android/audio_decoder_android.h" |
| 84 #include "webkit/common/gpu/webgraphicscontext3d_in_process_command_buffer_impl.
h" |
| 84 #endif | 85 #endif |
| 85 | 86 |
| 86 #if defined(OS_MACOSX) | 87 #if defined(OS_MACOSX) |
| 87 #include "content/common/mac/font_descriptor.h" | 88 #include "content/common/mac/font_descriptor.h" |
| 88 #include "content/common/mac/font_loader.h" | 89 #include "content/common/mac/font_loader.h" |
| 89 #include "content/renderer/webscrollbarbehavior_impl_mac.h" | 90 #include "content/renderer/webscrollbarbehavior_impl_mac.h" |
| 90 #include "third_party/WebKit/public/platform/mac/WebSandboxSupport.h" | 91 #include "third_party/WebKit/public/platform/mac/WebSandboxSupport.h" |
| 91 #endif | 92 #endif |
| 92 | 93 |
| 93 #if defined(OS_POSIX) | 94 #if defined(OS_POSIX) |
| (...skipping 851 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 945 return createOffscreenGraphicsContext3D(attributes, NULL); | 946 return createOffscreenGraphicsContext3D(attributes, NULL); |
| 946 } | 947 } |
| 947 | 948 |
| 948 blink::WebGraphicsContext3D* | 949 blink::WebGraphicsContext3D* |
| 949 RendererWebKitPlatformSupportImpl::createOffscreenGraphicsContext3D( | 950 RendererWebKitPlatformSupportImpl::createOffscreenGraphicsContext3D( |
| 950 const blink::WebGraphicsContext3D::Attributes& attributes, | 951 const blink::WebGraphicsContext3D::Attributes& attributes, |
| 951 blink::WebGraphicsContext3D* share_context) { | 952 blink::WebGraphicsContext3D* share_context) { |
| 952 if (!RenderThreadImpl::current()) | 953 if (!RenderThreadImpl::current()) |
| 953 return NULL; | 954 return NULL; |
| 954 | 955 |
| 955 scoped_ptr<webkit::gpu::WebGraphicsContext3DImpl> context; | |
| 956 bool must_use_synchronous_factory = false; | |
| 957 #if defined(OS_ANDROID) | 956 #if defined(OS_ANDROID) |
| 958 if (SynchronousCompositorFactory* factory = | 957 if (SynchronousCompositorFactory* factory = |
| 959 SynchronousCompositorFactory::GetInstance()) { | 958 SynchronousCompositorFactory::GetInstance()) { |
| 960 context.reset(factory->CreateOffscreenGraphicsContext3D(attributes)); | 959 scoped_ptr<webkit::gpu::WebGraphicsContext3DInProcessCommandBufferImpl> |
| 961 must_use_synchronous_factory = true; | 960 in_process_context( |
| 961 factory->CreateOffscreenGraphicsContext3D(attributes)); |
| 962 if (!in_process_context || |
| 963 !in_process_context->InitializeOnCurrentThread()) |
| 964 return NULL; |
| 965 return in_process_context.release(); |
| 962 } | 966 } |
| 963 #endif | 967 #endif |
| 964 if (!must_use_synchronous_factory) { | |
| 965 scoped_refptr<GpuChannelHost> gpu_channel_host( | |
| 966 RenderThreadImpl::current()->EstablishGpuChannelSync( | |
| 967 CAUSE_FOR_GPU_LAUNCH_WEBGRAPHICSCONTEXT3DCOMMANDBUFFERIMPL_INITIALIZ
E)); | |
| 968 | 968 |
| 969 WebGraphicsContext3DCommandBufferImpl::SharedMemoryLimits limits; | 969 scoped_refptr<GpuChannelHost> gpu_channel_host( |
| 970 bool lose_context_when_out_of_memory = false; | 970 RenderThreadImpl::current()->EstablishGpuChannelSync( |
| 971 context.reset(WebGraphicsContext3DCommandBufferImpl::CreateOffscreenContext( | 971 CAUSE_FOR_GPU_LAUNCH_WEBGRAPHICSCONTEXT3DCOMMANDBUFFERIMPL_INITIALIZE)
); |
| 972 gpu_channel_host.get(), | 972 |
| 973 attributes, | 973 WebGraphicsContext3DCommandBufferImpl::SharedMemoryLimits limits; |
| 974 lose_context_when_out_of_memory, | 974 bool lose_context_when_out_of_memory = false; |
| 975 GURL(attributes.topDocumentURL), | 975 scoped_ptr<WebGraphicsContext3DCommandBufferImpl> context( |
| 976 limits, | 976 WebGraphicsContext3DCommandBufferImpl::CreateOffscreenContext( |
| 977 static_cast<WebGraphicsContext3DCommandBufferImpl*>(share_context))); | 977 gpu_channel_host.get(), |
| 978 } | 978 attributes, |
| 979 lose_context_when_out_of_memory, |
| 980 GURL(attributes.topDocumentURL), |
| 981 limits, |
| 982 static_cast<WebGraphicsContext3DCommandBufferImpl*>(share_context))); |
| 983 |
| 979 // Most likely the GPU process exited and the attempt to reconnect to it | 984 // Most likely the GPU process exited and the attempt to reconnect to it |
| 980 // failed. Need to try to restore the context again later. | 985 // failed. Need to try to restore the context again later. |
| 981 if (!context || !context->InitializeOnCurrentThread()) | 986 if (!context || !context->InitializeOnCurrentThread()) |
| 982 return NULL; | 987 return NULL; |
| 983 return context.release(); | 988 return context.release(); |
| 984 } | 989 } |
| 985 | 990 |
| 986 //------------------------------------------------------------------------------ | 991 //------------------------------------------------------------------------------ |
| 987 | 992 |
| 988 blink::WebGraphicsContext3DProvider* RendererWebKitPlatformSupportImpl:: | 993 blink::WebGraphicsContext3DProvider* RendererWebKitPlatformSupportImpl:: |
| 989 createSharedOffscreenGraphicsContext3DProvider() { | 994 createSharedOffscreenGraphicsContext3DProvider() { |
| 990 scoped_refptr<webkit::gpu::ContextProviderWebContext> provider = | 995 scoped_refptr<webkit::gpu::ContextProviderWebContext> provider = |
| 991 RenderThreadImpl::current()->SharedMainThreadContextProvider(); | 996 RenderThreadImpl::current()->SharedMainThreadContextProvider(); |
| 992 if (!provider.get()) | 997 if (!provider.get()) |
| (...skipping 189 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1182 void RendererWebKitPlatformSupportImpl::MockBatteryStatusChangedForTesting( | 1187 void RendererWebKitPlatformSupportImpl::MockBatteryStatusChangedForTesting( |
| 1183 const blink::WebBatteryStatus& status) { | 1188 const blink::WebBatteryStatus& status) { |
| 1184 PlatformEventObserverBase* observer = | 1189 PlatformEventObserverBase* observer = |
| 1185 platform_event_observers_.Lookup(blink::WebPlatformEventBattery); | 1190 platform_event_observers_.Lookup(blink::WebPlatformEventBattery); |
| 1186 if (!observer) | 1191 if (!observer) |
| 1187 return; | 1192 return; |
| 1188 observer->SendFakeDataForTesting((void*)&status); | 1193 observer->SendFakeDataForTesting((void*)&status); |
| 1189 } | 1194 } |
| 1190 | 1195 |
| 1191 } // namespace content | 1196 } // namespace content |
| OLD | NEW |