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 497 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
522 } | 523 } |
523 | 524 |
524 bool CommandBufferProxyImpl::ProduceFrontBuffer(const gpu::Mailbox& mailbox) { | 525 bool CommandBufferProxyImpl::ProduceFrontBuffer(const gpu::Mailbox& mailbox) { |
525 if (last_state_.error != gpu::error::kNoError) | 526 if (last_state_.error != gpu::error::kNoError) |
526 return false; | 527 return false; |
527 | 528 |
528 return Send(new GpuCommandBufferMsg_ProduceFrontBuffer(route_id_, mailbox)); | 529 return Send(new GpuCommandBufferMsg_ProduceFrontBuffer(route_id_, mailbox)); |
529 } | 530 } |
530 | 531 |
531 scoped_ptr<media::VideoDecodeAccelerator> | 532 scoped_ptr<media::VideoDecodeAccelerator> |
532 CommandBufferProxyImpl::CreateVideoDecoder(media::VideoCodecProfile profile) { | 533 CommandBufferProxyImpl::CreateVideoDecoder() { |
533 int decoder_route_id; | 534 return scoped_ptr<media::VideoDecodeAccelerator>( |
534 scoped_ptr<media::VideoDecodeAccelerator> vda; | 535 new GpuVideoDecodeAcceleratorHost(channel_, this)); |
535 if (!Send(new GpuCommandBufferMsg_CreateVideoDecoder(route_id_, profile, | 536 } |
536 &decoder_route_id))) { | |
537 LOG(ERROR) << "Send(GpuCommandBufferMsg_CreateVideoDecoder) failed"; | |
538 return vda.Pass(); | |
539 } | |
540 | 537 |
541 if (decoder_route_id < 0) { | 538 scoped_ptr<media::VideoEncodeAccelerator> |
542 DLOG(ERROR) << "Failed to Initialize GPU decoder on profile: " << profile; | 539 CommandBufferProxyImpl::CreateVideoEncoder() { |
543 return vda.Pass(); | 540 return scoped_ptr<media::VideoEncodeAccelerator>( |
544 } | 541 new GpuVideoEncodeAcceleratorHost(channel_, this)); |
545 | |
546 GpuVideoDecodeAcceleratorHost* decoder_host = | |
547 new GpuVideoDecodeAcceleratorHost(channel_, decoder_route_id, this); | |
548 vda.reset(decoder_host); | |
549 return vda.Pass(); | |
550 } | 542 } |
551 | 543 |
552 gpu::error::Error CommandBufferProxyImpl::GetLastError() { | 544 gpu::error::Error CommandBufferProxyImpl::GetLastError() { |
553 return last_state_.error; | 545 return last_state_.error; |
554 } | 546 } |
555 | 547 |
556 bool CommandBufferProxyImpl::Send(IPC::Message* msg) { | 548 bool CommandBufferProxyImpl::Send(IPC::Message* msg) { |
557 // Caller should not intentionally send a message if the context is lost. | 549 // Caller should not intentionally send a message if the context is lost. |
558 DCHECK(last_state_.error == gpu::error::kNoError); | 550 DCHECK(last_state_.error == gpu::error::kNoError); |
559 | 551 |
(...skipping 27 matching lines...) Expand all Loading... |
587 void CommandBufferProxyImpl::SetOnConsoleMessageCallback( | 579 void CommandBufferProxyImpl::SetOnConsoleMessageCallback( |
588 const GpuConsoleMessageCallback& callback) { | 580 const GpuConsoleMessageCallback& callback) { |
589 console_message_callback_ = callback; | 581 console_message_callback_ = callback; |
590 } | 582 } |
591 | 583 |
592 void CommandBufferProxyImpl::TryUpdateState() { | 584 void CommandBufferProxyImpl::TryUpdateState() { |
593 if (last_state_.error == gpu::error::kNoError) | 585 if (last_state_.error == gpu::error::kNoError) |
594 shared_state()->Read(&last_state_); | 586 shared_state()->Read(&last_state_); |
595 } | 587 } |
596 | 588 |
| 589 gpu::CommandBufferSharedState* CommandBufferProxyImpl::shared_state() const { |
| 590 return reinterpret_cast<gpu::CommandBufferSharedState*>( |
| 591 shared_state_shm_->memory()); |
| 592 } |
| 593 |
597 } // namespace content | 594 } // namespace content |
OLD | NEW |