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

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

Issue 19762004: Add multi-process GpuMemoryBuffer framework. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 7 years, 2 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 | Annotate | Revision Log
« no previous file with comments | « content/renderer/render_thread_impl.h ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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/render_thread_impl.h" 5 #include "content/renderer/render_thread_impl.h"
6 6
7 #include <algorithm> 7 #include <algorithm>
8 #include <limits> 8 #include <limits>
9 #include <map> 9 #include <map>
10 #include <vector> 10 #include <vector>
(...skipping 26 matching lines...) Expand all
37 #include "content/child/resource_dispatcher.h" 37 #include "content/child/resource_dispatcher.h"
38 #include "content/child/runtime_features.h" 38 #include "content/child/runtime_features.h"
39 #include "content/child/thread_safe_sender.h" 39 #include "content/child/thread_safe_sender.h"
40 #include "content/child/web_database_observer_impl.h" 40 #include "content/child/web_database_observer_impl.h"
41 #include "content/common/child_process_messages.h" 41 #include "content/common/child_process_messages.h"
42 #include "content/common/content_constants_internal.h" 42 #include "content/common/content_constants_internal.h"
43 #include "content/common/database_messages.h" 43 #include "content/common/database_messages.h"
44 #include "content/common/dom_storage/dom_storage_messages.h" 44 #include "content/common/dom_storage/dom_storage_messages.h"
45 #include "content/common/gpu/client/context_provider_command_buffer.h" 45 #include "content/common/gpu/client/context_provider_command_buffer.h"
46 #include "content/common/gpu/client/gpu_channel_host.h" 46 #include "content/common/gpu/client/gpu_channel_host.h"
47 #include "content/common/gpu/client/gpu_memory_buffer_impl.h"
47 #include "content/common/gpu/gpu_messages.h" 48 #include "content/common/gpu/gpu_messages.h"
48 #include "content/common/resource_messages.h" 49 #include "content/common/resource_messages.h"
49 #include "content/common/view_messages.h" 50 #include "content/common/view_messages.h"
50 #include "content/public/common/content_constants.h" 51 #include "content/public/common/content_constants.h"
51 #include "content/public/common/content_paths.h" 52 #include "content/public/common/content_paths.h"
52 #include "content/public/common/content_switches.h" 53 #include "content/public/common/content_switches.h"
53 #include "content/public/common/renderer_preferences.h" 54 #include "content/public/common/renderer_preferences.h"
54 #include "content/public/common/url_constants.h" 55 #include "content/public/common/url_constants.h"
55 #include "content/public/renderer/content_renderer_client.h" 56 #include "content/public/renderer/content_renderer_client.h"
56 #include "content/public/renderer/render_process_observer.h" 57 #include "content/public/renderer/render_process_observer.h"
(...skipping 988 matching lines...) Expand 10 before | Expand all | Expand 10 after
1045 gfx::PluginWindowHandle window, 1046 gfx::PluginWindowHandle window,
1046 int32 image_id, 1047 int32 image_id,
1047 const CreateImageCallback& callback) { 1048 const CreateImageCallback& callback) {
1048 NOTREACHED(); 1049 NOTREACHED();
1049 } 1050 }
1050 1051
1051 void RenderThreadImpl::DeleteImage(int32 image_id, int32 sync_point) { 1052 void RenderThreadImpl::DeleteImage(int32 image_id, int32 sync_point) {
1052 NOTREACHED(); 1053 NOTREACHED();
1053 } 1054 }
1054 1055
1056 scoped_ptr<gfx::GpuMemoryBuffer> RenderThreadImpl::AllocateGpuMemoryBuffer(
1057 size_t width,
1058 size_t height,
1059 unsigned internalformat) {
1060 if (!GpuMemoryBufferImpl::IsFormatValid(internalformat))
1061 return scoped_ptr<gfx::GpuMemoryBuffer>();
1062
1063 size_t size = width * height *
1064 GpuMemoryBufferImpl::BytesPerPixel(internalformat);
1065 if (size > static_cast<size_t>(std::numeric_limits<int>::max()))
1066 return scoped_ptr<gfx::GpuMemoryBuffer>();
1067
1068 gfx::GpuMemoryBufferHandle handle;
1069 bool success;
1070 IPC::Message* message =
1071 new ChildProcessHostMsg_SyncAllocateGpuMemoryBuffer(size, &handle);
1072
1073 // Allow calling this from the compositor thread.
1074 if (base::MessageLoop::current() == message_loop())
1075 success = ChildThread::Send(message);
1076 else
1077 success = sync_message_filter()->Send(message);
1078
1079 if (!success)
1080 return scoped_ptr<gfx::GpuMemoryBuffer>();
1081
1082 // Currently, shared memory is the only supported buffer type.
1083 if (handle.type != gfx::SHARED_MEMORY_BUFFER)
1084 return scoped_ptr<gfx::GpuMemoryBuffer>();
1085
1086 if (!base::SharedMemory::IsHandleValid(handle.handle))
1087 return scoped_ptr<gfx::GpuMemoryBuffer>();
1088
1089 return make_scoped_ptr<gfx::GpuMemoryBuffer>(
1090 new GpuMemoryBufferImpl(
1091 make_scoped_ptr(new base::SharedMemory(handle.handle, false)),
1092 width,
1093 height,
1094 internalformat));
1095 }
1096
1055 void RenderThreadImpl::DoNotSuspendWebKitSharedTimer() { 1097 void RenderThreadImpl::DoNotSuspendWebKitSharedTimer() {
1056 suspend_webkit_shared_timer_ = false; 1098 suspend_webkit_shared_timer_ = false;
1057 } 1099 }
1058 1100
1059 void RenderThreadImpl::DoNotNotifyWebKitOfModalLoop() { 1101 void RenderThreadImpl::DoNotNotifyWebKitOfModalLoop() {
1060 notify_webkit_of_modal_loop_ = false; 1102 notify_webkit_of_modal_loop_ = false;
1061 } 1103 }
1062 1104
1063 void RenderThreadImpl::OnSetZoomLevelForCurrentURL(const std::string& scheme, 1105 void RenderThreadImpl::OnSetZoomLevelForCurrentURL(const std::string& scheme,
1064 const std::string& host, 1106 const std::string& host,
(...skipping 230 matching lines...) Expand 10 before | Expand all | Expand 10 after
1295 if (!gamepad_shared_memory_reader_) 1337 if (!gamepad_shared_memory_reader_)
1296 gamepad_shared_memory_reader_.reset(new GamepadSharedMemoryReader); 1338 gamepad_shared_memory_reader_.reset(new GamepadSharedMemoryReader);
1297 gamepad_shared_memory_reader_->SampleGamepads(*data); 1339 gamepad_shared_memory_reader_->SampleGamepads(*data);
1298 } 1340 }
1299 1341
1300 base::ProcessId RenderThreadImpl::renderer_process_id() const { 1342 base::ProcessId RenderThreadImpl::renderer_process_id() const {
1301 return renderer_process_id_; 1343 return renderer_process_id_;
1302 } 1344 }
1303 1345
1304 } // namespace content 1346 } // namespace content
OLDNEW
« no previous file with comments | « content/renderer/render_thread_impl.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698