Chromium Code Reviews| 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 648 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 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 | |
| 670 base::TimeTicks rasterize_begin_ticks = base::TimeTicks::Now(); | |
|
nduca
2012/11/06 21:30:53
HighResNow
hartmanng
2012/11/06 21:53:16
Done here and for the paint version of this.
| |
| 669 canvas->save(); | 671 canvas->save(); |
| 670 | 672 |
| 671 // Bring the canvas into the coordinate system of the paint rect. | 673 // Bring the canvas into the coordinate system of the paint rect. |
| 672 canvas->translate(static_cast<SkScalar>(-canvas_origin.x()), | 674 canvas->translate(static_cast<SkScalar>(-canvas_origin.x()), |
| 673 static_cast<SkScalar>(-canvas_origin.y())); | 675 static_cast<SkScalar>(-canvas_origin.y())); |
| 674 | 676 |
| 675 // If there is a custom background, tile it. | 677 // If there is a custom background, tile it. |
| 676 if (!background_.empty()) { | 678 if (!background_.empty()) { |
| 677 SkPaint paint; | 679 SkPaint paint; |
| 678 SkShader* shader = SkShader::CreateBitmapShader(background_, | 680 SkShader* shader = SkShader::CreateBitmapShader(background_, |
| (...skipping 58 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 737 base::TimeDelta paint_time = base::TimeTicks::Now() - paint_begin_ticks; | 739 base::TimeDelta paint_time = base::TimeTicks::Now() - paint_begin_ticks; |
| 738 if (!is_accelerated_compositing_active_) | 740 if (!is_accelerated_compositing_active_) |
| 739 software_stats_.totalPaintTimeInSeconds += paint_time.InSecondsF(); | 741 software_stats_.totalPaintTimeInSeconds += paint_time.InSecondsF(); |
| 740 | 742 |
| 741 // Flush to underlying bitmap. TODO(darin): is this needed? | 743 // Flush to underlying bitmap. TODO(darin): is this needed? |
| 742 skia::GetTopDevice(*canvas)->accessBitmap(false); | 744 skia::GetTopDevice(*canvas)->accessBitmap(false); |
| 743 } | 745 } |
| 744 | 746 |
| 745 PaintDebugBorder(rect, canvas); | 747 PaintDebugBorder(rect, canvas); |
| 746 canvas->restore(); | 748 canvas->restore(); |
| 749 | |
| 750 base::TimeDelta rasterize_time = | |
| 751 base::TimeTicks::Now() - rasterize_begin_ticks; | |
| 752 software_stats_.totalRasterizeTimeInSeconds += rasterize_time.InSecondsF(); | |
| 753 | |
| 754 int64 num_pixels_processed = rect.width() * rect.height(); | |
| 755 software_stats_.totalPixelsPainted += num_pixels_processed; | |
| 756 software_stats_.totalPixelsRasterized += num_pixels_processed; | |
| 747 } | 757 } |
| 748 | 758 |
| 749 void RenderWidget::PaintDebugBorder(const gfx::Rect& rect, | 759 void RenderWidget::PaintDebugBorder(const gfx::Rect& rect, |
| 750 skia::PlatformCanvas* canvas) { | 760 skia::PlatformCanvas* canvas) { |
| 751 static bool kPaintBorder = | 761 static bool kPaintBorder = |
| 752 CommandLine::ForCurrentProcess()->HasSwitch(switches::kShowPaintRects); | 762 CommandLine::ForCurrentProcess()->HasSwitch(switches::kShowPaintRects); |
| 753 if (!kPaintBorder) | 763 if (!kPaintBorder) |
| 754 return; | 764 return; |
| 755 | 765 |
| 756 // Cycle through these colors to help distinguish new paint rects. | 766 // Cycle through these colors to help distinguish new paint rects. |
| (...skipping 1126 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 1883 break; | 1893 break; |
| 1884 } | 1894 } |
| 1885 } | 1895 } |
| 1886 } | 1896 } |
| 1887 | 1897 |
| 1888 void RenderWidget::GetRenderingStats(WebKit::WebRenderingStats& stats) const { | 1898 void RenderWidget::GetRenderingStats(WebKit::WebRenderingStats& stats) const { |
| 1889 webwidget()->renderingStats(stats); | 1899 webwidget()->renderingStats(stats); |
| 1890 stats.numAnimationFrames += software_stats_.numAnimationFrames; | 1900 stats.numAnimationFrames += software_stats_.numAnimationFrames; |
| 1891 stats.numFramesSentToScreen += software_stats_.numFramesSentToScreen; | 1901 stats.numFramesSentToScreen += software_stats_.numFramesSentToScreen; |
| 1892 stats.totalPaintTimeInSeconds += software_stats_.totalPaintTimeInSeconds; | 1902 stats.totalPaintTimeInSeconds += software_stats_.totalPaintTimeInSeconds; |
| 1903 stats.totalPixelsPainted += software_stats_.totalPixelsPainted; | |
| 1904 stats.totalRasterizeTimeInSeconds += | |
| 1905 software_stats_.totalRasterizeTimeInSeconds; | |
| 1906 stats.totalPixelsRasterized += software_stats_.totalPixelsRasterized; | |
| 1893 } | 1907 } |
| 1894 | 1908 |
| 1895 bool RenderWidget::GetGpuRenderingStats(GpuRenderingStats* stats) const { | 1909 bool RenderWidget::GetGpuRenderingStats(GpuRenderingStats* stats) const { |
| 1896 GpuChannelHost* gpu_channel = RenderThreadImpl::current()->GetGpuChannel(); | 1910 GpuChannelHost* gpu_channel = RenderThreadImpl::current()->GetGpuChannel(); |
| 1897 if (!gpu_channel) | 1911 if (!gpu_channel) |
| 1898 return false; | 1912 return false; |
| 1899 | 1913 |
| 1900 return gpu_channel->CollectRenderingStatsForSurface(surface_id(), stats); | 1914 return gpu_channel->CollectRenderingStatsForSurface(surface_id(), stats); |
| 1901 } | 1915 } |
| 1902 | 1916 |
| (...skipping 18 matching lines...) Expand all Loading... | |
| 1921 | 1935 |
| 1922 bool RenderWidget::WillHandleMouseEvent(const WebKit::WebMouseEvent& event) { | 1936 bool RenderWidget::WillHandleMouseEvent(const WebKit::WebMouseEvent& event) { |
| 1923 return false; | 1937 return false; |
| 1924 } | 1938 } |
| 1925 | 1939 |
| 1926 bool RenderWidget::WebWidgetHandlesCompositorScheduling() const { | 1940 bool RenderWidget::WebWidgetHandlesCompositorScheduling() const { |
| 1927 return false; | 1941 return false; |
| 1928 } | 1942 } |
| 1929 | 1943 |
| 1930 } // namespace content | 1944 } // namespace content |
| OLD | NEW |