| 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 450 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 472 appendQuadsData.hadOcclusionFromOutsideTargetSurface |= hasOcclu
sionFromOutsideTargetSurface; | 473 appendQuadsData.hadOcclusionFromOutsideTargetSurface |= hasOcclu
sionFromOutsideTargetSurface; |
| 473 else { | 474 else { |
| 474 DCHECK_EQ(activeTree(), it->layerTreeImpl()); | 475 DCHECK_EQ(activeTree(), it->layerTreeImpl()); |
| 475 it->willDraw(m_resourceProvider.get()); | 476 it->willDraw(m_resourceProvider.get()); |
| 476 frame.willDrawLayers.push_back(*it); | 477 frame.willDrawLayers.push_back(*it); |
| 477 | 478 |
| 478 if (it->hasContributingDelegatedRenderPasses()) { | 479 if (it->hasContributingDelegatedRenderPasses()) { |
| 479 RenderPass::Id contributingRenderPassId = it->firstContribut
ingRenderPassId(); | 480 RenderPass::Id contributingRenderPassId = it->firstContribut
ingRenderPassId(); |
| 480 while (frame.renderPassesById.find(contributingRenderPassId)
!= frame.renderPassesById.end()) { | 481 while (frame.renderPassesById.find(contributingRenderPassId)
!= frame.renderPassesById.end()) { |
| 481 RenderPass* renderPass = frame.renderPassesById[contribu
tingRenderPassId]; | 482 RenderPass* renderPass = frame.renderPassesById[contribu
tingRenderPassId]; |
| 482 | 483 |
| 483 AppendQuadsData appendQuadsData(renderPass->id); | 484 AppendQuadsData appendQuadsData(renderPass->id); |
| 484 appendQuadsForLayer(renderPass, *it, occlusionTracker, a
ppendQuadsData); | 485 appendQuadsForLayer(renderPass, *it, occlusionTracker, a
ppendQuadsData); |
| 485 | 486 |
| 486 contributingRenderPassId = it->nextContributingRenderPas
sId(contributingRenderPassId); | 487 contributingRenderPassId = it->nextContributingRenderPas
sId(contributingRenderPassId); |
| 487 } | 488 } |
| 488 } | 489 } |
| 489 | 490 |
| 490 appendQuadsForLayer(targetRenderPass, *it, occlusionTracker, app
endQuadsData); | 491 appendQuadsForLayer(targetRenderPass, *it, occlusionTracker, app
endQuadsData); |
| 491 } | 492 } |
| 492 | 493 |
| (...skipping 719 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1212 // First find out which layer was hit from the saved list of visible layers | 1213 // First find out which layer was hit from the saved list of visible layers |
| 1213 // in the most recent frame. | 1214 // in the most recent frame. |
| 1214 LayerImpl* layerImpl = LayerTreeHostCommon::findLayerThatIsHitByPoint(device
ViewportPoint, activeTree()->RenderSurfaceLayerList()); | 1215 LayerImpl* layerImpl = LayerTreeHostCommon::findLayerThatIsHitByPoint(device
ViewportPoint, activeTree()->RenderSurfaceLayerList()); |
| 1215 | 1216 |
| 1216 // Walk up the hierarchy and look for a scrollable layer. | 1217 // Walk up the hierarchy and look for a scrollable layer. |
| 1217 LayerImpl* potentiallyScrollingLayerImpl = 0; | 1218 LayerImpl* potentiallyScrollingLayerImpl = 0; |
| 1218 for (; layerImpl; layerImpl = layerImpl->parent()) { | 1219 for (; layerImpl; layerImpl = layerImpl->parent()) { |
| 1219 // The content layer can also block attempts to scroll outside the main
thread. | 1220 // The content layer can also block attempts to scroll outside the main
thread. |
| 1220 if (layerImpl->tryScroll(deviceViewportPoint, type) == ScrollOnMainThrea
d) { | 1221 if (layerImpl->tryScroll(deviceViewportPoint, type) == ScrollOnMainThrea
d) { |
| 1221 m_numMainThreadScrolls++; | 1222 m_numMainThreadScrolls++; |
| 1223 UMA_HISTOGRAM_BOOLEAN("TryScroll.SlowScroll", true); |
| 1222 return ScrollOnMainThread; | 1224 return ScrollOnMainThread; |
| 1223 } | 1225 } |
| 1224 | 1226 |
| 1225 LayerImpl* scrollLayerImpl = findScrollLayerForContentLayer(layerImpl); | 1227 LayerImpl* scrollLayerImpl = findScrollLayerForContentLayer(layerImpl); |
| 1226 if (!scrollLayerImpl) | 1228 if (!scrollLayerImpl) |
| 1227 continue; | 1229 continue; |
| 1228 | 1230 |
| 1229 ScrollStatus status = scrollLayerImpl->tryScroll(deviceViewportPoint, ty
pe); | 1231 ScrollStatus status = scrollLayerImpl->tryScroll(deviceViewportPoint, ty
pe); |
| 1230 | 1232 |
| 1231 // If any layer wants to divert the scroll event to the main thread, abo
rt. | 1233 // If any layer wants to divert the scroll event to the main thread, abo
rt. |
| 1232 if (status == ScrollOnMainThread) { | 1234 if (status == ScrollOnMainThread) { |
| 1233 m_numMainThreadScrolls++; | 1235 m_numMainThreadScrolls++; |
| 1236 UMA_HISTOGRAM_BOOLEAN("TryScroll.SlowScroll", true); |
| 1234 return ScrollOnMainThread; | 1237 return ScrollOnMainThread; |
| 1235 } | 1238 } |
| 1236 | 1239 |
| 1237 if (status == ScrollStarted && !potentiallyScrollingLayerImpl) | 1240 if (status == ScrollStarted && !potentiallyScrollingLayerImpl) |
| 1238 potentiallyScrollingLayerImpl = scrollLayerImpl; | 1241 potentiallyScrollingLayerImpl = scrollLayerImpl; |
| 1239 } | 1242 } |
| 1240 | 1243 |
| 1241 if (potentiallyScrollingLayerImpl) { | 1244 if (potentiallyScrollingLayerImpl) { |
| 1242 m_activeTree->set_currently_scrolling_layer(potentiallyScrollingLayerImp
l); | 1245 m_activeTree->set_currently_scrolling_layer(potentiallyScrollingLayerImp
l); |
| 1243 // Gesture events need to be transformed from viewport coordinates to lo
cal layer coordinates | 1246 // Gesture events need to be transformed from viewport coordinates to lo
cal layer coordinates |
| 1244 // so that the scrolling contents exactly follow the user's finger. In c
ontrast, wheel | 1247 // so that the scrolling contents exactly follow the user's finger. In c
ontrast, wheel |
| 1245 // events are already in local layer coordinates so we can just apply th
em directly. | 1248 // events are already in local layer coordinates so we can just apply th
em directly. |
| 1246 m_scrollDeltaIsInViewportSpace = (type == Gesture); | 1249 m_scrollDeltaIsInViewportSpace = (type == Gesture); |
| 1247 m_numImplThreadScrolls++; | 1250 m_numImplThreadScrolls++; |
| 1248 m_client->renewTreePriority(); | 1251 m_client->renewTreePriority(); |
| 1252 UMA_HISTOGRAM_BOOLEAN("TryScroll.SlowScroll", false); |
| 1249 return ScrollStarted; | 1253 return ScrollStarted; |
| 1250 } | 1254 } |
| 1251 return ScrollIgnored; | 1255 return ScrollIgnored; |
| 1252 } | 1256 } |
| 1253 | 1257 |
| 1254 gfx::Vector2dF LayerTreeHostImpl::scrollLayerWithViewportSpaceDelta(LayerImpl* l
ayerImpl, float scaleFromViewportToScreenSpace, gfx::PointF viewportPoint, gfx::
Vector2dF viewportDelta) | 1258 gfx::Vector2dF LayerTreeHostImpl::scrollLayerWithViewportSpaceDelta(LayerImpl* l
ayerImpl, float scaleFromViewportToScreenSpace, gfx::PointF viewportPoint, gfx::
Vector2dF viewportDelta) |
| 1255 { | 1259 { |
| 1256 // Layers with non-invertible screen space transforms should not have passed
the scroll hit | 1260 // Layers with non-invertible screen space transforms should not have passed
the scroll hit |
| 1257 // test in the first place. | 1261 // test in the first place. |
| 1258 DCHECK(layerImpl->screenSpaceTransform().IsInvertible()); | 1262 DCHECK(layerImpl->screenSpaceTransform().IsInvertible()); |
| (...skipping 483 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1742 LayerImpl* layer = getNonCompositedContentLayerRecursive(tree->RootLayer()); | 1746 LayerImpl* layer = getNonCompositedContentLayerRecursive(tree->RootLayer()); |
| 1743 return layer ? layer->getPicture() : skia::RefPtr<SkPicture>(); | 1747 return layer ? layer->getPicture() : skia::RefPtr<SkPicture>(); |
| 1744 } | 1748 } |
| 1745 | 1749 |
| 1746 void LayerTreeHostImpl::savePaintTime(const base::TimeDelta& totalPaintTime) | 1750 void LayerTreeHostImpl::savePaintTime(const base::TimeDelta& totalPaintTime) |
| 1747 { | 1751 { |
| 1748 m_paintTimeCounter->SavePaintTime(totalPaintTime); | 1752 m_paintTimeCounter->SavePaintTime(totalPaintTime); |
| 1749 } | 1753 } |
| 1750 | 1754 |
| 1751 } // namespace cc | 1755 } // namespace cc |
| OLD | NEW |