| OLD | NEW |
| 1 // Copyright 2011 The Chromium Authors. All rights reserved. | 1 // Copyright 2011 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 "config.h" | 5 #include "config.h" |
| 6 | 6 |
| 7 #include "cc/layer_tree_host_impl.h" | 7 #include "cc/layer_tree_host_impl.h" |
| 8 | 8 |
| 9 #include "base/basictypes.h" | 9 #include "base/basictypes.h" |
| 10 #include "base/debug/trace_event.h" | 10 #include "base/debug/trace_event.h" |
| 11 #include "cc/append_quads_data.h" | 11 #include "cc/append_quads_data.h" |
| 12 #include "cc/damage_tracker.h" | 12 #include "cc/damage_tracker.h" |
| 13 #include "cc/debug_rect_history.h" | 13 #include "cc/debug_rect_history.h" |
| 14 #include "cc/delay_based_time_source.h" | 14 #include "cc/delay_based_time_source.h" |
| 15 #include "cc/font_atlas.h" | 15 #include "cc/font_atlas.h" |
| 16 #include "cc/frame_rate_counter.h" | 16 #include "cc/frame_rate_counter.h" |
| 17 #include "cc/gl_renderer.h" | 17 #include "cc/gl_renderer.h" |
| 18 #include "cc/heads_up_display_layer_impl.h" | 18 #include "cc/heads_up_display_layer_impl.h" |
| 19 #include "cc/layer_iterator.h" | 19 #include "cc/layer_iterator.h" |
| 20 #include "cc/layer_tree_host.h" | 20 #include "cc/layer_tree_host.h" |
| 21 #include "cc/layer_tree_host_common.h" | 21 #include "cc/layer_tree_host_common.h" |
| 22 #include "cc/math_util.h" | 22 #include "cc/math_util.h" |
| 23 #include "cc/overdraw_metrics.h" | 23 #include "cc/overdraw_metrics.h" |
| 24 #include "cc/page_scale_animation.h" | 24 #include "cc/page_scale_animation.h" |
| 25 #include "cc/prioritized_texture_manager.h" | 25 #include "cc/prioritized_texture_manager.h" |
| 26 #include "cc/render_pass_draw_quad.h" | 26 #include "cc/render_pass_draw_quad.h" |
| 27 #include "cc/rendering_stats.h" | 27 #include "cc/rendering_stats.h" |
| 28 #include "cc/rendering_stats_subscriber.h" |
| 28 #include "cc/scrollbar_animation_controller.h" | 29 #include "cc/scrollbar_animation_controller.h" |
| 29 #include "cc/scrollbar_layer_impl.h" | 30 #include "cc/scrollbar_layer_impl.h" |
| 30 #include "cc/settings.h" | 31 #include "cc/settings.h" |
| 31 #include "cc/single_thread_proxy.h" | 32 #include "cc/single_thread_proxy.h" |
| 32 #include "cc/software_renderer.h" | 33 #include "cc/software_renderer.h" |
| 33 #include "cc/texture_uploader.h" | 34 #include "cc/texture_uploader.h" |
| 34 #include <algorithm> | 35 #include <algorithm> |
| 35 | 36 |
| 36 using WebKit::WebTransformationMatrix; | 37 using WebKit::WebTransformationMatrix; |
| 37 | 38 |
| (...skipping 631 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 669 | 670 |
| 670 void LayerTreeHostImpl::drawLayers(const FrameData& frame) | 671 void LayerTreeHostImpl::drawLayers(const FrameData& frame) |
| 671 { | 672 { |
| 672 TRACE_EVENT0("cc", "LayerTreeHostImpl::drawLayers"); | 673 TRACE_EVENT0("cc", "LayerTreeHostImpl::drawLayers"); |
| 673 DCHECK(canDraw()); | 674 DCHECK(canDraw()); |
| 674 DCHECK(!frame.renderPasses.empty()); | 675 DCHECK(!frame.renderPasses.empty()); |
| 675 | 676 |
| 676 // FIXME: use the frame begin time from the overall compositor scheduler. | 677 // FIXME: use the frame begin time from the overall compositor scheduler. |
| 677 // This value is currently inaccessible because it is up in Chromium's | 678 // This value is currently inaccessible because it is up in Chromium's |
| 678 // RenderWidget. | 679 // RenderWidget. |
| 679 m_fpsCounter->markBeginningOfFrame(base::TimeTicks::Now()); | 680 base::TimeTicks now = base::TimeTicks::Now(); |
| 681 m_fpsCounter->markBeginningOfFrame(now); |
| 682 if (m_renderingStatsSubscriber) |
| 683 m_renderingStatsSubscriber->markBeginningOfFrame(now); |
| 680 | 684 |
| 681 if (m_settings.showDebugRects()) | 685 if (m_settings.showDebugRects()) |
| 682 m_debugRectHistory->saveDebugRectsForCurrentFrame(m_rootLayerImpl.get(),
*frame.renderSurfaceLayerList, frame.occludingScreenSpaceRects, settings()); | 686 m_debugRectHistory->saveDebugRectsForCurrentFrame(m_rootLayerImpl.get(),
*frame.renderSurfaceLayerList, frame.occludingScreenSpaceRects, settings()); |
| 683 | 687 |
| 684 // Because the contents of the HUD depend on everything else in the frame, t
he contents | 688 // Because the contents of the HUD depend on everything else in the frame, t
he contents |
| 685 // of its texture are updated as the last thing before the frame is drawn. | 689 // of its texture are updated as the last thing before the frame is drawn. |
| 686 if (m_hudLayerImpl) | 690 if (m_hudLayerImpl) |
| 687 m_hudLayerImpl->updateHudTexture(m_resourceProvider.get()); | 691 m_hudLayerImpl->updateHudTexture(m_resourceProvider.get()); |
| 688 | 692 |
| 689 m_renderer->drawFrame(frame.renderPasses, frame.renderPassesById); | 693 m_renderer->drawFrame(frame.renderPasses, frame.renderPassesById); |
| (...skipping 775 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1465 } | 1469 } |
| 1466 | 1470 |
| 1467 void LayerTreeHostImpl::renderingStats(RenderingStats* stats) const | 1471 void LayerTreeHostImpl::renderingStats(RenderingStats* stats) const |
| 1468 { | 1472 { |
| 1469 stats->numFramesSentToScreen = fpsCounter()->currentFrameNumber(); | 1473 stats->numFramesSentToScreen = fpsCounter()->currentFrameNumber(); |
| 1470 stats->droppedFrameCount = fpsCounter()->droppedFrameCount(); | 1474 stats->droppedFrameCount = fpsCounter()->droppedFrameCount(); |
| 1471 stats->numImplThreadScrolls = m_numImplThreadScrolls; | 1475 stats->numImplThreadScrolls = m_numImplThreadScrolls; |
| 1472 stats->numMainThreadScrolls = m_numMainThreadScrolls; | 1476 stats->numMainThreadScrolls = m_numMainThreadScrolls; |
| 1473 } | 1477 } |
| 1474 | 1478 |
| 1479 void LayerTreeHostImpl::startRecordingRenderingStats() |
| 1480 { |
| 1481 m_renderingStatsSubscriber = RenderingStatsSubscriber::create(); |
| 1482 } |
| 1483 |
| 1484 void LayerTreeHostImpl::stopRecordingRenderingStats(RenderingStats* stats) |
| 1485 { |
| 1486 double frame_rate_average = 0.0; |
| 1487 double frame_rate_standard_deviation = 0.0; |
| 1488 |
| 1489 m_renderingStatsSubscriber->getFPSAndStandardDeviation( |
| 1490 frame_rate_average, |
| 1491 frame_rate_standard_deviation); |
| 1492 |
| 1493 stats->frameRateAverage = frame_rate_average; |
| 1494 stats->frameRateStandardDeviation = frame_rate_standard_deviation; |
| 1495 |
| 1496 m_renderingStatsSubscriber.reset(); |
| 1497 } |
| 1498 |
| 1475 void LayerTreeHostImpl::animateScrollbars(base::TimeTicks time) | 1499 void LayerTreeHostImpl::animateScrollbars(base::TimeTicks time) |
| 1476 { | 1500 { |
| 1477 animateScrollbarsRecursive(m_rootLayerImpl.get(), time); | 1501 animateScrollbarsRecursive(m_rootLayerImpl.get(), time); |
| 1478 } | 1502 } |
| 1479 | 1503 |
| 1480 void LayerTreeHostImpl::animateScrollbarsRecursive(LayerImpl* layer, base::TimeT
icks time) | 1504 void LayerTreeHostImpl::animateScrollbarsRecursive(LayerImpl* layer, base::TimeT
icks time) |
| 1481 { | 1505 { |
| 1482 if (!layer) | 1506 if (!layer) |
| 1483 return; | 1507 return; |
| 1484 | 1508 |
| 1485 ScrollbarAnimationController* scrollbarController = layer->scrollbarAnimatio
nController(); | 1509 ScrollbarAnimationController* scrollbarController = layer->scrollbarAnimatio
nController(); |
| 1486 double monotonicTime = (time - base::TimeTicks()).InSecondsF(); | 1510 double monotonicTime = (time - base::TimeTicks()).InSecondsF(); |
| 1487 if (scrollbarController && scrollbarController->animate(monotonicTime)) | 1511 if (scrollbarController && scrollbarController->animate(monotonicTime)) |
| 1488 m_client->setNeedsRedrawOnImplThread(); | 1512 m_client->setNeedsRedrawOnImplThread(); |
| 1489 | 1513 |
| 1490 for (size_t i = 0; i < layer->children().size(); ++i) | 1514 for (size_t i = 0; i < layer->children().size(); ++i) |
| 1491 animateScrollbarsRecursive(layer->children()[i], time); | 1515 animateScrollbarsRecursive(layer->children()[i], time); |
| 1492 } | 1516 } |
| 1493 | 1517 |
| 1494 } // namespace cc | 1518 } // namespace cc |
| OLD | NEW |