diff options
author | bbudge@chromium.org <bbudge@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2014-06-16 22:01:20 +0000 |
---|---|---|
committer | bbudge@chromium.org <bbudge@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2014-06-16 22:01:20 +0000 |
commit | e9fc71c11a80196af87986b5b538e646933952c5 (patch) | |
tree | 1404e4c2b87272123691572e66abf0b3a2b516a4 /content/renderer | |
parent | f2164909fd82aee1283c9bf5c38b5e662b8db7ae (diff) | |
download | chromium_src-e9fc71c11a80196af87986b5b538e646933952c5.zip chromium_src-e9fc71c11a80196af87986b5b538e646933952c5.tar.gz chromium_src-e9fc71c11a80196af87986b5b538e646933952c5.tar.bz2 |
Pepper: Fix texture management in VideoDecoderShim on Reset.
- Use a hash_set to track available textures. This prevents weird behavior
if the plugin recycles a texture twice.
- Fix Reset, so all textures are made available on completion.
- Fix the plugin, which had a bug that allowed pictures to jump the queue
and didn't behave correctly on Reset.
BUG=281689
Review URL: https://codereview.chromium.org/337743003
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@277548 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'content/renderer')
-rw-r--r-- | content/renderer/pepper/pepper_video_decoder_host.cc | 2 | ||||
-rw-r--r-- | content/renderer/pepper/video_decoder_shim.cc | 41 | ||||
-rw-r--r-- | content/renderer/pepper/video_decoder_shim.h | 4 |
3 files changed, 30 insertions, 17 deletions
diff --git a/content/renderer/pepper/pepper_video_decoder_host.cc b/content/renderer/pepper/pepper_video_decoder_host.cc index d3364e1..5f656ac 100644 --- a/content/renderer/pepper/pepper_video_decoder_host.cc +++ b/content/renderer/pepper/pepper_video_decoder_host.cc @@ -337,12 +337,14 @@ void PepperVideoDecoderHost::NotifyEndOfBitstreamBuffer( } void PepperVideoDecoderHost::NotifyFlushDone() { + DCHECK(pending_decodes_.empty()); host()->SendReply(flush_reply_context_, PpapiPluginMsg_VideoDecoder_FlushReply()); flush_reply_context_ = ppapi::host::ReplyMessageContext(); } void PepperVideoDecoderHost::NotifyResetDone() { + DCHECK(pending_decodes_.empty()); host()->SendReply(reset_reply_context_, PpapiPluginMsg_VideoDecoder_ResetReply()); reset_reply_context_ = ppapi::host::ReplyMessageContext(); diff --git a/content/renderer/pepper/video_decoder_shim.cc b/content/renderer/pepper/video_decoder_shim.cc index eb833ff..36c4b9f 100644 --- a/content/renderer/pepper/video_decoder_shim.cc +++ b/content/renderer/pepper/video_decoder_shim.cc @@ -386,7 +386,7 @@ void VideoDecoderShim::AssignPictureBuffers( // Map the plugin texture id to the local texture id. uint32_t plugin_texture_id = buffers[i].texture_id(); texture_id_map_[plugin_texture_id] = local_texture_ids[i]; - available_textures_.push_back(plugin_texture_id); + available_textures_.insert(plugin_texture_id); } pending_texture_mailboxes_.clear(); SendPictures(); @@ -398,7 +398,7 @@ void VideoDecoderShim::ReusePictureBuffer(int32 picture_buffer_id) { if (textures_to_dismiss_.find(texture_id) != textures_to_dismiss_.end()) { DismissTexture(texture_id); } else if (texture_id_map_.find(texture_id) != texture_id_map_.end()) { - available_textures_.push_back(texture_id); + available_textures_.insert(texture_id); SendPictures(); } else { NOTREACHED(); @@ -442,18 +442,19 @@ void VideoDecoderShim::OnDecodeComplete(int32_t result, uint32_t decode_id) { DCHECK(RenderThreadImpl::current()); DCHECK(host_); + if (result == PP_ERROR_RESOURCE_FAILED) { + host_->NotifyError(media::VideoDecodeAccelerator::PLATFORM_FAILURE); + return; + } + num_pending_decodes_--; completed_decodes_.push(decode_id); - if (result == PP_OK) { - // If frames are being queued because we're out of textures, don't notify - // the host that decode has completed. This exerts "back pressure" to keep - // the host from sending buffers that will cause pending_frames_ to grow. - if (pending_frames_.empty()) - NotifyCompletedDecodes(); - } else if (result == PP_ERROR_RESOURCE_FAILED) { - host_->NotifyError(media::VideoDecodeAccelerator::PLATFORM_FAILURE); - } + // If frames are being queued because we're out of textures, don't notify + // the host that decode has completed. This exerts "back pressure" to keep + // the host from sending buffers that will cause pending_frames_ to grow. + if (pending_frames_.empty()) + NotifyCompletedDecodes(); } void VideoDecoderShim::OnOutputComplete(scoped_ptr<PendingFrame> frame) { @@ -470,8 +471,7 @@ void VideoDecoderShim::OnOutputComplete(scoped_ptr<PendingFrame> frame) { ++it) { textures_to_dismiss_.insert(it->second); } - for (std::vector<uint32_t>::const_iterator it = - available_textures_.begin(); + for (TextureIdSet::const_iterator it = available_textures_.begin(); it != available_textures_.end(); ++it) { DismissTexture(*it); @@ -501,8 +501,9 @@ void VideoDecoderShim::SendPictures() { while (!pending_frames_.empty() && !available_textures_.empty()) { const linked_ptr<PendingFrame>& frame = pending_frames_.front(); - uint32_t texture_id = available_textures_.back(); - available_textures_.pop_back(); + TextureIdSet::iterator it = available_textures_.begin(); + uint32_t texture_id = *it; + available_textures_.erase(it); uint32_t local_texture_id = texture_id_map_[texture_id]; gpu::gles2::GLES2Interface* gles2 = context_provider_->ContextGL(); @@ -544,6 +545,16 @@ void VideoDecoderShim::OnResetComplete() { pending_frames_.pop(); NotifyCompletedDecodes(); + // Dismiss any old textures now. + while (!textures_to_dismiss_.empty()) + DismissTexture(*textures_to_dismiss_.begin()); + // Make all textures available. + for (TextureIdMap::const_iterator it = texture_id_map_.begin(); + it != texture_id_map_.end(); + ++it) { + available_textures_.insert(it->first); + } + state_ = DECODING; host_->NotifyResetDone(); } diff --git a/content/renderer/pepper/video_decoder_shim.h b/content/renderer/pepper/video_decoder_shim.h index ca4ba1b..aa33a74 100644 --- a/content/renderer/pepper/video_decoder_shim.h +++ b/content/renderer/pepper/video_decoder_shim.h @@ -98,9 +98,9 @@ class VideoDecoderShim : public media::VideoDecodeAccelerator { typedef base::hash_map<uint32_t, uint32_t> TextureIdMap; TextureIdMap texture_id_map_; // Available textures (these are plugin ids.) - std::vector<uint32_t> available_textures_; - // Track textures that are no longer needed (these are plugin ids.) typedef base::hash_set<uint32_t> TextureIdSet; + TextureIdSet available_textures_; + // Track textures that are no longer needed (these are plugin ids.) TextureIdSet textures_to_dismiss_; // Mailboxes for pending texture requests, to write to plugin's textures. std::vector<gpu::Mailbox> pending_texture_mailboxes_; |