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_blink_platform_impl.h" | 5 #include "content/renderer/renderer_blink_platform_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/location.h" | 10 #include "base/location.h" |
(...skipping 958 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
969 return createOffscreenGraphicsContext3D(attributes, NULL); | 969 return createOffscreenGraphicsContext3D(attributes, NULL); |
970 } | 970 } |
971 | 971 |
972 blink::WebGraphicsContext3D* | 972 blink::WebGraphicsContext3D* |
973 RendererBlinkPlatformImpl::createOffscreenGraphicsContext3D( | 973 RendererBlinkPlatformImpl::createOffscreenGraphicsContext3D( |
974 const blink::WebGraphicsContext3D::Attributes& attributes, | 974 const blink::WebGraphicsContext3D::Attributes& attributes, |
975 blink::WebGraphicsContext3D* share_context) { | 975 blink::WebGraphicsContext3D* share_context) { |
976 return createOffscreenGraphicsContext3D(attributes, share_context, NULL); | 976 return createOffscreenGraphicsContext3D(attributes, share_context, NULL); |
977 } | 977 } |
978 | 978 |
979 static void collectGpuInformationOnFailure( | |
980 GpuChannelHost* host, | |
981 blink::WebGraphicsContext3D* share_context, | |
982 blink::WebGraphicsContext3D::WebGraphicsContext3DInfo* gl_info) { | |
983 if (!gl_info) | |
984 return; | |
985 std::string errorMessage("OffscreenContext Creation failed, "); | |
986 if (!host) { | |
987 errorMessage.append("GpuChannelHost creation failed"); | |
988 gl_info->errorMessage = WebString::fromUTF8(errorMessage); | |
989 return; | |
990 } | |
991 if (!share_context) { | |
992 errorMessage.append("WebGraphicsContext3D shared context is NULL"); | |
993 gl_info->errorMessage = WebString::fromUTF8(errorMessage); | |
994 } | |
995 const gpu::GPUInfo& gpu_info = host->gpu_info(); | |
996 gl_info->vendorId = gpu_info.gpu.vendor_id; | |
997 gl_info->deviceId = gpu_info.gpu.device_id; | |
998 switch (gpu_info.context_info_state) { | |
999 case gpu::kCollectInfoSuccess: | |
1000 case gpu::kCollectInfoNonFatalFailure: | |
1001 gl_info->rendererInfo = WebString::fromUTF8(gpu_info.gl_renderer); | |
1002 gl_info->vendorInfo = WebString::fromUTF8(gpu_info.gl_vendor); | |
1003 gl_info->driverVersion = WebString::fromUTF8(gpu_info.driver_version); | |
1004 gl_info->resetNotificationStrategy = | |
1005 gpu_info.gl_reset_notification_strategy; | |
1006 gl_info->sandboxed = gpu_info.sandboxed; | |
1007 gl_info->processCrashCount = gpu_info.process_crash_count; | |
1008 if (gpu_info.display_link_version.IsValid()) | |
1009 gl_info->displayLinkVersion = | |
1010 WebString::fromUTF8(gpu_info.display_link_version.GetString()); | |
1011 gl_info->lenovoDcute = gpu_info.lenovo_dcute; | |
1012 gl_info->amdSwitchable = gpu_info.amd_switchable; | |
1013 gl_info->optimus = gpu_info.optimus; | |
1014 break; | |
1015 case gpu::kCollectInfoFatalFailure: | |
1016 case gpu::kCollectInfoNone: | |
1017 errorMessage.append( | |
1018 "Failed to collect gpu information, GLSurface or GLContext " | |
1019 "creation " | |
1020 "failed"); | |
Ken Russell (switch to Gerrit)
2015/10/12 23:52:42
Please combine this and the previous line.
sivag
2015/10/15 17:16:38
Done.
| |
1021 gl_info->errorMessage = WebString::fromUTF8(errorMessage); | |
1022 break; | |
1023 default: | |
1024 NOTREACHED(); | |
1025 } | |
1026 } | |
1027 | |
979 blink::WebGraphicsContext3D* | 1028 blink::WebGraphicsContext3D* |
980 RendererBlinkPlatformImpl::createOffscreenGraphicsContext3D( | 1029 RendererBlinkPlatformImpl::createOffscreenGraphicsContext3D( |
981 const blink::WebGraphicsContext3D::Attributes& attributes, | 1030 const blink::WebGraphicsContext3D::Attributes& attributes, |
982 blink::WebGraphicsContext3D* share_context, | 1031 blink::WebGraphicsContext3D* share_context, |
983 blink::WebGLInfo* gl_info) { | 1032 blink::WebGraphicsContext3D::WebGraphicsContext3DInfo* gl_info) { |
984 if (!RenderThreadImpl::current()) | 1033 if (!RenderThreadImpl::current()) { |
1034 std::string errorMessage("Failed to run in Current RenderThreadImpl"); | |
1035 gl_info->errorMessage = WebString::fromUTF8(errorMessage); | |
985 return NULL; | 1036 return NULL; |
1037 } | |
986 | 1038 |
987 scoped_refptr<GpuChannelHost> gpu_channel_host( | 1039 scoped_refptr<GpuChannelHost> gpu_channel_host( |
988 RenderThreadImpl::current()->EstablishGpuChannelSync( | 1040 RenderThreadImpl::current()->EstablishGpuChannelSync( |
989 CAUSE_FOR_GPU_LAUNCH_WEBGRAPHICSCONTEXT3DCOMMANDBUFFERIMPL_INITIALIZE) ); | 1041 CAUSE_FOR_GPU_LAUNCH_WEBGRAPHICSCONTEXT3DCOMMANDBUFFERIMPL_INITIALIZE) ); |
990 | 1042 |
991 if (gpu_channel_host.get() && gl_info) { | |
992 const gpu::GPUInfo& gpu_info = gpu_channel_host->gpu_info(); | |
993 switch (gpu_info.context_info_state) { | |
994 case gpu::kCollectInfoSuccess: | |
995 case gpu::kCollectInfoNonFatalFailure: | |
996 gl_info->vendorInfo.assign( | |
997 blink::WebString::fromUTF8(gpu_info.gl_vendor)); | |
998 gl_info->rendererInfo.assign( | |
999 blink::WebString::fromUTF8(gpu_info.gl_renderer)); | |
1000 gl_info->driverVersion.assign( | |
1001 blink::WebString::fromUTF8(gpu_info.driver_version)); | |
1002 gl_info->vendorId = gpu_info.gpu.vendor_id; | |
1003 gl_info->deviceId = gpu_info.gpu.device_id; | |
1004 break; | |
1005 case gpu::kCollectInfoFatalFailure: | |
1006 case gpu::kCollectInfoNone: | |
1007 gl_info->contextInfoCollectionFailure.assign(blink::WebString::fromUTF8( | |
1008 "GPUInfoCollectionFailure: GPU initialization Failed. GPU " | |
1009 "Info not Collected.")); | |
1010 break; | |
1011 default: | |
1012 NOTREACHED(); | |
1013 } | |
1014 } | |
1015 | |
1016 WebGraphicsContext3DCommandBufferImpl::SharedMemoryLimits limits; | 1043 WebGraphicsContext3DCommandBufferImpl::SharedMemoryLimits limits; |
1017 bool lose_context_when_out_of_memory = false; | 1044 bool lose_context_when_out_of_memory = false; |
1018 scoped_ptr<WebGraphicsContext3DCommandBufferImpl> context( | 1045 scoped_ptr<WebGraphicsContext3DCommandBufferImpl> context( |
1019 WebGraphicsContext3DCommandBufferImpl::CreateOffscreenContext( | 1046 WebGraphicsContext3DCommandBufferImpl::CreateOffscreenContext( |
1020 gpu_channel_host.get(), | 1047 gpu_channel_host.get(), |
1021 attributes, | 1048 attributes, |
1022 lose_context_when_out_of_memory, | 1049 lose_context_when_out_of_memory, |
1023 GURL(attributes.topDocumentURL), | 1050 GURL(attributes.topDocumentURL), |
1024 limits, | 1051 limits, |
1025 static_cast<WebGraphicsContext3DCommandBufferImpl*>(share_context))); | 1052 static_cast<WebGraphicsContext3DCommandBufferImpl*>(share_context))); |
1026 | 1053 |
1027 // Most likely the GPU process exited and the attempt to reconnect to it | 1054 // Most likely the GPU process exited and the attempt to reconnect to it |
1028 // failed. Need to try to restore the context again later. | 1055 // failed. Need to try to restore the context again later. |
1029 if (!context || !context->InitializeOnCurrentThread()) | 1056 if (!context || !context->InitializeOnCurrentThread() || |
1030 return NULL; | 1057 gl_info->testFailContext) { |
1058 collectGpuInformationOnFailure(gpu_channel_host.get(), share_context, | |
1059 gl_info); | |
1060 return NULL; | |
1061 } | |
1031 return context.release(); | 1062 return context.release(); |
1032 } | 1063 } |
1033 | 1064 |
1034 //------------------------------------------------------------------------------ | 1065 //------------------------------------------------------------------------------ |
1035 | 1066 |
1036 blink::WebGraphicsContext3DProvider* | 1067 blink::WebGraphicsContext3DProvider* |
1037 RendererBlinkPlatformImpl::createSharedOffscreenGraphicsContext3DProvider() { | 1068 RendererBlinkPlatformImpl::createSharedOffscreenGraphicsContext3DProvider() { |
1038 scoped_refptr<cc_blink::ContextProviderWebContext> provider = | 1069 scoped_refptr<cc_blink::ContextProviderWebContext> provider = |
1039 RenderThreadImpl::current()->SharedMainThreadContextProvider(); | 1070 RenderThreadImpl::current()->SharedMainThreadContextProvider(); |
1040 if (!provider.get()) | 1071 if (!provider.get()) |
(...skipping 220 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
1261 //------------------------------------------------------------------------------ | 1292 //------------------------------------------------------------------------------ |
1262 | 1293 |
1263 void RendererBlinkPlatformImpl::MockBatteryStatusChangedForTesting( | 1294 void RendererBlinkPlatformImpl::MockBatteryStatusChangedForTesting( |
1264 const blink::WebBatteryStatus& status) { | 1295 const blink::WebBatteryStatus& status) { |
1265 if (!g_test_battery_status_listener) | 1296 if (!g_test_battery_status_listener) |
1266 return; | 1297 return; |
1267 g_test_battery_status_listener->updateBatteryStatus(status); | 1298 g_test_battery_status_listener->updateBatteryStatus(status); |
1268 } | 1299 } |
1269 | 1300 |
1270 } // namespace content | 1301 } // namespace content |
OLD | NEW |