OLD | NEW |
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 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 "content/renderer/render_widget.h" | 5 #include "content/renderer/render_widget.h" |
6 | 6 |
7 #include "base/bind.h" | 7 #include "base/bind.h" |
8 #include "base/command_line.h" | 8 #include "base/command_line.h" |
9 #include "base/debug/trace_event.h" | 9 #include "base/debug/trace_event.h" |
10 #include "base/logging.h" | 10 #include "base/logging.h" |
(...skipping 670 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
681 // GetBitmapForOptimizedPluginPaint in DoDeferredUpdate handles the | 681 // GetBitmapForOptimizedPluginPaint in DoDeferredUpdate handles the |
682 // painting, because that avoids copying the plugin image to a different | 682 // painting, because that avoids copying the plugin image to a different |
683 // paint rect. Unfortunately, if anything on the page is animating other | 683 // paint rect. Unfortunately, if anything on the page is animating other |
684 // than the movie, it break this optimization since the union of the | 684 // than the movie, it break this optimization since the union of the |
685 // invalid regions will be larger than the plugin. | 685 // invalid regions will be larger than the plugin. |
686 // | 686 // |
687 // This code optimizes that case, where we can still avoid painting in | 687 // This code optimizes that case, where we can still avoid painting in |
688 // WebKit and filling the background (which can be slow) and just painting | 688 // WebKit and filling the background (which can be slow) and just painting |
689 // the plugin. Unlike the DoDeferredUpdate case, an extra copy is still | 689 // the plugin. Unlike the DoDeferredUpdate case, an extra copy is still |
690 // required. | 690 // required. |
| 691 base::TimeTicks paint_begin_ticks = base::TimeTicks::Now(); |
691 optimized_instance->Paint(webkit_glue::ToWebCanvas(canvas), | 692 optimized_instance->Paint(webkit_glue::ToWebCanvas(canvas), |
692 optimized_copy_location, rect); | 693 optimized_copy_location, rect); |
| 694 base::TimeDelta paint_time = base::TimeTicks::Now() - paint_begin_ticks; |
| 695 if (!is_accelerated_compositing_active_) |
| 696 software_stats_.totalPaintTimeInSeconds += paint_time.InSecondsF(); |
693 } else { | 697 } else { |
694 // Normal painting case. | 698 // Normal painting case. |
| 699 base::TimeTicks paint_begin_ticks = base::TimeTicks::Now(); |
695 webwidget_->paint(webkit_glue::ToWebCanvas(canvas), rect); | 700 webwidget_->paint(webkit_glue::ToWebCanvas(canvas), rect); |
| 701 base::TimeDelta paint_time = base::TimeTicks::Now() - paint_begin_ticks; |
| 702 if (!is_accelerated_compositing_active_) |
| 703 software_stats_.totalPaintTimeInSeconds += paint_time.InSecondsF(); |
696 | 704 |
697 // Flush to underlying bitmap. TODO(darin): is this needed? | 705 // Flush to underlying bitmap. TODO(darin): is this needed? |
698 skia::GetTopDevice(*canvas)->accessBitmap(false); | 706 skia::GetTopDevice(*canvas)->accessBitmap(false); |
699 } | 707 } |
700 | 708 |
701 PaintDebugBorder(rect, canvas); | 709 PaintDebugBorder(rect, canvas); |
702 canvas->restore(); | 710 canvas->restore(); |
703 } | 711 } |
704 | 712 |
705 void RenderWidget::PaintDebugBorder(const gfx::Rect& rect, | 713 void RenderWidget::PaintDebugBorder(const gfx::Rect& rect, |
(...skipping 176 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
882 60); | 890 60); |
883 } | 891 } |
884 | 892 |
885 // Calculate filtered time per frame: | 893 // Calculate filtered time per frame: |
886 float frame_time_elapsed = static_cast<float>(delay.InSecondsF()); | 894 float frame_time_elapsed = static_cast<float>(delay.InSecondsF()); |
887 filtered_time_per_frame_ = | 895 filtered_time_per_frame_ = |
888 0.9f * filtered_time_per_frame_ + 0.1f * frame_time_elapsed; | 896 0.9f * filtered_time_per_frame_ + 0.1f * frame_time_elapsed; |
889 } | 897 } |
890 last_do_deferred_update_time_ = frame_begin_ticks; | 898 last_do_deferred_update_time_ = frame_begin_ticks; |
891 | 899 |
| 900 if (!is_accelerated_compositing_active_) { |
| 901 software_stats_.numAnimationFrames++; |
| 902 software_stats_.numFramesSentToScreen++; |
| 903 } |
| 904 |
892 // OK, save the pending update to a local since painting may cause more | 905 // OK, save the pending update to a local since painting may cause more |
893 // invalidation. Some WebCore rendering objects only layout when painted. | 906 // invalidation. Some WebCore rendering objects only layout when painted. |
894 PaintAggregator::PendingUpdate update; | 907 PaintAggregator::PendingUpdate update; |
895 paint_aggregator_.PopPendingUpdate(&update); | 908 paint_aggregator_.PopPendingUpdate(&update); |
896 | 909 |
897 gfx::Rect scroll_damage = update.GetScrollDamage(); | 910 gfx::Rect scroll_damage = update.GetScrollDamage(); |
898 gfx::Rect bounds = update.GetPaintBounds().Union(scroll_damage); | 911 gfx::Rect bounds = update.GetPaintBounds().Union(scroll_damage); |
899 | 912 |
900 // Notify derived classes that we're about to initiate a paint. | 913 // Notify derived classes that we're about to initiate a paint. |
901 WillInitiatePaint(); | 914 WillInitiatePaint(); |
(...skipping 860 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1762 void RenderWidget::CleanupWindowInPluginMoves(gfx::PluginWindowHandle window) { | 1775 void RenderWidget::CleanupWindowInPluginMoves(gfx::PluginWindowHandle window) { |
1763 for (WebPluginGeometryVector::iterator i = plugin_window_moves_.begin(); | 1776 for (WebPluginGeometryVector::iterator i = plugin_window_moves_.begin(); |
1764 i != plugin_window_moves_.end(); ++i) { | 1777 i != plugin_window_moves_.end(); ++i) { |
1765 if (i->window == window) { | 1778 if (i->window == window) { |
1766 plugin_window_moves_.erase(i); | 1779 plugin_window_moves_.erase(i); |
1767 break; | 1780 break; |
1768 } | 1781 } |
1769 } | 1782 } |
1770 } | 1783 } |
1771 | 1784 |
| 1785 void RenderWidget::GetRenderingStats(WebKit::WebRenderingStats& stats) const { |
| 1786 webwidget()->renderingStats(stats); |
| 1787 stats.numAnimationFrames += software_stats_.numAnimationFrames; |
| 1788 stats.numFramesSentToScreen += software_stats_.numFramesSentToScreen; |
| 1789 stats.totalPaintTimeInSeconds += software_stats_.totalPaintTimeInSeconds; |
| 1790 } |
| 1791 |
1772 void RenderWidget::BeginSmoothScroll(bool down, bool scroll_far) { | 1792 void RenderWidget::BeginSmoothScroll(bool down, bool scroll_far) { |
1773 Send(new ViewHostMsg_BeginSmoothScroll(routing_id_, down, scroll_far)); | 1793 Send(new ViewHostMsg_BeginSmoothScroll(routing_id_, down, scroll_far)); |
1774 } | 1794 } |
1775 | 1795 |
1776 bool RenderWidget::WillHandleMouseEvent(const WebKit::WebMouseEvent& event) { | 1796 bool RenderWidget::WillHandleMouseEvent(const WebKit::WebMouseEvent& event) { |
1777 return false; | 1797 return false; |
1778 } | 1798 } |
1779 | 1799 |
1780 bool RenderWidget::WebWidgetHandlesCompositorScheduling() const { | 1800 bool RenderWidget::WebWidgetHandlesCompositorScheduling() const { |
1781 return false; | 1801 return false; |
1782 } | 1802 } |
OLD | NEW |