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 58 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
69 is_hidden_(false), | 69 is_hidden_(false), |
70 needs_repainting_on_restore_(false), | 70 needs_repainting_on_restore_(false), |
71 has_focus_(false), | 71 has_focus_(false), |
72 handling_input_event_(false), | 72 handling_input_event_(false), |
73 closing_(false), | 73 closing_(false), |
74 input_method_is_active_(false), | 74 input_method_is_active_(false), |
75 text_input_type_(WebKit::WebTextInputTypeNone), | 75 text_input_type_(WebKit::WebTextInputTypeNone), |
76 popup_type_(popup_type), | 76 popup_type_(popup_type), |
77 pending_window_rect_count_(0), | 77 pending_window_rect_count_(0), |
78 suppress_next_char_events_(false), | 78 suppress_next_char_events_(false), |
79 is_accelerated_compositing_active_(false) { | 79 is_accelerated_compositing_active_(false), |
80 animation_update_pending_(false) { | |
80 RenderProcess::current()->AddRefProcess(); | 81 RenderProcess::current()->AddRefProcess(); |
81 DCHECK(render_thread_); | 82 DCHECK(render_thread_); |
82 } | 83 } |
83 | 84 |
84 RenderWidget::~RenderWidget() { | 85 RenderWidget::~RenderWidget() { |
85 DCHECK(!webwidget_) << "Leaking our WebWidget!"; | 86 DCHECK(!webwidget_) << "Leaking our WebWidget!"; |
86 if (current_paint_buf_) { | 87 if (current_paint_buf_) { |
87 RenderProcess::current()->ReleaseTransportDIB(current_paint_buf_); | 88 RenderProcess::current()->ReleaseTransportDIB(current_paint_buf_); |
88 current_paint_buf_ = NULL; | 89 current_paint_buf_ = NULL; |
89 } | 90 } |
(...skipping 389 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
479 canvas->drawIRect(irect, paint); | 480 canvas->drawIRect(irect, paint); |
480 } | 481 } |
481 | 482 |
482 void RenderWidget::CallDoDeferredUpdate() { | 483 void RenderWidget::CallDoDeferredUpdate() { |
483 DoDeferredUpdate(); | 484 DoDeferredUpdate(); |
484 | 485 |
485 if (pending_input_event_ack_.get()) | 486 if (pending_input_event_ack_.get()) |
486 Send(pending_input_event_ack_.release()); | 487 Send(pending_input_event_ack_.release()); |
487 } | 488 } |
488 | 489 |
490 void RenderWidget::UpdateAnimationsIfNeeded() { | |
491 if (!is_hidden() && animation_update_pending_ && base::Time::Now() > animation _floor_time_) { | |
darin (slow to review)
2011/01/11 22:02:30
nit: wrap lines at 80 chars
| |
492 animation_update_pending_ = false; | |
493 webwidget_->animate(); | |
494 } | |
495 } | |
496 | |
489 void RenderWidget::DoDeferredUpdate() { | 497 void RenderWidget::DoDeferredUpdate() { |
490 if (!webwidget_ || !paint_aggregator_.HasPendingUpdate() || | 498 if (!webwidget_ || update_reply_pending()) |
491 update_reply_pending()) | |
492 return; | 499 return; |
493 | 500 |
494 // Suppress updating when we are hidden. | 501 // Suppress updating when we are hidden. |
495 if (is_hidden_ || size_.IsEmpty()) { | 502 if (is_hidden_ || size_.IsEmpty()) { |
496 paint_aggregator_.ClearPendingUpdate(); | 503 paint_aggregator_.ClearPendingUpdate(); |
497 needs_repainting_on_restore_ = true; | 504 needs_repainting_on_restore_ = true; |
498 return; | 505 return; |
499 } | 506 } |
500 | 507 |
508 if (base::Time::Now() > animation_floor_time_) | |
509 UpdateAnimationsIfNeeded(); | |
darin (slow to review)
2011/01/11 22:02:30
nit: indent by 2
| |
510 | |
501 // Layout may generate more invalidation. It may also enable the | 511 // Layout may generate more invalidation. It may also enable the |
502 // GPU acceleration, so make sure to run layout before we send the | 512 // GPU acceleration, so make sure to run layout before we send the |
503 // GpuRenderingActivated message. | 513 // GpuRenderingActivated message. |
504 webwidget_->layout(); | 514 webwidget_->layout(); |
505 | 515 |
516 // Suppress painting if nothing is dirty. This has to be done after updating | |
517 // animations running layout as these may generate further invalidations. | |
518 if (!paint_aggregator_.HasPendingUpdate()) | |
519 return; | |
520 | |
506 // OK, save the pending update to a local since painting may cause more | 521 // OK, save the pending update to a local since painting may cause more |
507 // invalidation. Some WebCore rendering objects only layout when painted. | 522 // invalidation. Some WebCore rendering objects only layout when painted. |
508 PaintAggregator::PendingUpdate update; | 523 PaintAggregator::PendingUpdate update; |
509 paint_aggregator_.PopPendingUpdate(&update); | 524 paint_aggregator_.PopPendingUpdate(&update); |
510 | 525 |
511 gfx::Rect scroll_damage = update.GetScrollDamage(); | 526 gfx::Rect scroll_damage = update.GetScrollDamage(); |
512 gfx::Rect bounds = update.GetPaintBounds().Union(scroll_damage); | 527 gfx::Rect bounds = update.GetPaintBounds().Union(scroll_damage); |
513 | 528 |
514 // A plugin may be able to do an optimized paint. First check this, in which | 529 // A plugin may be able to do an optimized paint. First check this, in which |
515 // case we can skip all of the bitmap generation and regular paint code. | 530 // case we can skip all of the bitmap generation and regular paint code. |
(...skipping 158 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
674 void RenderWidget::scheduleComposite() { | 689 void RenderWidget::scheduleComposite() { |
675 // TODO(nduca): replace with something a little less hacky. The reason this | 690 // TODO(nduca): replace with something a little less hacky. The reason this |
676 // hack is still used is because the Invalidate-DoDeferredUpdate loop | 691 // hack is still used is because the Invalidate-DoDeferredUpdate loop |
677 // contains a lot of host-renderer synchronization logic that is still | 692 // contains a lot of host-renderer synchronization logic that is still |
678 // important for the accelerated compositing case. The option of simply | 693 // important for the accelerated compositing case. The option of simply |
679 // duplicating all that code is less desirable than "faking out" the | 694 // duplicating all that code is less desirable than "faking out" the |
680 // invalidation path using a magical damage rect. | 695 // invalidation path using a magical damage rect. |
681 didInvalidateRect(WebRect(0, 0, 1, 1)); | 696 didInvalidateRect(WebRect(0, 0, 1, 1)); |
682 } | 697 } |
683 | 698 |
699 void RenderWidget::scheduleAnimation() { | |
700 if (!animation_update_pending_) { | |
701 animation_update_pending_ = true; | |
702 animation_floor_time_ = base::Time::Now() + base::TimeDelta::FromMillise conds(10); | |
darin (slow to review)
2011/01/11 22:02:30
nit: indentation and line length limit
| |
703 MessageLoop::current()->PostDelayedTask(FROM_HERE, NewRunnableMethod( | |
704 this, &RenderWidget::UpdateAnimationsIfNeeded), 10); | |
705 } | |
706 } | |
707 | |
684 void RenderWidget::didChangeCursor(const WebCursorInfo& cursor_info) { | 708 void RenderWidget::didChangeCursor(const WebCursorInfo& cursor_info) { |
685 // TODO(darin): Eliminate this temporary. | 709 // TODO(darin): Eliminate this temporary. |
686 WebCursor cursor(cursor_info); | 710 WebCursor cursor(cursor_info); |
687 | 711 |
688 // Only send a SetCursor message if we need to make a change. | 712 // Only send a SetCursor message if we need to make a change. |
689 if (!current_cursor_.IsEqual(cursor)) { | 713 if (!current_cursor_.IsEqual(cursor)) { |
690 current_cursor_ = cursor; | 714 current_cursor_ = cursor; |
691 Send(new ViewHostMsg_SetCursor(routing_id_, cursor)); | 715 Send(new ViewHostMsg_SetCursor(routing_id_, cursor)); |
692 } | 716 } |
693 } | 717 } |
(...skipping 327 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
1021 | 1045 |
1022 void RenderWidget::CleanupWindowInPluginMoves(gfx::PluginWindowHandle window) { | 1046 void RenderWidget::CleanupWindowInPluginMoves(gfx::PluginWindowHandle window) { |
1023 for (WebPluginGeometryVector::iterator i = plugin_window_moves_.begin(); | 1047 for (WebPluginGeometryVector::iterator i = plugin_window_moves_.begin(); |
1024 i != plugin_window_moves_.end(); ++i) { | 1048 i != plugin_window_moves_.end(); ++i) { |
1025 if (i->window == window) { | 1049 if (i->window == window) { |
1026 plugin_window_moves_.erase(i); | 1050 plugin_window_moves_.erase(i); |
1027 break; | 1051 break; |
1028 } | 1052 } |
1029 } | 1053 } |
1030 } | 1054 } |
OLD | NEW |