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