| 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 "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/location.h" | 10 #include "base/location.h" |
| (...skipping 165 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 176 } | 176 } |
| 177 | 177 |
| 178 GpuVideoDecodeAccelerator::~GpuVideoDecodeAccelerator() { | 178 GpuVideoDecodeAccelerator::~GpuVideoDecodeAccelerator() { |
| 179 // This class can only be self-deleted from OnWillDestroyStub(), which means | 179 // This class can only be self-deleted from OnWillDestroyStub(), which means |
| 180 // the VDA has already been destroyed in there. | 180 // the VDA has already been destroyed in there. |
| 181 DCHECK(!video_decode_accelerator_); | 181 DCHECK(!video_decode_accelerator_); |
| 182 } | 182 } |
| 183 | 183 |
| 184 // static | 184 // static |
| 185 gpu::VideoDecodeAcceleratorCapabilities | 185 gpu::VideoDecodeAcceleratorCapabilities |
| 186 GpuVideoDecodeAccelerator::GetCapabilities( | 186 GpuVideoDecodeAccelerator::GetCapabilities() { |
| 187 const gpu::GpuPreferences& gpu_preferences) { | 187 return GpuVideoDecodeAcceleratorFactoryImpl::GetDecoderCapabilities(); |
| 188 return GpuVideoDecodeAcceleratorFactoryImpl::GetDecoderCapabilities( | |
| 189 gpu_preferences); | |
| 190 } | 188 } |
| 191 | 189 |
| 192 bool GpuVideoDecodeAccelerator::OnMessageReceived(const IPC::Message& msg) { | 190 bool GpuVideoDecodeAccelerator::OnMessageReceived(const IPC::Message& msg) { |
| 193 if (!video_decode_accelerator_) | 191 if (!video_decode_accelerator_) |
| 194 return false; | 192 return false; |
| 195 | 193 |
| 196 bool handled = true; | 194 bool handled = true; |
| 197 IPC_BEGIN_MESSAGE_MAP(GpuVideoDecodeAccelerator, msg) | 195 IPC_BEGIN_MESSAGE_MAP(GpuVideoDecodeAccelerator, msg) |
| 198 IPC_MESSAGE_HANDLER(AcceleratedVideoDecoderMsg_SetCdm, OnSetCdm) | 196 IPC_MESSAGE_HANDLER(AcceleratedVideoDecoderMsg_SetCdm, OnSetCdm) |
| 199 IPC_MESSAGE_HANDLER(AcceleratedVideoDecoderMsg_Decode, OnDecode) | 197 IPC_MESSAGE_HANDLER(AcceleratedVideoDecoderMsg_Decode, OnDecode) |
| (...skipping 146 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 346 scoped_ptr<GpuVideoDecodeAcceleratorFactoryImpl> vda_factory = | 344 scoped_ptr<GpuVideoDecodeAcceleratorFactoryImpl> vda_factory = |
| 347 GpuVideoDecodeAcceleratorFactoryImpl::CreateWithGLES2Decoder( | 345 GpuVideoDecodeAcceleratorFactoryImpl::CreateWithGLES2Decoder( |
| 348 get_gl_context_cb_, make_context_current_cb_, bind_image_cb_, | 346 get_gl_context_cb_, make_context_current_cb_, bind_image_cb_, |
| 349 get_gles2_decoder_cb_); | 347 get_gles2_decoder_cb_); |
| 350 | 348 |
| 351 if (!vda_factory) { | 349 if (!vda_factory) { |
| 352 LOG(ERROR) << "Failed creating the VDA factory"; | 350 LOG(ERROR) << "Failed creating the VDA factory"; |
| 353 return false; | 351 return false; |
| 354 } | 352 } |
| 355 | 353 |
| 356 const gpu::GpuPreferences& gpu_preferences = | 354 video_decode_accelerator_ = vda_factory->CreateVDA(this, config); |
| 357 stub_->channel()->gpu_channel_manager()->gpu_preferences(); | |
| 358 video_decode_accelerator_ = | |
| 359 vda_factory->CreateVDA(this, config, gpu_preferences); | |
| 360 if (!video_decode_accelerator_) { | 355 if (!video_decode_accelerator_) { |
| 361 LOG(ERROR) << "HW video decode not available for profile " << config.profile | 356 LOG(ERROR) << "HW video decode not available for profile " << config.profile |
| 362 << (config.is_encrypted ? " with encryption" : ""); | 357 << (config.is_encrypted ? " with encryption" : ""); |
| 363 return false; | 358 return false; |
| 364 } | 359 } |
| 365 | 360 |
| 366 // Attempt to set up performing decoding tasks on IO thread, if supported by | 361 // Attempt to set up performing decoding tasks on IO thread, if supported by |
| 367 // the VDA. | 362 // the VDA. |
| 368 if (video_decode_accelerator_->TryToSetupDecodeOnSeparateThread( | 363 if (video_decode_accelerator_->TryToSetupDecodeOnSeparateThread( |
| 369 weak_factory_for_io_.GetWeakPtr(), io_task_runner_)) { | 364 weak_factory_for_io_.GetWeakPtr(), io_task_runner_)) { |
| (...skipping 142 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 512 scoped_refptr<gpu::gles2::TextureRef> texture_ref = it->second; | 507 scoped_refptr<gpu::gles2::TextureRef> texture_ref = it->second; |
| 513 GLenum target = texture_ref->texture()->target(); | 508 GLenum target = texture_ref->texture()->target(); |
| 514 gpu::gles2::TextureManager* texture_manager = | 509 gpu::gles2::TextureManager* texture_manager = |
| 515 stub_->decoder()->GetContextGroup()->texture_manager(); | 510 stub_->decoder()->GetContextGroup()->texture_manager(); |
| 516 DCHECK(!texture_ref->texture()->IsLevelCleared(target, 0)); | 511 DCHECK(!texture_ref->texture()->IsLevelCleared(target, 0)); |
| 517 texture_manager->SetLevelCleared(texture_ref.get(), target, 0, true); | 512 texture_manager->SetLevelCleared(texture_ref.get(), target, 0, true); |
| 518 uncleared_textures_.erase(it); | 513 uncleared_textures_.erase(it); |
| 519 } | 514 } |
| 520 | 515 |
| 521 } // namespace content | 516 } // namespace content |
| OLD | NEW |