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 "content/common/gpu/gpu_command_buffer_stub.h" |
| 6 |
| 7 #include <utility> |
| 8 |
5 #include "base/bind.h" | 9 #include "base/bind.h" |
6 #include "base/bind_helpers.h" | 10 #include "base/bind_helpers.h" |
7 #include "base/command_line.h" | 11 #include "base/command_line.h" |
8 #include "base/hash.h" | 12 #include "base/hash.h" |
9 #include "base/json/json_writer.h" | 13 #include "base/json/json_writer.h" |
10 #include "base/macros.h" | 14 #include "base/macros.h" |
11 #include "base/memory/shared_memory.h" | 15 #include "base/memory/shared_memory.h" |
12 #include "base/time/time.h" | 16 #include "base/time/time.h" |
13 #include "base/trace_event/trace_event.h" | 17 #include "base/trace_event/trace_event.h" |
14 #include "build/build_config.h" | 18 #include "build/build_config.h" |
15 #include "content/common/gpu/gpu_channel.h" | 19 #include "content/common/gpu/gpu_channel.h" |
16 #include "content/common/gpu/gpu_channel_manager.h" | 20 #include "content/common/gpu/gpu_channel_manager.h" |
17 #include "content/common/gpu/gpu_command_buffer_stub.h" | |
18 #include "content/common/gpu/gpu_memory_manager.h" | 21 #include "content/common/gpu/gpu_memory_manager.h" |
19 #include "content/common/gpu/gpu_memory_tracking.h" | 22 #include "content/common/gpu/gpu_memory_tracking.h" |
20 #include "content/common/gpu/gpu_messages.h" | 23 #include "content/common/gpu/gpu_messages.h" |
21 #include "content/common/gpu/gpu_watchdog.h" | 24 #include "content/common/gpu/gpu_watchdog.h" |
22 #include "content/common/gpu/image_transport_surface.h" | 25 #include "content/common/gpu/image_transport_surface.h" |
23 #include "content/common/gpu/media/gpu_video_decode_accelerator.h" | 26 #include "content/common/gpu/media/gpu_video_decode_accelerator.h" |
24 #include "content/common/gpu/media/gpu_video_encode_accelerator.h" | 27 #include "content/common/gpu/media/gpu_video_encode_accelerator.h" |
25 #include "content/public/common/content_client.h" | 28 #include "content/public/common/content_client.h" |
26 #include "content/public/common/content_switches.h" | 29 #include "content/public/common/content_switches.h" |
27 #include "gpu/command_buffer/common/constants.h" | 30 #include "gpu/command_buffer/common/constants.h" |
(...skipping 630 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
658 base::Unretained(this))); | 661 base::Unretained(this))); |
659 } | 662 } |
660 | 663 |
661 const size_t kSharedStateSize = sizeof(gpu::CommandBufferSharedState); | 664 const size_t kSharedStateSize = sizeof(gpu::CommandBufferSharedState); |
662 if (!shared_state_shm->Map(kSharedStateSize)) { | 665 if (!shared_state_shm->Map(kSharedStateSize)) { |
663 DLOG(ERROR) << "Failed to map shared state buffer."; | 666 DLOG(ERROR) << "Failed to map shared state buffer."; |
664 OnInitializeFailed(reply_message); | 667 OnInitializeFailed(reply_message); |
665 return; | 668 return; |
666 } | 669 } |
667 command_buffer_->SetSharedStateBuffer(gpu::MakeBackingFromSharedMemory( | 670 command_buffer_->SetSharedStateBuffer(gpu::MakeBackingFromSharedMemory( |
668 shared_state_shm.Pass(), kSharedStateSize)); | 671 std::move(shared_state_shm), kSharedStateSize)); |
669 | 672 |
670 gpu::Capabilities capabilities = decoder_->GetCapabilities(); | 673 gpu::Capabilities capabilities = decoder_->GetCapabilities(); |
671 capabilities.future_sync_points = channel_->allow_future_sync_points(); | 674 capabilities.future_sync_points = channel_->allow_future_sync_points(); |
672 | 675 |
673 GpuCommandBufferMsg_Initialize::WriteReplyParams( | 676 GpuCommandBufferMsg_Initialize::WriteReplyParams( |
674 reply_message, true, capabilities); | 677 reply_message, true, capabilities); |
675 Send(reply_message); | 678 Send(reply_message); |
676 | 679 |
677 if (handle_.is_null() && !active_url_.is_empty()) { | 680 if (handle_.is_null() && !active_url_.is_empty()) { |
678 manager->Send(new GpuHostMsg_DidCreateOffscreenContext( | 681 manager->Send(new GpuHostMsg_DidCreateOffscreenContext( |
(...skipping 173 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
852 // This validates the size. | 855 // This validates the size. |
853 scoped_ptr<base::SharedMemory> shared_memory( | 856 scoped_ptr<base::SharedMemory> shared_memory( |
854 new base::SharedMemory(transfer_buffer, false)); | 857 new base::SharedMemory(transfer_buffer, false)); |
855 if (!shared_memory->Map(size)) { | 858 if (!shared_memory->Map(size)) { |
856 DVLOG(0) << "Failed to map shared memory."; | 859 DVLOG(0) << "Failed to map shared memory."; |
857 return; | 860 return; |
858 } | 861 } |
859 | 862 |
860 if (command_buffer_) { | 863 if (command_buffer_) { |
861 command_buffer_->RegisterTransferBuffer( | 864 command_buffer_->RegisterTransferBuffer( |
862 id, gpu::MakeBackingFromSharedMemory(shared_memory.Pass(), size)); | 865 id, gpu::MakeBackingFromSharedMemory(std::move(shared_memory), size)); |
863 } | 866 } |
864 } | 867 } |
865 | 868 |
866 void GpuCommandBufferStub::OnDestroyTransferBuffer(int32_t id) { | 869 void GpuCommandBufferStub::OnDestroyTransferBuffer(int32_t id) { |
867 TRACE_EVENT0("gpu", "GpuCommandBufferStub::OnDestroyTransferBuffer"); | 870 TRACE_EVENT0("gpu", "GpuCommandBufferStub::OnDestroyTransferBuffer"); |
868 | 871 |
869 if (command_buffer_) | 872 if (command_buffer_) |
870 command_buffer_->DestroyTransferBuffer(id); | 873 command_buffer_->DestroyTransferBuffer(id); |
871 } | 874 } |
872 | 875 |
(...skipping 379 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1252 result)); | 1255 result)); |
1253 } | 1256 } |
1254 | 1257 |
1255 void GpuCommandBufferStub::SendUpdateVSyncParameters(base::TimeTicks timebase, | 1258 void GpuCommandBufferStub::SendUpdateVSyncParameters(base::TimeTicks timebase, |
1256 base::TimeDelta interval) { | 1259 base::TimeDelta interval) { |
1257 Send(new GpuCommandBufferMsg_UpdateVSyncParameters(route_id_, timebase, | 1260 Send(new GpuCommandBufferMsg_UpdateVSyncParameters(route_id_, timebase, |
1258 interval)); | 1261 interval)); |
1259 } | 1262 } |
1260 | 1263 |
1261 } // namespace content | 1264 } // namespace content |
OLD | NEW |