diff options
author | wez@chromium.org <wez@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2012-04-08 02:58:45 +0000 |
---|---|---|
committer | wez@chromium.org <wez@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2012-04-08 02:58:45 +0000 |
commit | e174c49b8f65ac59b413f043514f0c652bfe3e68 (patch) | |
tree | 78cf9fc15a6b3582d72258ac421859f5951768b8 /remoting/client/plugin/pepper_view.cc | |
parent | 95c5f6dd3bc49b65c8c794a4cf03f066a388216b (diff) | |
download | chromium_src-e174c49b8f65ac59b413f043514f0c652bfe3e68.zip chromium_src-e174c49b8f65ac59b413f043514f0c652bfe3e68.tar.gz chromium_src-e174c49b8f65ac59b413f043514f0c652bfe3e68.tar.bz2 |
Switch PepperView to use asynchronous completion for Flush().
PepperView was requesting "optional" synchronous/asynchronous completion from Flush(), so as to be able to handle errors, which was not possible with the CompletionCallbackClosureAdapter, since the closure would not receive the result.
This CL replaces CompletionCallbackClosureAdapter with a PpCompletionCallback() function that accepts a base::Callback<void(int)> and returns a pp::CompletionCallback suitable for passing directly to Flush(). PepperView is also updated to use the new helper, and to expect Flush() to always complete asynchronously.
TEST=Chromoting client renders correctly.
Review URL: http://codereview.chromium.org/10010033
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@131304 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'remoting/client/plugin/pepper_view.cc')
-rw-r--r-- | remoting/client/plugin/pepper_view.cc | 46 |
1 files changed, 8 insertions, 38 deletions
diff --git a/remoting/client/plugin/pepper_view.cc b/remoting/client/plugin/pepper_view.cc index 908ad56..6b67eac 100644 --- a/remoting/client/plugin/pepper_view.cc +++ b/remoting/client/plugin/pepper_view.cc @@ -318,45 +318,16 @@ void PepperView::FlushBuffer(const SkIRect& clip_area, } // Flush the updated areas to the screen. - scoped_ptr<base::Closure> task( - new base::Closure( - base::Bind(&PepperView::OnFlushDone, AsWeakPtr(), start_time, - buffer))); - - // Flag needs to be set here in order to get a proper error code for Flush(). - // Otherwise Flush() will always return PP_OK_COMPLETIONPENDING and the error - // would be hidden. - // - // Note that we can also handle this by providing an actual callback which - // takes the result code. Right now everything goes to the task that doesn't - // result value. - pp::CompletionCallback pp_callback(&CompletionCallbackClosureAdapter, - task.get(), - PP_COMPLETIONCALLBACK_FLAG_OPTIONAL); - int error = graphics2d_.Flush(pp_callback); - - // If Flush() returns asynchronously then release the task. - flush_pending_ = (error == PP_OK_COMPLETIONPENDING); - if (flush_pending_) { - ignore_result(task.release()); - } else { - instance_->GetStats()->video_paint_ms()->Record( - (base::Time::Now() - start_time).InMilliseconds()); - - ReturnBuffer(buffer); - - // Resume painting for the buffer that was previoulsy postponed because of - // pending flush. - if (merge_buffer_ != NULL) { - buffer = merge_buffer_; - merge_buffer_ = NULL; - FlushBuffer(merge_clip_area_, buffer, merge_region_); - } - } + int error = graphics2d_.Flush( + PpCompletionCallback(base::Bind( + &PepperView::OnFlushDone, AsWeakPtr(), start_time, buffer))); + CHECK(error == PP_OK_COMPLETIONPENDING); + flush_pending_ = true; } void PepperView::OnFlushDone(base::Time paint_start, - pp::ImageData* buffer) { + pp::ImageData* buffer, + int result) { DCHECK(context_->main_message_loop()->BelongsToCurrentThread()); DCHECK(flush_pending_); @@ -366,8 +337,7 @@ void PepperView::OnFlushDone(base::Time paint_start, flush_pending_ = false; ReturnBuffer(buffer); - // Resume painting for the buffer that was previoulsy postponed because of - // pending flush. + // If there is a buffer queued for rendering then render it now. if (merge_buffer_ != NULL) { buffer = merge_buffer_; merge_buffer_ = NULL; |