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

Side by Side Diff: chrome/renderer/render_widget.cc

Issue 6007006: Support for requestAnimationFrame (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: 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 unified diff | Download patch | Annotate | Revision Log
« no previous file with comments | « chrome/renderer/render_widget.h ('k') | chrome/renderer/render_widget_fullscreen_pepper.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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 469 matching lines...) Expand 10 before | Expand all | Expand 10 after
480 } 480 }
481 481
482 void RenderWidget::CallDoDeferredUpdate() { 482 void RenderWidget::CallDoDeferredUpdate() {
483 DoDeferredUpdate(); 483 DoDeferredUpdate();
484 484
485 if (pending_input_event_ack_.get()) 485 if (pending_input_event_ack_.get())
486 Send(pending_input_event_ack_.release()); 486 Send(pending_input_event_ack_.release());
487 } 487 }
488 488
489 void RenderWidget::DoDeferredUpdate() { 489 void RenderWidget::DoDeferredUpdate() {
490 if (!webwidget_ || !paint_aggregator_.HasPendingUpdate() || 490 if (!webwidget_ || update_reply_pending())
491 update_reply_pending())
492 return; 491 return;
493 492
494 // Suppress updating when we are hidden. 493 // Suppress updating when we are hidden.
495 if (is_hidden_ || size_.IsEmpty()) { 494 if (is_hidden_ || size_.IsEmpty()) {
496 paint_aggregator_.ClearPendingUpdate(); 495 paint_aggregator_.ClearPendingUpdate();
497 needs_repainting_on_restore_ = true; 496 needs_repainting_on_restore_ = true;
498 return; 497 return;
499 } 498 }
500 499
500 // Request animation updates.
501 // TODO(jamesr): Do we wanna throttle?
502 webwidget_->animate();
503
501 // Layout may generate more invalidation. It may also enable the 504 // Layout may generate more invalidation. It may also enable the
502 // GPU acceleration, so make sure to run layout before we send the 505 // GPU acceleration, so make sure to run layout before we send the
503 // GpuRenderingActivated message. 506 // GpuRenderingActivated message.
504 webwidget_->layout(); 507 webwidget_->layout();
505 508
509 // Suppress painting if nothing is dirty. This has to be done after updating
510 // animations running layout as these may generate further invalidations.
511 if (!paint_aggregator_.HasPendingUpdate())
512 return;
513
506 // OK, save the pending update to a local since painting may cause more 514 // OK, save the pending update to a local since painting may cause more
507 // invalidation. Some WebCore rendering objects only layout when painted. 515 // invalidation. Some WebCore rendering objects only layout when painted.
508 PaintAggregator::PendingUpdate update; 516 PaintAggregator::PendingUpdate update;
509 paint_aggregator_.PopPendingUpdate(&update); 517 paint_aggregator_.PopPendingUpdate(&update);
510 518
511 gfx::Rect scroll_damage = update.GetScrollDamage(); 519 gfx::Rect scroll_damage = update.GetScrollDamage();
512 gfx::Rect bounds = update.GetPaintBounds().Union(scroll_damage); 520 gfx::Rect bounds = update.GetPaintBounds().Union(scroll_damage);
513 521
514 // A plugin may be able to do an optimized paint. First check this, in which 522 // 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. 523 // 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
674 void RenderWidget::scheduleComposite() { 682 void RenderWidget::scheduleComposite() {
675 // TODO(nduca): replace with something a little less hacky. The reason this 683 // TODO(nduca): replace with something a little less hacky. The reason this
676 // hack is still used is because the Invalidate-DoDeferredUpdate loop 684 // hack is still used is because the Invalidate-DoDeferredUpdate loop
677 // contains a lot of host-renderer synchronization logic that is still 685 // contains a lot of host-renderer synchronization logic that is still
678 // important for the accelerated compositing case. The option of simply 686 // important for the accelerated compositing case. The option of simply
679 // duplicating all that code is less desirable than "faking out" the 687 // duplicating all that code is less desirable than "faking out" the
680 // invalidation path using a magical damage rect. 688 // invalidation path using a magical damage rect.
681 didInvalidateRect(WebRect(0, 0, 1, 1)); 689 didInvalidateRect(WebRect(0, 0, 1, 1));
682 } 690 }
683 691
692 void RenderWidget::scheduleAnimation() {
693 // TODO(jamesr): Come up with a more intelligent scheduling algorithm.
694 MessageLoop::current()->PostTask(FROM_HERE, NewRunnableMethod(
695 this, &RenderWidget::scheduleComposite));
696 }
697
684 void RenderWidget::didChangeCursor(const WebCursorInfo& cursor_info) { 698 void RenderWidget::didChangeCursor(const WebCursorInfo& cursor_info) {
685 // TODO(darin): Eliminate this temporary. 699 // TODO(darin): Eliminate this temporary.
686 WebCursor cursor(cursor_info); 700 WebCursor cursor(cursor_info);
687 701
688 // Only send a SetCursor message if we need to make a change. 702 // Only send a SetCursor message if we need to make a change.
689 if (!current_cursor_.IsEqual(cursor)) { 703 if (!current_cursor_.IsEqual(cursor)) {
690 current_cursor_ = cursor; 704 current_cursor_ = cursor;
691 Send(new ViewHostMsg_SetCursor(routing_id_, cursor)); 705 Send(new ViewHostMsg_SetCursor(routing_id_, cursor));
692 } 706 }
693 } 707 }
(...skipping 327 matching lines...) Expand 10 before | Expand all | Expand 10 after
1021 1035
1022 void RenderWidget::CleanupWindowInPluginMoves(gfx::PluginWindowHandle window) { 1036 void RenderWidget::CleanupWindowInPluginMoves(gfx::PluginWindowHandle window) {
1023 for (WebPluginGeometryVector::iterator i = plugin_window_moves_.begin(); 1037 for (WebPluginGeometryVector::iterator i = plugin_window_moves_.begin();
1024 i != plugin_window_moves_.end(); ++i) { 1038 i != plugin_window_moves_.end(); ++i) {
1025 if (i->window == window) { 1039 if (i->window == window) {
1026 plugin_window_moves_.erase(i); 1040 plugin_window_moves_.erase(i);
1027 break; 1041 break;
1028 } 1042 }
1029 } 1043 }
1030 } 1044 }
OLDNEW
« no previous file with comments | « chrome/renderer/render_widget.h ('k') | chrome/renderer/render_widget_fullscreen_pepper.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698