Chromium Code Reviews| Index: content/renderer/renderer_blink_platform_impl.cc |
| diff --git a/content/renderer/renderer_blink_platform_impl.cc b/content/renderer/renderer_blink_platform_impl.cc |
| index 9da0779e3e3309e6ce6441910692dfea95ee39d8..0d5018b0007c8d96a11e84d0a4a49c83b662c58e 100644 |
| --- a/content/renderer/renderer_blink_platform_impl.cc |
| +++ b/content/renderer/renderer_blink_platform_impl.cc |
| @@ -973,46 +973,63 @@ blink::WebGraphicsContext3D* |
| RendererBlinkPlatformImpl::createOffscreenGraphicsContext3D( |
| const blink::WebGraphicsContext3D::Attributes& attributes, |
| blink::WebGraphicsContext3D* share_context) { |
| - return createOffscreenGraphicsContext3D(attributes, share_context, NULL); |
| + blink::WebGraphicsContext3D::WebGraphicsContext3DInfo info; |
| + return createOffscreenGraphicsContext3D(attributes, share_context, info); |
| } |
| -blink::WebGraphicsContext3D* |
| -RendererBlinkPlatformImpl::createOffscreenGraphicsContext3D( |
| - const blink::WebGraphicsContext3D::Attributes& attributes, |
| +static void collect3DContextInformationOnFailure( |
| blink::WebGraphicsContext3D* share_context, |
| - blink::WebGLInfo* gl_info) { |
| - if (!RenderThreadImpl::current()) |
| - return NULL; |
| - |
| - scoped_refptr<GpuChannelHost> gpu_channel_host( |
| - RenderThreadImpl::current()->EstablishGpuChannelSync( |
| - CAUSE_FOR_GPU_LAUNCH_WEBGRAPHICSCONTEXT3DCOMMANDBUFFERIMPL_INITIALIZE)); |
| - |
| - if (gpu_channel_host.get() && gl_info) { |
| - const gpu::GPUInfo& gpu_info = gpu_channel_host->gpu_info(); |
| + blink::WebGraphicsContext3D::WebGraphicsContext3DInfo& gl_info, |
| + GpuChannelHost* host) { |
| + std::string errorMessage("OffscreenContext Creation failed, "); |
| + if (host) { |
| + const gpu::GPUInfo& gpu_info = host->gpu_info(); |
| + gl_info.vendorId = gpu_info.gpu.vendor_id; |
| + gl_info.deviceId = gpu_info.gpu.device_id; |
| switch (gpu_info.context_info_state) { |
| case gpu::kCollectInfoSuccess: |
| case gpu::kCollectInfoNonFatalFailure: |
| - gl_info->vendorInfo.assign( |
| - blink::WebString::fromUTF8(gpu_info.gl_vendor)); |
| - gl_info->rendererInfo.assign( |
| - blink::WebString::fromUTF8(gpu_info.gl_renderer)); |
| - gl_info->driverVersion.assign( |
| - blink::WebString::fromUTF8(gpu_info.driver_version)); |
| - gl_info->vendorId = gpu_info.gpu.vendor_id; |
| - gl_info->deviceId = gpu_info.gpu.device_id; |
| + gl_info.rendererInfo = WebString::fromUTF8(gpu_info.gl_renderer); |
| + gl_info.vendorInfo = WebString::fromUTF8(gpu_info.gl_vendor); |
| + gl_info.driverVersion = WebString::fromUTF8(gpu_info.driver_version); |
| + gl_info.resetNotificationStrategy = |
| + gpu_info.gl_reset_notification_strategy; |
| + gl_info.sandboxed = gpu_info.sandboxed; |
| + gl_info.processCrashCount = gpu_info.process_crash_count; |
| + gl_info.amdSwitchable = gpu_info.amd_switchable; |
| + gl_info.optimus = gpu_info.optimus; |
| break; |
| case gpu::kCollectInfoFatalFailure: |
| case gpu::kCollectInfoNone: |
| - gl_info->contextInfoCollectionFailure.assign(blink::WebString::fromUTF8( |
| - "GPUInfoCollectionFailure: GPU initialization Failed. GPU " |
| - "Info not Collected.")); |
| + errorMessage.append( |
| + "Failed to collect gpu information, GLSurface or GLContext " |
| + "creation failed"); |
| + gl_info.errorMessage = WebString::fromUTF8(errorMessage); |
| break; |
| default: |
| NOTREACHED(); |
| } |
| + } else { |
| + errorMessage.append("GpuChannelHost creation failed"); |
| + gl_info.errorMessage = WebString::fromUTF8(errorMessage); |
| + } |
| +} |
| + |
| +blink::WebGraphicsContext3D* |
| +RendererBlinkPlatformImpl::createOffscreenGraphicsContext3D( |
| + const blink::WebGraphicsContext3D::Attributes& attributes, |
| + blink::WebGraphicsContext3D* share_context, |
| + blink::WebGraphicsContext3D::WebGraphicsContext3DInfo& gl_info) { |
| + if (!RenderThreadImpl::current()) { |
| + std::string errorMessage("Failed to run in Current RenderThreadImpl"); |
| + gl_info.errorMessage = WebString::fromUTF8(errorMessage); |
| + return NULL; |
| } |
| + scoped_refptr<GpuChannelHost> gpu_channel_host( |
| + RenderThreadImpl::current()->EstablishGpuChannelSync( |
| + CAUSE_FOR_GPU_LAUNCH_WEBGRAPHICSCONTEXT3DCOMMANDBUFFERIMPL_INITIALIZE)); |
| + |
| WebGraphicsContext3DCommandBufferImpl::SharedMemoryLimits limits; |
| bool lose_context_when_out_of_memory = false; |
| scoped_ptr<WebGraphicsContext3DCommandBufferImpl> context( |
| @@ -1026,8 +1043,15 @@ RendererBlinkPlatformImpl::createOffscreenGraphicsContext3D( |
| // Most likely the GPU process exited and the attempt to reconnect to it |
| // failed. Need to try to restore the context again later. |
| - if (!context || !context->InitializeOnCurrentThread()) |
| - return NULL; |
| + bool contextFailed = !context || !context->InitializeOnCurrentThread(); |
| + // Collect 3DContext info if there is a context failure or it is failed |
| + // purpousefully to run layout tests. |
| + if (contextFailed || gl_info.testFailContext) { |
| + collect3DContextInformationOnFailure(share_context, gl_info, |
| + gpu_channel_host.get()); |
|
Ken Russell (switch to Gerrit)
2015/10/15 21:30:28
I think this code should just return NULL here, ra
Zhenyao Mo
2015/10/15 22:30:37
+1
sivag
2015/10/16 18:29:19
Done.
|
| + } |
| + if (contextFailed) |
| + return NULL; |
| return context.release(); |
| } |