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

Unified Diff: gpu/command_buffer/service/transfer_buffer_manager.cc

Issue 211703003: GPU: 'Pass' SharedMemory when possible. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@GPU_ref_count_buffer
Patch Set: Rebase. Created 6 years, 9 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 side-by-side diff with in-line comments
Download patch
Index: gpu/command_buffer/service/transfer_buffer_manager.cc
diff --git a/gpu/command_buffer/service/transfer_buffer_manager.cc b/gpu/command_buffer/service/transfer_buffer_manager.cc
index 7130cb135a447fe4ac840117df102cf8c7688301..7f81115b85b5c653c936fef28156e86bd06d54b5 100644
--- a/gpu/command_buffer/service/transfer_buffer_manager.cc
+++ b/gpu/command_buffer/service/transfer_buffer_manager.cc
@@ -40,7 +40,7 @@ bool TransferBufferManager::Initialize() {
bool TransferBufferManager::RegisterTransferBuffer(
int32 id,
- base::SharedMemory* shared_memory,
+ scoped_ptr<base::SharedMemory> shared_memory,
size_t size) {
if (id <= 0) {
DVLOG(0) << "Cannot register transfer buffer with non-positive ID.";
@@ -53,25 +53,8 @@ bool TransferBufferManager::RegisterTransferBuffer(
return false;
}
- // Duplicate the handle.
- base::SharedMemoryHandle duped_shared_memory_handle;
- if (!shared_memory->ShareToProcess(base::GetCurrentProcessHandle(),
- &duped_shared_memory_handle)) {
- DVLOG(0) << "Failed to duplicate shared memory handle.";
- return false;
- }
- scoped_ptr<SharedMemory> duped_shared_memory(
- new SharedMemory(duped_shared_memory_handle, false));
-
- // Map the shared memory into this process. This validates the size.
- if (!duped_shared_memory->Map(size)) {
- DVLOG(0) << "Failed to map shared memory.";
- return false;
- }
-
- // If it could be mapped register the shared memory with the ID.
- scoped_refptr<Buffer> buffer =
- make_scoped_refptr(new gpu::Buffer(duped_shared_memory.Pass(), size));
+ // Register the shared memory with the ID.
+ scoped_refptr<Buffer> buffer = new gpu::Buffer(shared_memory.Pass(), size);
// Check buffer alignment is sane.
DCHECK(!(reinterpret_cast<uintptr_t>(buffer->memory()) &
« no previous file with comments | « gpu/command_buffer/service/transfer_buffer_manager.h ('k') | gpu/command_buffer/service/transfer_buffer_manager_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698