summaryrefslogtreecommitdiffstats
path: root/remoting
diff options
context:
space:
mode:
Diffstat (limited to 'remoting')
-rw-r--r--remoting/client/rectangle_update_decoder.cc22
-rw-r--r--remoting/client/rectangle_update_decoder.h6
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