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 673 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
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 optimized_instance->Paint(webkit_glue::ToWebCanvas(canvas), | 691 optimized_instance->Paint(webkit_glue::ToWebCanvas(canvas), |
692 optimized_copy_location, rect); | 692 optimized_copy_location, rect); |
693 } else { | 693 } else { |
694 base::TimeTicks paint_begin_ticks = base::TimeTicks::Now(); | |
694 // Normal painting case. | 695 // Normal painting case. |
695 webwidget_->paint(webkit_glue::ToWebCanvas(canvas), rect); | 696 webwidget_->paint(webkit_glue::ToWebCanvas(canvas), rect); |
697 base::TimeDelta paint_time = base::TimeTicks::Now() - paint_begin_ticks; | |
dtu
2012/07/31 01:35:00
Does base::TimeTicks::Now() have the needed resolu
| |
698 if (!is_accelerated_compositing_active_) | |
699 software_stats_.totalPaintTimeInSeconds += paint_time.InSecondsF(); | |
piman
2012/07/31 03:32:49
We should have this in the "optimized_instance" ca
dtu
2012/08/03 23:02:47
Done.
| |
696 | 700 |
697 // Flush to underlying bitmap. TODO(darin): is this needed? | 701 // Flush to underlying bitmap. TODO(darin): is this needed? |
698 skia::GetTopDevice(*canvas)->accessBitmap(false); | 702 skia::GetTopDevice(*canvas)->accessBitmap(false); |
699 } | 703 } |
700 | 704 |
701 PaintDebugBorder(rect, canvas); | 705 PaintDebugBorder(rect, canvas); |
702 canvas->restore(); | 706 canvas->restore(); |
703 } | 707 } |
704 | 708 |
705 void RenderWidget::PaintDebugBorder(const gfx::Rect& rect, | 709 void RenderWidget::PaintDebugBorder(const gfx::Rect& rect, |
(...skipping 176 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
882 60); | 886 60); |
883 } | 887 } |
884 | 888 |
885 // Calculate filtered time per frame: | 889 // Calculate filtered time per frame: |
886 float frame_time_elapsed = static_cast<float>(delay.InSecondsF()); | 890 float frame_time_elapsed = static_cast<float>(delay.InSecondsF()); |
887 filtered_time_per_frame_ = | 891 filtered_time_per_frame_ = |
888 0.9f * filtered_time_per_frame_ + 0.1f * frame_time_elapsed; | 892 0.9f * filtered_time_per_frame_ + 0.1f * frame_time_elapsed; |
889 } | 893 } |
890 last_do_deferred_update_time_ = frame_begin_ticks; | 894 last_do_deferred_update_time_ = frame_begin_ticks; |
891 | 895 |
896 if (!is_accelerated_compositing_active_) { | |
897 software_stats_.numAnimationFrames++; | |
898 software_stats_.numFramesSentToScreen++; | |
899 } | |
900 | |
892 // OK, save the pending update to a local since painting may cause more | 901 // OK, save the pending update to a local since painting may cause more |
893 // invalidation. Some WebCore rendering objects only layout when painted. | 902 // invalidation. Some WebCore rendering objects only layout when painted. |
894 PaintAggregator::PendingUpdate update; | 903 PaintAggregator::PendingUpdate update; |
895 paint_aggregator_.PopPendingUpdate(&update); | 904 paint_aggregator_.PopPendingUpdate(&update); |
896 | 905 |
897 gfx::Rect scroll_damage = update.GetScrollDamage(); | 906 gfx::Rect scroll_damage = update.GetScrollDamage(); |
898 gfx::Rect bounds = update.GetPaintBounds().Union(scroll_damage); | 907 gfx::Rect bounds = update.GetPaintBounds().Union(scroll_damage); |
899 | 908 |
900 // Notify derived classes that we're about to initiate a paint. | 909 // Notify derived classes that we're about to initiate a paint. |
901 WillInitiatePaint(); | 910 WillInitiatePaint(); |
(...skipping 860 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
1762 void RenderWidget::CleanupWindowInPluginMoves(gfx::PluginWindowHandle window) { | 1771 void RenderWidget::CleanupWindowInPluginMoves(gfx::PluginWindowHandle window) { |
1763 for (WebPluginGeometryVector::iterator i = plugin_window_moves_.begin(); | 1772 for (WebPluginGeometryVector::iterator i = plugin_window_moves_.begin(); |
1764 i != plugin_window_moves_.end(); ++i) { | 1773 i != plugin_window_moves_.end(); ++i) { |
1765 if (i->window == window) { | 1774 if (i->window == window) { |
1766 plugin_window_moves_.erase(i); | 1775 plugin_window_moves_.erase(i); |
1767 break; | 1776 break; |
1768 } | 1777 } |
1769 } | 1778 } |
1770 } | 1779 } |
1771 | 1780 |
1781 void RenderWidget::GetRenderingStats(WebKit::WebRenderingStats& stats) const { | |
1782 webwidget()->renderingStats(stats); | |
1783 stats.numAnimationFrames += software_stats_.numAnimationFrames; | |
1784 stats.numFramesSentToScreen += software_stats_.numFramesSentToScreen; | |
1785 stats.totalPaintTimeInSeconds += software_stats_.totalPaintTimeInSeconds; | |
1786 } | |
1787 | |
1772 void RenderWidget::BeginSmoothScroll(bool down, bool scroll_far) { | 1788 void RenderWidget::BeginSmoothScroll(bool down, bool scroll_far) { |
1773 Send(new ViewHostMsg_BeginSmoothScroll(routing_id_, down, scroll_far)); | 1789 Send(new ViewHostMsg_BeginSmoothScroll(routing_id_, down, scroll_far)); |
1774 } | 1790 } |
1775 | 1791 |
1776 bool RenderWidget::WillHandleMouseEvent(const WebKit::WebMouseEvent& event) { | 1792 bool RenderWidget::WillHandleMouseEvent(const WebKit::WebMouseEvent& event) { |
1777 return false; | 1793 return false; |
1778 } | 1794 } |
1779 | 1795 |
1780 bool RenderWidget::WebWidgetHandlesCompositorScheduling() const { | 1796 bool RenderWidget::WebWidgetHandlesCompositorScheduling() const { |
1781 return false; | 1797 return false; |
1782 } | 1798 } |
OLD | NEW |