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 1017 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1028 scoped_refptr<gpu::GpuChannelHost> gpu_channel_host( | 1028 scoped_refptr<gpu::GpuChannelHost> gpu_channel_host( |
1029 RenderThreadImpl::current()->EstablishGpuChannelSync( | 1029 RenderThreadImpl::current()->EstablishGpuChannelSync( |
1030 CAUSE_FOR_GPU_LAUNCH_WEBGRAPHICSCONTEXT3DCOMMANDBUFFERIMPL_INITIALIZE)
); | 1030 CAUSE_FOR_GPU_LAUNCH_WEBGRAPHICSCONTEXT3DCOMMANDBUFFERIMPL_INITIALIZE)
); |
1031 if (!gpu_channel_host) { | 1031 if (!gpu_channel_host) { |
1032 std::string error_message( | 1032 std::string error_message( |
1033 "OffscreenContext Creation failed, GpuChannelHost creation failed"); | 1033 "OffscreenContext Creation failed, GpuChannelHost creation failed"); |
1034 gl_info->errorMessage = WebString::fromUTF8(error_message); | 1034 gl_info->errorMessage = WebString::fromUTF8(error_message); |
1035 return nullptr; | 1035 return nullptr; |
1036 } | 1036 } |
1037 | 1037 |
| 1038 content::WebGraphicsContext3DProviderImpl* share_provider_impl = |
| 1039 static_cast<content::WebGraphicsContext3DProviderImpl*>(share_provider); |
| 1040 ContextProviderCommandBuffer* share_context = nullptr; |
| 1041 |
1038 // WebGL contexts must fail creation if the share group is lost. | 1042 // WebGL contexts must fail creation if the share group is lost. |
1039 if (share_provider && | 1043 if (share_provider_impl) { |
1040 share_provider->contextGL()->GetGraphicsResetStatusKHR() != GL_NO_ERROR) { | 1044 auto* gl = share_provider_impl->contextGL(); |
1041 std::string error_message( | 1045 if (gl->GetGraphicsResetStatusKHR() != GL_NO_ERROR) { |
1042 "OffscreenContext Creation failed, Shared context is lost"); | 1046 std::string error_message( |
1043 gl_info->errorMessage = WebString::fromUTF8(error_message); | 1047 "OffscreenContext Creation failed, Shared context is lost"); |
1044 return nullptr; | 1048 gl_info->errorMessage = WebString::fromUTF8(error_message); |
| 1049 return nullptr; |
| 1050 } |
| 1051 share_context = share_provider_impl->context_provider(); |
1045 } | 1052 } |
1046 | 1053 |
1047 WebGraphicsContext3DCommandBufferImpl* share_context = | |
1048 share_provider ? static_cast<WebGraphicsContext3DCommandBufferImpl*>( | |
1049 share_provider->context3d()) | |
1050 : nullptr; | |
1051 | |
1052 // This is an offscreen context, which doesn't use the default frame buffer, | 1054 // This is an offscreen context, which doesn't use the default frame buffer, |
1053 // so don't request any alpha, depth, stencil, antialiasing. | 1055 // so don't request any alpha, depth, stencil, antialiasing. |
1054 gpu::gles2::ContextCreationAttribHelper attributes; | 1056 gpu::gles2::ContextCreationAttribHelper attributes; |
1055 attributes.alpha_size = -1; | 1057 attributes.alpha_size = -1; |
1056 attributes.depth_size = 0; | 1058 attributes.depth_size = 0; |
1057 attributes.stencil_size = 0; | 1059 attributes.stencil_size = 0; |
1058 attributes.samples = 0; | 1060 attributes.samples = 0; |
1059 attributes.sample_buffers = 0; | 1061 attributes.sample_buffers = 0; |
1060 attributes.bind_generates_resource = false; | 1062 attributes.bind_generates_resource = false; |
1061 | 1063 |
1062 attributes.fail_if_major_perf_caveat = | 1064 attributes.fail_if_major_perf_caveat = |
1063 web_attributes.failIfMajorPerformanceCaveat; | 1065 web_attributes.failIfMajorPerformanceCaveat; |
1064 DCHECK_LE(web_attributes.webGLVersion, 2u); | 1066 DCHECK_LE(web_attributes.webGLVersion, 2u); |
1065 if (web_attributes.webGLVersion == 1) | 1067 if (web_attributes.webGLVersion == 1) |
1066 attributes.context_type = gpu::gles2::CONTEXT_TYPE_WEBGL1; | 1068 attributes.context_type = gpu::gles2::CONTEXT_TYPE_WEBGL1; |
1067 else if (web_attributes.webGLVersion == 2) | 1069 else if (web_attributes.webGLVersion == 2) |
1068 attributes.context_type = gpu::gles2::CONTEXT_TYPE_WEBGL2; | 1070 attributes.context_type = gpu::gles2::CONTEXT_TYPE_WEBGL2; |
1069 | 1071 |
1070 bool share_resources = false; | |
1071 bool automatic_flushes = true; | 1072 bool automatic_flushes = true; |
1072 // Prefer discrete GPU for WebGL. | 1073 // Prefer discrete GPU for WebGL. |
1073 gfx::GpuPreference gpu_preference = gfx::PreferDiscreteGpu; | 1074 gfx::GpuPreference gpu_preference = gfx::PreferDiscreteGpu; |
1074 | 1075 |
1075 scoped_refptr<ContextProviderCommandBuffer> provider( | 1076 scoped_refptr<ContextProviderCommandBuffer> provider( |
1076 new ContextProviderCommandBuffer( | 1077 new ContextProviderCommandBuffer( |
1077 base::WrapUnique(new WebGraphicsContext3DCommandBufferImpl( | 1078 base::WrapUnique(new WebGraphicsContext3DCommandBufferImpl( |
1078 gpu::kNullSurfaceHandle, GURL(top_document_web_url), | 1079 gpu::kNullSurfaceHandle, GURL(top_document_web_url), |
1079 gpu_channel_host.get(), attributes, gpu_preference, | 1080 gpu_channel_host.get(), attributes, gpu_preference, |
1080 share_resources, automatic_flushes, share_context)), | 1081 automatic_flushes)), |
1081 gpu::SharedMemoryLimits(), RENDERER_MAINTHREAD_CONTEXT)); | 1082 gpu::SharedMemoryLimits(), share_context, |
| 1083 RENDERER_MAINTHREAD_CONTEXT)); |
1082 if (!provider->BindToCurrentThread()) { | 1084 if (!provider->BindToCurrentThread()) { |
1083 // Collect Graphicsinfo if there is a context failure or it is failed | 1085 // Collect Graphicsinfo if there is a context failure or it is failed |
1084 // purposefully in case of layout tests. | 1086 // purposefully in case of layout tests. |
1085 Collect3DContextInformationOnFailure(gl_info, gpu_channel_host.get()); | 1087 Collect3DContextInformationOnFailure(gl_info, gpu_channel_host.get()); |
1086 return nullptr; | 1088 return nullptr; |
1087 } | 1089 } |
1088 return new WebGraphicsContext3DProviderImpl(std::move(provider)); | 1090 return new WebGraphicsContext3DProviderImpl(std::move(provider)); |
1089 } | 1091 } |
1090 | 1092 |
1091 //------------------------------------------------------------------------------ | 1093 //------------------------------------------------------------------------------ |
1092 | 1094 |
1093 blink::WebGraphicsContext3DProvider* | 1095 blink::WebGraphicsContext3DProvider* |
1094 RendererBlinkPlatformImpl::createSharedOffscreenGraphicsContext3DProvider() { | 1096 RendererBlinkPlatformImpl::createSharedOffscreenGraphicsContext3DProvider() { |
1095 scoped_refptr<cc_blink::ContextProviderWebContext> provider = | 1097 scoped_refptr<ContextProviderCommandBuffer> provider = |
1096 RenderThreadImpl::current()->SharedMainThreadContextProvider(); | 1098 RenderThreadImpl::current()->SharedMainThreadContextProvider(); |
1097 if (!provider) | 1099 if (!provider) |
1098 return nullptr; | 1100 return nullptr; |
1099 return new WebGraphicsContext3DProviderImpl(std::move(provider)); | 1101 return new WebGraphicsContext3DProviderImpl(std::move(provider)); |
1100 } | 1102 } |
1101 | 1103 |
1102 //------------------------------------------------------------------------------ | 1104 //------------------------------------------------------------------------------ |
1103 | 1105 |
1104 blink::WebCompositorSupport* RendererBlinkPlatformImpl::compositorSupport() { | 1106 blink::WebCompositorSupport* RendererBlinkPlatformImpl::compositorSupport() { |
1105 return &compositor_support_; | 1107 return &compositor_support_; |
(...skipping 197 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1303 } | 1305 } |
1304 | 1306 |
1305 //------------------------------------------------------------------------------ | 1307 //------------------------------------------------------------------------------ |
1306 | 1308 |
1307 blink::WebTrialTokenValidator* | 1309 blink::WebTrialTokenValidator* |
1308 RendererBlinkPlatformImpl::trialTokenValidator() { | 1310 RendererBlinkPlatformImpl::trialTokenValidator() { |
1309 return &trial_token_validator_; | 1311 return &trial_token_validator_; |
1310 } | 1312 } |
1311 | 1313 |
1312 } // namespace content | 1314 } // namespace content |
OLD | NEW |