| 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 <utility> | 7 #include <utility> |
| 8 | 8 |
| 9 #include "base/command_line.h" | 9 #include "base/command_line.h" |
| 10 #include "base/files/file_path.h" | 10 #include "base/files/file_path.h" |
| (...skipping 996 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1007 default: | 1007 default: |
| 1008 NOTREACHED(); | 1008 NOTREACHED(); |
| 1009 } | 1009 } |
| 1010 } | 1010 } |
| 1011 | 1011 |
| 1012 blink::WebGraphicsContext3DProvider* | 1012 blink::WebGraphicsContext3DProvider* |
| 1013 RendererBlinkPlatformImpl::createOffscreenGraphicsContext3DProvider( | 1013 RendererBlinkPlatformImpl::createOffscreenGraphicsContext3DProvider( |
| 1014 const blink::Platform::ContextAttributes& web_attributes, | 1014 const blink::Platform::ContextAttributes& web_attributes, |
| 1015 const blink::WebURL& top_document_web_url, | 1015 const blink::WebURL& top_document_web_url, |
| 1016 blink::WebGraphicsContext3DProvider* share_provider, | 1016 blink::WebGraphicsContext3DProvider* share_provider, |
| 1017 blink::Platform::GraphicsInfo* gl_info) { | 1017 blink::Platform::GraphicsInfo* gl_info, |
| 1018 blink::Platform::WillBindToCurrentThread will_bind_to_current_thread) { |
| 1018 DCHECK(gl_info); | 1019 DCHECK(gl_info); |
| 1019 if (!RenderThreadImpl::current()) { | 1020 if (!RenderThreadImpl::current()) { |
| 1020 std::string error_message("Failed to run in Current RenderThreadImpl"); | 1021 std::string error_message("Failed to run in Current RenderThreadImpl"); |
| 1021 gl_info->errorMessage = WebString::fromUTF8(error_message); | 1022 gl_info->errorMessage = WebString::fromUTF8(error_message); |
| 1022 return nullptr; | 1023 return nullptr; |
| 1023 } | 1024 } |
| 1024 | 1025 |
| 1025 scoped_refptr<gpu::GpuChannelHost> gpu_channel_host( | 1026 scoped_refptr<gpu::GpuChannelHost> gpu_channel_host( |
| 1026 RenderThreadImpl::current()->EstablishGpuChannelSync( | 1027 RenderThreadImpl::current()->EstablishGpuChannelSync( |
| 1027 CAUSE_FOR_GPU_LAUNCH_WEBGL_CONTEXT)); | 1028 CAUSE_FOR_GPU_LAUNCH_WEBGL_CONTEXT)); |
| 1028 if (!gpu_channel_host) { | 1029 if (!gpu_channel_host) { |
| 1029 std::string error_message( | 1030 std::string error_message( |
| 1030 "OffscreenContext Creation failed, GpuChannelHost creation failed"); | 1031 "OffscreenContext Creation failed, GpuChannelHost creation failed"); |
| 1031 gl_info->errorMessage = WebString::fromUTF8(error_message); | 1032 gl_info->errorMessage = WebString::fromUTF8(error_message); |
| 1032 return nullptr; | 1033 return nullptr; |
| 1033 } | 1034 } |
| 1034 | 1035 |
| 1035 content::WebGraphicsContext3DProviderImpl* share_provider_impl = | 1036 content::WebGraphicsContext3DProviderImpl* share_provider_impl = |
| 1036 static_cast<content::WebGraphicsContext3DProviderImpl*>(share_provider); | 1037 static_cast<content::WebGraphicsContext3DProviderImpl*>(share_provider); |
| 1037 ContextProviderCommandBuffer* share_context = nullptr; | 1038 ContextProviderCommandBuffer* share_context = nullptr; |
| 1038 | 1039 |
| 1040 if (will_bind_to_current_thread == blink::Platform::DoNotBindToCurrentThread) |
| 1041 DCHECK(!share_provider_impl); |
| 1042 |
| 1039 // WebGL contexts must fail creation if the share group is lost. | 1043 // WebGL contexts must fail creation if the share group is lost. |
| 1040 if (share_provider_impl) { | 1044 if (share_provider_impl) { |
| 1041 auto* gl = share_provider_impl->contextGL(); | 1045 auto* gl = share_provider_impl->contextGL(); |
| 1042 if (gl->GetGraphicsResetStatusKHR() != GL_NO_ERROR) { | 1046 if (gl->GetGraphicsResetStatusKHR() != GL_NO_ERROR) { |
| 1043 std::string error_message( | 1047 std::string error_message( |
| 1044 "OffscreenContext Creation failed, Shared context is lost"); | 1048 "OffscreenContext Creation failed, Shared context is lost"); |
| 1045 gl_info->errorMessage = WebString::fromUTF8(error_message); | 1049 gl_info->errorMessage = WebString::fromUTF8(error_message); |
| 1046 return nullptr; | 1050 return nullptr; |
| 1047 } | 1051 } |
| 1048 share_context = share_provider_impl->context_provider(); | 1052 share_context = share_provider_impl->context_provider(); |
| (...skipping 22 matching lines...) Expand all Loading... |
| 1071 // Prefer discrete GPU for WebGL. | 1075 // Prefer discrete GPU for WebGL. |
| 1072 gfx::GpuPreference gpu_preference = gfx::PreferDiscreteGpu; | 1076 gfx::GpuPreference gpu_preference = gfx::PreferDiscreteGpu; |
| 1073 const auto& gpu_info = gpu_channel_host->gpu_info(); | 1077 const auto& gpu_info = gpu_channel_host->gpu_info(); |
| 1074 | 1078 |
| 1075 scoped_refptr<ContextProviderCommandBuffer> provider( | 1079 scoped_refptr<ContextProviderCommandBuffer> provider( |
| 1076 new ContextProviderCommandBuffer( | 1080 new ContextProviderCommandBuffer( |
| 1077 std::move(gpu_channel_host), gpu::kNullSurfaceHandle, | 1081 std::move(gpu_channel_host), gpu::kNullSurfaceHandle, |
| 1078 GURL(top_document_web_url), gpu_preference, automatic_flushes, | 1082 GURL(top_document_web_url), gpu_preference, automatic_flushes, |
| 1079 gpu::SharedMemoryLimits(), attributes, share_context, | 1083 gpu::SharedMemoryLimits(), attributes, share_context, |
| 1080 command_buffer_metrics::OFFSCREEN_CONTEXT_FOR_WEBGL)); | 1084 command_buffer_metrics::OFFSCREEN_CONTEXT_FOR_WEBGL)); |
| 1081 if (!provider->BindToCurrentThread()) { | 1085 if (will_bind_to_current_thread == blink::Platform::BindToCurrentThread) { |
| 1082 // Collect Graphicsinfo if there is a context failure or it is failed | 1086 if (!provider->BindToCurrentThread()) { |
| 1083 // purposefully in case of layout tests. | 1087 // Collect Graphicsinfo if there is a context failure or it is failed |
| 1084 Collect3DContextInformationOnFailure(gl_info, gpu_info); | 1088 // purposefully in case of layout tests. |
| 1085 return nullptr; | 1089 Collect3DContextInformationOnFailure(gl_info, gpu_info); |
| 1090 return nullptr; |
| 1091 } |
| 1086 } | 1092 } |
| 1087 return new WebGraphicsContext3DProviderImpl(std::move(provider)); | 1093 return new WebGraphicsContext3DProviderImpl(std::move(provider)); |
| 1088 } | 1094 } |
| 1089 | 1095 |
| 1090 //------------------------------------------------------------------------------ | 1096 //------------------------------------------------------------------------------ |
| 1091 | 1097 |
| 1092 blink::WebGraphicsContext3DProvider* | 1098 blink::WebGraphicsContext3DProvider* |
| 1093 RendererBlinkPlatformImpl::createSharedOffscreenGraphicsContext3DProvider() { | 1099 RendererBlinkPlatformImpl::createSharedOffscreenGraphicsContext3DProvider() { |
| 1094 scoped_refptr<ContextProviderCommandBuffer> provider = | 1100 scoped_refptr<ContextProviderCommandBuffer> provider = |
| 1095 RenderThreadImpl::current()->SharedMainThreadContextProvider(); | 1101 RenderThreadImpl::current()->SharedMainThreadContextProvider(); |
| (...skipping 206 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1302 } | 1308 } |
| 1303 | 1309 |
| 1304 //------------------------------------------------------------------------------ | 1310 //------------------------------------------------------------------------------ |
| 1305 | 1311 |
| 1306 blink::WebTrialTokenValidator* | 1312 blink::WebTrialTokenValidator* |
| 1307 RendererBlinkPlatformImpl::trialTokenValidator() { | 1313 RendererBlinkPlatformImpl::trialTokenValidator() { |
| 1308 return &trial_token_validator_; | 1314 return &trial_token_validator_; |
| 1309 } | 1315 } |
| 1310 | 1316 |
| 1311 } // namespace content | 1317 } // namespace content |
| OLD | NEW |