Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(8817)

Unified Diff: chrome/renderer/render_widget.cc

Issue 6136005: Chromium support for window.webkitRequestAnimationFrame() (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: ScheduleAnimation implemented as part of WebWidgetHost Created 9 years, 11 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
Index: chrome/renderer/render_widget.cc
diff --git a/chrome/renderer/render_widget.cc b/chrome/renderer/render_widget.cc
index 6ec3040a4316acd4b2622af9f5d914c021e4dbcf..b72261c847e7161a9282c77bdfa4de6440f4f39d 100644
--- a/chrome/renderer/render_widget.cc
+++ b/chrome/renderer/render_widget.cc
@@ -76,7 +76,8 @@ RenderWidget::RenderWidget(RenderThreadBase* render_thread,
popup_type_(popup_type),
pending_window_rect_count_(0),
suppress_next_char_events_(false),
- is_accelerated_compositing_active_(false) {
+ is_accelerated_compositing_active_(false),
+ animation_update_pending_(false) {
RenderProcess::current()->AddRefProcess();
DCHECK(render_thread_);
}
@@ -486,9 +487,16 @@ void RenderWidget::CallDoDeferredUpdate() {
Send(pending_input_event_ack_.release());
}
+void RenderWidget::UpdateAnimationsIfNeeded() {
+ if (!is_hidden() && animation_update_pending_ &&
+ base::Time::Now() > animation_floor_time_) {
+ animation_update_pending_ = false;
+ webwidget_->animate();
+ }
+}
+
void RenderWidget::DoDeferredUpdate() {
- if (!webwidget_ || !paint_aggregator_.HasPendingUpdate() ||
- update_reply_pending())
+ if (!webwidget_ || update_reply_pending())
return;
// Suppress updating when we are hidden.
@@ -498,11 +506,19 @@ void RenderWidget::DoDeferredUpdate() {
return;
}
+ if (base::Time::Now() > animation_floor_time_)
+ UpdateAnimationsIfNeeded();
+
// Layout may generate more invalidation. It may also enable the
// GPU acceleration, so make sure to run layout before we send the
// GpuRenderingActivated message.
webwidget_->layout();
+ // Suppress painting if nothing is dirty. This has to be done after updating
+ // animations running layout as these may generate further invalidations.
+ if (!paint_aggregator_.HasPendingUpdate())
+ return;
+
// OK, save the pending update to a local since painting may cause more
// invalidation. Some WebCore rendering objects only layout when painted.
PaintAggregator::PendingUpdate update;
@@ -681,6 +697,16 @@ void RenderWidget::scheduleComposite() {
didInvalidateRect(WebRect(0, 0, 1, 1));
}
+void RenderWidget::scheduleAnimation() {
+ if (!animation_update_pending_) {
+ animation_update_pending_ = true;
+ animation_floor_time_ =
+ base::Time::Now() + base::TimeDelta::FromMilliseconds(10);
+ MessageLoop::current()->PostDelayedTask(FROM_HERE, NewRunnableMethod(
+ this, &RenderWidget::UpdateAnimationsIfNeeded), 10);
+ }
+}
+
void RenderWidget::didChangeCursor(const WebCursorInfo& cursor_info) {
// TODO(darin): Eliminate this temporary.
WebCursor cursor(cursor_info);

Powered by Google App Engine
This is Rietveld 408576698