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 #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" |
(...skipping 32 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
43 bool handled = true; | 43 bool handled = true; |
44 IPC_BEGIN_MESSAGE_MAP(CommandBufferProxy, message) | 44 IPC_BEGIN_MESSAGE_MAP(CommandBufferProxy, message) |
45 IPC_MESSAGE_HANDLER(GpuCommandBufferMsg_UpdateState, OnUpdateState); | 45 IPC_MESSAGE_HANDLER(GpuCommandBufferMsg_UpdateState, OnUpdateState); |
46 IPC_MESSAGE_HANDLER(GpuCommandBufferMsg_Destroyed, OnDestroyed); | 46 IPC_MESSAGE_HANDLER(GpuCommandBufferMsg_Destroyed, OnDestroyed); |
47 IPC_MESSAGE_HANDLER(GpuCommandBufferMsg_SwapBuffers, OnSwapBuffers); | 47 IPC_MESSAGE_HANDLER(GpuCommandBufferMsg_SwapBuffers, OnSwapBuffers); |
48 IPC_MESSAGE_HANDLER(GpuCommandBufferMsg_NotifyRepaint, | 48 IPC_MESSAGE_HANDLER(GpuCommandBufferMsg_NotifyRepaint, |
49 OnNotifyRepaint); | 49 OnNotifyRepaint); |
50 IPC_MESSAGE_UNHANDLED(handled = false) | 50 IPC_MESSAGE_UNHANDLED(handled = false) |
51 IPC_END_MESSAGE_MAP() | 51 IPC_END_MESSAGE_MAP() |
52 | 52 |
53 if (!handled && video_decoder_host_.get()) | 53 if (!handled && video_decoder_host_) |
54 handled = video_decoder_host_->OnMessageReceived(message); | 54 handled = video_decoder_host_->OnMessageReceived(message); |
55 | 55 |
56 DCHECK(handled); | 56 DCHECK(handled); |
57 return handled; | 57 return handled; |
58 } | 58 } |
59 | 59 |
60 void CommandBufferProxy::OnChannelError() { | 60 void CommandBufferProxy::OnChannelError() { |
61 video_decoder_host_->OnChannelError(); | 61 video_decoder_host_->OnChannelError(); |
62 OnDestroyed(gpu::error::kUnknown); | 62 OnDestroyed(gpu::error::kUnknown); |
63 } | 63 } |
(...skipping 315 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
379 if (last_state_.error != gpu::error::kNoError) | 379 if (last_state_.error != gpu::error::kNoError) |
380 return; | 380 return; |
381 | 381 |
382 Send(new GpuCommandBufferMsg_ResizeOffscreenFrameBuffer(route_id_, size)); | 382 Send(new GpuCommandBufferMsg_ResizeOffscreenFrameBuffer(route_id_, size)); |
383 } | 383 } |
384 | 384 |
385 void CommandBufferProxy::SetNotifyRepaintTask(Task* task) { | 385 void CommandBufferProxy::SetNotifyRepaintTask(Task* task) { |
386 notify_repaint_task_.reset(task); | 386 notify_repaint_task_.reset(task); |
387 } | 387 } |
388 | 388 |
389 GpuVideoDecodeAcceleratorHost* CommandBufferProxy::CreateVideoDecoder( | 389 scoped_refptr<GpuVideoDecodeAcceleratorHost> |
| 390 CommandBufferProxy::CreateVideoDecoder( |
390 const std::vector<uint32>& configs, | 391 const std::vector<uint32>& configs, |
391 gpu::CommandBufferHelper* cmd_buffer_helper, | 392 gpu::CommandBufferHelper* cmd_buffer_helper, |
392 media::VideoDecodeAccelerator::Client* client) { | 393 media::VideoDecodeAccelerator::Client* client) { |
393 video_decoder_host_.reset(new GpuVideoDecodeAcceleratorHost( | 394 video_decoder_host_ = new GpuVideoDecodeAcceleratorHost( |
394 channel_, route_id_, cmd_buffer_helper, client)); | 395 channel_, route_id_, cmd_buffer_helper, client); |
395 | 396 |
396 if (!Send(new GpuCommandBufferMsg_CreateVideoDecoder(route_id_, configs))) { | 397 if (!Send(new GpuCommandBufferMsg_CreateVideoDecoder(route_id_, configs))) { |
397 LOG(ERROR) << "Send(GpuChannelMsg_CreateVideoDecoder) failed"; | 398 LOG(ERROR) << "Send(GpuChannelMsg_CreateVideoDecoder) failed"; |
398 video_decoder_host_.reset(); | 399 video_decoder_host_ = NULL; |
399 } | 400 } |
400 | 401 |
401 return video_decoder_host_.get(); | 402 return video_decoder_host_; |
402 } | 403 } |
403 | 404 |
404 #if defined(OS_MACOSX) | 405 #if defined(OS_MACOSX) |
405 void CommandBufferProxy::SetWindowSize(const gfx::Size& size) { | 406 void CommandBufferProxy::SetWindowSize(const gfx::Size& size) { |
406 if (last_state_.error != gpu::error::kNoError) | 407 if (last_state_.error != gpu::error::kNoError) |
407 return; | 408 return; |
408 | 409 |
409 Send(new GpuCommandBufferMsg_SetWindowSize(route_id_, size)); | 410 Send(new GpuCommandBufferMsg_SetWindowSize(route_id_, size)); |
410 } | 411 } |
411 #endif | 412 #endif |
(...skipping 19 matching lines...) Expand all Loading... |
431 delete msg; | 432 delete msg; |
432 return false; | 433 return false; |
433 } | 434 } |
434 | 435 |
435 void CommandBufferProxy::OnUpdateState(const gpu::CommandBuffer::State& state) { | 436 void CommandBufferProxy::OnUpdateState(const gpu::CommandBuffer::State& state) { |
436 // Handle wraparound. It works as long as we don't have more than 2B state | 437 // Handle wraparound. It works as long as we don't have more than 2B state |
437 // updates in flight across which reordering occurs. | 438 // updates in flight across which reordering occurs. |
438 if (state.generation - last_state_.generation < 0x80000000U) | 439 if (state.generation - last_state_.generation < 0x80000000U) |
439 last_state_ = state; | 440 last_state_ = state; |
440 } | 441 } |
OLD | NEW |