Chromium Code Reviews| 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 67 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 102 << "failed"; | 105 << "failed"; |
| 103 } | 106 } |
| 104 } | 107 } |
| 105 | 108 |
| 106 void GpuVideoDecodeAccelerator::Initialize( | 109 void GpuVideoDecodeAccelerator::Initialize( |
| 107 const media::VideoDecodeAccelerator::Profile profile, | 110 const media::VideoDecodeAccelerator::Profile profile, |
| 108 IPC::Message* init_done_msg) { | 111 IPC::Message* init_done_msg) { |
| 109 DCHECK(!video_decode_accelerator_.get()); | 112 DCHECK(!video_decode_accelerator_.get()); |
| 110 DCHECK(!init_done_msg_); | 113 DCHECK(!init_done_msg_); |
| 111 DCHECK(init_done_msg); | 114 DCHECK(init_done_msg); |
| 115 init_done_msg_ = init_done_msg; | |
| 112 #if defined(OS_CHROMEOS) && defined(ARCH_CPU_ARMEL) | 116 #if defined(OS_CHROMEOS) && defined(ARCH_CPU_ARMEL) |
| 113 DCHECK(stub_ && stub_->decoder()); | 117 DCHECK(stub_ && stub_->decoder()); |
| 114 init_done_msg_ = init_done_msg; | |
| 115 OmxVideoDecodeAccelerator* omx_decoder = new OmxVideoDecodeAccelerator(this); | 118 OmxVideoDecodeAccelerator* omx_decoder = new OmxVideoDecodeAccelerator(this); |
| 116 omx_decoder->SetEglState( | 119 omx_decoder->SetEglState( |
| 117 gfx::GLSurfaceEGL::GetHardwareDisplay(), | 120 gfx::GLSurfaceEGL::GetHardwareDisplay(), |
| 118 stub_->decoder()->GetGLContext()->GetHandle()); | 121 stub_->decoder()->GetGLContext()->GetHandle()); |
| 119 video_decode_accelerator_ = omx_decoder; | 122 video_decode_accelerator_ = omx_decoder; |
| 120 video_decode_accelerator_->Initialize(profile); | 123 video_decode_accelerator_->Initialize(profile); |
| 121 #else | 124 #else // Update RenderViewImpl::createMediaPlayer when adding clauses. |
| 122 NOTIMPLEMENTED() << "HW video decode acceleration not available."; | 125 NOTIMPLEMENTED() << "HW video decode acceleration not available."; |
| 123 NotifyError(media::VideoDecodeAccelerator::PLATFORM_FAILURE); | 126 NotifyError(media::VideoDecodeAccelerator::PLATFORM_FAILURE); |
| 124 #endif // defined(OS_CHROMEOS) && defined(ARCH_CPU_ARMEL) | 127 #endif // defined(OS_CHROMEOS) && defined(ARCH_CPU_ARMEL) |
| 125 } | 128 } |
| 126 | 129 |
| 127 void GpuVideoDecodeAccelerator::OnDecode( | 130 void GpuVideoDecodeAccelerator::OnDecode( |
| 128 base::SharedMemoryHandle handle, int32 id, int32 size) { | 131 base::SharedMemoryHandle handle, int32 id, int32 size) { |
| 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 = | |
|
Ami GONE FROM CHROMIUM
2011/11/30 00:08:37
The changes in this file are pulled out to http://
| |
| 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 |