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

Unified Diff: content/common/gpu/gpu_command_buffer_stub.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
« no previous file with comments | « no previous file | gpu/command_buffer/common/buffer.h » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: content/common/gpu/gpu_command_buffer_stub.cc
diff --git a/content/common/gpu/gpu_command_buffer_stub.cc b/content/common/gpu/gpu_command_buffer_stub.cc
index 8bccd2abd2f66732ce60175a50a2f87802dbc42a..ef6a45a2e1916e21ed9fc8ba7611a40ea9f23a7c 100644
--- a/content/common/gpu/gpu_command_buffer_stub.cc
+++ b/content/common/gpu/gpu_command_buffer_stub.cc
@@ -686,9 +686,18 @@ void GpuCommandBufferStub::OnRegisterTransferBuffer(
base::SharedMemoryHandle transfer_buffer,
uint32 size) {
TRACE_EVENT0("gpu", "GpuCommandBufferStub::OnRegisterTransferBuffer");
- base::SharedMemory shared_memory(transfer_buffer, false);
+
+ // Take ownership of the memory and map it into this process.
+ // This validates the size.
+ scoped_ptr<base::SharedMemory> shared_memory(
+ new base::SharedMemory(transfer_buffer, false));
+ if (!shared_memory->Map(size)) {
+ DVLOG(0) << "Failed to map shared memory.";
+ return;
+ }
+
if (command_buffer_)
- command_buffer_->RegisterTransferBuffer(id, &shared_memory, size);
+ command_buffer_->RegisterTransferBuffer(id, shared_memory.Pass(), size);
}
void GpuCommandBufferStub::OnDestroyTransferBuffer(int32 id) {
« no previous file with comments | « no previous file | gpu/command_buffer/common/buffer.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698