Chromium Code Reviews| 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 "media/filters/gpu_video_decoder.h" | 5 #include "media/filters/gpu_video_decoder.h" |
| 6 | 6 |
| 7 #include <algorithm> | 7 #include <algorithm> |
| 8 #include <utility> | 8 #include <utility> |
| 9 | 9 |
| 10 #include "base/bind.h" | 10 #include "base/bind.h" |
| 11 #include "base/callback_helpers.h" | 11 #include "base/callback_helpers.h" |
| 12 #include "base/command_line.h" | 12 #include "base/command_line.h" |
| 13 #include "base/cpu.h" | 13 #include "base/cpu.h" |
| 14 #include "base/location.h" | 14 #include "base/location.h" |
| 15 #include "base/memory/ptr_util.h" | 15 #include "base/memory/ptr_util.h" |
| 16 #include "base/metrics/histogram.h" | 16 #include "base/metrics/histogram.h" |
| 17 #include "base/single_thread_task_runner.h" | 17 #include "base/single_thread_task_runner.h" |
| 18 #include "base/stl_util.h" | 18 #include "base/stl_util.h" |
| 19 #include "base/task_runner_util.h" | 19 #include "base/task_runner_util.h" |
| 20 #include "base/threading/thread_task_runner_handle.h" | 20 #include "base/threading/thread_task_runner_handle.h" |
| 21 #include "build/build_config.h" | 21 #include "build/build_config.h" |
| 22 #include "gpu/command_buffer/common/mailbox_holder.h" | 22 #include "gpu/command_buffer/common/mailbox_holder.h" |
| 23 #include "gpu/command_buffer/service/gpu_switches.h" | |
| 23 #include "media/base/bind_to_current_loop.h" | 24 #include "media/base/bind_to_current_loop.h" |
| 24 #include "media/base/cdm_context.h" | 25 #include "media/base/cdm_context.h" |
| 25 #include "media/base/decoder_buffer.h" | 26 #include "media/base/decoder_buffer.h" |
| 26 #include "media/base/media_switches.h" | 27 #include "media/base/media_switches.h" |
| 27 #include "media/base/pipeline_status.h" | 28 #include "media/base/pipeline_status.h" |
| 28 #include "media/base/surface_manager.h" | 29 #include "media/base/surface_manager.h" |
| 29 #include "media/base/video_decoder_config.h" | 30 #include "media/base/video_decoder_config.h" |
| 30 #include "media/renderers/gpu_video_accelerator_factories.h" | 31 #include "media/renderers/gpu_video_accelerator_factories.h" |
| 31 #include "third_party/skia/include/core/SkBitmap.h" | 32 #include "third_party/skia/include/core/SkBitmap.h" |
| 32 | 33 |
| (...skipping 45 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 78 factories_(factories), | 79 factories_(factories), |
| 79 state_(kNormal), | 80 state_(kNormal), |
| 80 request_surface_cb_(request_surface_cb), | 81 request_surface_cb_(request_surface_cb), |
| 81 decoder_texture_target_(0), | 82 decoder_texture_target_(0), |
| 82 pixel_format_(PIXEL_FORMAT_UNKNOWN), | 83 pixel_format_(PIXEL_FORMAT_UNKNOWN), |
| 83 next_picture_buffer_id_(0), | 84 next_picture_buffer_id_(0), |
| 84 next_bitstream_buffer_id_(0), | 85 next_bitstream_buffer_id_(0), |
| 85 available_pictures_(0), | 86 available_pictures_(0), |
| 86 needs_all_picture_buffers_to_decode_(false), | 87 needs_all_picture_buffers_to_decode_(false), |
| 87 supports_deferred_initialization_(false), | 88 supports_deferred_initialization_(false), |
| 89 enable_threaded_texture_mailboxes_(false), | |
| 88 weak_factory_(this) { | 90 weak_factory_(this) { |
| 89 DCHECK(factories_); | 91 DCHECK(factories_); |
| 90 } | 92 } |
| 91 | 93 |
| 92 void GpuVideoDecoder::Reset(const base::Closure& closure) { | 94 void GpuVideoDecoder::Reset(const base::Closure& closure) { |
| 93 DVLOG(3) << "Reset()"; | 95 DVLOG(3) << "Reset()"; |
| 94 DCheckGpuVideoAcceleratorFactoriesTaskRunnerIsCurrent(); | 96 DCheckGpuVideoAcceleratorFactoriesTaskRunnerIsCurrent(); |
| 95 | 97 |
| 96 if (state_ == kDrainingDecoder) { | 98 if (state_ == kDrainingDecoder) { |
| 97 base::ThreadTaskRunnerHandle::Get()->PostTask( | 99 base::ThreadTaskRunnerHandle::Get()->PostTask( |
| (...skipping 67 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 165 BindToCurrentLoop(init_cb)); | 167 BindToCurrentLoop(init_cb)); |
| 166 | 168 |
| 167 #if !defined(OS_ANDROID) | 169 #if !defined(OS_ANDROID) |
| 168 if (config.is_encrypted()) { | 170 if (config.is_encrypted()) { |
| 169 DVLOG(1) << "Encrypted stream not supported."; | 171 DVLOG(1) << "Encrypted stream not supported."; |
| 170 bound_init_cb.Run(false); | 172 bound_init_cb.Run(false); |
| 171 return; | 173 return; |
| 172 } | 174 } |
| 173 #endif | 175 #endif |
| 174 | 176 |
| 177 #if defined(OS_ANDROID) | |
| 178 enable_threaded_texture_mailboxes_ = | |
| 179 base::CommandLine::ForCurrentProcess()->HasSwitch( | |
| 180 switches::kEnableThreadedTextureMailboxes); | |
|
boliu
2016/06/09 15:37:15
you can't assume gpu switches are present in the r
| |
| 181 #endif | |
| 182 | |
| 175 bool previously_initialized = config_.IsValidConfig(); | 183 bool previously_initialized = config_.IsValidConfig(); |
| 176 DVLOG(1) << (previously_initialized ? "Reinitializing" : "Initializing") | 184 DVLOG(1) << (previously_initialized ? "Reinitializing" : "Initializing") |
| 177 << "GVD with config: " << config.AsHumanReadableString(); | 185 << "GVD with config: " << config.AsHumanReadableString(); |
| 178 | 186 |
| 179 // TODO(posciak): destroy and create a new VDA on codec/profile change | 187 // TODO(posciak): destroy and create a new VDA on codec/profile change |
| 180 // (http://crbug.com/260224). | 188 // (http://crbug.com/260224). |
| 181 if (previously_initialized && (config_.profile() != config.profile())) { | 189 if (previously_initialized && (config_.profile() != config.profile())) { |
| 182 DVLOG(1) << "Codec or profile changed, cannot reinitialize."; | 190 DVLOG(1) << "Codec or profile changed, cannot reinitialize."; |
| 183 bound_init_cb.Run(false); | 191 bound_init_cb.Run(false); |
| 184 return; | 192 return; |
| (...skipping 396 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 581 if (!frame) { | 589 if (!frame) { |
| 582 DLOG(ERROR) << "Create frame failed for: " << picture.picture_buffer_id(); | 590 DLOG(ERROR) << "Create frame failed for: " << picture.picture_buffer_id(); |
| 583 NotifyError(VideoDecodeAccelerator::PLATFORM_FAILURE); | 591 NotifyError(VideoDecodeAccelerator::PLATFORM_FAILURE); |
| 584 return; | 592 return; |
| 585 } | 593 } |
| 586 if (picture.allow_overlay()) | 594 if (picture.allow_overlay()) |
| 587 frame->metadata()->SetBoolean(VideoFrameMetadata::ALLOW_OVERLAY, true); | 595 frame->metadata()->SetBoolean(VideoFrameMetadata::ALLOW_OVERLAY, true); |
| 588 #if defined(OS_MACOSX) || defined(OS_WIN) | 596 #if defined(OS_MACOSX) || defined(OS_WIN) |
| 589 frame->metadata()->SetBoolean(VideoFrameMetadata::DECODER_OWNS_FRAME, true); | 597 frame->metadata()->SetBoolean(VideoFrameMetadata::DECODER_OWNS_FRAME, true); |
| 590 #endif | 598 #endif |
| 599 | |
| 600 #if defined(OS_ANDROID) | |
| 601 // For WebView. See http://crbug.com/582170. | |
| 602 if (enable_threaded_texture_mailboxes_) | |
| 603 frame->metadata()->SetBoolean(VideoFrameMetadata::COPY_REQUIRED, true); | |
| 604 #endif | |
| 605 | |
| 591 CHECK_GT(available_pictures_, 0); | 606 CHECK_GT(available_pictures_, 0); |
| 592 --available_pictures_; | 607 --available_pictures_; |
| 593 | 608 |
| 594 bool inserted = | 609 bool inserted = |
| 595 picture_buffers_at_display_ | 610 picture_buffers_at_display_ |
| 596 .insert(std::make_pair(picture.picture_buffer_id(), pb.texture_ids())) | 611 .insert(std::make_pair(picture.picture_buffer_id(), pb.texture_ids())) |
| 597 .second; | 612 .second; |
| 598 DCHECK(inserted); | 613 DCHECK(inserted); |
| 599 | 614 |
| 600 DeliverFrame(frame); | 615 DeliverFrame(frame); |
| (...skipping 190 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 791 } | 806 } |
| 792 return false; | 807 return false; |
| 793 } | 808 } |
| 794 | 809 |
| 795 void GpuVideoDecoder::DCheckGpuVideoAcceleratorFactoriesTaskRunnerIsCurrent() | 810 void GpuVideoDecoder::DCheckGpuVideoAcceleratorFactoriesTaskRunnerIsCurrent() |
| 796 const { | 811 const { |
| 797 DCHECK(factories_->GetTaskRunner()->BelongsToCurrentThread()); | 812 DCHECK(factories_->GetTaskRunner()->BelongsToCurrentThread()); |
| 798 } | 813 } |
| 799 | 814 |
| 800 } // namespace media | 815 } // namespace media |
| OLD | NEW |