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

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

Issue 77023002: gpu: Add IOSurface backed GpuMemoryBuffer implementation. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 7 years 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 1053 matching lines...) Expand 10 before | Expand all | Expand 10 after
1064 NOTREACHED(); 1064 NOTREACHED();
1065 } 1065 }
1066 1066
1067 scoped_ptr<gfx::GpuMemoryBuffer> RenderThreadImpl::AllocateGpuMemoryBuffer( 1067 scoped_ptr<gfx::GpuMemoryBuffer> RenderThreadImpl::AllocateGpuMemoryBuffer(
1068 size_t width, 1068 size_t width,
1069 size_t height, 1069 size_t height,
1070 unsigned internalformat) { 1070 unsigned internalformat) {
1071 if (!GpuMemoryBufferImpl::IsFormatValid(internalformat)) 1071 if (!GpuMemoryBufferImpl::IsFormatValid(internalformat))
1072 return scoped_ptr<gfx::GpuMemoryBuffer>(); 1072 return scoped_ptr<gfx::GpuMemoryBuffer>();
1073 1073
1074 size_t size = width * height *
1075 GpuMemoryBufferImpl::BytesPerPixel(internalformat);
1076 if (size > static_cast<size_t>(std::numeric_limits<int>::max()))
1077 return scoped_ptr<gfx::GpuMemoryBuffer>();
1078
1079 gfx::GpuMemoryBufferHandle handle; 1074 gfx::GpuMemoryBufferHandle handle;
1080 bool success; 1075 bool success;
1081 IPC::Message* message = 1076 IPC::Message* message =
1082 new ChildProcessHostMsg_SyncAllocateGpuMemoryBuffer(size, &handle); 1077 new ChildProcessHostMsg_SyncAllocateGpuMemoryBuffer(width,
1078 height,
1079 internalformat,
1080 &handle);
1083 1081
1084 // Allow calling this from the compositor thread. 1082 // Allow calling this from the compositor thread.
1085 if (base::MessageLoop::current() == message_loop()) 1083 if (base::MessageLoop::current() == message_loop())
1086 success = ChildThread::Send(message); 1084 success = ChildThread::Send(message);
1087 else 1085 else
1088 success = sync_message_filter()->Send(message); 1086 success = sync_message_filter()->Send(message);
1089 1087
1090 if (!success) 1088 if (!success)
1091 return scoped_ptr<gfx::GpuMemoryBuffer>(); 1089 return scoped_ptr<gfx::GpuMemoryBuffer>();
1092 1090
1093 // Currently, shared memory is the only supported buffer type. 1091 return GpuMemoryBufferImpl::Create(
1094 if (handle.type != gfx::SHARED_MEMORY_BUFFER) 1092 handle,
1095 return scoped_ptr<gfx::GpuMemoryBuffer>(); 1093 gfx::Size(width, height),
1096 1094 internalformat).PassAs<gfx::GpuMemoryBuffer>();
1097 if (!base::SharedMemory::IsHandleValid(handle.handle))
1098 return scoped_ptr<gfx::GpuMemoryBuffer>();
1099
1100 return make_scoped_ptr<gfx::GpuMemoryBuffer>(
1101 new GpuMemoryBufferImpl(
1102 make_scoped_ptr(new base::SharedMemory(handle.handle, false)),
1103 width,
1104 height,
1105 internalformat));
1106 } 1095 }
1107 1096
1108 void RenderThreadImpl::DoNotSuspendWebKitSharedTimer() { 1097 void RenderThreadImpl::DoNotSuspendWebKitSharedTimer() {
1109 suspend_webkit_shared_timer_ = false; 1098 suspend_webkit_shared_timer_ = false;
1110 } 1099 }
1111 1100
1112 void RenderThreadImpl::DoNotNotifyWebKitOfModalLoop() { 1101 void RenderThreadImpl::DoNotNotifyWebKitOfModalLoop() {
1113 notify_webkit_of_modal_loop_ = false; 1102 notify_webkit_of_modal_loop_ = false;
1114 } 1103 }
1115 1104
(...skipping 251 matching lines...) Expand 10 before | Expand all | Expand 10 after
1367 if (!gamepad_shared_memory_reader_) 1356 if (!gamepad_shared_memory_reader_)
1368 gamepad_shared_memory_reader_.reset(new GamepadSharedMemoryReader); 1357 gamepad_shared_memory_reader_.reset(new GamepadSharedMemoryReader);
1369 gamepad_shared_memory_reader_->SampleGamepads(*data); 1358 gamepad_shared_memory_reader_->SampleGamepads(*data);
1370 } 1359 }
1371 1360
1372 base::ProcessId RenderThreadImpl::renderer_process_id() const { 1361 base::ProcessId RenderThreadImpl::renderer_process_id() const {
1373 return renderer_process_id_; 1362 return renderer_process_id_;
1374 } 1363 }
1375 1364
1376 } // namespace content 1365 } // namespace content
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698