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 787 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
798 | 798 |
799 SkAutoCanvasRestore auto_restore(canvas, true); | 799 SkAutoCanvasRestore auto_restore(canvas, true); |
800 canvas->scale(device_scale_factor_, device_scale_factor_); | 800 canvas->scale(device_scale_factor_, device_scale_factor_); |
801 optimized_instance->Paint(webkit_glue::ToWebCanvas(canvas), | 801 optimized_instance->Paint(webkit_glue::ToWebCanvas(canvas), |
802 optimized_copy_location, rect); | 802 optimized_copy_location, rect); |
803 canvas->restore(); | 803 canvas->restore(); |
804 if (kEnableGpuBenchmarking) { | 804 if (kEnableGpuBenchmarking) { |
805 base::TimeDelta paint_time = | 805 base::TimeDelta paint_time = |
806 base::TimeTicks::HighResNow() - paint_begin_ticks; | 806 base::TimeTicks::HighResNow() - paint_begin_ticks; |
807 if (!is_accelerated_compositing_active_) | 807 if (!is_accelerated_compositing_active_) |
808 software_stats_.totalPaintTimeInSeconds += paint_time.InSecondsF(); | 808 software_stats_.totalPaintTime += paint_time; |
809 } | 809 } |
810 } else { | 810 } else { |
811 // Normal painting case. | 811 // Normal painting case. |
812 base::TimeTicks paint_begin_ticks; | 812 base::TimeTicks paint_begin_ticks; |
813 if (kEnableGpuBenchmarking) | 813 if (kEnableGpuBenchmarking) |
814 paint_begin_ticks = base::TimeTicks::HighResNow(); | 814 paint_begin_ticks = base::TimeTicks::HighResNow(); |
815 | 815 |
816 webwidget_->paint(webkit_glue::ToWebCanvas(canvas), rect); | 816 webwidget_->paint(webkit_glue::ToWebCanvas(canvas), rect); |
817 | 817 |
818 if (kEnableGpuBenchmarking) { | 818 if (kEnableGpuBenchmarking) { |
819 base::TimeDelta paint_time = | 819 base::TimeDelta paint_time = |
820 base::TimeTicks::HighResNow() - paint_begin_ticks; | 820 base::TimeTicks::HighResNow() - paint_begin_ticks; |
821 if (!is_accelerated_compositing_active_) | 821 if (!is_accelerated_compositing_active_) |
822 software_stats_.totalPaintTimeInSeconds += paint_time.InSecondsF(); | 822 software_stats_.totalPaintTime += paint_time; |
823 } | 823 } |
824 | 824 |
825 // Flush to underlying bitmap. TODO(darin): is this needed? | 825 // Flush to underlying bitmap. TODO(darin): is this needed? |
826 skia::GetTopDevice(*canvas)->accessBitmap(false); | 826 skia::GetTopDevice(*canvas)->accessBitmap(false); |
827 } | 827 } |
828 | 828 |
829 PaintDebugBorder(rect, canvas); | 829 PaintDebugBorder(rect, canvas); |
830 canvas->restore(); | 830 canvas->restore(); |
831 | 831 |
832 if (kEnableGpuBenchmarking) { | 832 if (kEnableGpuBenchmarking) { |
833 base::TimeDelta rasterize_time = | 833 base::TimeDelta rasterize_time = |
834 base::TimeTicks::HighResNow() - rasterize_begin_ticks; | 834 base::TimeTicks::HighResNow() - rasterize_begin_ticks; |
835 software_stats_.totalRasterizeTimeInSeconds += rasterize_time.InSecondsF(); | 835 software_stats_.totalRasterizeTime += rasterize_time; |
836 | 836 |
837 int64 num_pixels_processed = rect.width() * rect.height(); | 837 int64 num_pixels_processed = rect.width() * rect.height(); |
838 software_stats_.totalPixelsPainted += num_pixels_processed; | 838 software_stats_.totalPixelsPainted += num_pixels_processed; |
839 software_stats_.totalPixelsRasterized += num_pixels_processed; | 839 software_stats_.totalPixelsRasterized += num_pixels_processed; |
840 } | 840 } |
841 } | 841 } |
842 | 842 |
843 void RenderWidget::PaintDebugBorder(const gfx::Rect& rect, | 843 void RenderWidget::PaintDebugBorder(const gfx::Rect& rect, |
844 skia::PlatformCanvas* canvas) { | 844 skia::PlatformCanvas* canvas) { |
845 static bool kPaintBorder = | 845 static bool kPaintBorder = |
(...skipping 1150 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1996 } | 1996 } |
1997 | 1997 |
1998 void RenderWidget::GetRenderingStats( | 1998 void RenderWidget::GetRenderingStats( |
1999 WebKit::WebRenderingStatsImpl& stats) const { | 1999 WebKit::WebRenderingStatsImpl& stats) const { |
2000 webwidget()->renderingStats(stats); | 2000 webwidget()->renderingStats(stats); |
2001 | 2001 |
2002 stats.rendering_stats.numAnimationFrames += | 2002 stats.rendering_stats.numAnimationFrames += |
2003 software_stats_.numAnimationFrames; | 2003 software_stats_.numAnimationFrames; |
2004 stats.rendering_stats.numFramesSentToScreen += | 2004 stats.rendering_stats.numFramesSentToScreen += |
2005 software_stats_.numFramesSentToScreen; | 2005 software_stats_.numFramesSentToScreen; |
2006 stats.rendering_stats.totalPaintTimeInSeconds += | 2006 stats.rendering_stats.totalPaintTime += |
2007 software_stats_.totalPaintTimeInSeconds; | 2007 software_stats_.totalPaintTime; |
2008 stats.rendering_stats.totalPixelsPainted += | 2008 stats.rendering_stats.totalPixelsPainted += |
2009 software_stats_.totalPixelsPainted; | 2009 software_stats_.totalPixelsPainted; |
2010 stats.rendering_stats.totalRasterizeTimeInSeconds += | 2010 stats.rendering_stats.totalRasterizeTime += |
2011 software_stats_.totalRasterizeTimeInSeconds; | 2011 software_stats_.totalRasterizeTime; |
2012 stats.rendering_stats.totalPixelsRasterized += | 2012 stats.rendering_stats.totalPixelsRasterized += |
2013 software_stats_.totalPixelsRasterized; | 2013 software_stats_.totalPixelsRasterized; |
2014 } | 2014 } |
2015 | 2015 |
2016 bool RenderWidget::GetGpuRenderingStats(GpuRenderingStats* stats) const { | 2016 bool RenderWidget::GetGpuRenderingStats(GpuRenderingStats* stats) const { |
2017 GpuChannelHost* gpu_channel = RenderThreadImpl::current()->GetGpuChannel(); | 2017 GpuChannelHost* gpu_channel = RenderThreadImpl::current()->GetGpuChannel(); |
2018 if (!gpu_channel) | 2018 if (!gpu_channel) |
2019 return false; | 2019 return false; |
2020 | 2020 |
2021 return gpu_channel->CollectRenderingStatsForSurface(surface_id(), stats); | 2021 return gpu_channel->CollectRenderingStatsForSurface(surface_id(), stats); |
(...skipping 29 matching lines...) Expand all Loading... |
2051 | 2051 |
2052 bool RenderWidget::WebWidgetHandlesCompositorScheduling() const { | 2052 bool RenderWidget::WebWidgetHandlesCompositorScheduling() const { |
2053 return false; | 2053 return false; |
2054 } | 2054 } |
2055 | 2055 |
2056 bool RenderWidget::HasTouchEventHandlersAt(const gfx::Point& point) const { | 2056 bool RenderWidget::HasTouchEventHandlersAt(const gfx::Point& point) const { |
2057 return true; | 2057 return true; |
2058 } | 2058 } |
2059 | 2059 |
2060 } // namespace content | 2060 } // namespace content |
OLD | NEW |