| 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/client/command_buffer_proxy_impl.h" | 5 #include "content/common/gpu/client/command_buffer_proxy_impl.h" |
| 6 | 6 |
| 7 #include "base/callback.h" | 7 #include "base/callback.h" |
| 8 #include "base/debug/trace_event.h" | 8 #include "base/debug/trace_event.h" |
| 9 #include "base/logging.h" | 9 #include "base/logging.h" |
| 10 #include "base/memory/shared_memory.h" | 10 #include "base/memory/shared_memory.h" |
| 11 #include "base/stl_util.h" | 11 #include "base/stl_util.h" |
| 12 #include "content/common/child_process_messages.h" | 12 #include "content/common/child_process_messages.h" |
| 13 #include "content/common/gpu/client/gpu_channel_host.h" | 13 #include "content/common/gpu/client/gpu_channel_host.h" |
| 14 #include "content/common/gpu/client/gpu_video_decode_accelerator_host.h" | 14 #include "content/common/gpu/client/gpu_video_decode_accelerator_host.h" |
| 15 #include "content/common/gpu/client/gpu_video_encode_accelerator_host.h" |
| 15 #include "content/common/gpu/gpu_messages.h" | 16 #include "content/common/gpu/gpu_messages.h" |
| 16 #include "content/common/view_messages.h" | 17 #include "content/common/view_messages.h" |
| 17 #include "gpu/command_buffer/common/cmd_buffer_common.h" | 18 #include "gpu/command_buffer/common/cmd_buffer_common.h" |
| 18 #include "gpu/command_buffer/common/command_buffer_shared.h" | 19 #include "gpu/command_buffer/common/command_buffer_shared.h" |
| 19 #include "gpu/command_buffer/common/gpu_memory_allocation.h" | 20 #include "gpu/command_buffer/common/gpu_memory_allocation.h" |
| 20 #include "ui/gfx/size.h" | 21 #include "ui/gfx/size.h" |
| 21 | 22 |
| 22 namespace content { | 23 namespace content { |
| 23 | 24 |
| 24 CommandBufferProxyImpl::CommandBufferProxyImpl( | 25 CommandBufferProxyImpl::CommandBufferProxyImpl( |
| (...skipping 427 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 452 } | 453 } |
| 453 | 454 |
| 454 bool CommandBufferProxyImpl::ProduceFrontBuffer(const gpu::Mailbox& mailbox) { | 455 bool CommandBufferProxyImpl::ProduceFrontBuffer(const gpu::Mailbox& mailbox) { |
| 455 if (last_state_.error != gpu::error::kNoError) | 456 if (last_state_.error != gpu::error::kNoError) |
| 456 return false; | 457 return false; |
| 457 | 458 |
| 458 return Send(new GpuCommandBufferMsg_ProduceFrontBuffer(route_id_, mailbox)); | 459 return Send(new GpuCommandBufferMsg_ProduceFrontBuffer(route_id_, mailbox)); |
| 459 } | 460 } |
| 460 | 461 |
| 461 scoped_ptr<media::VideoDecodeAccelerator> | 462 scoped_ptr<media::VideoDecodeAccelerator> |
| 462 CommandBufferProxyImpl::CreateVideoDecoder(media::VideoCodecProfile profile) { | 463 CommandBufferProxyImpl::CreateVideoDecoder() { |
| 463 int decoder_route_id; | 464 return scoped_ptr<media::VideoDecodeAccelerator>( |
| 464 scoped_ptr<media::VideoDecodeAccelerator> vda; | 465 new GpuVideoDecodeAcceleratorHost(channel_, this)); |
| 465 if (!Send(new GpuCommandBufferMsg_CreateVideoDecoder(route_id_, profile, | 466 } |
| 466 &decoder_route_id))) { | |
| 467 LOG(ERROR) << "Send(GpuCommandBufferMsg_CreateVideoDecoder) failed"; | |
| 468 return vda.Pass(); | |
| 469 } | |
| 470 | 467 |
| 471 if (decoder_route_id < 0) { | 468 scoped_ptr<media::VideoEncodeAccelerator> |
| 472 DLOG(ERROR) << "Failed to Initialize GPU decoder on profile: " << profile; | 469 CommandBufferProxyImpl::CreateVideoEncoder() { |
| 473 return vda.Pass(); | 470 return scoped_ptr<media::VideoEncodeAccelerator>( |
| 474 } | 471 new GpuVideoEncodeAcceleratorHost(channel_, this)); |
| 475 | |
| 476 GpuVideoDecodeAcceleratorHost* decoder_host = | |
| 477 new GpuVideoDecodeAcceleratorHost(channel_, decoder_route_id, this); | |
| 478 vda.reset(decoder_host); | |
| 479 return vda.Pass(); | |
| 480 } | 472 } |
| 481 | 473 |
| 482 gpu::error::Error CommandBufferProxyImpl::GetLastError() { | 474 gpu::error::Error CommandBufferProxyImpl::GetLastError() { |
| 483 return last_state_.error; | 475 return last_state_.error; |
| 484 } | 476 } |
| 485 | 477 |
| 486 bool CommandBufferProxyImpl::Send(IPC::Message* msg) { | 478 bool CommandBufferProxyImpl::Send(IPC::Message* msg) { |
| 487 // Caller should not intentionally send a message if the context is lost. | 479 // Caller should not intentionally send a message if the context is lost. |
| 488 DCHECK(last_state_.error == gpu::error::kNoError); | 480 DCHECK(last_state_.error == gpu::error::kNoError); |
| 489 | 481 |
| (...skipping 27 matching lines...) Expand all Loading... |
| 517 void CommandBufferProxyImpl::SetOnConsoleMessageCallback( | 509 void CommandBufferProxyImpl::SetOnConsoleMessageCallback( |
| 518 const GpuConsoleMessageCallback& callback) { | 510 const GpuConsoleMessageCallback& callback) { |
| 519 console_message_callback_ = callback; | 511 console_message_callback_ = callback; |
| 520 } | 512 } |
| 521 | 513 |
| 522 void CommandBufferProxyImpl::TryUpdateState() { | 514 void CommandBufferProxyImpl::TryUpdateState() { |
| 523 if (last_state_.error == gpu::error::kNoError) | 515 if (last_state_.error == gpu::error::kNoError) |
| 524 shared_state()->Read(&last_state_); | 516 shared_state()->Read(&last_state_); |
| 525 } | 517 } |
| 526 | 518 |
| 519 gpu::CommandBufferSharedState* CommandBufferProxyImpl::shared_state() const { |
| 520 return reinterpret_cast<gpu::CommandBufferSharedState*>( |
| 521 shared_state_shm_->memory()); |
| 522 } |
| 523 |
| 527 } // namespace content | 524 } // namespace content |
| OLD | NEW |