Skip to content

Commit

Permalink
Call Pepper's Flush command properly
Browse files Browse the repository at this point in the history
Need to provide a flag to the Flush command otherwise it won't return
a proper error to notify that Flush has failed. Because of this there's
some content in the plugin area not updated until the next frame
arrives.

BUG=80000, 91300
TEST=Try chromoting, do a small action, stop the mouse, animation should completes.

Review URL: http://codereview.chromium.org/7550008

git-svn-id: svn://svn.chromium.org/chrome/trunk/src@95227 0039d316-1c4b-4281-b951-d872f2087c98
  • Loading branch information
hclam@chromium.org committed Aug 3, 2011
1 parent 6a77c9c commit 5174a84
Show file tree
Hide file tree
Showing 3 changed files with 31 additions and 9 deletions.
8 changes: 8 additions & 0 deletions remoting/client/chromoting_client.cc
Original file line number Diff line number Diff line change
Expand Up @@ -107,6 +107,14 @@ void ChromotingClient::ProcessVideoPacket(const VideoPacket* packet,
return;
}

// If the video packet is empty then drop it. Empty packets are used to
// maintain activity on the network.
if (!packet->has_data() || packet->data().size() == 0) {
done->Run();
delete done;
return;
}

// Record size of the packet for statistics.
stats_.video_bandwidth()->Record(packet->data().size());

Expand Down
30 changes: 22 additions & 8 deletions remoting/client/plugin/pepper_view.cc
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ namespace remoting {
PepperView::PepperView(ChromotingInstance* instance, ClientContext* context)
: instance_(instance),
context_(context),
pending_flush_(false),
flush_blocked_(false),
is_static_fill_(false),
static_fill_color_(0),
ALLOW_THIS_IN_INITIALIZER_LIST(task_factory_(this)) {
Expand Down Expand Up @@ -164,20 +164,34 @@ void PepperView::BlankRect(pp::ImageData& image_data, const pp::Rect& rect) {
}

void PepperView::FlushGraphics(base::Time paint_start) {
int error = graphics2d_.Flush(
TaskToCompletionCallback(
task_factory_.NewRunnableMethod(&PepperView::OnPaintDone,
paint_start)));
scoped_ptr<Task> task(
task_factory_.NewRunnableMethod(&PepperView::OnPaintDone, paint_start));

// 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(&CompletionCallbackTaskAdapter,
task.get(),
PP_COMPLETIONCALLBACK_FLAG_OPTIONAL);
int error = graphics2d_.Flush(pp_callback);

// There is already a flush in progress so set this flag to true so that we
// can flush again later.
// |paint_start| is then discarded but this is fine because we're not aiming
// for precise measurement of timing, otherwise we need to keep a list of
// queued start time(s).
if (error == PP_ERROR_INPROGRESS)
pending_flush_ = true;
flush_blocked_ = true;
else
pending_flush_ = false;
flush_blocked_ = false;

// If Flush() returns asynchronously then release the task.
if (error == PP_OK_COMPLETIONPENDING)
ignore_result(task.release());
}

void PepperView::SetSolidFill(uint32 color) {
Expand Down Expand Up @@ -326,7 +340,7 @@ void PepperView::OnPaintDone(base::Time paint_start) {

// If the last flush failed because there was already another one in progress
// then we perform the flush now.
if (pending_flush_)
if (flush_blocked_)
FlushGraphics(base::Time::Now());
return;
}
Expand Down
2 changes: 1 addition & 1 deletion remoting/client/plugin/pepper_view.h
Original file line number Diff line number Diff line change
Expand Up @@ -96,7 +96,7 @@ class PepperView : public ChromotingView,

// True if there is pending paint commands in Pepper's queue. This is set to
// true if the last flush returns a PP_ERROR_INPROGRESS error.
bool pending_flush_;
bool flush_blocked_;

// The size of the plugin element.
gfx::Size plugin_size_;
Expand Down

0 comments on commit 5174a84

Please sign in to comment.