diff options
author | vrk@google.com <vrk@google.com@0039d316-1c4b-4281-b951-d872f2087c98> | 2011-08-10 17:07:14 +0000 |
---|---|---|
committer | vrk@google.com <vrk@google.com@0039d316-1c4b-4281-b951-d872f2087c98> | 2011-08-10 17:07:14 +0000 |
commit | d0af56069939c36894d08d10c6b12415e1539bb7 (patch) | |
tree | 4d4649b0210d6e730feb4d91a292d6e6c39d0f15 /ppapi/examples | |
parent | f24584c7346ab9e321da270c46317831cc345878 (diff) | |
download | chromium_src-d0af56069939c36894d08d10c6b12415e1539bb7.zip chromium_src-d0af56069939c36894d08d10c6b12415e1539bb7.tar.gz chromium_src-d0af56069939c36894d08d10c6b12415e1539bb7.tar.bz2 |
Fix sporadic crash at the end of gles2 ppapi plugin
Fix plugin so that frames can still be painted after the decoder has
been destroyed.
BUG=NONE
TEST=gles2 consistently runs without crashing
Review URL: http://codereview.chromium.org/7607014
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@96196 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'ppapi/examples')
-rw-r--r-- | ppapi/examples/gles2/OWNERS | 2 | ||||
-rw-r--r-- | ppapi/examples/gles2/gles2.cc | 37 |
2 files changed, 21 insertions, 18 deletions
diff --git a/ppapi/examples/gles2/OWNERS b/ppapi/examples/gles2/OWNERS new file mode 100644 index 0000000..b1eea3a --- /dev/null +++ b/ppapi/examples/gles2/OWNERS @@ -0,0 +1,2 @@ +fischman@chromium.org +vrk@chromium.org diff --git a/ppapi/examples/gles2/gles2.cc b/ppapi/examples/gles2/gles2.cc index aa3a4fb..70c6596 100644 --- a/ppapi/examples/gles2/gles2.cc +++ b/ppapi/examples/gles2/gles2.cc @@ -85,7 +85,7 @@ class GLES2DemoInstance : public pp::Instance, void DecodeNextNALUs(); void DecodeNextNALU(); void GetNextNALUBoundary(size_t start_pos, size_t* end_pos); - void Render(const PP_PictureBuffer_Dev& buffer); + void PaintStart(const PP_Picture_Dev& picture); void DeleteOutstandingBitstreamBuffers(); // GL-related functions. @@ -324,6 +324,10 @@ void GLES2DemoInstance::DismissPictureBuffer(PP_Resource decoder, void GLES2DemoInstance::PictureReady(PP_Resource decoder, const PP_Picture_Dev& picture) { assert(decoder == video_decoder_->pp_resource()); + PaintStart(picture); +} + +void GLES2DemoInstance::PaintStart(const PP_Picture_Dev& picture) { if (first_frame_delivered_ticks_ == -1) assert((first_frame_delivered_ticks_ = core_if_->GetTimeTicks()) != -1); if (is_painting_) { @@ -333,7 +337,18 @@ void GLES2DemoInstance::PictureReady(PP_Resource decoder, PictureBufferMap::iterator it = buffers_by_id_.find(picture.picture_buffer_id); assert(it != buffers_by_id_.end()); - Render(it->second); + const PP_PictureBuffer_Dev& buffer = it->second; + assert(!is_painting_); + is_painting_ = true; + gles2_if_->ActiveTexture(context_->pp_resource(), GL_TEXTURE0); + gles2_if_->BindTexture( + context_->pp_resource(), GL_TEXTURE_2D, buffer.texture_id); + gles2_if_->DrawArrays(context_->pp_resource(), GL_TRIANGLE_STRIP, 0, 4); + pp::CompletionCallback cb = + callback_factory_.NewCallback( + &GLES2DemoInstance::PaintFinished, buffer.id); + last_swap_request_ticks_ = core_if_->GetTimeTicks(); + assert(surface_->SwapBuffers(cb) == PP_OK_COMPLETIONPENDING); } void GLES2DemoInstance::EndOfStream(PP_Resource decoder) { @@ -388,20 +403,6 @@ void GLES2DemoInstance::InitGL() { CreateGLObjects(); } -void GLES2DemoInstance::Render(const PP_PictureBuffer_Dev& buffer) { - assert(!is_painting_); - is_painting_ = true; - gles2_if_->ActiveTexture(context_->pp_resource(), GL_TEXTURE0); - gles2_if_->BindTexture( - context_->pp_resource(), GL_TEXTURE_2D, buffer.texture_id); - gles2_if_->DrawArrays(context_->pp_resource(), GL_TRIANGLE_STRIP, 0, 4); - pp::CompletionCallback cb = - callback_factory_.NewCallback( - &GLES2DemoInstance::PaintFinished, buffer.id); - last_swap_request_ticks_ = core_if_->GetTimeTicks(); - assert(surface_->SwapBuffers(cb) == PP_OK_COMPLETIONPENDING); -} - void GLES2DemoInstance::PaintFinished(int32_t result, int picture_buffer_id) { swap_ticks_ += core_if_->GetTimeTicks() - last_swap_request_ticks_; is_painting_ = false; @@ -416,10 +417,10 @@ void GLES2DemoInstance::PaintFinished(int32_t result, int picture_buffer_id) { } if (video_decoder_) video_decoder_->ReusePictureBuffer(picture_buffer_id); - while (!pictures_pending_paint_.empty() && !is_painting_) { + if (!pictures_pending_paint_.empty()) { PP_Picture_Dev picture = pictures_pending_paint_.front(); pictures_pending_paint_.pop_front(); - PictureReady(video_decoder_->pp_resource(), picture); + PaintStart(picture); } } |