| 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/common/gpu/media/gpu_video_decode_accelerator.h" | 5 #include "content/common/gpu/media/gpu_video_decode_accelerator.h" |
| 6 | 6 |
| 7 #include <vector> | 7 #include <vector> |
| 8 | 8 |
| 9 #include "base/bind.h" | 9 #include "base/bind.h" |
| 10 #include "base/logging.h" | 10 #include "base/logging.h" |
| 11 #include "base/stl_util.h" | 11 #include "base/stl_util.h" |
| 12 #include "gpu/command_buffer/common/command_buffer.h" | 12 #include "gpu/command_buffer/common/command_buffer.h" |
| 13 #include "ipc/ipc_message_macros.h" | 13 #include "ipc/ipc_message_macros.h" |
| 14 #include "ipc/ipc_message_utils.h" | 14 #include "ipc/ipc_message_utils.h" |
| 15 #include "content/common/gpu/gpu_channel.h" | 15 #include "content/common/gpu/gpu_channel.h" |
| 16 #include "content/common/gpu/gpu_command_buffer_stub.h" | 16 #include "content/common/gpu/gpu_command_buffer_stub.h" |
| 17 #include "content/common/gpu/gpu_messages.h" | 17 #include "content/common/gpu/gpu_messages.h" |
| 18 #if defined(OS_CHROMEOS) && defined(ARCH_CPU_ARMEL) | 18 #if defined(OS_CHROMEOS) && defined(ARCH_CPU_ARMEL) |
| 19 #include "content/common/gpu/media/omx_video_decode_accelerator.h" | 19 #include "content/common/gpu/media/omx_video_decode_accelerator.h" |
| 20 #include "ui/gfx/gl/gl_context.h" | 20 #include "ui/gfx/gl/gl_context.h" |
| 21 #include "ui/gfx/gl/gl_surface_egl.h" | 21 #include "ui/gfx/gl/gl_surface_egl.h" |
| 22 #endif | 22 #endif |
| 23 #include "gpu/command_buffer/service/texture_manager.h" |
| 23 #include "ui/gfx/size.h" | 24 #include "ui/gfx/size.h" |
| 24 | 25 |
| 26 using gpu::gles2::TextureManager; |
| 27 |
| 25 GpuVideoDecodeAccelerator::GpuVideoDecodeAccelerator( | 28 GpuVideoDecodeAccelerator::GpuVideoDecodeAccelerator( |
| 26 IPC::Message::Sender* sender, | 29 IPC::Message::Sender* sender, |
| 27 int32 host_route_id, | 30 int32 host_route_id, |
| 28 GpuCommandBufferStub* stub) | 31 GpuCommandBufferStub* stub) |
| 29 : sender_(sender), | 32 : sender_(sender), |
| 30 init_done_msg_(NULL), | 33 init_done_msg_(NULL), |
| 31 host_route_id_(host_route_id), | 34 host_route_id_(host_route_id), |
| 32 stub_(stub), | 35 stub_(stub), |
| 33 video_decode_accelerator_(NULL) { | 36 video_decode_accelerator_(NULL) { |
| 34 } | 37 } |
| (...skipping 94 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 129 DCHECK(video_decode_accelerator_.get()); | 132 DCHECK(video_decode_accelerator_.get()); |
| 130 video_decode_accelerator_->Decode(media::BitstreamBuffer(id, handle, size)); | 133 video_decode_accelerator_->Decode(media::BitstreamBuffer(id, handle, size)); |
| 131 } | 134 } |
| 132 | 135 |
| 133 void GpuVideoDecodeAccelerator::OnAssignPictureBuffers( | 136 void GpuVideoDecodeAccelerator::OnAssignPictureBuffers( |
| 134 const std::vector<int32>& buffer_ids, | 137 const std::vector<int32>& buffer_ids, |
| 135 const std::vector<uint32>& texture_ids, | 138 const std::vector<uint32>& texture_ids, |
| 136 const std::vector<gfx::Size>& sizes) { | 139 const std::vector<gfx::Size>& sizes) { |
| 137 DCHECK(stub_ && stub_->decoder()); // Ensure already Initialize()'d. | 140 DCHECK(stub_ && stub_->decoder()); // Ensure already Initialize()'d. |
| 138 gpu::gles2::GLES2Decoder* command_decoder = stub_->decoder(); | 141 gpu::gles2::GLES2Decoder* command_decoder = stub_->decoder(); |
| 142 gpu::gles2::TextureManager* texture_manager = |
| 143 command_decoder->GetContextGroup()->texture_manager(); |
| 139 | 144 |
| 140 std::vector<media::PictureBuffer> buffers; | 145 std::vector<media::PictureBuffer> buffers; |
| 141 for (uint32 i = 0; i < buffer_ids.size(); ++i) { | 146 for (uint32 i = 0; i < buffer_ids.size(); ++i) { |
| 147 gpu::gles2::TextureManager::TextureInfo* info = |
| 148 texture_manager->GetTextureInfo(texture_ids[i]); |
| 149 if (!info || |
| 150 !texture_manager->ClearRenderableLevels(command_decoder, info)) { |
| 151 // TODO(fischman): send an error for invalid textures. |
| 152 DLOG(DFATAL) << "Failed to Clear texture!"; |
| 153 return; |
| 154 } |
| 142 uint32 service_texture_id; | 155 uint32 service_texture_id; |
| 143 if (!command_decoder->GetServiceTextureId( | 156 if (!command_decoder->GetServiceTextureId( |
| 144 texture_ids[i], &service_texture_id)) { | 157 texture_ids[i], &service_texture_id)) { |
| 145 // TODO(vrk): Send an error for invalid GLES buffers. | 158 // TODO(vrk): Send an error for invalid GLES buffers. |
| 146 DLOG(DFATAL) << "Failed to translate texture!"; | 159 DLOG(DFATAL) << "Failed to translate texture!"; |
| 147 return; | 160 return; |
| 148 } | 161 } |
| 149 buffers.push_back(media::PictureBuffer( | 162 buffers.push_back(media::PictureBuffer( |
| 150 buffer_ids[i], sizes[i], service_texture_id)); | 163 buffer_ids[i], sizes[i], service_texture_id)); |
| 151 } | 164 } |
| (...skipping 44 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 196 | 209 |
| 197 void GpuVideoDecodeAccelerator::NotifyResetDone() { | 210 void GpuVideoDecodeAccelerator::NotifyResetDone() { |
| 198 if (!Send(new AcceleratedVideoDecoderHostMsg_ResetDone(host_route_id_))) | 211 if (!Send(new AcceleratedVideoDecoderHostMsg_ResetDone(host_route_id_))) |
| 199 DLOG(ERROR) << "Send(AcceleratedVideoDecoderHostMsg_ResetDone) failed"; | 212 DLOG(ERROR) << "Send(AcceleratedVideoDecoderHostMsg_ResetDone) failed"; |
| 200 } | 213 } |
| 201 | 214 |
| 202 bool GpuVideoDecodeAccelerator::Send(IPC::Message* message) { | 215 bool GpuVideoDecodeAccelerator::Send(IPC::Message* message) { |
| 203 DCHECK(sender_); | 216 DCHECK(sender_); |
| 204 return sender_->Send(message); | 217 return sender_->Send(message); |
| 205 } | 218 } |
| OLD | NEW |