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