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 1002 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1013 paint_begin_ticks = base::TimeTicks::HighResNow(); | 1013 paint_begin_ticks = base::TimeTicks::HighResNow(); |
1014 | 1014 |
1015 SkAutoCanvasRestore auto_restore(canvas, true); | 1015 SkAutoCanvasRestore auto_restore(canvas, true); |
1016 canvas->scale(device_scale_factor_, device_scale_factor_); | 1016 canvas->scale(device_scale_factor_, device_scale_factor_); |
1017 optimized_instance->Paint(canvas, optimized_copy_location, rect); | 1017 optimized_instance->Paint(canvas, optimized_copy_location, rect); |
1018 canvas->restore(); | 1018 canvas->restore(); |
1019 if (kEnableGpuBenchmarking) { | 1019 if (kEnableGpuBenchmarking) { |
1020 base::TimeDelta paint_time = | 1020 base::TimeDelta paint_time = |
1021 base::TimeTicks::HighResNow() - paint_begin_ticks; | 1021 base::TimeTicks::HighResNow() - paint_begin_ticks; |
1022 if (!is_accelerated_compositing_active_) | 1022 if (!is_accelerated_compositing_active_) |
1023 software_stats_.total_paint_time += paint_time; | 1023 software_stats_.main_stats.paint_time += paint_time; |
1024 } | 1024 } |
1025 #endif | 1025 #endif |
1026 } else { | 1026 } else { |
1027 // Normal painting case. | 1027 // Normal painting case. |
1028 base::TimeTicks paint_begin_ticks; | 1028 base::TimeTicks paint_begin_ticks; |
1029 if (kEnableGpuBenchmarking) | 1029 if (kEnableGpuBenchmarking) |
1030 paint_begin_ticks = base::TimeTicks::HighResNow(); | 1030 paint_begin_ticks = base::TimeTicks::HighResNow(); |
1031 | 1031 |
1032 webwidget_->paint(canvas, rect); | 1032 webwidget_->paint(canvas, rect); |
1033 | 1033 |
1034 if (kEnableGpuBenchmarking) { | 1034 if (kEnableGpuBenchmarking) { |
1035 base::TimeDelta paint_time = | 1035 base::TimeDelta paint_time = |
1036 base::TimeTicks::HighResNow() - paint_begin_ticks; | 1036 base::TimeTicks::HighResNow() - paint_begin_ticks; |
1037 if (!is_accelerated_compositing_active_) | 1037 if (!is_accelerated_compositing_active_) |
1038 software_stats_.total_paint_time += paint_time; | 1038 software_stats_.main_stats.paint_time += paint_time; |
1039 } | 1039 } |
1040 | 1040 |
1041 // Flush to underlying bitmap. TODO(darin): is this needed? | 1041 // Flush to underlying bitmap. TODO(darin): is this needed? |
1042 skia::GetTopDevice(*canvas)->accessBitmap(false); | 1042 skia::GetTopDevice(*canvas)->accessBitmap(false); |
1043 } | 1043 } |
1044 | 1044 |
1045 PaintDebugBorder(rect, canvas); | 1045 PaintDebugBorder(rect, canvas); |
1046 canvas->restore(); | 1046 canvas->restore(); |
1047 | 1047 |
1048 if (kEnableGpuBenchmarking) { | 1048 if (kEnableGpuBenchmarking) { |
1049 int64 num_pixels_processed = rect.width() * rect.height(); | 1049 int64 num_pixels_processed = rect.width() * rect.height(); |
1050 software_stats_.total_pixels_painted += num_pixels_processed; | 1050 software_stats_.main_stats.painted_pixel_count += num_pixels_processed; |
1051 } | 1051 } |
1052 } | 1052 } |
1053 | 1053 |
1054 void RenderWidget::PaintDebugBorder(const gfx::Rect& rect, | 1054 void RenderWidget::PaintDebugBorder(const gfx::Rect& rect, |
1055 skia::PlatformCanvas* canvas) { | 1055 skia::PlatformCanvas* canvas) { |
1056 static bool kPaintBorder = | 1056 static bool kPaintBorder = |
1057 CommandLine::ForCurrentProcess()->HasSwitch(switches::kShowPaintRects); | 1057 CommandLine::ForCurrentProcess()->HasSwitch(switches::kShowPaintRects); |
1058 if (!kPaintBorder) | 1058 if (!kPaintBorder) |
1059 return; | 1059 return; |
1060 | 1060 |
(...skipping 186 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1247 } | 1247 } |
1248 | 1248 |
1249 // Calculate filtered time per frame: | 1249 // Calculate filtered time per frame: |
1250 float frame_time_elapsed = static_cast<float>(delay.InSecondsF()); | 1250 float frame_time_elapsed = static_cast<float>(delay.InSecondsF()); |
1251 filtered_time_per_frame_ = | 1251 filtered_time_per_frame_ = |
1252 0.9f * filtered_time_per_frame_ + 0.1f * frame_time_elapsed; | 1252 0.9f * filtered_time_per_frame_ + 0.1f * frame_time_elapsed; |
1253 } | 1253 } |
1254 last_do_deferred_update_time_ = frame_begin_ticks; | 1254 last_do_deferred_update_time_ = frame_begin_ticks; |
1255 | 1255 |
1256 if (!is_accelerated_compositing_active_) { | 1256 if (!is_accelerated_compositing_active_) { |
1257 software_stats_.animation_frame_count++; | 1257 software_stats_.main_stats.animation_frame_count++; |
1258 software_stats_.screen_frame_count++; | 1258 software_stats_.main_stats.screen_frame_count++; |
1259 } | 1259 } |
1260 | 1260 |
1261 // OK, save the pending update to a local since painting may cause more | 1261 // OK, save the pending update to a local since painting may cause more |
1262 // invalidation. Some WebCore rendering objects only layout when painted. | 1262 // invalidation. Some WebCore rendering objects only layout when painted. |
1263 PaintAggregator::PendingUpdate update; | 1263 PaintAggregator::PendingUpdate update; |
1264 paint_aggregator_.PopPendingUpdate(&update); | 1264 paint_aggregator_.PopPendingUpdate(&update); |
1265 | 1265 |
1266 gfx::Rect scroll_damage = update.GetScrollDamage(); | 1266 gfx::Rect scroll_damage = update.GetScrollDamage(); |
1267 gfx::Rect bounds = gfx::UnionRects(update.GetPaintBounds(), scroll_damage); | 1267 gfx::Rect bounds = gfx::UnionRects(update.GetPaintBounds(), scroll_damage); |
1268 | 1268 |
(...skipping 1160 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2429 break; | 2429 break; |
2430 } | 2430 } |
2431 } | 2431 } |
2432 } | 2432 } |
2433 | 2433 |
2434 void RenderWidget::GetRenderingStats( | 2434 void RenderWidget::GetRenderingStats( |
2435 WebKit::WebRenderingStatsImpl& stats) const { | 2435 WebKit::WebRenderingStatsImpl& stats) const { |
2436 if (compositor_) | 2436 if (compositor_) |
2437 compositor_->GetRenderingStats(&stats.rendering_stats); | 2437 compositor_->GetRenderingStats(&stats.rendering_stats); |
2438 | 2438 |
2439 stats.rendering_stats.animation_frame_count += | 2439 stats.rendering_stats.main_stats.animation_frame_count += |
2440 software_stats_.animation_frame_count; | 2440 software_stats_.main_stats.animation_frame_count; |
2441 stats.rendering_stats.screen_frame_count += | 2441 stats.rendering_stats.main_stats.screen_frame_count += |
2442 software_stats_.screen_frame_count; | 2442 software_stats_.main_stats.screen_frame_count; |
2443 stats.rendering_stats.total_paint_time += | 2443 stats.rendering_stats.main_stats.paint_time += |
2444 software_stats_.total_paint_time; | 2444 software_stats_.main_stats.paint_time; |
2445 stats.rendering_stats.total_pixels_painted += | 2445 stats.rendering_stats.main_stats.painted_pixel_count += |
2446 software_stats_.total_pixels_painted; | 2446 software_stats_.main_stats.painted_pixel_count; |
2447 } | 2447 } |
2448 | 2448 |
2449 bool RenderWidget::GetGpuRenderingStats(GpuRenderingStats* stats) const { | 2449 bool RenderWidget::GetGpuRenderingStats(GpuRenderingStats* stats) const { |
2450 GpuChannelHost* gpu_channel = RenderThreadImpl::current()->GetGpuChannel(); | 2450 GpuChannelHost* gpu_channel = RenderThreadImpl::current()->GetGpuChannel(); |
2451 if (!gpu_channel) | 2451 if (!gpu_channel) |
2452 return false; | 2452 return false; |
2453 | 2453 |
2454 return gpu_channel->CollectRenderingStatsForSurface(surface_id(), stats); | 2454 return gpu_channel->CollectRenderingStatsForSurface(surface_id(), stats); |
2455 } | 2455 } |
2456 | 2456 |
(...skipping 65 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2522 | 2522 |
2523 if (!context->InitializeWithDefaultBufferSizes( | 2523 if (!context->InitializeWithDefaultBufferSizes( |
2524 attributes, | 2524 attributes, |
2525 false /* bind generates resources */, | 2525 false /* bind generates resources */, |
2526 CAUSE_FOR_GPU_LAUNCH_WEBGRAPHICSCONTEXT3DCOMMANDBUFFERIMPL_INITIALIZE)
) | 2526 CAUSE_FOR_GPU_LAUNCH_WEBGRAPHICSCONTEXT3DCOMMANDBUFFERIMPL_INITIALIZE)
) |
2527 return NULL; | 2527 return NULL; |
2528 return context.release(); | 2528 return context.release(); |
2529 } | 2529 } |
2530 | 2530 |
2531 } // namespace content | 2531 } // namespace content |
OLD | NEW |