| 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 872 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 883 | 883 |
| 884 SkAutoCanvasRestore auto_restore(canvas, true); | 884 SkAutoCanvasRestore auto_restore(canvas, true); |
| 885 canvas->scale(device_scale_factor_, device_scale_factor_); | 885 canvas->scale(device_scale_factor_, device_scale_factor_); |
| 886 optimized_instance->Paint(webkit_glue::ToWebCanvas(canvas), | 886 optimized_instance->Paint(webkit_glue::ToWebCanvas(canvas), |
| 887 optimized_copy_location, rect); | 887 optimized_copy_location, rect); |
| 888 canvas->restore(); | 888 canvas->restore(); |
| 889 if (kEnableGpuBenchmarking) { | 889 if (kEnableGpuBenchmarking) { |
| 890 base::TimeDelta paint_time = | 890 base::TimeDelta paint_time = |
| 891 base::TimeTicks::HighResNow() - paint_begin_ticks; | 891 base::TimeTicks::HighResNow() - paint_begin_ticks; |
| 892 if (!is_accelerated_compositing_active_) | 892 if (!is_accelerated_compositing_active_) |
| 893 software_stats_.totalPaintTime += paint_time; | 893 software_stats_.total_paint_time += paint_time; |
| 894 } | 894 } |
| 895 } else { | 895 } else { |
| 896 // Normal painting case. | 896 // Normal painting case. |
| 897 base::TimeTicks paint_begin_ticks; | 897 base::TimeTicks paint_begin_ticks; |
| 898 if (kEnableGpuBenchmarking) | 898 if (kEnableGpuBenchmarking) |
| 899 paint_begin_ticks = base::TimeTicks::HighResNow(); | 899 paint_begin_ticks = base::TimeTicks::HighResNow(); |
| 900 | 900 |
| 901 webwidget_->paint(webkit_glue::ToWebCanvas(canvas), rect); | 901 webwidget_->paint(webkit_glue::ToWebCanvas(canvas), rect); |
| 902 | 902 |
| 903 if (kEnableGpuBenchmarking) { | 903 if (kEnableGpuBenchmarking) { |
| 904 base::TimeDelta paint_time = | 904 base::TimeDelta paint_time = |
| 905 base::TimeTicks::HighResNow() - paint_begin_ticks; | 905 base::TimeTicks::HighResNow() - paint_begin_ticks; |
| 906 if (!is_accelerated_compositing_active_) | 906 if (!is_accelerated_compositing_active_) |
| 907 software_stats_.totalPaintTime += paint_time; | 907 software_stats_.total_paint_time += paint_time; |
| 908 } | 908 } |
| 909 | 909 |
| 910 // Flush to underlying bitmap. TODO(darin): is this needed? | 910 // Flush to underlying bitmap. TODO(darin): is this needed? |
| 911 skia::GetTopDevice(*canvas)->accessBitmap(false); | 911 skia::GetTopDevice(*canvas)->accessBitmap(false); |
| 912 } | 912 } |
| 913 | 913 |
| 914 PaintDebugBorder(rect, canvas); | 914 PaintDebugBorder(rect, canvas); |
| 915 canvas->restore(); | 915 canvas->restore(); |
| 916 | 916 |
| 917 if (kEnableGpuBenchmarking) { | 917 if (kEnableGpuBenchmarking) { |
| 918 int64 num_pixels_processed = rect.width() * rect.height(); | 918 int64 num_pixels_processed = rect.width() * rect.height(); |
| 919 software_stats_.totalPixelsPainted += num_pixels_processed; | 919 software_stats_.total_pixels_painted += num_pixels_processed; |
| 920 software_stats_.totalPixelsRasterized += num_pixels_processed; | 920 software_stats_.total_pixels_rasterized += num_pixels_processed; |
| 921 } | 921 } |
| 922 } | 922 } |
| 923 | 923 |
| 924 void RenderWidget::PaintDebugBorder(const gfx::Rect& rect, | 924 void RenderWidget::PaintDebugBorder(const gfx::Rect& rect, |
| 925 skia::PlatformCanvas* canvas) { | 925 skia::PlatformCanvas* canvas) { |
| 926 static bool kPaintBorder = | 926 static bool kPaintBorder = |
| 927 CommandLine::ForCurrentProcess()->HasSwitch(switches::kShowPaintRects); | 927 CommandLine::ForCurrentProcess()->HasSwitch(switches::kShowPaintRects); |
| 928 if (!kPaintBorder) | 928 if (!kPaintBorder) |
| 929 return; | 929 return; |
| 930 | 930 |
| (...skipping 183 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1114 } | 1114 } |
| 1115 | 1115 |
| 1116 // Calculate filtered time per frame: | 1116 // Calculate filtered time per frame: |
| 1117 float frame_time_elapsed = static_cast<float>(delay.InSecondsF()); | 1117 float frame_time_elapsed = static_cast<float>(delay.InSecondsF()); |
| 1118 filtered_time_per_frame_ = | 1118 filtered_time_per_frame_ = |
| 1119 0.9f * filtered_time_per_frame_ + 0.1f * frame_time_elapsed; | 1119 0.9f * filtered_time_per_frame_ + 0.1f * frame_time_elapsed; |
| 1120 } | 1120 } |
| 1121 last_do_deferred_update_time_ = frame_begin_ticks; | 1121 last_do_deferred_update_time_ = frame_begin_ticks; |
| 1122 | 1122 |
| 1123 if (!is_accelerated_compositing_active_) { | 1123 if (!is_accelerated_compositing_active_) { |
| 1124 software_stats_.numAnimationFrames++; | 1124 software_stats_.animation_frame_count++; |
| 1125 software_stats_.numFramesSentToScreen++; | 1125 software_stats_.screen_frame_count++; |
| 1126 } | 1126 } |
| 1127 | 1127 |
| 1128 // OK, save the pending update to a local since painting may cause more | 1128 // OK, save the pending update to a local since painting may cause more |
| 1129 // invalidation. Some WebCore rendering objects only layout when painted. | 1129 // invalidation. Some WebCore rendering objects only layout when painted. |
| 1130 PaintAggregator::PendingUpdate update; | 1130 PaintAggregator::PendingUpdate update; |
| 1131 paint_aggregator_.PopPendingUpdate(&update); | 1131 paint_aggregator_.PopPendingUpdate(&update); |
| 1132 | 1132 |
| 1133 gfx::Rect scroll_damage = update.GetScrollDamage(); | 1133 gfx::Rect scroll_damage = update.GetScrollDamage(); |
| 1134 gfx::Rect bounds = gfx::UnionRects(update.GetPaintBounds(), scroll_damage); | 1134 gfx::Rect bounds = gfx::UnionRects(update.GetPaintBounds(), scroll_damage); |
| 1135 | 1135 |
| (...skipping 1046 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2182 break; | 2182 break; |
| 2183 } | 2183 } |
| 2184 } | 2184 } |
| 2185 } | 2185 } |
| 2186 | 2186 |
| 2187 void RenderWidget::GetRenderingStats( | 2187 void RenderWidget::GetRenderingStats( |
| 2188 WebKit::WebRenderingStatsImpl& stats) const { | 2188 WebKit::WebRenderingStatsImpl& stats) const { |
| 2189 if (compositor_) | 2189 if (compositor_) |
| 2190 compositor_->GetRenderingStats(&stats.rendering_stats); | 2190 compositor_->GetRenderingStats(&stats.rendering_stats); |
| 2191 | 2191 |
| 2192 stats.rendering_stats.numAnimationFrames += | 2192 stats.rendering_stats.animation_frame_count += |
| 2193 software_stats_.numAnimationFrames; | 2193 software_stats_.animation_frame_count; |
| 2194 stats.rendering_stats.numFramesSentToScreen += | 2194 stats.rendering_stats.screen_frame_count += |
| 2195 software_stats_.numFramesSentToScreen; | 2195 software_stats_.screen_frame_count; |
| 2196 stats.rendering_stats.totalPaintTime += | 2196 stats.rendering_stats.total_paint_time += |
| 2197 software_stats_.totalPaintTime; | 2197 software_stats_.total_paint_time; |
| 2198 stats.rendering_stats.totalPixelsPainted += | 2198 stats.rendering_stats.total_pixels_painted += |
| 2199 software_stats_.totalPixelsPainted; | 2199 software_stats_.total_pixels_painted; |
| 2200 stats.rendering_stats.totalRasterizeTime += | 2200 stats.rendering_stats.total_rasterize_time += |
| 2201 software_stats_.totalRasterizeTime; | 2201 software_stats_.total_rasterize_time; |
| 2202 stats.rendering_stats.totalPixelsRasterized += | 2202 stats.rendering_stats.total_pixels_rasterized += |
| 2203 software_stats_.totalPixelsRasterized; | 2203 software_stats_.total_pixels_rasterized; |
| 2204 } | 2204 } |
| 2205 | 2205 |
| 2206 bool RenderWidget::GetGpuRenderingStats(GpuRenderingStats* stats) const { | 2206 bool RenderWidget::GetGpuRenderingStats(GpuRenderingStats* stats) const { |
| 2207 GpuChannelHost* gpu_channel = RenderThreadImpl::current()->GetGpuChannel(); | 2207 GpuChannelHost* gpu_channel = RenderThreadImpl::current()->GetGpuChannel(); |
| 2208 if (!gpu_channel) | 2208 if (!gpu_channel) |
| 2209 return false; | 2209 return false; |
| 2210 | 2210 |
| 2211 return gpu_channel->CollectRenderingStatsForSurface(surface_id(), stats); | 2211 return gpu_channel->CollectRenderingStatsForSurface(surface_id(), stats); |
| 2212 } | 2212 } |
| 2213 | 2213 |
| (...skipping 42 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2256 | 2256 |
| 2257 if (!context->Initialize( | 2257 if (!context->Initialize( |
| 2258 attributes, | 2258 attributes, |
| 2259 false /* bind generates resources */, | 2259 false /* bind generates resources */, |
| 2260 CAUSE_FOR_GPU_LAUNCH_WEBGRAPHICSCONTEXT3DCOMMANDBUFFERIMPL_INITIALIZE)
) | 2260 CAUSE_FOR_GPU_LAUNCH_WEBGRAPHICSCONTEXT3DCOMMANDBUFFERIMPL_INITIALIZE)
) |
| 2261 return NULL; | 2261 return NULL; |
| 2262 return context.release(); | 2262 return context.release(); |
| 2263 } | 2263 } |
| 2264 | 2264 |
| 2265 } // namespace content | 2265 } // namespace content |
| OLD | NEW |