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 collect3DContextInformationOnFailure( | |
piman
2015/10/20 01:45:04
nit: this is chromium code, please use chromium st
sivag
2015/10/20 10:14:41
Done.
sivag
2015/10/20 10:14:41
Done.
| |
980 blink::WebGraphicsContext3D* share_context, | |
981 blink::WebGraphicsContext3D::WebGraphicsInfo* gl_info, | |
982 GpuChannelHost* host) { | |
983 if (!gl_info) | |
984 return; | |
Zhenyao Mo
2015/10/19 17:44:48
nit: maybe DCHECK(gl_info)? because caller makes s
sivag
2015/10/20 10:14:41
Done.
| |
985 std::string errorMessage("OffscreenContext Creation failed, "); | |
piman
2015/10/20 01:45:04
nit: Chromium style (error_message)
sivag
2015/10/20 10:14:41
Done.
| |
986 if (host) { | |
987 const gpu::GPUInfo& gpu_info = host->gpu_info(); | |
988 gl_info->vendorId = gpu_info.gpu.vendor_id; | |
989 gl_info->deviceId = gpu_info.gpu.device_id; | |
990 switch (gpu_info.context_info_state) { | |
991 case gpu::kCollectInfoSuccess: | |
992 case gpu::kCollectInfoNonFatalFailure: | |
993 gl_info->rendererInfo = WebString::fromUTF8(gpu_info.gl_renderer); | |
994 gl_info->vendorInfo = WebString::fromUTF8(gpu_info.gl_vendor); | |
995 gl_info->driverVersion = WebString::fromUTF8(gpu_info.driver_version); | |
996 gl_info->resetNotificationStrategy = | |
997 gpu_info.gl_reset_notification_strategy; | |
998 gl_info->sandboxed = gpu_info.sandboxed; | |
999 gl_info->processCrashCount = gpu_info.process_crash_count; | |
1000 gl_info->amdSwitchable = gpu_info.amd_switchable; | |
1001 gl_info->optimus = gpu_info.optimus; | |
1002 break; | |
1003 case gpu::kCollectInfoFatalFailure: | |
1004 case gpu::kCollectInfoNone: | |
1005 errorMessage.append( | |
1006 "Failed to collect gpu information, GLSurface or GLContext " | |
1007 "creation failed"); | |
1008 gl_info->errorMessage = WebString::fromUTF8(errorMessage); | |
1009 break; | |
1010 default: | |
1011 NOTREACHED(); | |
1012 } | |
1013 } else { | |
1014 errorMessage.append("GpuChannelHost creation failed"); | |
1015 gl_info->errorMessage = WebString::fromUTF8(errorMessage); | |
1016 } | |
1017 } | |
1018 | |
979 blink::WebGraphicsContext3D* | 1019 blink::WebGraphicsContext3D* |
980 RendererBlinkPlatformImpl::createOffscreenGraphicsContext3D( | 1020 RendererBlinkPlatformImpl::createOffscreenGraphicsContext3D( |
981 const blink::WebGraphicsContext3D::Attributes& attributes, | 1021 const blink::WebGraphicsContext3D::Attributes& attributes, |
982 blink::WebGraphicsContext3D* share_context, | 1022 blink::WebGraphicsContext3D* share_context, |
983 blink::WebGLInfo* gl_info) { | 1023 blink::WebGraphicsContext3D::WebGraphicsInfo* gl_info) { |
984 if (!RenderThreadImpl::current()) | 1024 if (!RenderThreadImpl::current()) { |
985 return NULL; | 1025 if (gl_info) { |
1026 std::string errorMessage("Failed to run in Current RenderThreadImpl"); | |
1027 gl_info->errorMessage = WebString::fromUTF8(errorMessage); | |
1028 return NULL; | |
1029 } | |
1030 } | |
986 | 1031 |
987 scoped_refptr<GpuChannelHost> gpu_channel_host( | 1032 scoped_refptr<GpuChannelHost> gpu_channel_host( |
988 RenderThreadImpl::current()->EstablishGpuChannelSync( | 1033 RenderThreadImpl::current()->EstablishGpuChannelSync( |
989 CAUSE_FOR_GPU_LAUNCH_WEBGRAPHICSCONTEXT3DCOMMANDBUFFERIMPL_INITIALIZE) ); | 1034 CAUSE_FOR_GPU_LAUNCH_WEBGRAPHICSCONTEXT3DCOMMANDBUFFERIMPL_INITIALIZE) ); |
990 | 1035 |
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; | 1036 WebGraphicsContext3DCommandBufferImpl::SharedMemoryLimits limits; |
1017 bool lose_context_when_out_of_memory = false; | 1037 bool lose_context_when_out_of_memory = false; |
1018 scoped_ptr<WebGraphicsContext3DCommandBufferImpl> context( | 1038 scoped_ptr<WebGraphicsContext3DCommandBufferImpl> context( |
1019 WebGraphicsContext3DCommandBufferImpl::CreateOffscreenContext( | 1039 WebGraphicsContext3DCommandBufferImpl::CreateOffscreenContext( |
1020 gpu_channel_host.get(), | 1040 gpu_channel_host.get(), |
1021 attributes, | 1041 attributes, |
1022 lose_context_when_out_of_memory, | 1042 lose_context_when_out_of_memory, |
1023 GURL(attributes.topDocumentURL), | 1043 GURL(attributes.topDocumentURL), |
1024 limits, | 1044 limits, |
1025 static_cast<WebGraphicsContext3DCommandBufferImpl*>(share_context))); | 1045 static_cast<WebGraphicsContext3DCommandBufferImpl*>(share_context))); |
1026 | 1046 |
1027 // Most likely the GPU process exited and the attempt to reconnect to it | 1047 // Most likely the GPU process exited and the attempt to reconnect to it |
1028 // failed. Need to try to restore the context again later. | 1048 // failed. Need to try to restore the context again later. |
1029 if (!context || !context->InitializeOnCurrentThread()) | 1049 if (!context || !context->InitializeOnCurrentThread() || |
1030 return NULL; | 1050 (gl_info && gl_info->testFailContext)) { |
1051 // Collect Graphicsinfo if there is a context failure or it is failed | |
1052 // purposefully in caseof layout tests. | |
Zhenyao Mo
2015/10/19 17:44:48
nit: caseof -> case of
sivag
2015/10/20 10:14:41
Done.
| |
1053 collect3DContextInformationOnFailure(share_context, gl_info, | |
1054 gpu_channel_host.get()); | |
1055 return NULL; | |
1056 } | |
1031 return context.release(); | 1057 return context.release(); |
1032 } | 1058 } |
1033 | 1059 |
1034 //------------------------------------------------------------------------------ | 1060 //------------------------------------------------------------------------------ |
1035 | 1061 |
1036 blink::WebGraphicsContext3DProvider* | 1062 blink::WebGraphicsContext3DProvider* |
1037 RendererBlinkPlatformImpl::createSharedOffscreenGraphicsContext3DProvider() { | 1063 RendererBlinkPlatformImpl::createSharedOffscreenGraphicsContext3DProvider() { |
1038 scoped_refptr<cc_blink::ContextProviderWebContext> provider = | 1064 scoped_refptr<cc_blink::ContextProviderWebContext> provider = |
1039 RenderThreadImpl::current()->SharedMainThreadContextProvider(); | 1065 RenderThreadImpl::current()->SharedMainThreadContextProvider(); |
1040 if (!provider.get()) | 1066 if (!provider.get()) |
(...skipping 220 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
1261 //------------------------------------------------------------------------------ | 1287 //------------------------------------------------------------------------------ |
1262 | 1288 |
1263 void RendererBlinkPlatformImpl::MockBatteryStatusChangedForTesting( | 1289 void RendererBlinkPlatformImpl::MockBatteryStatusChangedForTesting( |
1264 const blink::WebBatteryStatus& status) { | 1290 const blink::WebBatteryStatus& status) { |
1265 if (!g_test_battery_status_listener) | 1291 if (!g_test_battery_status_listener) |
1266 return; | 1292 return; |
1267 g_test_battery_status_listener->updateBatteryStatus(status); | 1293 g_test_battery_status_listener->updateBatteryStatus(status); |
1268 } | 1294 } |
1269 | 1295 |
1270 } // namespace content | 1296 } // namespace content |
OLD | NEW |