Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(209)

Side by Side Diff: content/renderer/pepper/video_decoder_shim.cc

Issue 1207043002: Introduce a client minimum picture pool size (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Documented actual may be larger than requested count. Created 5 years, 5 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
1 // Copyright 2014 The Chromium Authors. All rights reserved. 1 // Copyright 2014 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/renderer/pepper/video_decoder_shim.h" 5 #include "content/renderer/pepper/video_decoder_shim.h"
6 6
7 #include <GLES2/gl2.h> 7 #include <GLES2/gl2.h>
8 #include <GLES2/gl2ext.h> 8 #include <GLES2/gl2ext.h>
9 #include <GLES2/gl2extchromium.h> 9 #include <GLES2/gl2extchromium.h>
10 10
(...skipping 716 matching lines...) Expand 10 before | Expand all | Expand 10 after
727 // again. 727 // again.
728 while (!pending_decodes_.empty()) 728 while (!pending_decodes_.empty())
729 pending_decodes_.pop(); 729 pending_decodes_.pop();
730 decoder_.reset(); 730 decoder_.reset();
731 // This instance is deleted once we exit this scope. 731 // This instance is deleted once we exit this scope.
732 } 732 }
733 733
734 void VideoDecoderShim::DecoderImpl::OnInitDone(bool success) { 734 void VideoDecoderShim::DecoderImpl::OnInitDone(bool success) {
735 int32_t result = success ? PP_OK : PP_ERROR_NOTSUPPORTED; 735 int32_t result = success ? PP_OK : PP_ERROR_NOTSUPPORTED;
736 736
737 // Calculate how many textures the shim should create.
738 uint32_t shim_texture_pool_size = media::limits::kMaxVideoFrames + 1;
739 main_task_runner_->PostTask( 737 main_task_runner_->PostTask(
740 FROM_HERE, base::Bind(&VideoDecoderShim::OnInitializeComplete, shim_, 738 FROM_HERE, base::Bind(&VideoDecoderShim::OnInitializeComplete, shim_,
741 result, shim_texture_pool_size)); 739 result));
742 } 740 }
743 741
744 void VideoDecoderShim::DecoderImpl::DoDecode() { 742 void VideoDecoderShim::DecoderImpl::DoDecode() {
745 if (pending_decodes_.empty() || awaiting_decoder_) 743 if (pending_decodes_.empty() || awaiting_decoder_)
746 return; 744 return;
747 745
748 awaiting_decoder_ = true; 746 awaiting_decoder_ = true;
749 const PendingDecode& decode = pending_decodes_.front(); 747 const PendingDecode& decode = pending_decodes_.front();
750 decode_id_ = decode.decode_id; 748 decode_id_ = decode.decode_id;
751 decoder_->Decode(decode.buffer, 749 decoder_->Decode(decode.buffer,
(...skipping 44 matching lines...) Expand 10 before | Expand all | Expand 10 after
796 main_task_runner_->PostTask( 794 main_task_runner_->PostTask(
797 FROM_HERE, base::Bind(&VideoDecoderShim::OnOutputComplete, shim_, 795 FROM_HERE, base::Bind(&VideoDecoderShim::OnOutputComplete, shim_,
798 base::Passed(&pending_frame))); 796 base::Passed(&pending_frame)));
799 } 797 }
800 798
801 void VideoDecoderShim::DecoderImpl::OnResetComplete() { 799 void VideoDecoderShim::DecoderImpl::OnResetComplete() {
802 main_task_runner_->PostTask( 800 main_task_runner_->PostTask(
803 FROM_HERE, base::Bind(&VideoDecoderShim::OnResetComplete, shim_)); 801 FROM_HERE, base::Bind(&VideoDecoderShim::OnResetComplete, shim_));
804 } 802 }
805 803
806 VideoDecoderShim::VideoDecoderShim(PepperVideoDecoderHost* host) 804 VideoDecoderShim::VideoDecoderShim(
805 PepperVideoDecoderHost* host, uint32_t texture_pool_size)
807 : state_(UNINITIALIZED), 806 : state_(UNINITIALIZED),
808 host_(host), 807 host_(host),
809 media_task_runner_( 808 media_task_runner_(
810 RenderThreadImpl::current()->GetMediaThreadTaskRunner()), 809 RenderThreadImpl::current()->GetMediaThreadTaskRunner()),
811 context_provider_( 810 context_provider_(
812 RenderThreadImpl::current()->SharedMainThreadContextProvider()), 811 RenderThreadImpl::current()->SharedMainThreadContextProvider()),
813 texture_pool_size_(0), 812 texture_pool_size_(texture_pool_size),
814 num_pending_decodes_(0), 813 num_pending_decodes_(0),
815 yuv_converter_(new YUVConverter(context_provider_)), 814 yuv_converter_(new YUVConverter(context_provider_)),
816 weak_ptr_factory_(this) { 815 weak_ptr_factory_(this) {
817 DCHECK(host_); 816 DCHECK(host_);
818 DCHECK(media_task_runner_.get()); 817 DCHECK(media_task_runner_.get());
819 DCHECK(context_provider_.get()); 818 DCHECK(context_provider_.get());
820 decoder_impl_.reset(new DecoderImpl(weak_ptr_factory_.GetWeakPtr())); 819 decoder_impl_.reset(new DecoderImpl(weak_ptr_factory_.GetWeakPtr()));
821 } 820 }
822 821
823 VideoDecoderShim::~VideoDecoderShim() { 822 VideoDecoderShim::~VideoDecoderShim() {
(...skipping 125 matching lines...) Expand 10 before | Expand all | Expand 10 after
949 media_task_runner_->PostTask( 948 media_task_runner_->PostTask(
950 FROM_HERE, 949 FROM_HERE,
951 base::Bind(&VideoDecoderShim::DecoderImpl::Reset, 950 base::Bind(&VideoDecoderShim::DecoderImpl::Reset,
952 base::Unretained(decoder_impl_.get()))); 951 base::Unretained(decoder_impl_.get())));
953 } 952 }
954 953
955 void VideoDecoderShim::Destroy() { 954 void VideoDecoderShim::Destroy() {
956 delete this; 955 delete this;
957 } 956 }
958 957
959 void VideoDecoderShim::OnInitializeComplete(int32_t result, 958 void VideoDecoderShim::OnInitializeComplete(int32_t result) {
960 uint32_t texture_pool_size) {
961 DCHECK(RenderThreadImpl::current()); 959 DCHECK(RenderThreadImpl::current());
962 DCHECK(host_); 960 DCHECK(host_);
963 961
964 if (result == PP_OK) { 962 if (result == PP_OK) {
965 state_ = DECODING; 963 state_ = DECODING;
966 texture_pool_size_ = texture_pool_size;
967 } 964 }
968 965
969 host_->OnInitializeComplete(result); 966 host_->OnInitializeComplete(result);
970 } 967 }
971 968
972 void VideoDecoderShim::OnDecodeComplete(int32_t result, uint32_t decode_id) { 969 void VideoDecoderShim::OnDecodeComplete(int32_t result, uint32_t decode_id) {
973 DCHECK(RenderThreadImpl::current()); 970 DCHECK(RenderThreadImpl::current());
974 DCHECK(host_); 971 DCHECK(host_);
975 972
976 if (result == PP_ERROR_RESOURCE_FAILED) { 973 if (result == PP_ERROR_RESOURCE_FAILED) {
(...skipping 117 matching lines...) Expand 10 before | Expand all | Expand 10 after
1094 void VideoDecoderShim::DeleteTexture(uint32_t texture_id) { 1091 void VideoDecoderShim::DeleteTexture(uint32_t texture_id) {
1095 gpu::gles2::GLES2Interface* gles2 = context_provider_->ContextGL(); 1092 gpu::gles2::GLES2Interface* gles2 = context_provider_->ContextGL();
1096 gles2->DeleteTextures(1, &texture_id); 1093 gles2->DeleteTextures(1, &texture_id);
1097 } 1094 }
1098 1095
1099 void VideoDecoderShim::FlushCommandBuffer() { 1096 void VideoDecoderShim::FlushCommandBuffer() {
1100 context_provider_->ContextGL()->Flush(); 1097 context_provider_->ContextGL()->Flush();
1101 } 1098 }
1102 1099
1103 } // namespace content 1100 } // namespace content
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698