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 #if defined(OS_WIN) | 5 #if defined(OS_WIN) |
6 #include <windows.h> | 6 #include <windows.h> |
7 #endif | 7 #endif |
8 | 8 |
9 #include "content/common/gpu/gpu_channel.h" | 9 #include "content/common/gpu/gpu_channel.h" |
10 | 10 |
11 #include <queue> | 11 #include <queue> |
12 #include <vector> | 12 #include <vector> |
13 | 13 |
14 #include "base/bind.h" | 14 #include "base/bind.h" |
15 #include "base/command_line.h" | 15 #include "base/command_line.h" |
16 #include "base/location.h" | 16 #include "base/location.h" |
17 #include "base/single_thread_task_runner.h" | 17 #include "base/single_thread_task_runner.h" |
18 #include "base/stl_util.h" | 18 #include "base/stl_util.h" |
19 #include "base/strings/string_util.h" | 19 #include "base/strings/string_util.h" |
20 #include "base/thread_task_runner_handle.h" | 20 #include "base/thread_task_runner_handle.h" |
21 #include "base/timer/timer.h" | 21 #include "base/timer/timer.h" |
22 #include "base/trace_event/trace_event.h" | 22 #include "base/trace_event/trace_event.h" |
23 #include "content/common/gpu/gpu_channel_manager.h" | 23 #include "content/common/gpu/gpu_channel_manager.h" |
24 #include "content/common/gpu/gpu_memory_buffer_factory.h" | 24 #include "content/common/gpu/gpu_memory_buffer_factory.h" |
25 #include "content/common/gpu/gpu_messages.h" | 25 #include "content/common/gpu/gpu_messages.h" |
| 26 #include "content/common/gpu/media/gpu_jpeg_decode_accelerator.h" |
26 #include "content/public/common/content_switches.h" | 27 #include "content/public/common/content_switches.h" |
27 #include "gpu/command_buffer/common/mailbox.h" | 28 #include "gpu/command_buffer/common/mailbox.h" |
28 #include "gpu/command_buffer/common/value_state.h" | 29 #include "gpu/command_buffer/common/value_state.h" |
29 #include "gpu/command_buffer/service/gpu_scheduler.h" | 30 #include "gpu/command_buffer/service/gpu_scheduler.h" |
30 #include "gpu/command_buffer/service/image_factory.h" | 31 #include "gpu/command_buffer/service/image_factory.h" |
31 #include "gpu/command_buffer/service/mailbox_manager_impl.h" | 32 #include "gpu/command_buffer/service/mailbox_manager_impl.h" |
32 #include "gpu/command_buffer/service/sync_point_manager.h" | 33 #include "gpu/command_buffer/service/sync_point_manager.h" |
33 #include "gpu/command_buffer/service/valuebuffer_manager.h" | 34 #include "gpu/command_buffer/service/valuebuffer_manager.h" |
34 #include "ipc/ipc_channel.h" | 35 #include "ipc/ipc_channel.h" |
35 #include "ipc/message_filter.h" | 36 #include "ipc/message_filter.h" |
(...skipping 623 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
659 gpu_channel_manager_->RemoveChannel(client_id_); | 660 gpu_channel_manager_->RemoveChannel(client_id_); |
660 } | 661 } |
661 | 662 |
662 bool GpuChannel::OnControlMessageReceived(const IPC::Message& msg) { | 663 bool GpuChannel::OnControlMessageReceived(const IPC::Message& msg) { |
663 bool handled = true; | 664 bool handled = true; |
664 IPC_BEGIN_MESSAGE_MAP(GpuChannel, msg) | 665 IPC_BEGIN_MESSAGE_MAP(GpuChannel, msg) |
665 IPC_MESSAGE_HANDLER(GpuChannelMsg_CreateOffscreenCommandBuffer, | 666 IPC_MESSAGE_HANDLER(GpuChannelMsg_CreateOffscreenCommandBuffer, |
666 OnCreateOffscreenCommandBuffer) | 667 OnCreateOffscreenCommandBuffer) |
667 IPC_MESSAGE_HANDLER(GpuChannelMsg_DestroyCommandBuffer, | 668 IPC_MESSAGE_HANDLER(GpuChannelMsg_DestroyCommandBuffer, |
668 OnDestroyCommandBuffer) | 669 OnDestroyCommandBuffer) |
| 670 IPC_MESSAGE_HANDLER_DELAY_REPLY(GpuMsg_CreateJpegDecoder, |
| 671 OnCreateJpegDecoder) |
669 IPC_MESSAGE_UNHANDLED(handled = false) | 672 IPC_MESSAGE_UNHANDLED(handled = false) |
670 IPC_END_MESSAGE_MAP() | 673 IPC_END_MESSAGE_MAP() |
671 DCHECK(handled) << msg.type(); | 674 DCHECK(handled) << msg.type(); |
672 return handled; | 675 return handled; |
673 } | 676 } |
674 | 677 |
675 void GpuChannel::HandleMessage() { | 678 void GpuChannel::HandleMessage() { |
676 handle_messages_scheduled_ = false; | 679 handle_messages_scheduled_ = false; |
677 if (deferred_messages_.empty()) | 680 if (deferred_messages_.empty()) |
678 return; | 681 return; |
(...skipping 101 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
780 router_.RemoveRoute(route_id); | 783 router_.RemoveRoute(route_id); |
781 stubs_.Remove(route_id); | 784 stubs_.Remove(route_id); |
782 // In case the renderer is currently blocked waiting for a sync reply from the | 785 // In case the renderer is currently blocked waiting for a sync reply from the |
783 // stub, we need to make sure to reschedule the GpuChannel here. | 786 // stub, we need to make sure to reschedule the GpuChannel here. |
784 if (need_reschedule) { | 787 if (need_reschedule) { |
785 // This stub won't get a chance to reschedule, so update the count now. | 788 // This stub won't get a chance to reschedule, so update the count now. |
786 StubSchedulingChanged(true); | 789 StubSchedulingChanged(true); |
787 } | 790 } |
788 } | 791 } |
789 | 792 |
| 793 void GpuChannel::OnCreateJpegDecoder(int32 route_id, IPC::Message* reply_msg) { |
| 794 if (!jpeg_decoder_) { |
| 795 jpeg_decoder_.reset(new GpuJpegDecodeAccelerator(this, io_task_runner_)); |
| 796 } |
| 797 jpeg_decoder_->AddClient(route_id, reply_msg); |
| 798 } |
| 799 |
790 void GpuChannel::MessageProcessed() { | 800 void GpuChannel::MessageProcessed() { |
791 messages_processed_++; | 801 messages_processed_++; |
792 if (preempting_flag_.get()) { | 802 if (preempting_flag_.get()) { |
793 io_task_runner_->PostTask( | 803 io_task_runner_->PostTask( |
794 FROM_HERE, base::Bind(&GpuChannelMessageFilter::MessageProcessed, | 804 FROM_HERE, base::Bind(&GpuChannelMessageFilter::MessageProcessed, |
795 filter_, messages_processed_)); | 805 filter_, messages_processed_)); |
796 } | 806 } |
797 } | 807 } |
798 | 808 |
799 void GpuChannel::CacheShader(const std::string& key, | 809 void GpuChannel::CacheShader(const std::string& key, |
(...skipping 48 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
848 } | 858 } |
849 } | 859 } |
850 } | 860 } |
851 | 861 |
852 void GpuChannel::HandleUpdateValueState( | 862 void GpuChannel::HandleUpdateValueState( |
853 unsigned int target, const gpu::ValueState& state) { | 863 unsigned int target, const gpu::ValueState& state) { |
854 pending_valuebuffer_state_->UpdateState(target, state); | 864 pending_valuebuffer_state_->UpdateState(target, state); |
855 } | 865 } |
856 | 866 |
857 } // namespace content | 867 } // namespace content |
OLD | NEW |