OLD | NEW |
1 // Copyright 2015 The Chromium Authors. All rights reserved. | 1 // Copyright 2015 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/pepper/pepper_video_encoder_host.h" | 5 #include "content/renderer/pepper/pepper_video_encoder_host.h" |
6 | 6 |
7 #include <utility> | 7 #include <utility> |
8 | 8 |
9 #include "base/bind.h" | 9 #include "base/bind.h" |
10 #include "base/memory/shared_memory.h" | 10 #include "base/memory/shared_memory.h" |
(...skipping 481 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
492 | 492 |
493 bool PepperVideoEncoderHost::EnsureGpuChannel() { | 493 bool PepperVideoEncoderHost::EnsureGpuChannel() { |
494 DCHECK(RenderThreadImpl::current()); | 494 DCHECK(RenderThreadImpl::current()); |
495 | 495 |
496 if (command_buffer_) | 496 if (command_buffer_) |
497 return true; | 497 return true; |
498 | 498 |
499 // There is no guarantee that we have a 3D context to work with. So | 499 // There is no guarantee that we have a 3D context to work with. So |
500 // we create a dummy command buffer to communicate with the gpu process. | 500 // we create a dummy command buffer to communicate with the gpu process. |
501 channel_ = RenderThreadImpl::current()->EstablishGpuChannelSync( | 501 channel_ = RenderThreadImpl::current()->EstablishGpuChannelSync( |
502 CAUSE_FOR_GPU_LAUNCH_PEPPERVIDEOENCODERACCELERATOR_INITIALIZE); | 502 gpu::CAUSE_FOR_GPU_LAUNCH_PEPPERVIDEOENCODERACCELERATOR_INITIALIZE); |
503 if (!channel_) | 503 if (!channel_) |
504 return false; | 504 return false; |
505 | 505 |
506 std::vector<int32_t> attribs(1, PP_GRAPHICS3DATTRIB_NONE); | 506 std::vector<int32_t> attribs(1, PP_GRAPHICS3DATTRIB_NONE); |
507 command_buffer_ = channel_->CreateCommandBuffer( | 507 command_buffer_ = channel_->CreateCommandBuffer( |
508 gpu::kNullSurfaceHandle, gfx::Size(), nullptr, | 508 gpu::kNullSurfaceHandle, gfx::Size(), nullptr, |
509 GpuChannelHost::kDefaultStreamId, GpuChannelHost::kDefaultStreamPriority, | 509 GpuChannelHost::kDefaultStreamId, GpuChannelHost::kDefaultStreamPriority, |
510 attribs, GURL::EmptyGURL(), gfx::PreferIntegratedGpu); | 510 attribs, GURL::EmptyGURL(), gfx::PreferIntegratedGpu); |
511 if (!command_buffer_) { | 511 if (!command_buffer_) { |
512 Close(); | 512 Close(); |
(...skipping 147 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
660 } | 660 } |
661 | 661 |
662 uint8_t* PepperVideoEncoderHost::ShmHandleToAddress(int32_t buffer_id) { | 662 uint8_t* PepperVideoEncoderHost::ShmHandleToAddress(int32_t buffer_id) { |
663 DCHECK(RenderThreadImpl::current()); | 663 DCHECK(RenderThreadImpl::current()); |
664 DCHECK_GE(buffer_id, 0); | 664 DCHECK_GE(buffer_id, 0); |
665 DCHECK_LT(buffer_id, static_cast<int32_t>(shm_buffers_.size())); | 665 DCHECK_LT(buffer_id, static_cast<int32_t>(shm_buffers_.size())); |
666 return static_cast<uint8_t*>(shm_buffers_[buffer_id]->shm->memory()); | 666 return static_cast<uint8_t*>(shm_buffers_[buffer_id]->shm->memory()); |
667 } | 667 } |
668 | 668 |
669 } // namespace content | 669 } // namespace content |
OLD | NEW |