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

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 651 matching lines...) Expand 10 before | Expand all | Expand 10 after
662 // which case we do not want to unfocus ourself. 662 // which case we do not want to unfocus ourself.
663 if (!has_focus_ && webwidget_) 663 if (!has_focus_ && webwidget_)
664 webwidget_->setFocus(false); 664 webwidget_->setFocus(false);
665 } 665 }
666 666
667 void RenderWidget::PaintRect(const gfx::Rect& rect, 667 void RenderWidget::PaintRect(const gfx::Rect& rect,
668 const gfx::Point& canvas_origin, 668 const gfx::Point& canvas_origin,
669 skia::PlatformCanvas* canvas) { 669 skia::PlatformCanvas* canvas) {
670 TRACE_EVENT2("renderer", "PaintRect", 670 TRACE_EVENT2("renderer", "PaintRect",
671 "width", rect.width(), "height", rect.height()); 671 "width", rect.width(), "height", rect.height());
672
673 const bool kEnableGpuBenchmarking =
674 CommandLine::ForCurrentProcess()->HasSwitch(
675 switches::kEnableGpuBenchmarking);
676 base::TimeTicks rasterize_begin_ticks;
677 if (kEnableGpuBenchmarking)
678 rasterize_begin_ticks = base::TimeTicks::HighResNow();
672 canvas->save(); 679 canvas->save();
673 680
674 // Bring the canvas into the coordinate system of the paint rect. 681 // Bring the canvas into the coordinate system of the paint rect.
675 canvas->translate(static_cast<SkScalar>(-canvas_origin.x()), 682 canvas->translate(static_cast<SkScalar>(-canvas_origin.x()),
676 static_cast<SkScalar>(-canvas_origin.y())); 683 static_cast<SkScalar>(-canvas_origin.y()));
677 684
678 // If there is a custom background, tile it. 685 // If there is a custom background, tile it.
679 if (!background_.empty()) { 686 if (!background_.empty()) {
680 SkPaint paint; 687 SkPaint paint;
681 SkShader* shader = SkShader::CreateBitmapShader(background_, 688 SkShader* shader = SkShader::CreateBitmapShader(background_,
(...skipping 35 matching lines...) Expand 10 before | Expand all | Expand 10 after
717 // GetBitmapForOptimizedPluginPaint in DoDeferredUpdate handles the 724 // GetBitmapForOptimizedPluginPaint in DoDeferredUpdate handles the
718 // painting, because that avoids copying the plugin image to a different 725 // painting, because that avoids copying the plugin image to a different
719 // paint rect. Unfortunately, if anything on the page is animating other 726 // paint rect. Unfortunately, if anything on the page is animating other
720 // than the movie, it break this optimization since the union of the 727 // than the movie, it break this optimization since the union of the
721 // invalid regions will be larger than the plugin. 728 // invalid regions will be larger than the plugin.
722 // 729 //
723 // This code optimizes that case, where we can still avoid painting in 730 // This code optimizes that case, where we can still avoid painting in
724 // WebKit and filling the background (which can be slow) and just painting 731 // WebKit and filling the background (which can be slow) and just painting
725 // the plugin. Unlike the DoDeferredUpdate case, an extra copy is still 732 // the plugin. Unlike the DoDeferredUpdate case, an extra copy is still
726 // required. 733 // required.
727 base::TimeTicks paint_begin_ticks = base::TimeTicks::Now(); 734 base::TimeTicks paint_begin_ticks;
735 if (kEnableGpuBenchmarking)
736 paint_begin_ticks = base::TimeTicks::HighResNow();
737
728 SkAutoCanvasRestore auto_restore(canvas, true); 738 SkAutoCanvasRestore auto_restore(canvas, true);
729 canvas->scale(device_scale_factor_, device_scale_factor_); 739 canvas->scale(device_scale_factor_, device_scale_factor_);
730 optimized_instance->Paint(webkit_glue::ToWebCanvas(canvas), 740 optimized_instance->Paint(webkit_glue::ToWebCanvas(canvas),
731 optimized_copy_location, rect); 741 optimized_copy_location, rect);
732 canvas->restore(); 742 canvas->restore();
733 base::TimeDelta paint_time = base::TimeTicks::Now() - paint_begin_ticks; 743 if (kEnableGpuBenchmarking) {
734 if (!is_accelerated_compositing_active_) 744 base::TimeDelta paint_time =
735 software_stats_.totalPaintTimeInSeconds += paint_time.InSecondsF(); 745 base::TimeTicks::HighResNow() - paint_begin_ticks;
746 if (!is_accelerated_compositing_active_)
747 software_stats_.totalPaintTimeInSeconds += paint_time.InSecondsF();
748 }
736 } else { 749 } else {
737 // Normal painting case. 750 // Normal painting case.
738 base::TimeTicks paint_begin_ticks = base::TimeTicks::Now(); 751 base::TimeTicks paint_begin_ticks;
752 if (kEnableGpuBenchmarking)
753 paint_begin_ticks = base::TimeTicks::HighResNow();
754
739 webwidget_->paint(webkit_glue::ToWebCanvas(canvas), rect); 755 webwidget_->paint(webkit_glue::ToWebCanvas(canvas), rect);
740 base::TimeDelta paint_time = base::TimeTicks::Now() - paint_begin_ticks; 756
741 if (!is_accelerated_compositing_active_) 757 if (kEnableGpuBenchmarking) {
742 software_stats_.totalPaintTimeInSeconds += paint_time.InSecondsF(); 758 base::TimeDelta paint_time =
759 base::TimeTicks::HighResNow() - paint_begin_ticks;
760 if (!is_accelerated_compositing_active_)
761 software_stats_.totalPaintTimeInSeconds += paint_time.InSecondsF();
762 }
743 763
744 // Flush to underlying bitmap. TODO(darin): is this needed? 764 // Flush to underlying bitmap. TODO(darin): is this needed?
745 skia::GetTopDevice(*canvas)->accessBitmap(false); 765 skia::GetTopDevice(*canvas)->accessBitmap(false);
746 } 766 }
747 767
748 PaintDebugBorder(rect, canvas); 768 PaintDebugBorder(rect, canvas);
749 canvas->restore(); 769 canvas->restore();
770
771 if (kEnableGpuBenchmarking) {
772 base::TimeDelta rasterize_time =
773 base::TimeTicks::HighResNow() - rasterize_begin_ticks;
774 software_stats_.totalRasterizeTimeInSeconds += rasterize_time.InSecondsF();
775
776 int64 num_pixels_processed = rect.width() * rect.height();
777 software_stats_.totalPixelsPainted += num_pixels_processed;
778 software_stats_.totalPixelsRasterized += num_pixels_processed;
779 }
750 } 780 }
751 781
752 void RenderWidget::PaintDebugBorder(const gfx::Rect& rect, 782 void RenderWidget::PaintDebugBorder(const gfx::Rect& rect,
753 skia::PlatformCanvas* canvas) { 783 skia::PlatformCanvas* canvas) {
754 static bool kPaintBorder = 784 static bool kPaintBorder =
755 CommandLine::ForCurrentProcess()->HasSwitch(switches::kShowPaintRects); 785 CommandLine::ForCurrentProcess()->HasSwitch(switches::kShowPaintRects);
756 if (!kPaintBorder) 786 if (!kPaintBorder)
757 return; 787 return;
758 788
759 // Cycle through these colors to help distinguish new paint rects. 789 // Cycle through these colors to help distinguish new paint rects.
(...skipping 1119 matching lines...) Expand 10 before | Expand all | Expand 10 after
1879 break; 1909 break;
1880 } 1910 }
1881 } 1911 }
1882 } 1912 }
1883 1913
1884 void RenderWidget::GetRenderingStats(WebKit::WebRenderingStats& stats) const { 1914 void RenderWidget::GetRenderingStats(WebKit::WebRenderingStats& stats) const {
1885 webwidget()->renderingStats(stats); 1915 webwidget()->renderingStats(stats);
1886 stats.numAnimationFrames += software_stats_.numAnimationFrames; 1916 stats.numAnimationFrames += software_stats_.numAnimationFrames;
1887 stats.numFramesSentToScreen += software_stats_.numFramesSentToScreen; 1917 stats.numFramesSentToScreen += software_stats_.numFramesSentToScreen;
1888 stats.totalPaintTimeInSeconds += software_stats_.totalPaintTimeInSeconds; 1918 stats.totalPaintTimeInSeconds += software_stats_.totalPaintTimeInSeconds;
1919 stats.totalPixelsPainted += software_stats_.totalPixelsPainted;
1920 stats.totalRasterizeTimeInSeconds +=
1921 software_stats_.totalRasterizeTimeInSeconds;
1922 stats.totalPixelsRasterized += software_stats_.totalPixelsRasterized;
1889 } 1923 }
1890 1924
1891 bool RenderWidget::GetGpuRenderingStats(GpuRenderingStats* stats) const { 1925 bool RenderWidget::GetGpuRenderingStats(GpuRenderingStats* stats) const {
1892 GpuChannelHost* gpu_channel = RenderThreadImpl::current()->GetGpuChannel(); 1926 GpuChannelHost* gpu_channel = RenderThreadImpl::current()->GetGpuChannel();
1893 if (!gpu_channel) 1927 if (!gpu_channel)
1894 return false; 1928 return false;
1895 1929
1896 return gpu_channel->CollectRenderingStatsForSurface(surface_id(), stats); 1930 return gpu_channel->CollectRenderingStatsForSurface(surface_id(), stats);
1897 } 1931 }
1898 1932
(...skipping 23 matching lines...) Expand all
1922 bool RenderWidget::WillHandleGestureEvent( 1956 bool RenderWidget::WillHandleGestureEvent(
1923 const WebKit::WebGestureEvent& event) { 1957 const WebKit::WebGestureEvent& event) {
1924 return false; 1958 return false;
1925 } 1959 }
1926 1960
1927 bool RenderWidget::WebWidgetHandlesCompositorScheduling() const { 1961 bool RenderWidget::WebWidgetHandlesCompositorScheduling() const {
1928 return false; 1962 return false;
1929 } 1963 }
1930 1964
1931 } // namespace content 1965 } // namespace content
OLDNEW
« no previous file with comments | « content/renderer/gpu/gpu_benchmarking_extension.cc ('k') | webkit/compositor_bindings/web_layer_tree_view_impl.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698