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