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 558 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
569 return; | 569 return; |
570 | 570 |
571 // OK, save the pending update to a local since painting may cause more | 571 // OK, save the pending update to a local since painting may cause more |
572 // invalidation. Some WebCore rendering objects only layout when painted. | 572 // invalidation. Some WebCore rendering objects only layout when painted. |
573 PaintAggregator::PendingUpdate update; | 573 PaintAggregator::PendingUpdate update; |
574 paint_aggregator_.PopPendingUpdate(&update); | 574 paint_aggregator_.PopPendingUpdate(&update); |
575 | 575 |
576 gfx::Rect scroll_damage = update.GetScrollDamage(); | 576 gfx::Rect scroll_damage = update.GetScrollDamage(); |
577 gfx::Rect bounds = update.GetPaintBounds().Union(scroll_damage); | 577 gfx::Rect bounds = update.GetPaintBounds().Union(scroll_damage); |
578 | 578 |
| 579 // Compositing the page may disable accelerated compositing. |
| 580 bool accelerated_compositing_was_active = is_accelerated_compositing_active_; |
| 581 |
579 // A plugin may be able to do an optimized paint. First check this, in which | 582 // A plugin may be able to do an optimized paint. First check this, in which |
580 // case we can skip all of the bitmap generation and regular paint code. | 583 // case we can skip all of the bitmap generation and regular paint code. |
581 // This optimization allows PPAPI plugins that declare themselves on top of | 584 // This optimization allows PPAPI plugins that declare themselves on top of |
582 // the page (like a traditional windowed plugin) to be able to animate (think | 585 // the page (like a traditional windowed plugin) to be able to animate (think |
583 // movie playing) without repeatedly re-painting the page underneath, or | 586 // movie playing) without repeatedly re-painting the page underneath, or |
584 // copying the plugin backing store (since we can send the plugin's backing | 587 // copying the plugin backing store (since we can send the plugin's backing |
585 // store directly to the browser). | 588 // store directly to the browser). |
586 // | 589 // |
587 // This optimization only works when the entire invalid region is contained | 590 // This optimization only works when the entire invalid region is contained |
588 // within the plugin. There is a related optimization in PaintRect for the | 591 // within the plugin. There is a related optimization in PaintRect for the |
589 // case where there may be multiple invalid regions. | 592 // case where there may be multiple invalid regions. |
590 TransportDIB::Id dib_id = TransportDIB::Id(); | 593 TransportDIB::Id dib_id = TransportDIB::InvalidId(); |
591 TransportDIB* dib = NULL; | 594 TransportDIB* dib = NULL; |
592 std::vector<gfx::Rect> copy_rects; | 595 std::vector<gfx::Rect> copy_rects; |
593 gfx::Rect optimized_copy_rect, optimized_copy_location; | 596 gfx::Rect optimized_copy_rect, optimized_copy_location; |
594 if (update.scroll_rect.IsEmpty() && | 597 if (update.scroll_rect.IsEmpty() && |
595 !is_accelerated_compositing_active_ && | 598 !is_accelerated_compositing_active_ && |
596 GetBitmapForOptimizedPluginPaint(bounds, &dib, &optimized_copy_location, | 599 GetBitmapForOptimizedPluginPaint(bounds, &dib, &optimized_copy_location, |
597 &optimized_copy_rect)) { | 600 &optimized_copy_rect)) { |
598 // Only update the part of the plugin that actually changed. | 601 // Only update the part of the plugin that actually changed. |
599 optimized_copy_rect = optimized_copy_rect.Intersect(bounds); | 602 optimized_copy_rect = optimized_copy_rect.Intersect(bounds); |
600 bounds = optimized_copy_location; | 603 bounds = optimized_copy_location; |
(...skipping 31 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
632 // Begin painting. | 635 // Begin painting. |
633 webwidget_->composite(false); | 636 webwidget_->composite(false); |
634 } | 637 } |
635 | 638 |
636 // sending an ack to browser process that the paint is complete... | 639 // sending an ack to browser process that the paint is complete... |
637 ViewHostMsg_UpdateRect_Params params; | 640 ViewHostMsg_UpdateRect_Params params; |
638 params.bitmap = dib_id; | 641 params.bitmap = dib_id; |
639 params.bitmap_rect = bounds; | 642 params.bitmap_rect = bounds; |
640 params.dx = update.scroll_delta.x(); | 643 params.dx = update.scroll_delta.x(); |
641 params.dy = update.scroll_delta.y(); | 644 params.dy = update.scroll_delta.y(); |
642 if (is_accelerated_compositing_active_) { | 645 if (accelerated_compositing_was_active) { |
643 // If painting is done via the gpu process then we clear out all damage | 646 // If painting is done via the gpu process then we clear out all damage |
644 // rects to save the browser process from doing unecessary work. | 647 // rects to save the browser process from doing unecessary work. |
645 params.scroll_rect = gfx::Rect(); | 648 params.scroll_rect = gfx::Rect(); |
646 params.copy_rects.clear(); | 649 params.copy_rects.clear(); |
647 } else { | 650 } else { |
648 params.scroll_rect = update.scroll_rect; | 651 params.scroll_rect = update.scroll_rect; |
649 params.copy_rects.swap(copy_rects); // TODO(darin): clip to bounds? | 652 params.copy_rects.swap(copy_rects); // TODO(darin): clip to bounds? |
650 } | 653 } |
651 params.view_size = size_; | 654 params.view_size = size_; |
652 params.resizer_rect = resizer_rect_; | 655 params.resizer_rect = resizer_rect_; |
(...skipping 449 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1102 | 1105 |
1103 void RenderWidget::CleanupWindowInPluginMoves(gfx::PluginWindowHandle window) { | 1106 void RenderWidget::CleanupWindowInPluginMoves(gfx::PluginWindowHandle window) { |
1104 for (WebPluginGeometryVector::iterator i = plugin_window_moves_.begin(); | 1107 for (WebPluginGeometryVector::iterator i = plugin_window_moves_.begin(); |
1105 i != plugin_window_moves_.end(); ++i) { | 1108 i != plugin_window_moves_.end(); ++i) { |
1106 if (i->window == window) { | 1109 if (i->window == window) { |
1107 plugin_window_moves_.erase(i); | 1110 plugin_window_moves_.erase(i); |
1108 break; | 1111 break; |
1109 } | 1112 } |
1110 } | 1113 } |
1111 } | 1114 } |
OLD | NEW |