| 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/media/gpu_video_decode_accelerator.h" | 5 #include "media/gpu/ipc/service/gpu_video_decode_accelerator.h" |
| 6 | 6 |
| 7 #include <memory> | 7 #include <memory> |
| 8 #include <vector> | 8 #include <vector> |
| 9 | 9 |
| 10 #include "base/bind.h" | 10 #include "base/bind.h" |
| 11 #include "base/location.h" | 11 #include "base/location.h" |
| 12 #include "base/logging.h" | 12 #include "base/logging.h" |
| 13 #include "base/memory/ref_counted.h" | 13 #include "base/memory/ref_counted.h" |
| 14 #include "base/single_thread_task_runner.h" | 14 #include "base/single_thread_task_runner.h" |
| 15 #include "base/stl_util.h" | 15 #include "base/stl_util.h" |
| 16 #include "base/thread_task_runner_handle.h" | 16 #include "base/thread_task_runner_handle.h" |
| 17 #include "build/build_config.h" | 17 #include "build/build_config.h" |
| 18 #include "content/common/gpu/media/gpu_video_decode_accelerator_factory_impl.h" | |
| 19 #include "gpu/command_buffer/common/command_buffer.h" | 18 #include "gpu/command_buffer/common/command_buffer.h" |
| 20 #include "gpu/command_buffer/service/gpu_preferences.h" | 19 #include "gpu/command_buffer/service/gpu_preferences.h" |
| 21 #include "gpu/ipc/service/gpu_channel.h" | 20 #include "gpu/ipc/service/gpu_channel.h" |
| 22 #include "gpu/ipc/service/gpu_channel_manager.h" | 21 #include "gpu/ipc/service/gpu_channel_manager.h" |
| 23 #include "ipc/ipc_message_macros.h" | 22 #include "ipc/ipc_message_macros.h" |
| 24 #include "ipc/ipc_message_utils.h" | 23 #include "ipc/ipc_message_utils.h" |
| 25 #include "ipc/message_filter.h" | 24 #include "ipc/message_filter.h" |
| 26 #include "media/base/limits.h" | 25 #include "media/base/limits.h" |
| 27 #include "media/gpu/ipc/common/gpu_video_accelerator_util.h" | 26 #include "media/gpu/gpu_video_accelerator_util.h" |
| 27 #include "media/gpu/gpu_video_decode_accelerator_factory_impl.h" |
| 28 #include "media/gpu/ipc/common/media_messages.h" | 28 #include "media/gpu/ipc/common/media_messages.h" |
| 29 #include "ui/gfx/geometry/size.h" | 29 #include "ui/gfx/geometry/size.h" |
| 30 #include "ui/gl/gl_context.h" | 30 #include "ui/gl/gl_context.h" |
| 31 #include "ui/gl/gl_image.h" | 31 #include "ui/gl/gl_image.h" |
| 32 | 32 |
| 33 namespace content { | 33 namespace media { |
| 34 | 34 |
| 35 namespace { | 35 namespace { |
| 36 static gfx::GLContext* GetGLContext( | 36 static gfx::GLContext* GetGLContext( |
| 37 const base::WeakPtr<gpu::GpuCommandBufferStub>& stub) { | 37 const base::WeakPtr<gpu::GpuCommandBufferStub>& stub) { |
| 38 if (!stub) { | 38 if (!stub) { |
| 39 DLOG(ERROR) << "Stub is gone; no GLContext."; | 39 DLOG(ERROR) << "Stub is gone; no GLContext."; |
| 40 return nullptr; | 40 return nullptr; |
| 41 } | 41 } |
| 42 | 42 |
| 43 return stub->decoder()->GetGLContext(); | 43 return stub->decoder()->GetGLContext(); |
| (...skipping 200 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 244 // Notify client that picture buffer is now unused. | 244 // Notify client that picture buffer is now unused. |
| 245 if (!Send(new AcceleratedVideoDecoderHostMsg_DismissPictureBuffer( | 245 if (!Send(new AcceleratedVideoDecoderHostMsg_DismissPictureBuffer( |
| 246 host_route_id_, picture_buffer_id))) { | 246 host_route_id_, picture_buffer_id))) { |
| 247 DLOG(ERROR) << "Send(AcceleratedVideoDecoderHostMsg_DismissPictureBuffer) " | 247 DLOG(ERROR) << "Send(AcceleratedVideoDecoderHostMsg_DismissPictureBuffer) " |
| 248 << "failed"; | 248 << "failed"; |
| 249 } | 249 } |
| 250 DebugAutoLock auto_lock(debug_uncleared_textures_lock_); | 250 DebugAutoLock auto_lock(debug_uncleared_textures_lock_); |
| 251 uncleared_textures_.erase(picture_buffer_id); | 251 uncleared_textures_.erase(picture_buffer_id); |
| 252 } | 252 } |
| 253 | 253 |
| 254 void GpuVideoDecodeAccelerator::PictureReady( | 254 void GpuVideoDecodeAccelerator::PictureReady(const media::Picture& picture) { |
| 255 const media::Picture& picture) { | |
| 256 // VDA may call PictureReady on IO thread. SetTextureCleared should run on | 255 // VDA may call PictureReady on IO thread. SetTextureCleared should run on |
| 257 // the child thread. VDA is responsible to call PictureReady on the child | 256 // the child thread. VDA is responsible to call PictureReady on the child |
| 258 // thread when a picture buffer is delivered the first time. | 257 // thread when a picture buffer is delivered the first time. |
| 259 if (child_task_runner_->BelongsToCurrentThread()) { | 258 if (child_task_runner_->BelongsToCurrentThread()) { |
| 260 SetTextureCleared(picture); | 259 SetTextureCleared(picture); |
| 261 } else { | 260 } else { |
| 262 DCHECK(io_task_runner_->BelongsToCurrentThread()); | 261 DCHECK(io_task_runner_->BelongsToCurrentThread()); |
| 263 DebugAutoLock auto_lock(debug_uncleared_textures_lock_); | 262 DebugAutoLock auto_lock(debug_uncleared_textures_lock_); |
| 264 DCHECK_EQ(0u, uncleared_textures_.count(picture.picture_buffer_id())); | 263 DCHECK_EQ(0u, uncleared_textures_.count(picture.picture_buffer_id())); |
| 265 } | 264 } |
| (...skipping 21 matching lines...) Expand all Loading... |
| 287 DLOG(ERROR) << "Send(AcceleratedVideoDecoderHostMsg_FlushDone) failed"; | 286 DLOG(ERROR) << "Send(AcceleratedVideoDecoderHostMsg_FlushDone) failed"; |
| 288 } | 287 } |
| 289 | 288 |
| 290 void GpuVideoDecodeAccelerator::NotifyResetDone() { | 289 void GpuVideoDecodeAccelerator::NotifyResetDone() { |
| 291 if (!Send(new AcceleratedVideoDecoderHostMsg_ResetDone(host_route_id_))) | 290 if (!Send(new AcceleratedVideoDecoderHostMsg_ResetDone(host_route_id_))) |
| 292 DLOG(ERROR) << "Send(AcceleratedVideoDecoderHostMsg_ResetDone) failed"; | 291 DLOG(ERROR) << "Send(AcceleratedVideoDecoderHostMsg_ResetDone) failed"; |
| 293 } | 292 } |
| 294 | 293 |
| 295 void GpuVideoDecodeAccelerator::NotifyError( | 294 void GpuVideoDecodeAccelerator::NotifyError( |
| 296 media::VideoDecodeAccelerator::Error error) { | 295 media::VideoDecodeAccelerator::Error error) { |
| 297 if (!Send(new AcceleratedVideoDecoderHostMsg_ErrorNotification( | 296 if (!Send(new AcceleratedVideoDecoderHostMsg_ErrorNotification(host_route_id_, |
| 298 host_route_id_, error))) { | 297 error))) { |
| 299 DLOG(ERROR) << "Send(AcceleratedVideoDecoderHostMsg_ErrorNotification) " | 298 DLOG(ERROR) << "Send(AcceleratedVideoDecoderHostMsg_ErrorNotification) " |
| 300 << "failed"; | 299 << "failed"; |
| 301 } | 300 } |
| 302 } | 301 } |
| 303 | 302 |
| 304 void GpuVideoDecodeAccelerator::OnWillDestroyStub() { | 303 void GpuVideoDecodeAccelerator::OnWillDestroyStub() { |
| 305 // The stub is going away, so we have to stop and destroy VDA here, before | 304 // The stub is going away, so we have to stop and destroy VDA here, before |
| 306 // returning, because the VDA may need the GL context to run and/or do its | 305 // returning, because the VDA may need the GL context to run and/or do its |
| 307 // cleanup. We cannot destroy the VDA before the IO thread message filter is | 306 // cleanup. We cannot destroy the VDA before the IO thread message filter is |
| 308 // removed however, since we cannot service incoming messages with VDA gone. | 307 // removed however, since we cannot service incoming messages with VDA gone. |
| (...skipping 208 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 517 for (auto texture_ref : it->second) { | 516 for (auto texture_ref : it->second) { |
| 518 GLenum target = texture_ref->texture()->target(); | 517 GLenum target = texture_ref->texture()->target(); |
| 519 gpu::gles2::TextureManager* texture_manager = | 518 gpu::gles2::TextureManager* texture_manager = |
| 520 stub_->decoder()->GetContextGroup()->texture_manager(); | 519 stub_->decoder()->GetContextGroup()->texture_manager(); |
| 521 DCHECK(!texture_ref->texture()->IsLevelCleared(target, 0)); | 520 DCHECK(!texture_ref->texture()->IsLevelCleared(target, 0)); |
| 522 texture_manager->SetLevelCleared(texture_ref.get(), target, 0, true); | 521 texture_manager->SetLevelCleared(texture_ref.get(), target, 0, true); |
| 523 } | 522 } |
| 524 uncleared_textures_.erase(it); | 523 uncleared_textures_.erase(it); |
| 525 } | 524 } |
| 526 | 525 |
| 527 } // namespace content | 526 } // namespace media |
| OLD | NEW |