| 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/gl_renderer.h" | 16 #include "cc/gl_renderer.h" |
| 18 #include "cc/heads_up_display_layer_impl.h" | 17 #include "cc/heads_up_display_layer_impl.h" |
| 19 #include "cc/layer_iterator.h" | 18 #include "cc/layer_iterator.h" |
| 20 #include "cc/layer_tree_host.h" | 19 #include "cc/layer_tree_host.h" |
| 21 #include "cc/layer_tree_host_common.h" | 20 #include "cc/layer_tree_host_common.h" |
| 22 #include "cc/math_util.h" | 21 #include "cc/math_util.h" |
| 23 #include "cc/overdraw_metrics.h" | 22 #include "cc/overdraw_metrics.h" |
| 24 #include "cc/page_scale_animation.h" | 23 #include "cc/page_scale_animation.h" |
| 25 #include "cc/prioritized_resource_manager.h" | 24 #include "cc/prioritized_resource_manager.h" |
| (...skipping 178 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 204 LayerTreeHostImpl::LayerTreeHostImpl(const LayerTreeSettings& settings, LayerTre
eHostImplClient* client, Proxy* proxy) | 203 LayerTreeHostImpl::LayerTreeHostImpl(const LayerTreeSettings& settings, LayerTre
eHostImplClient* client, Proxy* proxy) |
| 205 : m_client(client) | 204 : m_client(client) |
| 206 , m_proxy(proxy) | 205 , m_proxy(proxy) |
| 207 , m_sourceFrameNumber(-1) | 206 , m_sourceFrameNumber(-1) |
| 208 , m_rootScrollLayerImpl(0) | 207 , m_rootScrollLayerImpl(0) |
| 209 , m_currentlyScrollingLayerImpl(0) | 208 , m_currentlyScrollingLayerImpl(0) |
| 210 , m_hudLayerImpl(0) | 209 , m_hudLayerImpl(0) |
| 211 , m_scrollingLayerIdFromPreviousTree(-1) | 210 , m_scrollingLayerIdFromPreviousTree(-1) |
| 212 , m_scrollDeltaIsInViewportSpace(false) | 211 , m_scrollDeltaIsInViewportSpace(false) |
| 213 , m_settings(settings) | 212 , m_settings(settings) |
| 213 , m_debugState(settings.initialDebugState) |
| 214 , m_deviceScaleFactor(1) | 214 , m_deviceScaleFactor(1) |
| 215 , m_visible(true) | 215 , m_visible(true) |
| 216 , m_contentsTexturesPurged(false) | 216 , m_contentsTexturesPurged(false) |
| 217 , m_managedMemoryPolicy(PrioritizedResourceManager::defaultMemoryAllocationL
imit(), | 217 , m_managedMemoryPolicy(PrioritizedResourceManager::defaultMemoryAllocationL
imit(), |
| 218 PriorityCalculator::allowEverythingCutoff(), | 218 PriorityCalculator::allowEverythingCutoff(), |
| 219 0, | 219 0, |
| 220 PriorityCalculator::allowNothingCutoff()) | 220 PriorityCalculator::allowNothingCutoff()) |
| 221 , m_backgroundColor(0) | 221 , m_backgroundColor(0) |
| 222 , m_hasTransparentBackground(false) | 222 , m_hasTransparentBackground(false) |
| 223 , m_needsAnimateLayers(false) | 223 , m_needsAnimateLayers(false) |
| (...skipping 266 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 490 // Create the render passes in dependency order. | 490 // Create the render passes in dependency order. |
| 491 for (int surfaceIndex = frame.renderSurfaceLayerList->size() - 1; surfaceInd
ex >= 0 ; --surfaceIndex) { | 491 for (int surfaceIndex = frame.renderSurfaceLayerList->size() - 1; surfaceInd
ex >= 0 ; --surfaceIndex) { |
| 492 LayerImpl* renderSurfaceLayer = (*frame.renderSurfaceLayerList)[surfaceI
ndex]; | 492 LayerImpl* renderSurfaceLayer = (*frame.renderSurfaceLayerList)[surfaceI
ndex]; |
| 493 renderSurfaceLayer->renderSurface()->appendRenderPasses(frame); | 493 renderSurfaceLayer->renderSurface()->appendRenderPasses(frame); |
| 494 } | 494 } |
| 495 | 495 |
| 496 bool recordMetricsForFrame = m_settings.showOverdrawInTracing && base::debug
::TraceLog::GetInstance() && base::debug::TraceLog::GetInstance()->IsEnabled(); | 496 bool recordMetricsForFrame = m_settings.showOverdrawInTracing && base::debug
::TraceLog::GetInstance() && base::debug::TraceLog::GetInstance()->IsEnabled(); |
| 497 OcclusionTrackerImpl occlusionTracker(m_rootLayerImpl->renderSurface()->cont
entRect(), recordMetricsForFrame); | 497 OcclusionTrackerImpl occlusionTracker(m_rootLayerImpl->renderSurface()->cont
entRect(), recordMetricsForFrame); |
| 498 occlusionTracker.setMinimumTrackingSize(m_settings.minimumOcclusionTrackingS
ize); | 498 occlusionTracker.setMinimumTrackingSize(m_settings.minimumOcclusionTrackingS
ize); |
| 499 | 499 |
| 500 if (settings().showOccludingRects) | 500 if (m_debugState.showOccludingRects) |
| 501 occlusionTracker.setOccludingScreenSpaceRectsContainer(&frame.occludingS
creenSpaceRects); | 501 occlusionTracker.setOccludingScreenSpaceRectsContainer(&frame.occludingS
creenSpaceRects); |
| 502 if (settings().showNonOccludingRects) | 502 if (m_debugState.showNonOccludingRects) |
| 503 occlusionTracker.setNonOccludingScreenSpaceRectsContainer(&frame.nonOccl
udingScreenSpaceRects); | 503 occlusionTracker.setNonOccludingScreenSpaceRectsContainer(&frame.nonOccl
udingScreenSpaceRects); |
| 504 | 504 |
| 505 // Add quads to the Render passes in FrontToBack order to allow for testing
occlusion and performing culling during the tree walk. | 505 // Add quads to the Render passes in FrontToBack order to allow for testing
occlusion and performing culling during the tree walk. |
| 506 typedef LayerIterator<LayerImpl, std::vector<LayerImpl*>, RenderSurfaceImpl,
LayerIteratorActions::FrontToBack> LayerIteratorType; | 506 typedef LayerIterator<LayerImpl, std::vector<LayerImpl*>, RenderSurfaceImpl,
LayerIteratorActions::FrontToBack> LayerIteratorType; |
| 507 | 507 |
| 508 // Typically when we are missing a texture and use a checkerboard quad, we s
till draw the frame. However when the layer being | 508 // Typically when we are missing a texture and use a checkerboard quad, we s
till draw the frame. However when the layer being |
| 509 // checkerboarded is moving due to an impl-animation, we drop the frame to a
void flashing due to the texture suddenly appearing | 509 // checkerboarded is moving due to an impl-animation, we drop the frame to a
void flashing due to the texture suddenly appearing |
| 510 // in the future. | 510 // in the future. |
| 511 bool drawFrame = true; | 511 bool drawFrame = true; |
| 512 | 512 |
| (...skipping 307 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 820 { | 820 { |
| 821 TRACE_EVENT0("cc", "LayerTreeHostImpl::drawLayers"); | 821 TRACE_EVENT0("cc", "LayerTreeHostImpl::drawLayers"); |
| 822 DCHECK(canDraw()); | 822 DCHECK(canDraw()); |
| 823 DCHECK(!frame.renderPasses.empty()); | 823 DCHECK(!frame.renderPasses.empty()); |
| 824 | 824 |
| 825 // FIXME: use the frame begin time from the overall compositor scheduler. | 825 // FIXME: use the frame begin time from the overall compositor scheduler. |
| 826 // This value is currently inaccessible because it is up in Chromium's | 826 // This value is currently inaccessible because it is up in Chromium's |
| 827 // RenderWidget. | 827 // RenderWidget. |
| 828 m_fpsCounter->markBeginningOfFrame(base::TimeTicks::Now()); | 828 m_fpsCounter->markBeginningOfFrame(base::TimeTicks::Now()); |
| 829 | 829 |
| 830 if (m_settings.showDebugRects()) | 830 if (m_debugState.showHudRects()) |
| 831 m_debugRectHistory->saveDebugRectsForCurrentFrame(m_rootLayerImpl.get(),
*frame.renderSurfaceLayerList, frame.occludingScreenSpaceRects, frame.nonOcclud
ingScreenSpaceRects, settings()); | 831 m_debugRectHistory->saveDebugRectsForCurrentFrame(m_rootLayerImpl.get(),
*frame.renderSurfaceLayerList, frame.occludingScreenSpaceRects, frame.nonOcclud
ingScreenSpaceRects, m_debugState); |
| 832 | 832 |
| 833 // Because the contents of the HUD depend on everything else in the frame, t
he contents | 833 // Because the contents of the HUD depend on everything else in the frame, t
he contents |
| 834 // of its texture are updated as the last thing before the frame is drawn. | 834 // of its texture are updated as the last thing before the frame is drawn. |
| 835 if (m_hudLayerImpl) | 835 if (m_hudLayerImpl) |
| 836 m_hudLayerImpl->updateHudTexture(m_resourceProvider.get()); | 836 m_hudLayerImpl->updateHudTexture(m_resourceProvider.get()); |
| 837 | 837 |
| 838 m_renderer->drawFrame(frame.renderPasses, frame.renderPassesById); | 838 m_renderer->drawFrame(frame.renderPasses, frame.renderPassesById); |
| 839 | 839 |
| 840 // Once a RenderPass has been drawn, its damage should be cleared in | 840 // Once a RenderPass has been drawn, its damage should be cleared in |
| 841 // case the RenderPass will be reused next frame. | 841 // case the RenderPass will be reused next frame. |
| (...skipping 787 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1629 ScrollbarAnimationController* scrollbarController = layer->scrollbarAnimatio
nController(); | 1629 ScrollbarAnimationController* scrollbarController = layer->scrollbarAnimatio
nController(); |
| 1630 double monotonicTime = (time - base::TimeTicks()).InSecondsF(); | 1630 double monotonicTime = (time - base::TimeTicks()).InSecondsF(); |
| 1631 if (scrollbarController && scrollbarController->animate(monotonicTime)) | 1631 if (scrollbarController && scrollbarController->animate(monotonicTime)) |
| 1632 m_client->setNeedsRedrawOnImplThread(); | 1632 m_client->setNeedsRedrawOnImplThread(); |
| 1633 | 1633 |
| 1634 for (size_t i = 0; i < layer->children().size(); ++i) | 1634 for (size_t i = 0; i < layer->children().size(); ++i) |
| 1635 animateScrollbarsRecursive(layer->children()[i], time); | 1635 animateScrollbarsRecursive(layer->children()[i], time); |
| 1636 } | 1636 } |
| 1637 | 1637 |
| 1638 } // namespace cc | 1638 } // namespace cc |
| OLD | NEW |