diff options
author | wez@chromium.org <wez@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2012-03-13 22:40:50 +0000 |
---|---|---|
committer | wez@chromium.org <wez@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2012-03-13 22:40:50 +0000 |
commit | 55eed9dbfd8b0b0cd34d525f90ce8774a53ab24c (patch) | |
tree | 975c777365a1e71692efb2c70104a9a95a92b264 /remoting | |
parent | 15574f8e671304dec5ef5aa33c76f1089df81117 (diff) | |
download | chromium_src-55eed9dbfd8b0b0cd34d525f90ce8774a53ab24c.zip chromium_src-55eed9dbfd8b0b0cd34d525f90ce8774a53ab24c.tar.gz chromium_src-55eed9dbfd8b0b0cd34d525f90ce8774a53ab24c.tar.bz2 |
Schedule a paint if the client plugin's view size or clip change.
Without this the view will only update after being scrolled when the next change is received from the host.
This CL also coalesces multiple scheduled paints to a single operation to avoid operations such as simultaneous resize and scroll from duplicating work.
BUG=117494,117925
Review URL: http://codereview.chromium.org/9677026
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@126485 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'remoting')
-rw-r--r-- | remoting/client/rectangle_update_decoder.cc | 22 | ||||
-rw-r--r-- | remoting/client/rectangle_update_decoder.h | 6 |
2 files changed, 23 insertions, 5 deletions
diff --git a/remoting/client/rectangle_update_decoder.cc b/remoting/client/rectangle_update_decoder.cc index 1a0b059..d829576 100644 --- a/remoting/client/rectangle_update_decoder.cc +++ b/remoting/client/rectangle_update_decoder.cc @@ -30,7 +30,8 @@ RectangleUpdateDecoder::RectangleUpdateDecoder( consumer_(consumer), source_size_(SkISize::Make(0, 0)), view_size_(SkISize::Make(0, 0)), - clip_area_(SkIRect::MakeEmpty()) { + clip_area_(SkIRect::MakeEmpty()), + paint_scheduled_(false) { } RectangleUpdateDecoder::~RectangleUpdateDecoder() { @@ -90,10 +91,21 @@ void RectangleUpdateDecoder::DecodePacket(const VideoPacket* packet, } if (decoder_->DecodePacket(packet) == Decoder::DECODE_DONE) - DoPaint(); + SchedulePaint(); +} + +void RectangleUpdateDecoder::SchedulePaint() { + if (paint_scheduled_) + return; + paint_scheduled_ = true; + message_loop_->PostTask( + FROM_HERE, base::Bind(&RectangleUpdateDecoder::DoPaint, this)); } void RectangleUpdateDecoder::DoPaint() { + DCHECK(paint_scheduled_); + paint_scheduled_ = false; + // If the view size is empty or we have no output buffers ready, return. if (buffers_.empty() || view_size_.isEmpty()) return; @@ -146,7 +158,7 @@ void RectangleUpdateDecoder::DrawBuffer(pp::ImageData* buffer) { clip_area_.height() <= buffer->size().height()); buffers_.push_back(buffer); - DoPaint(); + SchedulePaint(); } void RectangleUpdateDecoder::InvalidateRegion(const SkRegion& region) { @@ -159,7 +171,7 @@ void RectangleUpdateDecoder::InvalidateRegion(const SkRegion& region) { if (decoder_.get()) { decoder_->Invalidate(view_size_, region); - DoPaint(); + SchedulePaint(); } } @@ -197,6 +209,8 @@ void RectangleUpdateDecoder::SetOutputSizeAndClip(const SkISize& view_size, ++i; } } + + SchedulePaint(); } } diff --git a/remoting/client/rectangle_update_decoder.h b/remoting/client/rectangle_update_decoder.h index c61acb4..daa6dfd 100644 --- a/remoting/client/rectangle_update_decoder.h +++ b/remoting/client/rectangle_update_decoder.h @@ -61,8 +61,9 @@ class RectangleUpdateDecoder : virtual ~RectangleUpdateDecoder(); - // Paint the invalidated region to the next available buffer and return it + // Paints the invalidated region to the next available buffer and returns it // to the consumer. + void SchedulePaint(); void DoPaint(); scoped_refptr<base::MessageLoopProxy> message_loop_; @@ -79,6 +80,9 @@ class RectangleUpdateDecoder : // The drawing buffers supplied by the frame consumer. std::list<pp::ImageData*> buffers_; + + // Flag used to coalesce runs of SchedulePaint()s into a single DoPaint(). + bool paint_scheduled_; }; } // namespace remoting |