OLD | NEW |
1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2011 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(ENABLE_GPU) | 5 #if defined(ENABLE_GPU) |
6 | 6 |
7 #include "base/bind.h" | 7 #include "base/bind.h" |
8 #include "base/debug/trace_event.h" | 8 #include "base/debug/trace_event.h" |
9 #include "base/process_util.h" | 9 #include "base/process_util.h" |
10 #include "base/shared_memory.h" | 10 #include "base/shared_memory.h" |
(...skipping 86 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
97 IPC_MESSAGE_HANDLER(GpuCommandBufferMsg_DestroyVideoDecoder, | 97 IPC_MESSAGE_HANDLER(GpuCommandBufferMsg_DestroyVideoDecoder, |
98 OnDestroyVideoDecoder) | 98 OnDestroyVideoDecoder) |
99 IPC_MESSAGE_HANDLER(GpuCommandBufferMsg_ResizeOffscreenFrameBuffer, | 99 IPC_MESSAGE_HANDLER(GpuCommandBufferMsg_ResizeOffscreenFrameBuffer, |
100 OnResizeOffscreenFrameBuffer); | 100 OnResizeOffscreenFrameBuffer); |
101 #if defined(OS_MACOSX) | 101 #if defined(OS_MACOSX) |
102 IPC_MESSAGE_HANDLER(GpuCommandBufferMsg_SetWindowSize, OnSetWindowSize); | 102 IPC_MESSAGE_HANDLER(GpuCommandBufferMsg_SetWindowSize, OnSetWindowSize); |
103 #endif // defined(OS_MACOSX) | 103 #endif // defined(OS_MACOSX) |
104 IPC_MESSAGE_UNHANDLED(handled = false) | 104 IPC_MESSAGE_UNHANDLED(handled = false) |
105 IPC_END_MESSAGE_MAP() | 105 IPC_END_MESSAGE_MAP() |
106 | 106 |
107 // If this message isn't intended for the stub, try to route it to the video | |
108 // decoder. | |
109 if (!handled && video_decoder_.get()) | |
110 handled = video_decoder_->OnMessageReceived(message); | |
111 | |
112 DCHECK(handled); | 107 DCHECK(handled); |
113 return handled; | 108 return handled; |
114 } | 109 } |
115 | 110 |
116 bool GpuCommandBufferStub::Send(IPC::Message* message) { | 111 bool GpuCommandBufferStub::Send(IPC::Message* message) { |
117 return channel_->Send(message); | 112 return channel_->Send(message); |
118 } | 113 } |
119 | 114 |
120 bool GpuCommandBufferStub::IsScheduled() { | 115 bool GpuCommandBufferStub::IsScheduled() { |
121 return !scheduler_.get() || scheduler_->IsScheduled(); | 116 return !scheduler_.get() || scheduler_->IsScheduled(); |
(...skipping 425 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
547 } else { | 542 } else { |
548 IPC::Message* msg = new GpuCommandBufferMsg_UpdateState(route_id_, state); | 543 IPC::Message* msg = new GpuCommandBufferMsg_UpdateState(route_id_, state); |
549 msg->set_unblock(true); | 544 msg->set_unblock(true); |
550 Send(msg); | 545 Send(msg); |
551 } | 546 } |
552 } | 547 } |
553 | 548 |
554 void GpuCommandBufferStub::OnCreateVideoDecoder( | 549 void GpuCommandBufferStub::OnCreateVideoDecoder( |
555 const std::vector<int32>& configs, | 550 const std::vector<int32>& configs, |
556 IPC::Message* reply_message) { | 551 IPC::Message* reply_message) { |
557 video_decoder_.reset( | 552 int decoder_route_id = channel_->GenerateRouteID(); |
558 new GpuVideoDecodeAccelerator(this, route_id_, this)); | 553 GpuCommandBufferMsg_CreateVideoDecoder::WriteReplyParams( |
559 video_decoder_->Initialize(configs, reply_message); | 554 reply_message, decoder_route_id); |
| 555 GpuVideoDecodeAccelerator* decoder = |
| 556 new GpuVideoDecodeAccelerator(this, decoder_route_id, this); |
| 557 video_decoders_.AddWithID(decoder, decoder_route_id); |
| 558 channel_->AddRoute(decoder_route_id, decoder); |
| 559 decoder->Initialize(configs, reply_message); |
560 } | 560 } |
561 | 561 |
562 void GpuCommandBufferStub::OnDestroyVideoDecoder() { | 562 void GpuCommandBufferStub::OnDestroyVideoDecoder(int decoder_route_id) { |
563 LOG(ERROR) << "GpuCommandBufferStub::OnDestroyVideoDecoder"; | 563 channel_->RemoveRoute(decoder_route_id); |
564 video_decoder_.reset(); | 564 video_decoders_.Remove(decoder_route_id); |
565 } | 565 } |
566 | 566 |
567 #endif // defined(ENABLE_GPU) | 567 #endif // defined(ENABLE_GPU) |
OLD | NEW |