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

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 655 matching lines...) Expand 10 before | Expand all | Expand 10 after
666 // which case we do not want to unfocus ourself. 666 // which case we do not want to unfocus ourself.
667 if (!has_focus_ && webwidget_) 667 if (!has_focus_ && webwidget_)
668 webwidget_->setFocus(false); 668 webwidget_->setFocus(false);
669 } 669 }
670 670
671 void RenderWidget::PaintRect(const gfx::Rect& rect, 671 void RenderWidget::PaintRect(const gfx::Rect& rect,
672 const gfx::Point& canvas_origin, 672 const gfx::Point& canvas_origin,
673 skia::PlatformCanvas* canvas) { 673 skia::PlatformCanvas* canvas) {
674 TRACE_EVENT2("renderer", "PaintRect", 674 TRACE_EVENT2("renderer", "PaintRect",
675 "width", rect.width(), "height", rect.height()); 675 "width", rect.width(), "height", rect.height());
676
677 base::TimeTicks rasterize_begin_ticks;
678 if (CommandLine::ForCurrentProcess()->HasSwitch(
679 switches::kEnableGpuBenchmarking))
680 rasterize_begin_ticks = base::TimeTicks::HighResNow();
676 canvas->save(); 681 canvas->save();
677 682
678 // Bring the canvas into the coordinate system of the paint rect. 683 // Bring the canvas into the coordinate system of the paint rect.
679 canvas->translate(static_cast<SkScalar>(-canvas_origin.x()), 684 canvas->translate(static_cast<SkScalar>(-canvas_origin.x()),
680 static_cast<SkScalar>(-canvas_origin.y())); 685 static_cast<SkScalar>(-canvas_origin.y()));
681 686
682 // If there is a custom background, tile it. 687 // If there is a custom background, tile it.
683 if (!background_.empty()) { 688 if (!background_.empty()) {
684 SkPaint paint; 689 SkPaint paint;
685 SkShader* shader = SkShader::CreateBitmapShader(background_, 690 SkShader* shader = SkShader::CreateBitmapShader(background_,
(...skipping 35 matching lines...) Expand 10 before | Expand all | Expand 10 after
721 // GetBitmapForOptimizedPluginPaint in DoDeferredUpdate handles the 726 // GetBitmapForOptimizedPluginPaint in DoDeferredUpdate handles the
722 // painting, because that avoids copying the plugin image to a different 727 // painting, because that avoids copying the plugin image to a different
723 // paint rect. Unfortunately, if anything on the page is animating other 728 // paint rect. Unfortunately, if anything on the page is animating other
724 // than the movie, it break this optimization since the union of the 729 // than the movie, it break this optimization since the union of the
725 // invalid regions will be larger than the plugin. 730 // invalid regions will be larger than the plugin.
726 // 731 //
727 // This code optimizes that case, where we can still avoid painting in 732 // This code optimizes that case, where we can still avoid painting in
728 // WebKit and filling the background (which can be slow) and just painting 733 // WebKit and filling the background (which can be slow) and just painting
729 // the plugin. Unlike the DoDeferredUpdate case, an extra copy is still 734 // the plugin. Unlike the DoDeferredUpdate case, an extra copy is still
730 // required. 735 // required.
731 base::TimeTicks paint_begin_ticks = base::TimeTicks::Now(); 736 base::TimeTicks paint_begin_ticks;
737 if (CommandLine::ForCurrentProcess()->HasSwitch(
738 switches::kEnableGpuBenchmarking))
jamesr 2012/11/08 23:33:12 we're repeating this a lot - can we stash this in
hartmanng 2012/11/09 14:07:11 Done.
739 paint_begin_ticks = base::TimeTicks::HighResNow();
740
732 SkAutoCanvasRestore auto_restore(canvas, true); 741 SkAutoCanvasRestore auto_restore(canvas, true);
733 canvas->scale(device_scale_factor_, device_scale_factor_); 742 canvas->scale(device_scale_factor_, device_scale_factor_);
734 optimized_instance->Paint(webkit_glue::ToWebCanvas(canvas), 743 optimized_instance->Paint(webkit_glue::ToWebCanvas(canvas),
735 optimized_copy_location, rect); 744 optimized_copy_location, rect);
736 canvas->restore(); 745 canvas->restore();
737 base::TimeDelta paint_time = base::TimeTicks::Now() - paint_begin_ticks; 746 if (CommandLine::ForCurrentProcess()->HasSwitch(
738 if (!is_accelerated_compositing_active_) 747 switches::kEnableGpuBenchmarking)) {
739 software_stats_.totalPaintTimeInSeconds += paint_time.InSecondsF(); 748 base::TimeDelta paint_time =
749 base::TimeTicks::HighResNow() - paint_begin_ticks;
750 if (!is_accelerated_compositing_active_)
751 software_stats_.totalPaintTimeInSeconds += paint_time.InSecondsF();
752 }
740 } else { 753 } else {
741 // Normal painting case. 754 // Normal painting case.
742 base::TimeTicks paint_begin_ticks = base::TimeTicks::Now(); 755 base::TimeTicks paint_begin_ticks;
756 if (CommandLine::ForCurrentProcess()->HasSwitch(
757 switches::kEnableGpuBenchmarking))
758 paint_begin_ticks = base::TimeTicks::HighResNow();
759
743 webwidget_->paint(webkit_glue::ToWebCanvas(canvas), rect); 760 webwidget_->paint(webkit_glue::ToWebCanvas(canvas), rect);
744 base::TimeDelta paint_time = base::TimeTicks::Now() - paint_begin_ticks; 761
745 if (!is_accelerated_compositing_active_) 762 if (CommandLine::ForCurrentProcess()->HasSwitch(
746 software_stats_.totalPaintTimeInSeconds += paint_time.InSecondsF(); 763 switches::kEnableGpuBenchmarking)) {
764 base::TimeDelta paint_time =
765 base::TimeTicks::HighResNow() - paint_begin_ticks;
766 if (!is_accelerated_compositing_active_)
767 software_stats_.totalPaintTimeInSeconds += paint_time.InSecondsF();
768 }
747 769
748 // Flush to underlying bitmap. TODO(darin): is this needed? 770 // Flush to underlying bitmap. TODO(darin): is this needed?
749 skia::GetTopDevice(*canvas)->accessBitmap(false); 771 skia::GetTopDevice(*canvas)->accessBitmap(false);
750 } 772 }
751 773
752 PaintDebugBorder(rect, canvas); 774 PaintDebugBorder(rect, canvas);
753 canvas->restore(); 775 canvas->restore();
776
777 if (CommandLine::ForCurrentProcess()->HasSwitch(
778 switches::kEnableGpuBenchmarking)) {
779 base::TimeDelta rasterize_time =
780 base::TimeTicks::HighResNow() - rasterize_begin_ticks;
781 software_stats_.totalRasterizeTimeInSeconds += rasterize_time.InSecondsF();
782
783 int64 num_pixels_processed = rect.width() * rect.height();
784 software_stats_.totalPixelsPainted += num_pixels_processed;
785 software_stats_.totalPixelsRasterized += num_pixels_processed;
786 }
754 } 787 }
755 788
756 void RenderWidget::PaintDebugBorder(const gfx::Rect& rect, 789 void RenderWidget::PaintDebugBorder(const gfx::Rect& rect,
757 skia::PlatformCanvas* canvas) { 790 skia::PlatformCanvas* canvas) {
758 static bool kPaintBorder = 791 static bool kPaintBorder =
759 CommandLine::ForCurrentProcess()->HasSwitch(switches::kShowPaintRects); 792 CommandLine::ForCurrentProcess()->HasSwitch(switches::kShowPaintRects);
760 if (!kPaintBorder) 793 if (!kPaintBorder)
761 return; 794 return;
762 795
763 // Cycle through these colors to help distinguish new paint rects. 796 // Cycle through these colors to help distinguish new paint rects.
(...skipping 1126 matching lines...) Expand 10 before | Expand all | Expand 10 after
1890 break; 1923 break;
1891 } 1924 }
1892 } 1925 }
1893 } 1926 }
1894 1927
1895 void RenderWidget::GetRenderingStats(WebKit::WebRenderingStats& stats) const { 1928 void RenderWidget::GetRenderingStats(WebKit::WebRenderingStats& stats) const {
1896 webwidget()->renderingStats(stats); 1929 webwidget()->renderingStats(stats);
1897 stats.numAnimationFrames += software_stats_.numAnimationFrames; 1930 stats.numAnimationFrames += software_stats_.numAnimationFrames;
1898 stats.numFramesSentToScreen += software_stats_.numFramesSentToScreen; 1931 stats.numFramesSentToScreen += software_stats_.numFramesSentToScreen;
1899 stats.totalPaintTimeInSeconds += software_stats_.totalPaintTimeInSeconds; 1932 stats.totalPaintTimeInSeconds += software_stats_.totalPaintTimeInSeconds;
1933 stats.totalPixelsPainted += software_stats_.totalPixelsPainted;
1934 stats.totalRasterizeTimeInSeconds +=
1935 software_stats_.totalRasterizeTimeInSeconds;
1936 stats.totalPixelsRasterized += software_stats_.totalPixelsRasterized;
1900 } 1937 }
1901 1938
1902 bool RenderWidget::GetGpuRenderingStats(GpuRenderingStats* stats) const { 1939 bool RenderWidget::GetGpuRenderingStats(GpuRenderingStats* stats) const {
1903 GpuChannelHost* gpu_channel = RenderThreadImpl::current()->GetGpuChannel(); 1940 GpuChannelHost* gpu_channel = RenderThreadImpl::current()->GetGpuChannel();
1904 if (!gpu_channel) 1941 if (!gpu_channel)
1905 return false; 1942 return false;
1906 1943
1907 return gpu_channel->CollectRenderingStatsForSurface(surface_id(), stats); 1944 return gpu_channel->CollectRenderingStatsForSurface(surface_id(), stats);
1908 } 1945 }
1909 1946
(...skipping 23 matching lines...) Expand all
1933 bool RenderWidget::WillHandleGestureEvent( 1970 bool RenderWidget::WillHandleGestureEvent(
1934 const WebKit::WebGestureEvent& event) { 1971 const WebKit::WebGestureEvent& event) {
1935 return false; 1972 return false;
1936 } 1973 }
1937 1974
1938 bool RenderWidget::WebWidgetHandlesCompositorScheduling() const { 1975 bool RenderWidget::WebWidgetHandlesCompositorScheduling() const {
1939 return false; 1976 return false;
1940 } 1977 }
1941 1978
1942 } // namespace content 1979 } // 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