OLD | NEW |
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 "base/bind.h" | 5 #include "base/bind.h" |
6 #include "base/bind_helpers.h" | 6 #include "base/bind_helpers.h" |
7 #include "base/command_line.h" | 7 #include "base/command_line.h" |
8 #include "base/debug/trace_event.h" | 8 #include "base/debug/trace_event.h" |
9 #include "base/hash.h" | 9 #include "base/hash.h" |
10 #include "base/memory/shared_memory.h" | 10 #include "base/memory/shared_memory.h" |
(...skipping 668 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
679 | 679 |
680 if (pre_state.get_offset != post_state.get_offset) | 680 if (pre_state.get_offset != post_state.get_offset) |
681 ReportState(); | 681 ReportState(); |
682 } | 682 } |
683 | 683 |
684 void GpuCommandBufferStub::OnRegisterTransferBuffer( | 684 void GpuCommandBufferStub::OnRegisterTransferBuffer( |
685 int32 id, | 685 int32 id, |
686 base::SharedMemoryHandle transfer_buffer, | 686 base::SharedMemoryHandle transfer_buffer, |
687 uint32 size) { | 687 uint32 size) { |
688 TRACE_EVENT0("gpu", "GpuCommandBufferStub::OnRegisterTransferBuffer"); | 688 TRACE_EVENT0("gpu", "GpuCommandBufferStub::OnRegisterTransferBuffer"); |
689 base::SharedMemory shared_memory(transfer_buffer, false); | 689 |
| 690 // Take ownership of the memory and map it into this process. |
| 691 // This validates the size. |
| 692 scoped_ptr<base::SharedMemory> shared_memory( |
| 693 new base::SharedMemory(transfer_buffer, false)); |
| 694 if (!shared_memory->Map(size)) { |
| 695 DVLOG(0) << "Failed to map shared memory."; |
| 696 return; |
| 697 } |
| 698 |
690 if (command_buffer_) | 699 if (command_buffer_) |
691 command_buffer_->RegisterTransferBuffer(id, &shared_memory, size); | 700 command_buffer_->RegisterTransferBuffer(id, shared_memory.Pass(), size); |
692 } | 701 } |
693 | 702 |
694 void GpuCommandBufferStub::OnDestroyTransferBuffer(int32 id) { | 703 void GpuCommandBufferStub::OnDestroyTransferBuffer(int32 id) { |
695 TRACE_EVENT0("gpu", "GpuCommandBufferStub::OnDestroyTransferBuffer"); | 704 TRACE_EVENT0("gpu", "GpuCommandBufferStub::OnDestroyTransferBuffer"); |
696 | 705 |
697 if (command_buffer_) | 706 if (command_buffer_) |
698 command_buffer_->DestroyTransferBuffer(id); | 707 command_buffer_->DestroyTransferBuffer(id); |
699 } | 708 } |
700 | 709 |
701 void GpuCommandBufferStub::OnGetTransferBuffer( | 710 void GpuCommandBufferStub::OnGetTransferBuffer( |
(...skipping 275 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
977 if (decoder_) | 986 if (decoder_) |
978 decoder_->LoseContext(GL_UNKNOWN_CONTEXT_RESET_ARB); | 987 decoder_->LoseContext(GL_UNKNOWN_CONTEXT_RESET_ARB); |
979 command_buffer_->SetParseError(gpu::error::kLostContext); | 988 command_buffer_->SetParseError(gpu::error::kLostContext); |
980 } | 989 } |
981 | 990 |
982 uint64 GpuCommandBufferStub::GetMemoryUsage() const { | 991 uint64 GpuCommandBufferStub::GetMemoryUsage() const { |
983 return GetMemoryManager()->GetClientMemoryUsage(this); | 992 return GetMemoryManager()->GetClientMemoryUsage(this); |
984 } | 993 } |
985 | 994 |
986 } // namespace content | 995 } // namespace content |
OLD | NEW |