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 1067 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1078 | 1078 |
1079 // This is an offscreen context, which doesn't use the default frame buffer, | 1079 // This is an offscreen context, which doesn't use the default frame buffer, |
1080 // so don't request any alpha, depth, stencil, antialiasing. | 1080 // so don't request any alpha, depth, stencil, antialiasing. |
1081 gpu::gles2::ContextCreationAttribHelper attributes; | 1081 gpu::gles2::ContextCreationAttribHelper attributes; |
1082 attributes.alpha_size = -1; | 1082 attributes.alpha_size = -1; |
1083 attributes.depth_size = 0; | 1083 attributes.depth_size = 0; |
1084 attributes.stencil_size = 0; | 1084 attributes.stencil_size = 0; |
1085 attributes.samples = 0; | 1085 attributes.samples = 0; |
1086 attributes.sample_buffers = 0; | 1086 attributes.sample_buffers = 0; |
1087 attributes.bind_generates_resource = false; | 1087 attributes.bind_generates_resource = false; |
1088 // Prefer discrete GPU for WebGL. | |
1089 attributes.gpu_preference = gl::PreferDiscreteGpu; | |
1090 | 1088 |
1091 attributes.fail_if_major_perf_caveat = | 1089 attributes.fail_if_major_perf_caveat = |
1092 web_attributes.failIfMajorPerformanceCaveat; | 1090 web_attributes.failIfMajorPerformanceCaveat; |
1093 DCHECK_GT(web_attributes.webGLVersion, 0u); | 1091 DCHECK_GT(web_attributes.webGLVersion, 0u); |
1094 DCHECK_LE(web_attributes.webGLVersion, 2u); | 1092 DCHECK_LE(web_attributes.webGLVersion, 2u); |
1095 if (web_attributes.webGLVersion == 2) | 1093 if (web_attributes.webGLVersion == 2) |
1096 attributes.context_type = gpu::gles2::CONTEXT_TYPE_WEBGL2; | 1094 attributes.context_type = gpu::gles2::CONTEXT_TYPE_WEBGL2; |
1097 else | 1095 else |
1098 attributes.context_type = gpu::gles2::CONTEXT_TYPE_WEBGL1; | 1096 attributes.context_type = gpu::gles2::CONTEXT_TYPE_WEBGL1; |
1099 | 1097 |
1100 constexpr bool automatic_flushes = true; | 1098 constexpr bool automatic_flushes = true; |
1101 constexpr bool support_locking = false; | 1099 constexpr bool support_locking = false; |
| 1100 // Prefer discrete GPU for WebGL. |
| 1101 constexpr gl::GpuPreference gpu_preference = gl::PreferDiscreteGpu; |
1102 | 1102 |
1103 scoped_refptr<ContextProviderCommandBuffer> provider( | 1103 scoped_refptr<ContextProviderCommandBuffer> provider( |
1104 new ContextProviderCommandBuffer( | 1104 new ContextProviderCommandBuffer( |
1105 std::move(gpu_channel_host), gpu::GPU_STREAM_DEFAULT, | 1105 std::move(gpu_channel_host), gpu::GPU_STREAM_DEFAULT, |
1106 gpu::GpuStreamPriority::NORMAL, gpu::kNullSurfaceHandle, | 1106 gpu::GpuStreamPriority::NORMAL, gpu::kNullSurfaceHandle, |
1107 GURL(top_document_web_url), automatic_flushes, support_locking, | 1107 GURL(top_document_web_url), gpu_preference, automatic_flushes, |
1108 gpu::SharedMemoryLimits(), attributes, share_context, | 1108 support_locking, gpu::SharedMemoryLimits(), attributes, share_context, |
1109 command_buffer_metrics::OFFSCREEN_CONTEXT_FOR_WEBGL)); | 1109 command_buffer_metrics::OFFSCREEN_CONTEXT_FOR_WEBGL)); |
1110 return new WebGraphicsContext3DProviderImpl(std::move(provider)); | 1110 return new WebGraphicsContext3DProviderImpl(std::move(provider)); |
1111 } | 1111 } |
1112 | 1112 |
1113 //------------------------------------------------------------------------------ | 1113 //------------------------------------------------------------------------------ |
1114 | 1114 |
1115 blink::WebGraphicsContext3DProvider* | 1115 blink::WebGraphicsContext3DProvider* |
1116 RendererBlinkPlatformImpl::createSharedOffscreenGraphicsContext3DProvider() { | 1116 RendererBlinkPlatformImpl::createSharedOffscreenGraphicsContext3DProvider() { |
1117 scoped_refptr<ContextProviderCommandBuffer> provider = | 1117 scoped_refptr<ContextProviderCommandBuffer> provider = |
1118 RenderThreadImpl::current()->SharedMainThreadContextProvider(); | 1118 RenderThreadImpl::current()->SharedMainThreadContextProvider(); |
(...skipping 190 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1309 return &trial_token_validator_; | 1309 return &trial_token_validator_; |
1310 } | 1310 } |
1311 | 1311 |
1312 void RendererBlinkPlatformImpl::workerContextCreated( | 1312 void RendererBlinkPlatformImpl::workerContextCreated( |
1313 const v8::Local<v8::Context>& worker) { | 1313 const v8::Local<v8::Context>& worker) { |
1314 GetContentClient()->renderer()->DidInitializeWorkerContextOnWorkerThread( | 1314 GetContentClient()->renderer()->DidInitializeWorkerContextOnWorkerThread( |
1315 worker); | 1315 worker); |
1316 } | 1316 } |
1317 | 1317 |
1318 } // namespace content | 1318 } // namespace content |
OLD | NEW |