| 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 260 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 484 // Create the render passes in dependency order. | 484 // Create the render passes in dependency order. |
| 485 for (int surfaceIndex = frame.renderSurfaceLayerList->size() - 1; surfaceInd
ex >= 0 ; --surfaceIndex) { | 485 for (int surfaceIndex = frame.renderSurfaceLayerList->size() - 1; surfaceInd
ex >= 0 ; --surfaceIndex) { |
| 486 LayerImpl* renderSurfaceLayer = (*frame.renderSurfaceLayerList)[surfaceI
ndex]; | 486 LayerImpl* renderSurfaceLayer = (*frame.renderSurfaceLayerList)[surfaceI
ndex]; |
| 487 renderSurfaceLayer->renderSurface()->appendRenderPasses(frame); | 487 renderSurfaceLayer->renderSurface()->appendRenderPasses(frame); |
| 488 } | 488 } |
| 489 | 489 |
| 490 bool recordMetricsForFrame = m_settings.showOverdrawInTracing && base::debug
::TraceLog::GetInstance() && base::debug::TraceLog::GetInstance()->IsEnabled(); | 490 bool recordMetricsForFrame = m_settings.showOverdrawInTracing && base::debug
::TraceLog::GetInstance() && base::debug::TraceLog::GetInstance()->IsEnabled(); |
| 491 OcclusionTrackerImpl occlusionTracker(m_rootLayerImpl->renderSurface()->cont
entRect(), recordMetricsForFrame); | 491 OcclusionTrackerImpl occlusionTracker(m_rootLayerImpl->renderSurface()->cont
entRect(), recordMetricsForFrame); |
| 492 occlusionTracker.setMinimumTrackingSize(m_settings.minimumOcclusionTrackingS
ize); | 492 occlusionTracker.setMinimumTrackingSize(m_settings.minimumOcclusionTrackingS
ize); |
| 493 | 493 |
| 494 if (settings().showOccludingRects) | 494 if (m_debugState.showOccludingRects) |
| 495 occlusionTracker.setOccludingScreenSpaceRectsContainer(&frame.occludingS
creenSpaceRects); | 495 occlusionTracker.setOccludingScreenSpaceRectsContainer(&frame.occludingS
creenSpaceRects); |
| 496 if (settings().showNonOccludingRects) | 496 if (m_debugState.showNonOccludingRects) |
| 497 occlusionTracker.setNonOccludingScreenSpaceRectsContainer(&frame.nonOccl
udingScreenSpaceRects); | 497 occlusionTracker.setNonOccludingScreenSpaceRectsContainer(&frame.nonOccl
udingScreenSpaceRects); |
| 498 | 498 |
| 499 // Add quads to the Render passes in FrontToBack order to allow for testing
occlusion and performing culling during the tree walk. | 499 // Add quads to the Render passes in FrontToBack order to allow for testing
occlusion and performing culling during the tree walk. |
| 500 typedef LayerIterator<LayerImpl, std::vector<LayerImpl*>, RenderSurfaceImpl,
LayerIteratorActions::FrontToBack> LayerIteratorType; | 500 typedef LayerIterator<LayerImpl, std::vector<LayerImpl*>, RenderSurfaceImpl,
LayerIteratorActions::FrontToBack> LayerIteratorType; |
| 501 | 501 |
| 502 // Typically when we are missing a texture and use a checkerboard quad, we s
till draw the frame. However when the layer being | 502 // Typically when we are missing a texture and use a checkerboard quad, we s
till draw the frame. However when the layer being |
| 503 // checkerboarded is moving due to an impl-animation, we drop the frame to a
void flashing due to the texture suddenly appearing | 503 // checkerboarded is moving due to an impl-animation, we drop the frame to a
void flashing due to the texture suddenly appearing |
| 504 // in the future. | 504 // in the future. |
| 505 bool drawFrame = true; | 505 bool drawFrame = true; |
| 506 | 506 |
| (...skipping 286 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 793 { | 793 { |
| 794 TRACE_EVENT0("cc", "LayerTreeHostImpl::drawLayers"); | 794 TRACE_EVENT0("cc", "LayerTreeHostImpl::drawLayers"); |
| 795 DCHECK(canDraw()); | 795 DCHECK(canDraw()); |
| 796 DCHECK(!frame.renderPasses.empty()); | 796 DCHECK(!frame.renderPasses.empty()); |
| 797 | 797 |
| 798 // FIXME: use the frame begin time from the overall compositor scheduler. | 798 // FIXME: use the frame begin time from the overall compositor scheduler. |
| 799 // This value is currently inaccessible because it is up in Chromium's | 799 // This value is currently inaccessible because it is up in Chromium's |
| 800 // RenderWidget. | 800 // RenderWidget. |
| 801 m_fpsCounter->markBeginningOfFrame(base::TimeTicks::Now()); | 801 m_fpsCounter->markBeginningOfFrame(base::TimeTicks::Now()); |
| 802 | 802 |
| 803 if (m_settings.showDebugRects()) | 803 if (m_debugState.showHudRects()) |
| 804 m_debugRectHistory->saveDebugRectsForCurrentFrame(m_rootLayerImpl.get(),
*frame.renderSurfaceLayerList, frame.occludingScreenSpaceRects, frame.nonOcclud
ingScreenSpaceRects, settings()); | 804 m_debugRectHistory->saveDebugRectsForCurrentFrame(m_rootLayerImpl.get(),
*frame.renderSurfaceLayerList, frame.occludingScreenSpaceRects, frame.nonOcclud
ingScreenSpaceRects, m_debugState); |
| 805 | 805 |
| 806 // Because the contents of the HUD depend on everything else in the frame, t
he contents | 806 // Because the contents of the HUD depend on everything else in the frame, t
he contents |
| 807 // of its texture are updated as the last thing before the frame is drawn. | 807 // of its texture are updated as the last thing before the frame is drawn. |
| 808 if (m_hudLayerImpl) | 808 if (m_hudLayerImpl) |
| 809 m_hudLayerImpl->updateHudTexture(m_resourceProvider.get()); | 809 m_hudLayerImpl->updateHudTexture(m_resourceProvider.get()); |
| 810 | 810 |
| 811 m_renderer->drawFrame(frame.renderPasses, frame.renderPassesById); | 811 m_renderer->drawFrame(frame.renderPasses, frame.renderPassesById); |
| 812 | 812 |
| 813 // Once a RenderPass has been drawn, its damage should be cleared in | 813 // Once a RenderPass has been drawn, its damage should be cleared in |
| 814 // case the RenderPass will be reused next frame. | 814 // case the RenderPass will be reused next frame. |
| (...skipping 783 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1598 ScrollbarAnimationController* scrollbarController = layer->scrollbarAnimatio
nController(); | 1598 ScrollbarAnimationController* scrollbarController = layer->scrollbarAnimatio
nController(); |
| 1599 double monotonicTime = (time - base::TimeTicks()).InSecondsF(); | 1599 double monotonicTime = (time - base::TimeTicks()).InSecondsF(); |
| 1600 if (scrollbarController && scrollbarController->animate(monotonicTime)) | 1600 if (scrollbarController && scrollbarController->animate(monotonicTime)) |
| 1601 m_client->setNeedsRedrawOnImplThread(); | 1601 m_client->setNeedsRedrawOnImplThread(); |
| 1602 | 1602 |
| 1603 for (size_t i = 0; i < layer->children().size(); ++i) | 1603 for (size_t i = 0; i < layer->children().size(); ++i) |
| 1604 animateScrollbarsRecursive(layer->children()[i], time); | 1604 animateScrollbarsRecursive(layer->children()[i], time); |
| 1605 } | 1605 } |
| 1606 | 1606 |
| 1607 } // namespace cc | 1607 } // namespace cc |
| OLD | NEW |