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 "cc/layer_tree_host_impl.h" | 5 #include "cc/layer_tree_host_impl.h" |
6 | 6 |
7 #include <algorithm> | 7 #include <algorithm> |
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" | |
16 #include "cc/frame_rate_counter.h" | 15 #include "cc/frame_rate_counter.h" |
17 #include "cc/geometry.h" | 16 #include "cc/geometry.h" |
18 #include "cc/gl_renderer.h" | 17 #include "cc/gl_renderer.h" |
19 #include "cc/heads_up_display_layer_impl.h" | 18 #include "cc/heads_up_display_layer_impl.h" |
20 #include "cc/layer_iterator.h" | 19 #include "cc/layer_iterator.h" |
21 #include "cc/layer_tree_host.h" | 20 #include "cc/layer_tree_host.h" |
22 #include "cc/layer_tree_host_common.h" | 21 #include "cc/layer_tree_host_common.h" |
23 #include "cc/math_util.h" | 22 #include "cc/math_util.h" |
24 #include "cc/overdraw_metrics.h" | 23 #include "cc/overdraw_metrics.h" |
25 #include "cc/page_scale_animation.h" | 24 #include "cc/page_scale_animation.h" |
(...skipping 369 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
395 // Create the render passes in dependency order. | 394 // Create the render passes in dependency order. |
396 for (int surfaceIndex = frame.renderSurfaceLayerList->size() - 1; surfaceInd ex >= 0 ; --surfaceIndex) { | 395 for (int surfaceIndex = frame.renderSurfaceLayerList->size() - 1; surfaceInd ex >= 0 ; --surfaceIndex) { |
397 LayerImpl* renderSurfaceLayer = (*frame.renderSurfaceLayerList)[surfaceI ndex]; | 396 LayerImpl* renderSurfaceLayer = (*frame.renderSurfaceLayerList)[surfaceI ndex]; |
398 renderSurfaceLayer->renderSurface()->appendRenderPasses(frame); | 397 renderSurfaceLayer->renderSurface()->appendRenderPasses(frame); |
399 } | 398 } |
400 | 399 |
401 bool recordMetricsForFrame = m_settings.showOverdrawInTracing && base::debug ::TraceLog::GetInstance() && base::debug::TraceLog::GetInstance()->IsEnabled(); | 400 bool recordMetricsForFrame = m_settings.showOverdrawInTracing && base::debug ::TraceLog::GetInstance() && base::debug::TraceLog::GetInstance()->IsEnabled(); |
402 OcclusionTrackerImpl occlusionTracker(m_rootLayerImpl->renderSurface()->cont entRect(), recordMetricsForFrame); | 401 OcclusionTrackerImpl occlusionTracker(m_rootLayerImpl->renderSurface()->cont entRect(), recordMetricsForFrame); |
403 occlusionTracker.setMinimumTrackingSize(m_settings.minimumOcclusionTrackingS ize); | 402 occlusionTracker.setMinimumTrackingSize(m_settings.minimumOcclusionTrackingS ize); |
404 | 403 |
405 if (settings().showOccludingRects) | 404 if (m_hudLayerImpl) { |
406 occlusionTracker.setOccludingScreenSpaceRectsContainer(&frame.occludingS creenSpaceRects); | 405 if (m_hudLayerImpl->settings().showOccludingRects) |
407 if (settings().showNonOccludingRects) | 406 occlusionTracker.setOccludingScreenSpaceRectsContainer(&frame.occlud ingScreenSpaceRects); |
408 occlusionTracker.setNonOccludingScreenSpaceRectsContainer(&frame.nonOccl udingScreenSpaceRects); | 407 if (m_hudLayerImpl->settings().showNonOccludingRects) |
408 occlusionTracker.setNonOccludingScreenSpaceRectsContainer(&frame.non OccludingScreenSpaceRects); | |
409 } | |
409 | 410 |
410 // Add quads to the Render passes in FrontToBack order to allow for testing occlusion and performing culling during the tree walk. | 411 // Add quads to the Render passes in FrontToBack order to allow for testing occlusion and performing culling during the tree walk. |
411 typedef LayerIterator<LayerImpl, std::vector<LayerImpl*>, RenderSurfaceImpl, LayerIteratorActions::FrontToBack> LayerIteratorType; | 412 typedef LayerIterator<LayerImpl, std::vector<LayerImpl*>, RenderSurfaceImpl, LayerIteratorActions::FrontToBack> LayerIteratorType; |
412 | 413 |
413 // Typically when we are missing a texture and use a checkerboard quad, we s till draw the frame. However when the layer being | 414 // Typically when we are missing a texture and use a checkerboard quad, we s till draw the frame. However when the layer being |
414 // checkerboarded is moving due to an impl-animation, we drop the frame to a void flashing due to the texture suddenly appearing | 415 // checkerboarded is moving due to an impl-animation, we drop the frame to a void flashing due to the texture suddenly appearing |
415 // in the future. | 416 // in the future. |
416 bool drawFrame = true; | 417 bool drawFrame = true; |
417 | 418 |
418 LayerIteratorType end = LayerIteratorType::end(frame.renderSurfaceLayerList) ; | 419 LayerIteratorType end = LayerIteratorType::end(frame.renderSurfaceLayerList) ; |
(...skipping 285 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
704 { | 705 { |
705 TRACE_EVENT0("cc", "LayerTreeHostImpl::drawLayers"); | 706 TRACE_EVENT0("cc", "LayerTreeHostImpl::drawLayers"); |
706 DCHECK(canDraw()); | 707 DCHECK(canDraw()); |
707 DCHECK(!frame.renderPasses.empty()); | 708 DCHECK(!frame.renderPasses.empty()); |
708 | 709 |
709 // FIXME: use the frame begin time from the overall compositor scheduler. | 710 // FIXME: use the frame begin time from the overall compositor scheduler. |
710 // This value is currently inaccessible because it is up in Chromium's | 711 // This value is currently inaccessible because it is up in Chromium's |
711 // RenderWidget. | 712 // RenderWidget. |
712 m_fpsCounter->markBeginningOfFrame(base::TimeTicks::Now()); | 713 m_fpsCounter->markBeginningOfFrame(base::TimeTicks::Now()); |
713 | 714 |
714 if (m_settings.showDebugRects()) | |
715 m_debugRectHistory->saveDebugRectsForCurrentFrame(m_rootLayerImpl.get(), *frame.renderSurfaceLayerList, frame.occludingScreenSpaceRects, frame.nonOcclud ingScreenSpaceRects, settings()); | |
716 | |
717 // Because the contents of the HUD depend on everything else in the frame, t he contents | 715 // Because the contents of the HUD depend on everything else in the frame, t he contents |
718 // of its texture are updated as the last thing before the frame is drawn. | 716 // of its texture are updated as the last thing before the frame is drawn. |
719 if (m_hudLayerImpl) | 717 if (m_hudLayerImpl && m_hudLayerImpl->settings().showDebugInfo()) { |
egraether
2012/11/20 21:30:30
prevent updating when nothing is displayed.
| |
718 if (m_hudLayerImpl->settings().showDebugRects()) | |
719 m_debugRectHistory->saveDebugRectsForCurrentFrame(m_rootLayerImpl.ge t(), *frame.renderSurfaceLayerList, frame.occludingScreenSpaceRects, frame.nonOc cludingScreenSpaceRects, m_hudLayerImpl->settings()); | |
720 m_hudLayerImpl->updateHudTexture(m_resourceProvider.get()); | 720 m_hudLayerImpl->updateHudTexture(m_resourceProvider.get()); |
721 } | |
721 | 722 |
722 m_renderer->drawFrame(frame.renderPasses, frame.renderPassesById); | 723 m_renderer->drawFrame(frame.renderPasses, frame.renderPassesById); |
723 | 724 |
724 // Once a RenderPass has been drawn, its damage should be cleared in | 725 // Once a RenderPass has been drawn, its damage should be cleared in |
725 // case the RenderPass will be reused next frame. | 726 // case the RenderPass will be reused next frame. |
726 for (unsigned int i = 0; i < frame.renderPasses.size(); i++) | 727 for (unsigned int i = 0; i < frame.renderPasses.size(); i++) |
727 frame.renderPasses[i]->setDamageRect(gfx::RectF()); | 728 frame.renderPasses[i]->setDamageRect(gfx::RectF()); |
728 | 729 |
729 // The next frame should start by assuming nothing has changed, and changes are noted as they occur. | 730 // The next frame should start by assuming nothing has changed, and changes are noted as they occur. |
730 for (unsigned int i = 0; i < frame.renderSurfaceLayerList->size(); i++) | 731 for (unsigned int i = 0; i < frame.renderSurfaceLayerList->size(); i++) |
(...skipping 778 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
1509 ScrollbarAnimationController* scrollbarController = layer->scrollbarAnimatio nController(); | 1510 ScrollbarAnimationController* scrollbarController = layer->scrollbarAnimatio nController(); |
1510 double monotonicTime = (time - base::TimeTicks()).InSecondsF(); | 1511 double monotonicTime = (time - base::TimeTicks()).InSecondsF(); |
1511 if (scrollbarController && scrollbarController->animate(monotonicTime)) | 1512 if (scrollbarController && scrollbarController->animate(monotonicTime)) |
1512 m_client->setNeedsRedrawOnImplThread(); | 1513 m_client->setNeedsRedrawOnImplThread(); |
1513 | 1514 |
1514 for (size_t i = 0; i < layer->children().size(); ++i) | 1515 for (size_t i = 0; i < layer->children().size(); ++i) |
1515 animateScrollbarsRecursive(layer->children()[i], time); | 1516 animateScrollbarsRecursive(layer->children()[i], time); |
1516 } | 1517 } |
1517 | 1518 |
1518 } // namespace cc | 1519 } // namespace cc |
OLD | NEW |