OLD | NEW |
---|---|
1 // Copyright (c) 2010 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2010 The Chromium Authors. All rights reserved. |
2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
4 | 4 |
5 #include "chrome/renderer/render_widget.h" | 5 #include "chrome/renderer/render_widget.h" |
6 | 6 |
7 #include "app/surface/transport_dib.h" | 7 #include "app/surface/transport_dib.h" |
8 #include "base/command_line.h" | 8 #include "base/command_line.h" |
9 #include "base/logging.h" | 9 #include "base/logging.h" |
10 #include "base/message_loop.h" | 10 #include "base/message_loop.h" |
(...skipping 465 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
476 paint.setColor(colors[color_selector++ % arraysize(colors)]); | 476 paint.setColor(colors[color_selector++ % arraysize(colors)]); |
477 paint.setStrokeWidth(1); | 477 paint.setStrokeWidth(1); |
478 | 478 |
479 SkIRect irect; | 479 SkIRect irect; |
480 irect.set(rect.x(), rect.y(), rect.right() - 1, rect.bottom() - 1); | 480 irect.set(rect.x(), rect.y(), rect.right() - 1, rect.bottom() - 1); |
481 canvas->drawIRect(irect, paint); | 481 canvas->drawIRect(irect, paint); |
482 } | 482 } |
483 | 483 |
484 void RenderWidget::AnimationCallback() { | 484 void RenderWidget::AnimationCallback() { |
485 animation_task_posted_ = false; | 485 animation_task_posted_ = false; |
486 UMA_HISTOGRAM_CUSTOM_COUNTS("Renderer4.AnimationDelayTime", 0, 0, 16, 17); | 486 if (animation_update_pending_) { |
jar (doing other things)
2011/02/18 07:31:29
nit: Suggest an early return, rather than indentin
| |
487 CallDoDeferredUpdate(); | 487 if (!animation_floor_time_.is_null()) { |
488 // Record when we fired (according to base::Time::Now()) relative to when | |
489 // we posted the task to quantify how much the base::Time/base::TimeTicks | |
490 // skew is affecting animations. | |
491 base::TimeDelta animation_callback_delay = base::Time::Now() - | |
492 (animation_floor_time_ - base::TimeDelta::FromMilliseconds(16)); | |
493 UMA_HISTOGRAM_CUSTOM_TIMES("Renderer4.AnimationCallbackDelayTime", | |
494 animation_callback_delay, | |
495 base::TimeDelta::FromMilliseconds(0), | |
496 base::TimeDelta::FromMilliseconds(30), | |
497 25); | |
498 } | |
499 CallDoDeferredUpdate(); | |
500 } | |
488 } | 501 } |
489 | 502 |
490 void RenderWidget::AnimateIfNeeded() { | 503 void RenderWidget::AnimateIfNeeded() { |
491 if (animation_update_pending_) { | 504 if (animation_update_pending_) { |
jar (doing other things)
2011/02/18 07:31:29
nit: This would be much easier to read if you used
| |
492 base::Time now = base::Time::Now(); | 505 base::Time now = base::Time::Now(); |
493 if (now >= animation_floor_time_) { | 506 if (now >= animation_floor_time_) { |
494 animation_floor_time_ = now + base::TimeDelta::FromMilliseconds(16); | 507 animation_floor_time_ = now + base::TimeDelta::FromMilliseconds(16); |
jar (doing other things)
2011/02/18 07:31:29
FYI: It is interesting that this will "drift" late
| |
495 // Set a timer to call us back after 16ms (targetting 60FPS) before | 508 // Set a timer to call us back after 16ms (targetting 60FPS) before |
496 // running animation callbacks so that if a callback requests another | 509 // running animation callbacks so that if a callback requests another |
497 // we'll be sure to run it at the proper time. | 510 // we'll be sure to run it at the proper time. |
498 MessageLoop::current()->PostDelayedTask(FROM_HERE, NewRunnableMethod( | 511 MessageLoop::current()->PostDelayedTask(FROM_HERE, NewRunnableMethod( |
499 this, &RenderWidget::AnimationCallback), 16); | 512 this, &RenderWidget::AnimationCallback), 16); |
500 animation_task_posted_ = true; | 513 animation_task_posted_ = true; |
501 animation_update_pending_ = false; | 514 animation_update_pending_ = false; |
502 webwidget_->animate(); | 515 webwidget_->animate(); |
jar (doing other things)
2011/02/18 07:31:29
nit: Here again, a return statement would mean tha
| |
503 } else if (!animation_task_posted_) { | 516 } else if (!animation_task_posted_) { |
jar (doing other things)
2011/02/18 07:31:29
nit: Again, I'd find it more readable to see:
if (
| |
504 // This code uses base::Time::Now() to calculate the floor and next fire | 517 // This code uses base::Time::Now() to calculate the floor and next fire |
505 // time because javascript's Date object uses base::Time::Now(). The | 518 // time because javascript's Date object uses base::Time::Now(). The |
506 // message loop uses base::TimeTicks, which on windows can have a | 519 // message loop uses base::TimeTicks, which on windows can have a |
507 // different granularity than base::Time. | 520 // different granularity than base::Time. |
508 // The upshot of all this is that this function might be called before | 521 // The upshot of all this is that this function might be called before |
509 // base::Time::Now() has advanced past the animation_floor_time_. To | 522 // base::Time::Now() has advanced past the animation_floor_time_. To |
510 // avoid exposing this delay to javascript, we keep posting delayed | 523 // avoid exposing this delay to javascript, we keep posting delayed |
511 // tasks until base::Time::Now() has advanced far enough. | 524 // tasks until base::Time::Now() has advanced far enough. |
512 int64 delay = (animation_floor_time_ - now).InMillisecondsRoundedUp(); | 525 int64 delay = (animation_floor_time_ - now).InMillisecondsRoundedUp(); |
jar (doing other things)
2011/02/18 07:31:29
Comment: It is interesting that delay could be as
| |
513 UMA_HISTOGRAM_CUSTOM_COUNTS("Renderer4.AnimationDelayTime", | |
514 static_cast<int>(delay), 0, 16, 17); | |
515 animation_task_posted_ = true; | 526 animation_task_posted_ = true; |
516 MessageLoop::current()->PostDelayedTask(FROM_HERE, NewRunnableMethod( | 527 MessageLoop::current()->PostDelayedTask(FROM_HERE, |
517 this, &RenderWidget::AnimationCallback), delay); | 528 NewRunnableMethod(this, &RenderWidget::AnimationCallback), delay); |
518 } | 529 } |
519 } | 530 } |
520 } | 531 } |
521 | 532 |
522 void RenderWidget::CallDoDeferredUpdate() { | 533 void RenderWidget::CallDoDeferredUpdate() { |
523 DoDeferredUpdate(); | 534 DoDeferredUpdate(); |
524 | 535 |
525 if (pending_input_event_ack_.get()) | 536 if (pending_input_event_ack_.get()) |
526 Send(pending_input_event_ack_.release()); | 537 Send(pending_input_event_ack_.release()); |
527 } | 538 } |
(...skipping 555 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
1083 | 1094 |
1084 void RenderWidget::CleanupWindowInPluginMoves(gfx::PluginWindowHandle window) { | 1095 void RenderWidget::CleanupWindowInPluginMoves(gfx::PluginWindowHandle window) { |
1085 for (WebPluginGeometryVector::iterator i = plugin_window_moves_.begin(); | 1096 for (WebPluginGeometryVector::iterator i = plugin_window_moves_.begin(); |
1086 i != plugin_window_moves_.end(); ++i) { | 1097 i != plugin_window_moves_.end(); ++i) { |
1087 if (i->window == window) { | 1098 if (i->window == window) { |
1088 plugin_window_moves_.erase(i); | 1099 plugin_window_moves_.erase(i); |
1089 break; | 1100 break; |
1090 } | 1101 } |
1091 } | 1102 } |
1092 } | 1103 } |
OLD | NEW |