summaryrefslogtreecommitdiffstats
path: root/remoting/client
diff options
context:
space:
mode:
authorhclam@chromium.org <hclam@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2011-08-01 19:49:57 +0000
committerhclam@chromium.org <hclam@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2011-08-01 19:49:57 +0000
commit32e22dbaac79161e82ad10f46fbd602d506e1951 (patch)
treefe45ad5bdd37a3569e68b1e2f572d0a81b845116 /remoting/client
parent37fa50ff7d75f7053fa834d7993db3518ef63904 (diff)
downloadchromium_src-32e22dbaac79161e82ad10f46fbd602d506e1951.zip
chromium_src-32e22dbaac79161e82ad10f46fbd602d506e1951.tar.gz
chromium_src-32e22dbaac79161e82ad10f46fbd602d506e1951.tar.bz2
If pepper flush returns an error then save a pending flush
If there is already a flush in progress then flush will return an error. Save a flag so that when the last flush completes the client plugin will flush again. BUG=80000 TEST=chromoting client renders correctly Review URL: http://codereview.chromium.org/7518024 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@94961 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'remoting/client')
-rw-r--r--remoting/client/plugin/pepper_view.cc34
-rw-r--r--remoting/client/plugin/pepper_view.h7
2 files changed, 33 insertions, 8 deletions
diff --git a/remoting/client/plugin/pepper_view.cc b/remoting/client/plugin/pepper_view.cc
index 71774cd..3def351 100644
--- a/remoting/client/plugin/pepper_view.cc
+++ b/remoting/client/plugin/pepper_view.cc
@@ -23,6 +23,7 @@ namespace remoting {
PepperView::PepperView(ChromotingInstance* instance, ClientContext* context)
: instance_(instance),
context_(context),
+ pending_flush_(false),
is_static_fill_(false),
static_fill_color_(0),
ALLOW_THIS_IN_INITIALIZER_LIST(task_factory_(this)) {
@@ -69,9 +70,7 @@ void PepperView::Paint() {
// For ReplaceContents, make sure the image size matches the device context
// size! Otherwise, this will just silently do nothing.
graphics2d_.ReplaceContents(&image);
- graphics2d_.Flush(TaskToCompletionCallback(
- task_factory_.NewRunnableMethod(&PepperView::OnPaintDone,
- base::Time::Now())));
+ FlushGraphics(base::Time::Now());
} else {
// TODO(ajwong): We need to keep a backing store image of the host screen
// that has the data here which can be redrawn.
@@ -112,11 +111,8 @@ void PepperView::PaintFrame(media::VideoFrame* frame, UpdatedRects* rects) {
for (size_t i = 0; i < rects->size(); ++i)
changes_made |= PaintRect(frame, (*rects)[i]);
- if (changes_made) {
- graphics2d_.Flush(TaskToCompletionCallback(
- task_factory_.NewRunnableMethod(&PepperView::OnPaintDone,
- start_time)));
- }
+ if (changes_made)
+ FlushGraphics(start_time);
TraceContext::tracer()->PrintString("End Paint Frame.");
}
@@ -167,6 +163,23 @@ 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)));
+
+ // 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;
+ else
+ pending_flush_ = false;
+}
+
void PepperView::SetSolidFill(uint32 color) {
DCHECK(CurrentlyOnPluginThread());
@@ -310,6 +323,11 @@ void PepperView::OnPaintDone(base::Time paint_start) {
TraceContext::tracer()->PrintString("Paint flushed");
instance_->GetStats()->video_paint_ms()->Record(
(base::Time::Now() - paint_start).InMilliseconds());
+
+ // If the last flush failed because there was already another one in progress
+ // then we perform the flush now.
+ if (pending_flush_)
+ FlushGraphics(base::Time::Now());
return;
}
diff --git a/remoting/client/plugin/pepper_view.h b/remoting/client/plugin/pepper_view.h
index dbd0f93..d88e658 100644
--- a/remoting/client/plugin/pepper_view.h
+++ b/remoting/client/plugin/pepper_view.h
@@ -78,6 +78,9 @@ class PepperView : public ChromotingView,
// Blanks out a rectangle in an image.
void BlankRect(pp::ImageData& image_data, const pp::Rect& rect);
+ // Perform a flush on the graphics context.
+ void FlushGraphics(base::Time paint_start);
+
// Reference to the creating plugin instance. Needed for interacting with
// pepper. Marking explicitly as const since it must be initialized at
// object creation, and never change.
@@ -91,6 +94,10 @@ class PepperView : public ChromotingView,
// A backing store that saves the current desktop image.
scoped_ptr<pp::ImageData> backing_store_;
+ // 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_;
+
// The size of the plugin element.
gfx::Size plugin_size_;