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 662 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
673 return DatabaseUtil::DatabaseSetFileSize( | 673 return DatabaseUtil::DatabaseSetFileSize( |
674 vfs_file_name, size, sync_message_filter_.get()); | 674 vfs_file_name, size, sync_message_filter_.get()); |
675 } | 675 } |
676 | 676 |
677 WebString RendererBlinkPlatformImpl::databaseCreateOriginIdentifier( | 677 WebString RendererBlinkPlatformImpl::databaseCreateOriginIdentifier( |
678 const blink::WebSecurityOrigin& origin) { | 678 const blink::WebSecurityOrigin& origin) { |
679 return WebString::fromUTF8(storage::GetIdentifierFromOrigin( | 679 return WebString::fromUTF8(storage::GetIdentifierFromOrigin( |
680 WebSecurityOriginToGURL(origin))); | 680 WebSecurityOriginToGURL(origin))); |
681 } | 681 } |
682 | 682 |
683 bool RendererBlinkPlatformImpl::canAccelerate2dCanvas() { | |
684 RenderThreadImpl* thread = RenderThreadImpl::current(); | |
685 scoped_refptr<gpu::GpuChannelHost> host = thread->EstablishGpuChannelSync(); | |
686 if (!host) | |
687 return false; | |
688 | |
689 return !host->gpu_info().software_rendering; | |
690 } | |
691 | |
692 bool RendererBlinkPlatformImpl::isThreadedCompositingEnabled() { | 683 bool RendererBlinkPlatformImpl::isThreadedCompositingEnabled() { |
693 RenderThreadImpl* thread = RenderThreadImpl::current(); | 684 RenderThreadImpl* thread = RenderThreadImpl::current(); |
694 // thread can be NULL in tests. | 685 // thread can be NULL in tests. |
695 return thread && thread->compositor_task_runner().get(); | 686 return thread && thread->compositor_task_runner().get(); |
696 } | 687 } |
697 | 688 |
698 bool RendererBlinkPlatformImpl::isThreadedAnimationEnabled() { | 689 bool RendererBlinkPlatformImpl::isThreadedAnimationEnabled() { |
699 RenderThreadImpl* thread = RenderThreadImpl::current(); | 690 RenderThreadImpl* thread = RenderThreadImpl::current(); |
700 return thread ? thread->IsThreadedAnimationEnabled() : true; | 691 return thread ? thread->IsThreadedAnimationEnabled() : true; |
701 } | 692 } |
(...skipping 376 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1078 auto* gl = share_provider_impl->contextGL(); | 1069 auto* gl = share_provider_impl->contextGL(); |
1079 if (gl->GetGraphicsResetStatusKHR() != GL_NO_ERROR) { | 1070 if (gl->GetGraphicsResetStatusKHR() != GL_NO_ERROR) { |
1080 std::string error_message( | 1071 std::string error_message( |
1081 "OffscreenContext Creation failed, Shared context is lost"); | 1072 "OffscreenContext Creation failed, Shared context is lost"); |
1082 gl_info->errorMessage = WebString::fromUTF8(error_message); | 1073 gl_info->errorMessage = WebString::fromUTF8(error_message); |
1083 return nullptr; | 1074 return nullptr; |
1084 } | 1075 } |
1085 share_context = share_provider_impl->context_provider(); | 1076 share_context = share_provider_impl->context_provider(); |
1086 } | 1077 } |
1087 | 1078 |
| 1079 bool is_software_rendering = gpu_channel_host->gpu_info().software_rendering; |
| 1080 |
1088 // This is an offscreen context, which doesn't use the default frame buffer, | 1081 // This is an offscreen context, which doesn't use the default frame buffer, |
1089 // so don't request any alpha, depth, stencil, antialiasing. | 1082 // so don't request any alpha, depth, stencil, antialiasing. |
1090 gpu::gles2::ContextCreationAttribHelper attributes; | 1083 gpu::gles2::ContextCreationAttribHelper attributes; |
1091 attributes.alpha_size = -1; | 1084 attributes.alpha_size = -1; |
1092 attributes.depth_size = 0; | 1085 attributes.depth_size = 0; |
1093 attributes.stencil_size = 0; | 1086 attributes.stencil_size = 0; |
1094 attributes.samples = 0; | 1087 attributes.samples = 0; |
1095 attributes.sample_buffers = 0; | 1088 attributes.sample_buffers = 0; |
1096 attributes.bind_generates_resource = false; | 1089 attributes.bind_generates_resource = false; |
1097 // Prefer discrete GPU for WebGL. | 1090 // Prefer discrete GPU for WebGL. |
(...skipping 11 matching lines...) Expand all Loading... |
1109 constexpr bool automatic_flushes = true; | 1102 constexpr bool automatic_flushes = true; |
1110 constexpr bool support_locking = false; | 1103 constexpr bool support_locking = false; |
1111 | 1104 |
1112 scoped_refptr<ContextProviderCommandBuffer> provider( | 1105 scoped_refptr<ContextProviderCommandBuffer> provider( |
1113 new ContextProviderCommandBuffer( | 1106 new ContextProviderCommandBuffer( |
1114 std::move(gpu_channel_host), gpu::GPU_STREAM_DEFAULT, | 1107 std::move(gpu_channel_host), gpu::GPU_STREAM_DEFAULT, |
1115 gpu::GpuStreamPriority::NORMAL, gpu::kNullSurfaceHandle, | 1108 gpu::GpuStreamPriority::NORMAL, gpu::kNullSurfaceHandle, |
1116 GURL(top_document_web_url), automatic_flushes, support_locking, | 1109 GURL(top_document_web_url), automatic_flushes, support_locking, |
1117 gpu::SharedMemoryLimits(), attributes, share_context, | 1110 gpu::SharedMemoryLimits(), attributes, share_context, |
1118 command_buffer_metrics::OFFSCREEN_CONTEXT_FOR_WEBGL)); | 1111 command_buffer_metrics::OFFSCREEN_CONTEXT_FOR_WEBGL)); |
1119 return new WebGraphicsContext3DProviderImpl(std::move(provider)); | 1112 return new WebGraphicsContext3DProviderImpl(std::move(provider), |
| 1113 is_software_rendering); |
1120 } | 1114 } |
1121 | 1115 |
1122 //------------------------------------------------------------------------------ | 1116 //------------------------------------------------------------------------------ |
1123 | 1117 |
1124 blink::WebGraphicsContext3DProvider* | 1118 blink::WebGraphicsContext3DProvider* |
1125 RendererBlinkPlatformImpl::createSharedOffscreenGraphicsContext3DProvider() { | 1119 RendererBlinkPlatformImpl::createSharedOffscreenGraphicsContext3DProvider() { |
| 1120 auto* thread = RenderThreadImpl::current(); |
| 1121 |
1126 scoped_refptr<ContextProviderCommandBuffer> provider = | 1122 scoped_refptr<ContextProviderCommandBuffer> provider = |
1127 RenderThreadImpl::current()->SharedMainThreadContextProvider(); | 1123 thread->SharedMainThreadContextProvider(); |
1128 if (!provider) | 1124 if (!provider) |
1129 return nullptr; | 1125 return nullptr; |
1130 return new WebGraphicsContext3DProviderImpl(std::move(provider)); | 1126 |
| 1127 scoped_refptr<gpu::GpuChannelHost> host = thread->EstablishGpuChannelSync(); |
| 1128 // This shouldn't normally fail because we just got |provider|. But the |
| 1129 // channel can become lost on the IO thread since then. It is important that |
| 1130 // this happens after getting |provider|. In the case that this GpuChannelHost |
| 1131 // is not the same one backing |provider|, the context behind the |provider| |
| 1132 // will be already lost/dead on arrival, so the value we get for |
| 1133 // |is_software_rendering| will never be wrong. |
| 1134 if (!host) |
| 1135 return nullptr; |
| 1136 |
| 1137 bool is_software_rendering = host->gpu_info().software_rendering; |
| 1138 |
| 1139 return new WebGraphicsContext3DProviderImpl(std::move(provider), |
| 1140 is_software_rendering); |
1131 } | 1141 } |
1132 | 1142 |
1133 //------------------------------------------------------------------------------ | 1143 //------------------------------------------------------------------------------ |
1134 | 1144 |
1135 std::unique_ptr<cc::SharedBitmap> | 1145 std::unique_ptr<cc::SharedBitmap> |
1136 RendererBlinkPlatformImpl::allocateSharedBitmap(const blink::WebSize& size) { | 1146 RendererBlinkPlatformImpl::allocateSharedBitmap(const blink::WebSize& size) { |
1137 return ChildThreadImpl::current() | 1147 return ChildThreadImpl::current() |
1138 ->shared_bitmap_manager() | 1148 ->shared_bitmap_manager() |
1139 ->AllocateSharedBitmap(gfx::Size(size.width, size.height)); | 1149 ->AllocateSharedBitmap(gfx::Size(size.width, size.height)); |
1140 } | 1150 } |
(...skipping 186 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1327 return &trial_token_validator_; | 1337 return &trial_token_validator_; |
1328 } | 1338 } |
1329 | 1339 |
1330 void RendererBlinkPlatformImpl::workerContextCreated( | 1340 void RendererBlinkPlatformImpl::workerContextCreated( |
1331 const v8::Local<v8::Context>& worker) { | 1341 const v8::Local<v8::Context>& worker) { |
1332 GetContentClient()->renderer()->DidInitializeWorkerContextOnWorkerThread( | 1342 GetContentClient()->renderer()->DidInitializeWorkerContextOnWorkerThread( |
1333 worker); | 1343 worker); |
1334 } | 1344 } |
1335 | 1345 |
1336 } // namespace content | 1346 } // namespace content |
OLD | NEW |