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

Side by Side Diff: content/renderer/gpu/command_buffer_proxy.cc

Issue 7659001: Support multiple HW video decoders per context. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: . Created 9 years, 4 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 unified diff | Download patch | Annotate | Revision Log
OLDNEW
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 #include "content/renderer/gpu/command_buffer_proxy.h" 5 #include "content/renderer/gpu/command_buffer_proxy.h"
6 6
7 #include "base/debug/trace_event.h" 7 #include "base/debug/trace_event.h"
8 #include "base/logging.h" 8 #include "base/logging.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"
11 #include "base/task.h" 11 #include "base/task.h"
12 #include "content/common/gpu/gpu_messages.h" 12 #include "content/common/gpu/gpu_messages.h"
13 #include "content/common/plugin_messages.h" 13 #include "content/common/plugin_messages.h"
14 #include "content/common/view_messages.h" 14 #include "content/common/view_messages.h"
15 #include "content/renderer/gpu/gpu_channel_host.h"
15 #include "content/renderer/plugin_channel_host.h" 16 #include "content/renderer/plugin_channel_host.h"
16 #include "content/renderer/render_thread.h" 17 #include "content/renderer/render_thread.h"
17 #include "gpu/command_buffer/common/cmd_buffer_common.h" 18 #include "gpu/command_buffer/common/cmd_buffer_common.h"
18 #include "ui/gfx/size.h" 19 #include "ui/gfx/size.h"
19 20
20 using gpu::Buffer; 21 using gpu::Buffer;
21 22
22 CommandBufferProxy::CommandBufferProxy( 23 CommandBufferProxy::CommandBufferProxy(
23 IPC::Channel::Sender* channel, 24 GpuChannelHost* channel,
24 int route_id) 25 int route_id)
25 : num_entries_(0), 26 : num_entries_(0),
26 channel_(channel), 27 channel_(channel),
27 route_id_(route_id), 28 route_id_(route_id),
28 flush_count_(0) { 29 flush_count_(0) {
29 } 30 }
30 31
31 CommandBufferProxy::~CommandBufferProxy() { 32 CommandBufferProxy::~CommandBufferProxy() {
32 // Delete all the locally cached shared memory objects, closing the handle 33 // Delete all the locally cached shared memory objects, closing the handle
33 // in this process. 34 // in this process.
34 for (TransferBufferMap::iterator it = transfer_buffers_.begin(); 35 for (TransferBufferMap::iterator it = transfer_buffers_.begin();
35 it != transfer_buffers_.end(); 36 it != transfer_buffers_.end();
36 ++it) { 37 ++it) {
37 delete it->second.shared_memory; 38 delete it->second.shared_memory;
38 it->second.shared_memory = NULL; 39 it->second.shared_memory = NULL;
39 } 40 }
40 } 41 }
41 42
42 bool CommandBufferProxy::OnMessageReceived(const IPC::Message& message) { 43 bool CommandBufferProxy::OnMessageReceived(const IPC::Message& message) {
43 bool handled = true; 44 bool handled = true;
44 IPC_BEGIN_MESSAGE_MAP(CommandBufferProxy, message) 45 IPC_BEGIN_MESSAGE_MAP(CommandBufferProxy, message)
45 IPC_MESSAGE_HANDLER(GpuCommandBufferMsg_UpdateState, OnUpdateState); 46 IPC_MESSAGE_HANDLER(GpuCommandBufferMsg_UpdateState, OnUpdateState);
46 IPC_MESSAGE_HANDLER(GpuCommandBufferMsg_Destroyed, OnDestroyed); 47 IPC_MESSAGE_HANDLER(GpuCommandBufferMsg_Destroyed, OnDestroyed);
47 IPC_MESSAGE_HANDLER(GpuCommandBufferMsg_SwapBuffers, OnSwapBuffers); 48 IPC_MESSAGE_HANDLER(GpuCommandBufferMsg_SwapBuffers, OnSwapBuffers);
48 IPC_MESSAGE_HANDLER(GpuCommandBufferMsg_NotifyRepaint, 49 IPC_MESSAGE_HANDLER(GpuCommandBufferMsg_NotifyRepaint,
49 OnNotifyRepaint); 50 OnNotifyRepaint);
50 IPC_MESSAGE_UNHANDLED(handled = false) 51 IPC_MESSAGE_UNHANDLED(handled = false)
51 IPC_END_MESSAGE_MAP() 52 IPC_END_MESSAGE_MAP()
52 53
53 if (!handled && video_decoder_host_)
54 handled = video_decoder_host_->OnMessageReceived(message);
55
56 DCHECK(handled); 54 DCHECK(handled);
57 return handled; 55 return handled;
58 } 56 }
59 57
60 void CommandBufferProxy::OnChannelError() { 58 void CommandBufferProxy::OnChannelError() {
61 if (video_decoder_host_) 59 for (Decoders::iterator it = video_decoder_hosts_.begin();
62 video_decoder_host_->OnChannelError(); 60 it != video_decoder_hosts_.end(); ++it) {
61 it->second->OnChannelError();
62 }
63 OnDestroyed(gpu::error::kUnknown); 63 OnDestroyed(gpu::error::kUnknown);
64 } 64 }
65 65
66 void CommandBufferProxy::OnDestroyed(gpu::error::ContextLostReason reason) { 66 void CommandBufferProxy::OnDestroyed(gpu::error::ContextLostReason reason) {
67 // Prevent any further messages from being sent. 67 // Prevent any further messages from being sent.
68 channel_ = NULL; 68 channel_ = NULL;
69 69
70 // When the client sees that the context is lost, they should delete this 70 // When the client sees that the context is lost, they should delete this
71 // CommandBufferProxy and create a new one. 71 // CommandBufferProxy and create a new one.
72 last_state_.error = gpu::error::kLostContext; 72 last_state_.error = gpu::error::kLostContext;
(...skipping 315 matching lines...) Expand 10 before | Expand all | Expand 10 after
388 } 388 }
389 389
390 void CommandBufferProxy::SetNotifyRepaintTask(Task* task) { 390 void CommandBufferProxy::SetNotifyRepaintTask(Task* task) {
391 notify_repaint_task_.reset(task); 391 notify_repaint_task_.reset(task);
392 } 392 }
393 393
394 scoped_refptr<GpuVideoDecodeAcceleratorHost> 394 scoped_refptr<GpuVideoDecodeAcceleratorHost>
395 CommandBufferProxy::CreateVideoDecoder( 395 CommandBufferProxy::CreateVideoDecoder(
396 const std::vector<int32>& configs, 396 const std::vector<int32>& configs,
397 media::VideoDecodeAccelerator::Client* client) { 397 media::VideoDecodeAccelerator::Client* client) {
398 video_decoder_host_ = new GpuVideoDecodeAcceleratorHost( 398 int decoder_route_id;
399 channel_, route_id_, client); 399 if (!Send(new GpuCommandBufferMsg_CreateVideoDecoder(route_id_, configs,
400 400 &decoder_route_id))) {
401 if (!Send(new GpuCommandBufferMsg_CreateVideoDecoder(route_id_, configs))) {
402 LOG(ERROR) << "Send(GpuChannelMsg_CreateVideoDecoder) failed"; 401 LOG(ERROR) << "Send(GpuChannelMsg_CreateVideoDecoder) failed";
403 video_decoder_host_ = NULL; 402 return NULL;
404 } 403 }
405 404
406 return video_decoder_host_; 405 scoped_refptr<GpuVideoDecodeAcceleratorHost> decoder_host =
406 new GpuVideoDecodeAcceleratorHost(channel_, decoder_route_id, client);
407 bool inserted = video_decoder_hosts_.insert(std::make_pair(
408 decoder_route_id, decoder_host)).second;
409 DCHECK(inserted);
410
411 channel_->AddRoute(decoder_route_id, decoder_host.get());
412
413 return decoder_host;
407 } 414 }
408 415
409 #if defined(OS_MACOSX) 416 #if defined(OS_MACOSX)
410 void CommandBufferProxy::SetWindowSize(const gfx::Size& size) { 417 void CommandBufferProxy::SetWindowSize(const gfx::Size& size) {
411 if (last_state_.error != gpu::error::kNoError) 418 if (last_state_.error != gpu::error::kNoError)
412 return; 419 return;
413 420
414 Send(new GpuCommandBufferMsg_SetWindowSize(route_id_, size)); 421 Send(new GpuCommandBufferMsg_SetWindowSize(route_id_, size));
415 } 422 }
416 #endif 423 #endif
(...skipping 19 matching lines...) Expand all
436 delete msg; 443 delete msg;
437 return false; 444 return false;
438 } 445 }
439 446
440 void CommandBufferProxy::OnUpdateState(const gpu::CommandBuffer::State& state) { 447 void CommandBufferProxy::OnUpdateState(const gpu::CommandBuffer::State& state) {
441 // Handle wraparound. It works as long as we don't have more than 2B state 448 // Handle wraparound. It works as long as we don't have more than 2B state
442 // updates in flight across which reordering occurs. 449 // updates in flight across which reordering occurs.
443 if (state.generation - last_state_.generation < 0x80000000U) 450 if (state.generation - last_state_.generation < 0x80000000U)
444 last_state_ = state; 451 last_state_ = state;
445 } 452 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698