Chromium Code Reviews| 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 "base/json/json_writer.h" | 11 #include "base/json/json_writer.h" |
| 12 #include "base/metrics/histogram.h" | |
| 12 #include "base/stl_util.h" | 13 #include "base/stl_util.h" |
| 13 #include "cc/append_quads_data.h" | 14 #include "cc/append_quads_data.h" |
| 14 #include "cc/compositor_frame_metadata.h" | 15 #include "cc/compositor_frame_metadata.h" |
| 15 #include "cc/damage_tracker.h" | 16 #include "cc/damage_tracker.h" |
| 16 #include "cc/debug_rect_history.h" | 17 #include "cc/debug_rect_history.h" |
| 17 #include "cc/delay_based_time_source.h" | 18 #include "cc/delay_based_time_source.h" |
| 18 #include "cc/delegating_renderer.h" | 19 #include "cc/delegating_renderer.h" |
| 19 #include "cc/frame_rate_counter.h" | 20 #include "cc/frame_rate_counter.h" |
| 20 #include "cc/gl_renderer.h" | 21 #include "cc/gl_renderer.h" |
| 21 #include "cc/heads_up_display_layer_impl.h" | 22 #include "cc/heads_up_display_layer_impl.h" |
| (...skipping 470 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 492 appendQuadsData.hadOcclusionFromOutsideTargetSurface |= hasOcclu sionFromOutsideTargetSurface; | 493 appendQuadsData.hadOcclusionFromOutsideTargetSurface |= hasOcclu sionFromOutsideTargetSurface; |
| 493 else { | 494 else { |
| 494 DCHECK_EQ(activeTree(), it->layerTreeImpl()); | 495 DCHECK_EQ(activeTree(), it->layerTreeImpl()); |
| 495 it->willDraw(m_resourceProvider.get()); | 496 it->willDraw(m_resourceProvider.get()); |
| 496 frame.willDrawLayers.push_back(*it); | 497 frame.willDrawLayers.push_back(*it); |
| 497 | 498 |
| 498 if (it->hasContributingDelegatedRenderPasses()) { | 499 if (it->hasContributingDelegatedRenderPasses()) { |
| 499 RenderPass::Id contributingRenderPassId = it->firstContribut ingRenderPassId(); | 500 RenderPass::Id contributingRenderPassId = it->firstContribut ingRenderPassId(); |
| 500 while (frame.renderPassesById.find(contributingRenderPassId) != frame.renderPassesById.end()) { | 501 while (frame.renderPassesById.find(contributingRenderPassId) != frame.renderPassesById.end()) { |
| 501 RenderPass* renderPass = frame.renderPassesById[contribu tingRenderPassId]; | 502 RenderPass* renderPass = frame.renderPassesById[contribu tingRenderPassId]; |
| 502 | 503 |
| 503 AppendQuadsData appendQuadsData(renderPass->id); | 504 AppendQuadsData appendQuadsData(renderPass->id); |
| 504 appendQuadsForLayer(renderPass, *it, occlusionTracker, a ppendQuadsData); | 505 appendQuadsForLayer(renderPass, *it, occlusionTracker, a ppendQuadsData); |
| 505 | 506 |
| 506 contributingRenderPassId = it->nextContributingRenderPas sId(contributingRenderPassId); | 507 contributingRenderPassId = it->nextContributingRenderPas sId(contributingRenderPassId); |
| 507 } | 508 } |
| 508 } | 509 } |
| 509 | 510 |
| 510 appendQuadsForLayer(targetRenderPass, *it, occlusionTracker, app endQuadsData); | 511 appendQuadsForLayer(targetRenderPass, *it, occlusionTracker, app endQuadsData); |
| 511 } | 512 } |
| 512 | 513 |
| (...skipping 641 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 1154 // First find out which layer was hit from the saved list of visible layers | 1155 // First find out which layer was hit from the saved list of visible layers |
| 1155 // in the most recent frame. | 1156 // in the most recent frame. |
| 1156 LayerImpl* layerImpl = LayerTreeHostCommon::findLayerThatIsHitByPoint(device ViewportPoint, activeTree()->RenderSurfaceLayerList()); | 1157 LayerImpl* layerImpl = LayerTreeHostCommon::findLayerThatIsHitByPoint(device ViewportPoint, activeTree()->RenderSurfaceLayerList()); |
| 1157 | 1158 |
| 1158 // Walk up the hierarchy and look for a scrollable layer. | 1159 // Walk up the hierarchy and look for a scrollable layer. |
| 1159 LayerImpl* potentiallyScrollingLayerImpl = 0; | 1160 LayerImpl* potentiallyScrollingLayerImpl = 0; |
| 1160 for (; layerImpl; layerImpl = layerImpl->parent()) { | 1161 for (; layerImpl; layerImpl = layerImpl->parent()) { |
| 1161 // The content layer can also block attempts to scroll outside the main thread. | 1162 // The content layer can also block attempts to scroll outside the main thread. |
| 1162 if (layerImpl->tryScroll(deviceViewportPoint, type) == ScrollOnMainThrea d) { | 1163 if (layerImpl->tryScroll(deviceViewportPoint, type) == ScrollOnMainThrea d) { |
| 1163 m_numMainThreadScrolls++; | 1164 m_numMainThreadScrolls++; |
| 1165 UMA_HISTOGRAM_BOOLEAN("TryScroll.SlowScroll", true); | |
| 1164 return ScrollOnMainThread; | 1166 return ScrollOnMainThread; |
| 1165 } | 1167 } |
| 1166 | 1168 |
| 1167 LayerImpl* scrollLayerImpl = findScrollLayerForContentLayer(layerImpl); | 1169 LayerImpl* scrollLayerImpl = findScrollLayerForContentLayer(layerImpl); |
| 1168 if (!scrollLayerImpl) | 1170 if (!scrollLayerImpl) |
| 1169 continue; | 1171 continue; |
| 1170 | 1172 |
| 1171 ScrollStatus status = scrollLayerImpl->tryScroll(deviceViewportPoint, ty pe); | 1173 ScrollStatus status = scrollLayerImpl->tryScroll(deviceViewportPoint, ty pe); |
| 1172 | 1174 |
| 1173 // If any layer wants to divert the scroll event to the main thread, abo rt. | 1175 // If any layer wants to divert the scroll event to the main thread, abo rt. |
| 1174 if (status == ScrollOnMainThread) { | 1176 if (status == ScrollOnMainThread) { |
| 1175 m_numMainThreadScrolls++; | 1177 m_numMainThreadScrolls++; |
| 1178 UMA_HISTOGRAM_BOOLEAN("TryScroll.SlowScroll", true); | |
| 1176 return ScrollOnMainThread; | 1179 return ScrollOnMainThread; |
| 1177 } | 1180 } |
| 1178 | 1181 |
| 1182 UMA_HISTOGRAM_BOOLEAN("TryScroll.SlowScroll", false); | |
|
aelias_OOO_until_Jul13
2013/01/29 22:00:08
Please put this one right before ScrollStarted sin
clholgat
2013/01/31 18:55:50
Done.
| |
| 1179 if (status == ScrollStarted && !potentiallyScrollingLayerImpl) | 1183 if (status == ScrollStarted && !potentiallyScrollingLayerImpl) |
| 1180 potentiallyScrollingLayerImpl = scrollLayerImpl; | 1184 potentiallyScrollingLayerImpl = scrollLayerImpl; |
| 1181 } | 1185 } |
| 1182 | 1186 |
| 1183 if (potentiallyScrollingLayerImpl) { | 1187 if (potentiallyScrollingLayerImpl) { |
| 1184 m_activeTree->set_currently_scrolling_layer(potentiallyScrollingLayerImp l); | 1188 m_activeTree->set_currently_scrolling_layer(potentiallyScrollingLayerImp l); |
| 1185 // Gesture events need to be transformed from viewport coordinates to lo cal layer coordinates | 1189 // Gesture events need to be transformed from viewport coordinates to lo cal layer coordinates |
| 1186 // so that the scrolling contents exactly follow the user's finger. In c ontrast, wheel | 1190 // so that the scrolling contents exactly follow the user's finger. In c ontrast, wheel |
| 1187 // events are already in local layer coordinates so we can just apply th em directly. | 1191 // events are already in local layer coordinates so we can just apply th em directly. |
| 1188 m_scrollDeltaIsInViewportSpace = (type == Gesture); | 1192 m_scrollDeltaIsInViewportSpace = (type == Gesture); |
| (...skipping 504 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 1693 LayerImpl* layer = getNonCompositedContentLayerRecursive(tree->RootLayer()); | 1697 LayerImpl* layer = getNonCompositedContentLayerRecursive(tree->RootLayer()); |
| 1694 return layer ? layer->getPicture() : skia::RefPtr<SkPicture>(); | 1698 return layer ? layer->getPicture() : skia::RefPtr<SkPicture>(); |
| 1695 } | 1699 } |
| 1696 | 1700 |
| 1697 void LayerTreeHostImpl::savePaintTime(const base::TimeDelta& totalPaintTime) | 1701 void LayerTreeHostImpl::savePaintTime(const base::TimeDelta& totalPaintTime) |
| 1698 { | 1702 { |
| 1699 m_paintTimeCounter->SavePaintTime(totalPaintTime); | 1703 m_paintTimeCounter->SavePaintTime(totalPaintTime); |
| 1700 } | 1704 } |
| 1701 | 1705 |
| 1702 } // namespace cc | 1706 } // namespace cc |
| OLD | NEW |