Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(78)

Side by Side Diff: content/renderer/renderer_blink_platform_impl.cc

Issue 1990063004: Move bindToCurrentThread out to the creators of WebGL contexts. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: bindwebgl: . Created 4 years, 7 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
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 1010 matching lines...) Expand 10 before | Expand all | Expand 10 after
1021 "creation failed"); 1021 "creation failed");
1022 break; 1022 break;
1023 } 1023 }
1024 } 1024 }
1025 1025
1026 blink::WebGraphicsContext3DProvider* 1026 blink::WebGraphicsContext3DProvider*
1027 RendererBlinkPlatformImpl::createOffscreenGraphicsContext3DProvider( 1027 RendererBlinkPlatformImpl::createOffscreenGraphicsContext3DProvider(
1028 const blink::Platform::ContextAttributes& web_attributes, 1028 const blink::Platform::ContextAttributes& web_attributes,
1029 const blink::WebURL& top_document_web_url, 1029 const blink::WebURL& top_document_web_url,
1030 blink::WebGraphicsContext3DProvider* share_provider, 1030 blink::WebGraphicsContext3DProvider* share_provider,
1031 blink::Platform::GraphicsInfo* gl_info, 1031 blink::Platform::GraphicsInfo* gl_info) {
1032 blink::Platform::WillBindToCurrentThread will_bind_to_current_thread) {
1033 DCHECK(gl_info); 1032 DCHECK(gl_info);
1034 if (!RenderThreadImpl::current()) { 1033 if (!RenderThreadImpl::current()) {
1035 std::string error_message("Failed to run in Current RenderThreadImpl"); 1034 std::string error_message("Failed to run in Current RenderThreadImpl");
1036 gl_info->errorMessage = WebString::fromUTF8(error_message); 1035 gl_info->errorMessage = WebString::fromUTF8(error_message);
1037 return nullptr; 1036 return nullptr;
1038 } 1037 }
1039 1038
1040 scoped_refptr<gpu::GpuChannelHost> gpu_channel_host( 1039 scoped_refptr<gpu::GpuChannelHost> gpu_channel_host(
1041 RenderThreadImpl::current()->EstablishGpuChannelSync( 1040 RenderThreadImpl::current()->EstablishGpuChannelSync(
1042 CAUSE_FOR_GPU_LAUNCH_WEBGL_CONTEXT)); 1041 CAUSE_FOR_GPU_LAUNCH_WEBGL_CONTEXT));
1043 if (!gpu_channel_host) { 1042 if (!gpu_channel_host) {
1044 std::string error_message( 1043 std::string error_message(
1045 "OffscreenContext Creation failed, GpuChannelHost creation failed"); 1044 "OffscreenContext Creation failed, GpuChannelHost creation failed");
1046 gl_info->errorMessage = WebString::fromUTF8(error_message); 1045 gl_info->errorMessage = WebString::fromUTF8(error_message);
1047 return nullptr; 1046 return nullptr;
1048 } 1047 }
1049 Collect3DContextInformation(gl_info, gpu_channel_host->gpu_info()); 1048 Collect3DContextInformation(gl_info, gpu_channel_host->gpu_info());
1050 1049
1051 content::WebGraphicsContext3DProviderImpl* share_provider_impl = 1050 content::WebGraphicsContext3DProviderImpl* share_provider_impl =
1052 static_cast<content::WebGraphicsContext3DProviderImpl*>(share_provider); 1051 static_cast<content::WebGraphicsContext3DProviderImpl*>(share_provider);
1053 ContextProviderCommandBuffer* share_context = nullptr; 1052 ContextProviderCommandBuffer* share_context = nullptr;
1054 1053
1055 if (will_bind_to_current_thread == blink::Platform::DoNotBindToCurrentThread)
1056 DCHECK(!share_provider_impl);
1057
1058 // WebGL contexts must fail creation if the share group is lost. 1054 // WebGL contexts must fail creation if the share group is lost.
1059 if (share_provider_impl) { 1055 if (share_provider_impl) {
1060 auto* gl = share_provider_impl->contextGL(); 1056 auto* gl = share_provider_impl->contextGL();
1061 if (gl->GetGraphicsResetStatusKHR() != GL_NO_ERROR) { 1057 if (gl->GetGraphicsResetStatusKHR() != GL_NO_ERROR) {
1062 std::string error_message( 1058 std::string error_message(
1063 "OffscreenContext Creation failed, Shared context is lost"); 1059 "OffscreenContext Creation failed, Shared context is lost");
1064 gl_info->errorMessage = WebString::fromUTF8(error_message); 1060 gl_info->errorMessage = WebString::fromUTF8(error_message);
1065 return nullptr; 1061 return nullptr;
1066 } 1062 }
1067 share_context = share_provider_impl->context_provider(); 1063 share_context = share_provider_impl->context_provider();
(...skipping 23 matching lines...) Expand all
1091 // Prefer discrete GPU for WebGL. 1087 // Prefer discrete GPU for WebGL.
1092 constexpr gfx::GpuPreference gpu_preference = gfx::PreferDiscreteGpu; 1088 constexpr gfx::GpuPreference gpu_preference = gfx::PreferDiscreteGpu;
1093 1089
1094 scoped_refptr<ContextProviderCommandBuffer> provider( 1090 scoped_refptr<ContextProviderCommandBuffer> provider(
1095 new ContextProviderCommandBuffer( 1091 new ContextProviderCommandBuffer(
1096 std::move(gpu_channel_host), gpu::GPU_STREAM_DEFAULT, 1092 std::move(gpu_channel_host), gpu::GPU_STREAM_DEFAULT,
1097 gpu::GpuStreamPriority::NORMAL, gpu::kNullSurfaceHandle, 1093 gpu::GpuStreamPriority::NORMAL, gpu::kNullSurfaceHandle,
1098 GURL(top_document_web_url), gpu_preference, automatic_flushes, 1094 GURL(top_document_web_url), gpu_preference, automatic_flushes,
1099 support_locking, gpu::SharedMemoryLimits(), attributes, share_context, 1095 support_locking, gpu::SharedMemoryLimits(), attributes, share_context,
1100 command_buffer_metrics::OFFSCREEN_CONTEXT_FOR_WEBGL)); 1096 command_buffer_metrics::OFFSCREEN_CONTEXT_FOR_WEBGL));
1101 if (will_bind_to_current_thread == blink::Platform::BindToCurrentThread) {
1102 if (!provider->BindToCurrentThread()) {
1103 std::string error_message(
1104 "ContextProviderCommandBuffer::BindToCurrentThread failed: ");
1105 error_message.append(gl_info->errorMessage.utf8());
1106 gl_info->errorMessage = WebString::fromUTF8(error_message);
1107 return nullptr;
1108 }
1109 }
1110 return new WebGraphicsContext3DProviderImpl(std::move(provider)); 1097 return new WebGraphicsContext3DProviderImpl(std::move(provider));
1111 } 1098 }
1112 1099
1113 //------------------------------------------------------------------------------ 1100 //------------------------------------------------------------------------------
1114 1101
1115 blink::WebGraphicsContext3DProvider* 1102 blink::WebGraphicsContext3DProvider*
1116 RendererBlinkPlatformImpl::createSharedOffscreenGraphicsContext3DProvider() { 1103 RendererBlinkPlatformImpl::createSharedOffscreenGraphicsContext3DProvider() {
1117 scoped_refptr<ContextProviderCommandBuffer> provider = 1104 scoped_refptr<ContextProviderCommandBuffer> provider =
1118 RenderThreadImpl::current()->SharedMainThreadContextProvider(); 1105 RenderThreadImpl::current()->SharedMainThreadContextProvider();
1119 if (!provider) 1106 if (!provider)
(...skipping 189 matching lines...) Expand 10 before | Expand all | Expand 10 after
1309 return &trial_token_validator_; 1296 return &trial_token_validator_;
1310 } 1297 }
1311 1298
1312 void RendererBlinkPlatformImpl::workerContextCreated( 1299 void RendererBlinkPlatformImpl::workerContextCreated(
1313 const v8::Local<v8::Context>& worker) { 1300 const v8::Local<v8::Context>& worker) {
1314 GetContentClient()->renderer()->DidInitializeWorkerContextOnWorkerThread( 1301 GetContentClient()->renderer()->DidInitializeWorkerContextOnWorkerThread(
1315 worker); 1302 worker);
1316 } 1303 }
1317 1304
1318 } // namespace content 1305 } // namespace content
OLDNEW
« no previous file with comments | « content/renderer/renderer_blink_platform_impl.h ('k') | content/renderer/webgraphicscontext3d_provider_impl.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698