Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(1081)

Side by Side Diff: content/renderer/renderer_blink_platform_impl.cc

Issue 1384233003: Improve usefulness of webglcontextcreationerror statusMessage (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 5 years, 2 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
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
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 gl_info;
977 return createOffscreenGraphicsContext3D(attributes, share_context, &gl_info);
978 }
979
980 static void Collect3DContextInformationOnFailure(
981 blink::WebGraphicsContext3D* share_context,
982 blink::WebGraphicsContext3D::WebGraphicsInfo* gl_info,
983 GpuChannelHost* host) {
984 DCHECK(gl_info);
985 std::string error_message("OffscreenContext Creation failed, ");
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 error_message.append(
1006 "Failed to collect gpu information, GLSurface or GLContext "
1007 "creation failed");
1008 gl_info->errorMessage = WebString::fromUTF8(error_message);
1009 break;
1010 default:
1011 NOTREACHED();
1012 }
1013 } else {
1014 error_message.append("GpuChannelHost creation failed");
1015 gl_info->errorMessage = WebString::fromUTF8(error_message);
1016 }
977 } 1017 }
978 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 DCHECK(gl_info);
1025 if (!RenderThreadImpl::current()) {
1026 std::string error_message("Failed to run in Current RenderThreadImpl");
1027 gl_info->errorMessage = WebString::fromUTF8(error_message);
985 return NULL; 1028 return NULL;
1029 }
986 1030
987 scoped_refptr<GpuChannelHost> gpu_channel_host( 1031 scoped_refptr<GpuChannelHost> gpu_channel_host(
988 RenderThreadImpl::current()->EstablishGpuChannelSync( 1032 RenderThreadImpl::current()->EstablishGpuChannelSync(
989 CAUSE_FOR_GPU_LAUNCH_WEBGRAPHICSCONTEXT3DCOMMANDBUFFERIMPL_INITIALIZE) ); 1033 CAUSE_FOR_GPU_LAUNCH_WEBGRAPHICSCONTEXT3DCOMMANDBUFFERIMPL_INITIALIZE) );
990 1034
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; 1035 WebGraphicsContext3DCommandBufferImpl::SharedMemoryLimits limits;
1017 bool lose_context_when_out_of_memory = false; 1036 bool lose_context_when_out_of_memory = false;
1018 scoped_ptr<WebGraphicsContext3DCommandBufferImpl> context( 1037 scoped_ptr<WebGraphicsContext3DCommandBufferImpl> context(
1019 WebGraphicsContext3DCommandBufferImpl::CreateOffscreenContext( 1038 WebGraphicsContext3DCommandBufferImpl::CreateOffscreenContext(
1020 gpu_channel_host.get(), 1039 gpu_channel_host.get(),
1021 attributes, 1040 attributes,
1022 lose_context_when_out_of_memory, 1041 lose_context_when_out_of_memory,
1023 GURL(attributes.topDocumentURL), 1042 GURL(attributes.topDocumentURL),
1024 limits, 1043 limits,
1025 static_cast<WebGraphicsContext3DCommandBufferImpl*>(share_context))); 1044 static_cast<WebGraphicsContext3DCommandBufferImpl*>(share_context)));
1026 1045
1027 // Most likely the GPU process exited and the attempt to reconnect to it 1046 // Most likely the GPU process exited and the attempt to reconnect to it
1028 // failed. Need to try to restore the context again later. 1047 // failed. Need to try to restore the context again later.
1029 if (!context || !context->InitializeOnCurrentThread()) 1048 if (!context || !context->InitializeOnCurrentThread() ||
1049 gl_info->testFailContext) {
1050 // Collect Graphicsinfo if there is a context failure or it is failed
1051 // purposefully in case of layout tests.
1052 Collect3DContextInformationOnFailure(share_context, gl_info,
1053 gpu_channel_host.get());
1030 return NULL; 1054 return NULL;
1055 }
1031 return context.release(); 1056 return context.release();
1032 } 1057 }
1033 1058
1034 //------------------------------------------------------------------------------ 1059 //------------------------------------------------------------------------------
1035 1060
1036 blink::WebGraphicsContext3DProvider* 1061 blink::WebGraphicsContext3DProvider*
1037 RendererBlinkPlatformImpl::createSharedOffscreenGraphicsContext3DProvider() { 1062 RendererBlinkPlatformImpl::createSharedOffscreenGraphicsContext3DProvider() {
1038 scoped_refptr<cc_blink::ContextProviderWebContext> provider = 1063 scoped_refptr<cc_blink::ContextProviderWebContext> provider =
1039 RenderThreadImpl::current()->SharedMainThreadContextProvider(); 1064 RenderThreadImpl::current()->SharedMainThreadContextProvider();
1040 if (!provider.get()) 1065 if (!provider.get())
(...skipping 220 matching lines...) Expand 10 before | Expand all | Expand 10 after
1261 //------------------------------------------------------------------------------ 1286 //------------------------------------------------------------------------------
1262 1287
1263 void RendererBlinkPlatformImpl::MockBatteryStatusChangedForTesting( 1288 void RendererBlinkPlatformImpl::MockBatteryStatusChangedForTesting(
1264 const blink::WebBatteryStatus& status) { 1289 const blink::WebBatteryStatus& status) {
1265 if (!g_test_battery_status_listener) 1290 if (!g_test_battery_status_listener)
1266 return; 1291 return;
1267 g_test_battery_status_listener->updateBatteryStatus(status); 1292 g_test_battery_status_listener->updateBatteryStatus(status);
1268 } 1293 }
1269 1294
1270 } // namespace content 1295 } // namespace content
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698