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

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

Issue 10982078: Adding hooks for gathering total pixels painted and rasterized stats. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 8 years, 1 month 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
OLDNEW
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 648 matching lines...) Expand 10 before | Expand all | Expand 10 after
659 // which case we do not want to unfocus ourself. 659 // which case we do not want to unfocus ourself.
660 if (!has_focus_ && webwidget_) 660 if (!has_focus_ && webwidget_)
661 webwidget_->setFocus(false); 661 webwidget_->setFocus(false);
662 } 662 }
663 663
664 void RenderWidget::PaintRect(const gfx::Rect& rect, 664 void RenderWidget::PaintRect(const gfx::Rect& rect,
665 const gfx::Point& canvas_origin, 665 const gfx::Point& canvas_origin,
666 skia::PlatformCanvas* canvas) { 666 skia::PlatformCanvas* canvas) {
667 TRACE_EVENT2("renderer", "PaintRect", 667 TRACE_EVENT2("renderer", "PaintRect",
668 "width", rect.width(), "height", rect.height()); 668 "width", rect.width(), "height", rect.height());
669
nduca 2012/11/07 04:24:42 I wouldn't bother with static bool. Just check it
hartmanng 2012/11/07 14:45:02 Done.
670 static bool kEnableGpuBenchmarking =
671 CommandLine::ForCurrentProcess()->HasSwitch(
672 switches::kEnableGpuBenchmarking);
673
674 base::TimeTicks rasterize_begin_ticks;
675 if (kEnableGpuBenchmarking)
676 rasterize_begin_ticks = base::TimeTicks::HighResNow();
669 canvas->save(); 677 canvas->save();
670 678
671 // Bring the canvas into the coordinate system of the paint rect. 679 // Bring the canvas into the coordinate system of the paint rect.
672 canvas->translate(static_cast<SkScalar>(-canvas_origin.x()), 680 canvas->translate(static_cast<SkScalar>(-canvas_origin.x()),
673 static_cast<SkScalar>(-canvas_origin.y())); 681 static_cast<SkScalar>(-canvas_origin.y()));
674 682
675 // If there is a custom background, tile it. 683 // If there is a custom background, tile it.
676 if (!background_.empty()) { 684 if (!background_.empty()) {
677 SkPaint paint; 685 SkPaint paint;
678 SkShader* shader = SkShader::CreateBitmapShader(background_, 686 SkShader* shader = SkShader::CreateBitmapShader(background_,
(...skipping 35 matching lines...) Expand 10 before | Expand all | Expand 10 after
714 // GetBitmapForOptimizedPluginPaint in DoDeferredUpdate handles the 722 // GetBitmapForOptimizedPluginPaint in DoDeferredUpdate handles the
715 // painting, because that avoids copying the plugin image to a different 723 // painting, because that avoids copying the plugin image to a different
716 // paint rect. Unfortunately, if anything on the page is animating other 724 // paint rect. Unfortunately, if anything on the page is animating other
717 // than the movie, it break this optimization since the union of the 725 // than the movie, it break this optimization since the union of the
718 // invalid regions will be larger than the plugin. 726 // invalid regions will be larger than the plugin.
719 // 727 //
720 // This code optimizes that case, where we can still avoid painting in 728 // This code optimizes that case, where we can still avoid painting in
721 // WebKit and filling the background (which can be slow) and just painting 729 // WebKit and filling the background (which can be slow) and just painting
722 // the plugin. Unlike the DoDeferredUpdate case, an extra copy is still 730 // the plugin. Unlike the DoDeferredUpdate case, an extra copy is still
723 // required. 731 // required.
724 base::TimeTicks paint_begin_ticks = base::TimeTicks::Now(); 732 base::TimeTicks paint_begin_ticks = base::TimeTicks::HighResNow();
725 SkAutoCanvasRestore auto_restore(canvas, true); 733 SkAutoCanvasRestore auto_restore(canvas, true);
726 canvas->scale(device_scale_factor_, device_scale_factor_); 734 canvas->scale(device_scale_factor_, device_scale_factor_);
727 optimized_instance->Paint(webkit_glue::ToWebCanvas(canvas), 735 optimized_instance->Paint(webkit_glue::ToWebCanvas(canvas),
728 optimized_copy_location, rect); 736 optimized_copy_location, rect);
729 canvas->restore(); 737 canvas->restore();
730 base::TimeDelta paint_time = base::TimeTicks::Now() - paint_begin_ticks; 738 base::TimeDelta paint_time =
739 base::TimeTicks::HighResNow() - paint_begin_ticks;
731 if (!is_accelerated_compositing_active_) 740 if (!is_accelerated_compositing_active_)
732 software_stats_.totalPaintTimeInSeconds += paint_time.InSecondsF(); 741 software_stats_.totalPaintTimeInSeconds += paint_time.InSecondsF();
733 } else { 742 } else {
734 // Normal painting case. 743 // Normal painting case.
735 base::TimeTicks paint_begin_ticks = base::TimeTicks::Now(); 744 base::TimeTicks paint_begin_ticks = base::TimeTicks::HighResNow();
736 webwidget_->paint(webkit_glue::ToWebCanvas(canvas), rect); 745 webwidget_->paint(webkit_glue::ToWebCanvas(canvas), rect);
737 base::TimeDelta paint_time = base::TimeTicks::Now() - paint_begin_ticks; 746 base::TimeDelta paint_time =
747 base::TimeTicks::HighResNow() - paint_begin_ticks;
738 if (!is_accelerated_compositing_active_) 748 if (!is_accelerated_compositing_active_)
739 software_stats_.totalPaintTimeInSeconds += paint_time.InSecondsF(); 749 software_stats_.totalPaintTimeInSeconds += paint_time.InSecondsF();
740 750
741 // Flush to underlying bitmap. TODO(darin): is this needed? 751 // Flush to underlying bitmap. TODO(darin): is this needed?
742 skia::GetTopDevice(*canvas)->accessBitmap(false); 752 skia::GetTopDevice(*canvas)->accessBitmap(false);
743 } 753 }
744 754
745 PaintDebugBorder(rect, canvas); 755 PaintDebugBorder(rect, canvas);
746 canvas->restore(); 756 canvas->restore();
757
758 if (kEnableGpuBenchmarking) {
759 base::TimeDelta rasterize_time =
760 base::TimeTicks::HighResNow() - rasterize_begin_ticks;
761 software_stats_.totalRasterizeTimeInSeconds += rasterize_time.InSecondsF();
762
763 int64 num_pixels_processed = rect.width() * rect.height();
764 software_stats_.totalPixelsPainted += num_pixels_processed;
765 software_stats_.totalPixelsRasterized += num_pixels_processed;
766 }
747 } 767 }
748 768
749 void RenderWidget::PaintDebugBorder(const gfx::Rect& rect, 769 void RenderWidget::PaintDebugBorder(const gfx::Rect& rect,
750 skia::PlatformCanvas* canvas) { 770 skia::PlatformCanvas* canvas) {
751 static bool kPaintBorder = 771 static bool kPaintBorder =
752 CommandLine::ForCurrentProcess()->HasSwitch(switches::kShowPaintRects); 772 CommandLine::ForCurrentProcess()->HasSwitch(switches::kShowPaintRects);
753 if (!kPaintBorder) 773 if (!kPaintBorder)
754 return; 774 return;
755 775
756 // Cycle through these colors to help distinguish new paint rects. 776 // Cycle through these colors to help distinguish new paint rects.
(...skipping 1126 matching lines...) Expand 10 before | Expand all | Expand 10 after
1883 break; 1903 break;
1884 } 1904 }
1885 } 1905 }
1886 } 1906 }
1887 1907
1888 void RenderWidget::GetRenderingStats(WebKit::WebRenderingStats& stats) const { 1908 void RenderWidget::GetRenderingStats(WebKit::WebRenderingStats& stats) const {
1889 webwidget()->renderingStats(stats); 1909 webwidget()->renderingStats(stats);
1890 stats.numAnimationFrames += software_stats_.numAnimationFrames; 1910 stats.numAnimationFrames += software_stats_.numAnimationFrames;
1891 stats.numFramesSentToScreen += software_stats_.numFramesSentToScreen; 1911 stats.numFramesSentToScreen += software_stats_.numFramesSentToScreen;
1892 stats.totalPaintTimeInSeconds += software_stats_.totalPaintTimeInSeconds; 1912 stats.totalPaintTimeInSeconds += software_stats_.totalPaintTimeInSeconds;
1913 stats.totalPixelsPainted += software_stats_.totalPixelsPainted;
1914 stats.totalRasterizeTimeInSeconds +=
1915 software_stats_.totalRasterizeTimeInSeconds;
1916 stats.totalPixelsRasterized += software_stats_.totalPixelsRasterized;
1893 } 1917 }
1894 1918
1895 bool RenderWidget::GetGpuRenderingStats(GpuRenderingStats* stats) const { 1919 bool RenderWidget::GetGpuRenderingStats(GpuRenderingStats* stats) const {
1896 GpuChannelHost* gpu_channel = RenderThreadImpl::current()->GetGpuChannel(); 1920 GpuChannelHost* gpu_channel = RenderThreadImpl::current()->GetGpuChannel();
1897 if (!gpu_channel) 1921 if (!gpu_channel)
1898 return false; 1922 return false;
1899 1923
1900 return gpu_channel->CollectRenderingStatsForSurface(surface_id(), stats); 1924 return gpu_channel->CollectRenderingStatsForSurface(surface_id(), stats);
1901 } 1925 }
1902 1926
(...skipping 18 matching lines...) Expand all
1921 1945
1922 bool RenderWidget::WillHandleMouseEvent(const WebKit::WebMouseEvent& event) { 1946 bool RenderWidget::WillHandleMouseEvent(const WebKit::WebMouseEvent& event) {
1923 return false; 1947 return false;
1924 } 1948 }
1925 1949
1926 bool RenderWidget::WebWidgetHandlesCompositorScheduling() const { 1950 bool RenderWidget::WebWidgetHandlesCompositorScheduling() const {
1927 return false; 1951 return false;
1928 } 1952 }
1929 1953
1930 } // namespace content 1954 } // namespace content
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698