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

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
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 989 matching lines...) Expand 10 before | Expand all | Expand 10 after
1046 gfx::PluginWindowHandle window, 1047 gfx::PluginWindowHandle window,
1047 int32 image_id, 1048 int32 image_id,
1048 const CreateImageCallback& callback) { 1049 const CreateImageCallback& callback) {
1049 NOTREACHED(); 1050 NOTREACHED();
1050 } 1051 }
1051 1052
1052 void RenderThreadImpl::DeleteImage(int32 image_id, int32 sync_point) { 1053 void RenderThreadImpl::DeleteImage(int32 image_id, int32 sync_point) {
1053 NOTREACHED(); 1054 NOTREACHED();
1054 } 1055 }
1055 1056
1057 scoped_ptr<gfx::GpuMemoryBuffer> RenderThreadImpl::AllocateGpuMemoryBuffer(
1058 size_t width,
1059 size_t height,
1060 unsigned internalformat) {
1061 DCHECK(GpuMemoryBufferImpl::IsFormatValid(internalformat));
1062 if (!GpuMemoryBufferImpl::IsFormatValid(internalformat))
1063 return scoped_ptr<gfx::GpuMemoryBuffer>();
1064
1065 size_t size = width * height *
1066 GpuMemoryBufferImpl::BytesPerPixel(internalformat);
1067 if (size > static_cast<size_t>(std::numeric_limits<int>::max()))
1068 return scoped_ptr<gfx::GpuMemoryBuffer>();
1069
1070 base::SharedMemoryHandle handle;
1071 bool success;
1072 IPC::Message* message =
1073 new ChildProcessHostMsg_SyncAllocateGpuMemoryBuffer(size, &handle);
1074
1075 // Allow calling this from the compositor thread.
1076 if (base::MessageLoop::current() == message_loop())
1077 success = ChildThread::Send(message);
1078 else
1079 success = sync_message_filter()->Send(message);
1080
1081 if (!success)
1082 return scoped_ptr<gfx::GpuMemoryBuffer>();
1083
1084 if (!base::SharedMemory::IsHandleValid(handle))
1085 return scoped_ptr<gfx::GpuMemoryBuffer>();
1086
1087 return make_scoped_ptr<gfx::GpuMemoryBuffer>(
1088 new GpuMemoryBufferImpl(
1089 make_scoped_ptr(new base::SharedMemory(handle, false)),
1090 width,
1091 height,
1092 internalformat));
1093 }
1094
1056 void RenderThreadImpl::DoNotSuspendWebKitSharedTimer() { 1095 void RenderThreadImpl::DoNotSuspendWebKitSharedTimer() {
1057 suspend_webkit_shared_timer_ = false; 1096 suspend_webkit_shared_timer_ = false;
1058 } 1097 }
1059 1098
1060 void RenderThreadImpl::DoNotNotifyWebKitOfModalLoop() { 1099 void RenderThreadImpl::DoNotNotifyWebKitOfModalLoop() {
1061 notify_webkit_of_modal_loop_ = false; 1100 notify_webkit_of_modal_loop_ = false;
1062 } 1101 }
1063 1102
1064 void RenderThreadImpl::OnSetZoomLevelForCurrentURL(const std::string& scheme, 1103 void RenderThreadImpl::OnSetZoomLevelForCurrentURL(const std::string& scheme,
1065 const std::string& host, 1104 const std::string& host,
(...skipping 230 matching lines...) Expand 10 before | Expand all | Expand 10 after
1296 if (!gamepad_shared_memory_reader_) 1335 if (!gamepad_shared_memory_reader_)
1297 gamepad_shared_memory_reader_.reset(new GamepadSharedMemoryReader); 1336 gamepad_shared_memory_reader_.reset(new GamepadSharedMemoryReader);
1298 gamepad_shared_memory_reader_->SampleGamepads(*data); 1337 gamepad_shared_memory_reader_->SampleGamepads(*data);
1299 } 1338 }
1300 1339
1301 base::ProcessId RenderThreadImpl::renderer_process_id() const { 1340 base::ProcessId RenderThreadImpl::renderer_process_id() const {
1302 return renderer_process_id_; 1341 return renderer_process_id_;
1303 } 1342 }
1304 1343
1305 } // namespace content 1344 } // namespace content
OLDNEW
« content/common/gpu/gpu_messages.h ('K') | « content/renderer/render_thread_impl.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698