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" |
(...skipping 198 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
209 , m_debugState(settings.initialDebugState) | 209 , m_debugState(settings.initialDebugState) |
210 , m_deviceScaleFactor(1) | 210 , m_deviceScaleFactor(1) |
211 , m_visible(true) | 211 , m_visible(true) |
212 , m_contentsTexturesPurged(false) | 212 , m_contentsTexturesPurged(false) |
213 , m_managedMemoryPolicy(PrioritizedResourceManager::defaultMemoryAllocationL imit(), | 213 , m_managedMemoryPolicy(PrioritizedResourceManager::defaultMemoryAllocationL imit(), |
214 PriorityCalculator::allowEverythingCutoff(), | 214 PriorityCalculator::allowEverythingCutoff(), |
215 0, | 215 0, |
216 PriorityCalculator::allowNothingCutoff()) | 216 PriorityCalculator::allowNothingCutoff()) |
217 , m_backgroundColor(0) | 217 , m_backgroundColor(0) |
218 , m_hasTransparentBackground(false) | 218 , m_hasTransparentBackground(false) |
219 , m_needsUpdateDrawProperties(false) | |
219 , m_pinchGestureActive(false) | 220 , m_pinchGestureActive(false) |
220 , m_fpsCounter(FrameRateCounter::create(m_proxy->hasImplThread())) | 221 , m_fpsCounter(FrameRateCounter::create(m_proxy->hasImplThread())) |
221 , m_debugRectHistory(DebugRectHistory::create()) | 222 , m_debugRectHistory(DebugRectHistory::create()) |
222 , m_numImplThreadScrolls(0) | 223 , m_numImplThreadScrolls(0) |
223 , m_numMainThreadScrolls(0) | 224 , m_numMainThreadScrolls(0) |
224 , m_cumulativeNumLayersDrawn(0) | 225 , m_cumulativeNumLayersDrawn(0) |
225 { | 226 { |
226 DCHECK(m_proxy->isImplThread()); | 227 DCHECK(m_proxy->isImplThread()); |
227 didVisibilityChange(this, m_visible); | 228 didVisibilityChange(this, m_visible); |
228 | 229 |
(...skipping 16 matching lines...) Expand all Loading... | |
245 } | 246 } |
246 } | 247 } |
247 | 248 |
248 void LayerTreeHostImpl::beginCommit() | 249 void LayerTreeHostImpl::beginCommit() |
249 { | 250 { |
250 } | 251 } |
251 | 252 |
252 void LayerTreeHostImpl::commitComplete() | 253 void LayerTreeHostImpl::commitComplete() |
253 { | 254 { |
254 TRACE_EVENT0("cc", "LayerTreeHostImpl::commitComplete"); | 255 TRACE_EVENT0("cc", "LayerTreeHostImpl::commitComplete"); |
256 | |
257 // Impl-side painting needs an update immediately post-commit to have the | |
258 // opportunity to create tilings. Other paths can call updateDrawProperties | |
259 // more lazily when needed prior to drawing. | |
260 setNeedsUpdateDrawProperties(); | |
261 if (m_settings.implSidePainting) | |
262 updateDrawProperties(); | |
263 | |
255 // Recompute max scroll position; must be after layer content bounds are | 264 // Recompute max scroll position; must be after layer content bounds are |
256 // updated. | 265 // updated. |
257 updateMaxScrollOffset(); | 266 updateMaxScrollOffset(); |
258 m_client->sendManagedMemoryStats(); | 267 m_client->sendManagedMemoryStats(); |
259 } | 268 } |
260 | 269 |
261 bool LayerTreeHostImpl::canDraw() | 270 bool LayerTreeHostImpl::canDraw() |
262 { | 271 { |
263 // Note: If you are changing this function or any other function that might | 272 // Note: If you are changing this function or any other function that might |
264 // affect the result of canDraw, make sure to call m_client->onCanDrawStateC hanged | 273 // affect the result of canDraw, make sure to call m_client->onCanDrawStateC hanged |
(...skipping 57 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
322 if (!m_settings.pageScalePinchZoomEnabled) | 331 if (!m_settings.pageScalePinchZoomEnabled) |
323 anchor.Scale(1 / pageScale); | 332 anchor.Scale(1 / pageScale); |
324 m_pageScaleAnimation->zoomWithAnchor(anchor, pageScale, duration.InSecon dsF()); | 333 m_pageScaleAnimation->zoomWithAnchor(anchor, pageScale, duration.InSecon dsF()); |
325 } else { | 334 } else { |
326 gfx::Vector2dF scaledTargetOffset = targetOffset; | 335 gfx::Vector2dF scaledTargetOffset = targetOffset; |
327 if (!m_settings.pageScalePinchZoomEnabled) | 336 if (!m_settings.pageScalePinchZoomEnabled) |
328 scaledTargetOffset.Scale(1 / pageScale); | 337 scaledTargetOffset.Scale(1 / pageScale); |
329 m_pageScaleAnimation->zoomTo(scaledTargetOffset, pageScale, duration.InS econdsF()); | 338 m_pageScaleAnimation->zoomTo(scaledTargetOffset, pageScale, duration.InS econdsF()); |
330 } | 339 } |
331 | 340 |
341 setNeedsUpdateDrawProperties(); | |
332 m_client->setNeedsRedrawOnImplThread(); | 342 m_client->setNeedsRedrawOnImplThread(); |
333 m_client->setNeedsCommitOnImplThread(); | 343 m_client->setNeedsCommitOnImplThread(); |
334 } | 344 } |
335 | 345 |
336 void LayerTreeHostImpl::scheduleAnimation() | 346 void LayerTreeHostImpl::scheduleAnimation() |
337 { | 347 { |
338 m_client->setNeedsRedrawOnImplThread(); | 348 m_client->setNeedsRedrawOnImplThread(); |
339 } | 349 } |
340 | 350 |
341 bool LayerTreeHostImpl::haveTouchEventHandlersAt(const gfx::Point& viewportPoint ) | 351 bool LayerTreeHostImpl::haveTouchEventHandlersAt(const gfx::Point& viewportPoint ) |
(...skipping 25 matching lines...) Expand all Loading... | |
367 } | 377 } |
368 } | 378 } |
369 | 379 |
370 void LayerTreeHostImpl::updateRootScrollLayerImplTransform() | 380 void LayerTreeHostImpl::updateRootScrollLayerImplTransform() |
371 { | 381 { |
372 if (rootScrollLayer()) { | 382 if (rootScrollLayer()) { |
373 rootScrollLayer()->setImplTransform(implTransform()); | 383 rootScrollLayer()->setImplTransform(implTransform()); |
374 } | 384 } |
375 } | 385 } |
376 | 386 |
387 void LayerTreeHostImpl::updateDrawProperties() | |
388 { | |
389 if (!needsUpdateDrawProperties()) | |
390 return; | |
391 | |
392 m_renderSurfaceLayerList.clear(); | |
393 m_needsUpdateDrawProperties = false; | |
394 | |
395 if (!rootLayer()) | |
396 return; | |
397 | |
398 calculateRenderSurfaceLayerList(m_renderSurfaceLayerList); | |
399 } | |
400 | |
377 void LayerTreeHostImpl::calculateRenderSurfaceLayerList(LayerList& renderSurface LayerList) | 401 void LayerTreeHostImpl::calculateRenderSurfaceLayerList(LayerList& renderSurface LayerList) |
378 { | 402 { |
379 DCHECK(renderSurfaceLayerList.empty()); | 403 DCHECK(renderSurfaceLayerList.empty()); |
380 DCHECK(rootLayer()); | 404 DCHECK(rootLayer()); |
381 DCHECK(m_renderer); // For maxTextureSize. | 405 DCHECK(m_renderer); // For maxTextureSize. |
382 | |
383 { | 406 { |
384 updateRootScrollLayerImplTransform(); | 407 updateRootScrollLayerImplTransform(); |
385 | 408 |
386 TRACE_EVENT0("cc", "LayerTreeHostImpl::calcDrawEtc"); | 409 TRACE_EVENT0("cc", "LayerTreeHostImpl::calcDrawEtc"); |
387 float pageScaleFactor = m_pinchZoomViewport.pageScaleFactor(); | 410 float pageScaleFactor = m_pinchZoomViewport.pageScaleFactor(); |
388 LayerTreeHostCommon::calculateDrawProperties(rootLayer(), deviceViewport Size(), m_deviceScaleFactor, pageScaleFactor, rendererCapabilities().maxTextureS ize, renderSurfaceLayerList); | 411 LayerTreeHostCommon::calculateDrawProperties(rootLayer(), deviceViewport Size(), m_deviceScaleFactor, pageScaleFactor, rendererCapabilities().maxTextureS ize, renderSurfaceLayerList); |
389 | |
390 trackDamageForAllSurfaces(rootLayer(), renderSurfaceLayerList); | |
391 } | 412 } |
392 } | 413 } |
393 | 414 |
394 void LayerTreeHostImpl::FrameData::appendRenderPass(scoped_ptr<RenderPass> rende rPass) | 415 void LayerTreeHostImpl::FrameData::appendRenderPass(scoped_ptr<RenderPass> rende rPass) |
395 { | 416 { |
396 RenderPass* pass = renderPass.get(); | 417 RenderPass* pass = renderPass.get(); |
397 renderPasses.push_back(pass); | 418 renderPasses.push_back(pass); |
398 renderPassesById.set(pass->id, renderPass.Pass()); | 419 renderPassesById.set(pass->id, renderPass.Pass()); |
399 } | 420 } |
400 | 421 |
(...skipping 79 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
480 scoped_ptr<SolidColorDrawQuad> quad = SolidColorDrawQuad::Create(); | 501 scoped_ptr<SolidColorDrawQuad> quad = SolidColorDrawQuad::Create(); |
481 quad->SetNew(sharedQuadState, layerRect, screenBackgroundColor); | 502 quad->SetNew(sharedQuadState, layerRect, screenBackgroundColor); |
482 quadCuller.append(quad.PassAs<DrawQuad>(), appendQuadsData); | 503 quadCuller.append(quad.PassAs<DrawQuad>(), appendQuadsData); |
483 } | 504 } |
484 } | 505 } |
485 | 506 |
486 bool LayerTreeHostImpl::calculateRenderPasses(FrameData& frame) | 507 bool LayerTreeHostImpl::calculateRenderPasses(FrameData& frame) |
487 { | 508 { |
488 DCHECK(frame.renderPasses.empty()); | 509 DCHECK(frame.renderPasses.empty()); |
489 | 510 |
490 calculateRenderSurfaceLayerList(*frame.renderSurfaceLayerList); | 511 updateDrawProperties(); |
512 trackDamageForAllSurfaces(rootLayer(), *frame.renderSurfaceLayerList); | |
491 | 513 |
492 TRACE_EVENT1("cc", "LayerTreeHostImpl::calculateRenderPasses", "renderSurfac eLayerList.size()", static_cast<long long unsigned>(frame.renderSurfaceLayerList ->size())); | 514 TRACE_EVENT1("cc", "LayerTreeHostImpl::calculateRenderPasses", "renderSurfac eLayerList.size()", static_cast<long long unsigned>(frame.renderSurfaceLayerList ->size())); |
493 | 515 |
494 // Create the render passes in dependency order. | 516 // Create the render passes in dependency order. |
495 for (int surfaceIndex = frame.renderSurfaceLayerList->size() - 1; surfaceInd ex >= 0 ; --surfaceIndex) { | 517 for (int surfaceIndex = frame.renderSurfaceLayerList->size() - 1; surfaceInd ex >= 0 ; --surfaceIndex) { |
496 LayerImpl* renderSurfaceLayer = (*frame.renderSurfaceLayerList)[surfaceI ndex]; | 518 LayerImpl* renderSurfaceLayer = (*frame.renderSurfaceLayerList)[surfaceI ndex]; |
497 renderSurfaceLayer->renderSurface()->appendRenderPasses(frame); | 519 renderSurfaceLayer->renderSurface()->appendRenderPasses(frame); |
498 } | 520 } |
499 | 521 |
500 bool recordMetricsForFrame = m_settings.showOverdrawInTracing && base::debug ::TraceLog::GetInstance() && base::debug::TraceLog::GetInstance()->IsEnabled(); | 522 bool recordMetricsForFrame = m_settings.showOverdrawInTracing && base::debug ::TraceLog::GetInstance() && base::debug::TraceLog::GetInstance()->IsEnabled(); |
(...skipping 25 matching lines...) Expand all Loading... | |
526 if (it.representsContributingRenderSurface()) { | 548 if (it.representsContributingRenderSurface()) { |
527 RenderPass::Id contributingRenderPassId = it->renderSurface()->rende rPassId(); | 549 RenderPass::Id contributingRenderPassId = it->renderSurface()->rende rPassId(); |
528 RenderPass* contributingRenderPass = frame.renderPassesById.get(cont ributingRenderPassId); | 550 RenderPass* contributingRenderPass = frame.renderPassesById.get(cont ributingRenderPassId); |
529 appendQuadsForRenderSurfaceLayer(targetRenderPass, *it, contributing RenderPass, occlusionTracker, appendQuadsData); | 551 appendQuadsForRenderSurfaceLayer(targetRenderPass, *it, contributing RenderPass, occlusionTracker, appendQuadsData); |
530 } else if (it.representsItself() && !it->visibleContentRect().IsEmpty()) { | 552 } else if (it.representsItself() && !it->visibleContentRect().IsEmpty()) { |
531 bool hasOcclusionFromOutsideTargetSurface; | 553 bool hasOcclusionFromOutsideTargetSurface; |
532 bool implDrawTransformIsUnknown = false; | 554 bool implDrawTransformIsUnknown = false; |
533 if (occlusionTracker.occluded(it->renderTarget(), it->visibleContent Rect(), it->drawTransform(), implDrawTransformIsUnknown, it->drawableContentRect (), &hasOcclusionFromOutsideTargetSurface)) | 555 if (occlusionTracker.occluded(it->renderTarget(), it->visibleContent Rect(), it->drawTransform(), implDrawTransformIsUnknown, it->drawableContentRect (), &hasOcclusionFromOutsideTargetSurface)) |
534 appendQuadsData.hadOcclusionFromOutsideTargetSurface |= hasOcclu sionFromOutsideTargetSurface; | 556 appendQuadsData.hadOcclusionFromOutsideTargetSurface |= hasOcclu sionFromOutsideTargetSurface; |
535 else { | 557 else { |
558 DCHECK_EQ(this, it->layerTreeHostImpl()); | |
536 it->willDraw(m_resourceProvider.get()); | 559 it->willDraw(m_resourceProvider.get()); |
537 frame.willDrawLayers.push_back(*it); | 560 frame.willDrawLayers.push_back(*it); |
538 | 561 |
539 if (it->hasContributingDelegatedRenderPasses()) { | 562 if (it->hasContributingDelegatedRenderPasses()) { |
540 RenderPass::Id contributingRenderPassId = it->firstContribut ingRenderPassId(); | 563 RenderPass::Id contributingRenderPassId = it->firstContribut ingRenderPassId(); |
541 while (frame.renderPassesById.contains(contributingRenderPas sId)) { | 564 while (frame.renderPassesById.contains(contributingRenderPas sId)) { |
542 RenderPass* renderPass = frame.renderPassesById.get(cont ributingRenderPassId); | 565 RenderPass* renderPass = frame.renderPassesById.get(cont ributingRenderPassId); |
543 | 566 |
544 AppendQuadsData appendQuadsData(renderPass->id); | 567 AppendQuadsData appendQuadsData(renderPass->id); |
545 appendQuadsForLayer(renderPass, *it, occlusionTracker, a ppendQuadsData); | 568 appendQuadsForLayer(renderPass, *it, occlusionTracker, a ppendQuadsData); |
(...skipping 165 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
711 { | 734 { |
712 TRACE_EVENT0("cc", "LayerTreeHostImpl::prepareToDraw"); | 735 TRACE_EVENT0("cc", "LayerTreeHostImpl::prepareToDraw"); |
713 DCHECK(canDraw()); | 736 DCHECK(canDraw()); |
714 | 737 |
715 if (m_tileManager) | 738 if (m_tileManager) |
716 m_tileManager->CheckForCompletedSetPixels(); | 739 m_tileManager->CheckForCompletedSetPixels(); |
717 | 740 |
718 frame.renderSurfaceLayerList = &m_renderSurfaceLayerList; | 741 frame.renderSurfaceLayerList = &m_renderSurfaceLayerList; |
719 frame.renderPasses.clear(); | 742 frame.renderPasses.clear(); |
720 frame.renderPassesById.clear(); | 743 frame.renderPassesById.clear(); |
721 frame.renderSurfaceLayerList->clear(); | |
722 frame.willDrawLayers.clear(); | 744 frame.willDrawLayers.clear(); |
723 | 745 |
724 if (!calculateRenderPasses(frame)) | 746 if (!calculateRenderPasses(frame)) |
725 return false; | 747 return false; |
726 | 748 |
727 // If we return true, then we expect drawLayers() to be called before this f unction is called again. | 749 // If we return true, then we expect drawLayers() to be called before this f unction is called again. |
728 return true; | 750 return true; |
729 } | 751 } |
730 | 752 |
731 void LayerTreeHostImpl::enforceManagedMemoryPolicy(const ManagedMemoryPolicy& po licy) | 753 void LayerTreeHostImpl::enforceManagedMemoryPolicy(const ManagedMemoryPolicy& po licy) |
(...skipping 174 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
906 return layerImpl; | 928 return layerImpl; |
907 | 929 |
908 if (layerImpl->drawsContent() && layerImpl->parent() && layerImpl->parent()- >scrollable()) | 930 if (layerImpl->drawsContent() && layerImpl->parent() && layerImpl->parent()- >scrollable()) |
909 return layerImpl->parent(); | 931 return layerImpl->parent(); |
910 | 932 |
911 return 0; | 933 return 0; |
912 } | 934 } |
913 | 935 |
914 void LayerTreeHostImpl::setRootLayer(scoped_ptr<LayerImpl> layer) | 936 void LayerTreeHostImpl::setRootLayer(scoped_ptr<LayerImpl> layer) |
915 { | 937 { |
916 m_activeTree->SetRootLayer(layer.Pass()); | 938 m_activeTree->SetRootLayer(layer.Pass()); |
939 setNeedsUpdateDrawProperties(); | |
917 } | 940 } |
918 | 941 |
919 scoped_ptr<LayerImpl> LayerTreeHostImpl::detachLayerTree() | 942 scoped_ptr<LayerImpl> LayerTreeHostImpl::detachLayerTree() |
920 { | 943 { |
921 scoped_ptr<LayerImpl> layer = m_activeTree->DetachLayerTree(); | 944 scoped_ptr<LayerImpl> layer = m_activeTree->DetachLayerTree(); |
922 m_renderSurfaceLayerList.clear(); | 945 m_renderSurfaceLayerList.clear(); |
923 return layer.Pass(); | 946 setNeedsUpdateDrawProperties(); |
947 return layer.Pass(); | |
924 } | 948 } |
925 | 949 |
926 void LayerTreeHostImpl::setVisible(bool visible) | 950 void LayerTreeHostImpl::setVisible(bool visible) |
927 { | 951 { |
928 DCHECK(m_proxy->isImplThread()); | 952 DCHECK(m_proxy->isImplThread()); |
929 | 953 |
930 if (m_visible == visible) | 954 if (m_visible == visible) |
931 return; | 955 return; |
932 m_visible = visible; | 956 m_visible = visible; |
933 didVisibilityChange(this, m_visible); | 957 didVisibilityChange(this, m_visible); |
(...skipping 112 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
1046 } | 1070 } |
1047 | 1071 |
1048 void LayerTreeHostImpl::setPageScaleFactorAndLimits(float pageScaleFactor, float minPageScaleFactor, float maxPageScaleFactor) | 1072 void LayerTreeHostImpl::setPageScaleFactorAndLimits(float pageScaleFactor, float minPageScaleFactor, float maxPageScaleFactor) |
1049 { | 1073 { |
1050 if (!pageScaleFactor) | 1074 if (!pageScaleFactor) |
1051 return; | 1075 return; |
1052 | 1076 |
1053 float pageScaleChange = pageScaleFactor / m_pinchZoomViewport.pageScaleFacto r(); | 1077 float pageScaleChange = pageScaleFactor / m_pinchZoomViewport.pageScaleFacto r(); |
1054 m_pinchZoomViewport.setPageScaleFactorAndLimits(pageScaleFactor, minPageScal eFactor, maxPageScaleFactor); | 1078 m_pinchZoomViewport.setPageScaleFactorAndLimits(pageScaleFactor, minPageScal eFactor, maxPageScaleFactor); |
1055 | 1079 |
1056 if (!m_settings.pageScalePinchZoomEnabled) { | 1080 if (!m_settings.pageScalePinchZoomEnabled && pageScaleChange != 1) |
1057 if (pageScaleChange != 1) | 1081 adjustScrollsForPageScaleChange(rootScrollLayer(), pageScaleChange); |
1058 adjustScrollsForPageScaleChange(rootScrollLayer(), pageScaleChange); | |
1059 } | |
1060 | 1082 |
1061 // Clamp delta to limits and refresh display matrix. | 1083 // Clamp delta to limits and refresh display matrix. |
1062 setPageScaleDelta(m_pinchZoomViewport.pageScaleDelta() / m_pinchZoomViewport .sentPageScaleDelta()); | 1084 setPageScaleDelta(m_pinchZoomViewport.pageScaleDelta() / m_pinchZoomViewport .sentPageScaleDelta()); |
1063 m_pinchZoomViewport.setSentPageScaleDelta(1); | 1085 m_pinchZoomViewport.setSentPageScaleDelta(1); |
1064 } | 1086 } |
1065 | 1087 |
1066 void LayerTreeHostImpl::setPageScaleDelta(float delta) | 1088 void LayerTreeHostImpl::setPageScaleDelta(float delta) |
1067 { | 1089 { |
1068 m_pinchZoomViewport.setPageScaleDelta(delta); | 1090 m_pinchZoomViewport.setPageScaleDelta(delta); |
1069 | 1091 |
(...skipping 34 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
1104 rootScrollLayer()->setMaxScrollOffset(gfx::ToFlooredVector2d(maxScroll)); | 1126 rootScrollLayer()->setMaxScrollOffset(gfx::ToFlooredVector2d(maxScroll)); |
1105 } | 1127 } |
1106 | 1128 |
1107 void LayerTreeHostImpl::setNeedsRedraw() | 1129 void LayerTreeHostImpl::setNeedsRedraw() |
1108 { | 1130 { |
1109 m_client->setNeedsRedrawOnImplThread(); | 1131 m_client->setNeedsRedrawOnImplThread(); |
1110 } | 1132 } |
1111 | 1133 |
1112 bool LayerTreeHostImpl::ensureRenderSurfaceLayerList() | 1134 bool LayerTreeHostImpl::ensureRenderSurfaceLayerList() |
1113 { | 1135 { |
1136 // TODO(enne): See http://crbug.com/164949. This function should really | |
1137 // just call updateDrawProperties(), but that breaks a number of | |
1138 // impl transform tests that don't expect the tree to be updated. | |
1114 if (!rootLayer()) | 1139 if (!rootLayer()) |
1115 return false; | 1140 return false; |
1116 if (!m_renderer) | 1141 if (!m_renderer) |
1117 return false; | 1142 return false; |
1118 | 1143 |
1119 // We need both a non-empty render surface layer list and a root render | 1144 // We need both a non-empty render surface layer list and a root render |
1120 // surface to be able to iterate over the visible layers. | 1145 // surface to be able to iterate over the visible layers. |
1121 if (m_renderSurfaceLayerList.size() && rootLayer()->renderSurface()) | 1146 if (m_renderSurfaceLayerList.size() && rootLayer()->renderSurface()) |
1122 return true; | 1147 return true; |
1123 | 1148 |
1124 // If we are called after setRootLayer() but before prepareToDraw(), we need | 1149 // If we are called after setRootLayer() but before prepareToDraw(), we need |
1125 // to recalculate the visible layers. This prevents being unable to scroll | 1150 // to recalculate the visible layers. This prevents being unable to scroll |
1126 // during part of a commit. | 1151 // during part of a commit. |
1127 m_renderSurfaceLayerList.clear(); | 1152 setNeedsUpdateDrawProperties(); |
1128 calculateRenderSurfaceLayerList(m_renderSurfaceLayerList); | 1153 updateDrawProperties(); |
1129 | 1154 |
1130 return m_renderSurfaceLayerList.size(); | 1155 return m_renderSurfaceLayerList.size(); |
1131 } | 1156 } |
1132 | 1157 |
1133 InputHandlerClient::ScrollStatus LayerTreeHostImpl::scrollBegin(gfx::Point viewp ortPoint, InputHandlerClient::ScrollInputType type) | 1158 InputHandlerClient::ScrollStatus LayerTreeHostImpl::scrollBegin(gfx::Point viewp ortPoint, InputHandlerClient::ScrollInputType type) |
1134 { | 1159 { |
1135 TRACE_EVENT0("cc", "LayerTreeHostImpl::scrollBegin"); | 1160 TRACE_EVENT0("cc", "LayerTreeHostImpl::scrollBegin"); |
1136 | 1161 |
1137 DCHECK(!currentlyScrollingLayer()); | 1162 DCHECK(!currentlyScrollingLayer()); |
1138 clearCurrentlyScrollingLayer(); | 1163 clearCurrentlyScrollingLayer(); |
(...skipping 32 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
1171 potentiallyScrollingLayerImpl = scrollLayerImpl; | 1196 potentiallyScrollingLayerImpl = scrollLayerImpl; |
1172 } | 1197 } |
1173 | 1198 |
1174 if (potentiallyScrollingLayerImpl) { | 1199 if (potentiallyScrollingLayerImpl) { |
1175 m_activeTree->set_currently_scrolling_layer(potentiallyScrollingLayerImp l); | 1200 m_activeTree->set_currently_scrolling_layer(potentiallyScrollingLayerImp l); |
1176 // Gesture events need to be transformed from viewport coordinates to lo cal layer coordinates | 1201 // Gesture events need to be transformed from viewport coordinates to lo cal layer coordinates |
1177 // so that the scrolling contents exactly follow the user's finger. In c ontrast, wheel | 1202 // so that the scrolling contents exactly follow the user's finger. In c ontrast, wheel |
1178 // events are already in local layer coordinates so we can just apply th em directly. | 1203 // events are already in local layer coordinates so we can just apply th em directly. |
1179 m_scrollDeltaIsInViewportSpace = (type == Gesture); | 1204 m_scrollDeltaIsInViewportSpace = (type == Gesture); |
1180 m_numImplThreadScrolls++; | 1205 m_numImplThreadScrolls++; |
1206 setNeedsUpdateDrawProperties(); | |
1181 return ScrollStarted; | 1207 return ScrollStarted; |
1182 } | 1208 } |
1183 return ScrollIgnored; | 1209 return ScrollIgnored; |
1184 } | 1210 } |
1185 | 1211 |
1186 static gfx::Vector2dF scrollLayerWithViewportSpaceDelta(PinchZoomViewport* viewp ort, LayerImpl& layerImpl, float scaleFromViewportToScreenSpace, gfx::PointF vie wportPoint, gfx::Vector2dF viewportDelta) | 1212 static gfx::Vector2dF scrollLayerWithViewportSpaceDelta(PinchZoomViewport* viewp ort, LayerImpl& layerImpl, float scaleFromViewportToScreenSpace, gfx::PointF vie wportPoint, gfx::Vector2dF viewportDelta) |
1187 { | 1213 { |
1188 // Layers with non-invertible screen space transforms should not have passed the scroll hit | 1214 // Layers with non-invertible screen space transforms should not have passed the scroll hit |
1189 // test in the first place. | 1215 // test in the first place. |
1190 DCHECK(layerImpl.screenSpaceTransform().IsInvertible()); | 1216 DCHECK(layerImpl.screenSpaceTransform().IsInvertible()); |
(...skipping 94 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
1285 gfx::Vector2dF perpendicularAxis(-appliedDelta.y(), appliedDelta.x()); | 1311 gfx::Vector2dF perpendicularAxis(-appliedDelta.y(), appliedDelta.x()); |
1286 pendingDelta = MathUtil::projectVector(pendingDelta, perpendicularAxis); | 1312 pendingDelta = MathUtil::projectVector(pendingDelta, perpendicularAxis); |
1287 | 1313 |
1288 if (gfx::ToFlooredVector2d(pendingDelta).IsZero()) | 1314 if (gfx::ToFlooredVector2d(pendingDelta).IsZero()) |
1289 break; | 1315 break; |
1290 } | 1316 } |
1291 | 1317 |
1292 if (didScroll) { | 1318 if (didScroll) { |
1293 m_client->setNeedsCommitOnImplThread(); | 1319 m_client->setNeedsCommitOnImplThread(); |
1294 m_client->setNeedsRedrawOnImplThread(); | 1320 m_client->setNeedsRedrawOnImplThread(); |
1321 setNeedsUpdateDrawProperties(); | |
1295 } | 1322 } |
1296 return didScroll; | 1323 return didScroll; |
1297 } | 1324 } |
1298 | 1325 |
1299 void LayerTreeHostImpl::clearCurrentlyScrollingLayer() | 1326 void LayerTreeHostImpl::clearCurrentlyScrollingLayer() |
1300 { | 1327 { |
1301 m_activeTree->ClearCurrentlyScrollingLayer(); | 1328 m_activeTree->ClearCurrentlyScrollingLayer(); |
1302 } | 1329 } |
1303 | 1330 |
1304 void LayerTreeHostImpl::scrollEnd() | 1331 void LayerTreeHostImpl::scrollEnd() |
(...skipping 34 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
1339 } | 1366 } |
1340 | 1367 |
1341 gfx::Vector2dF scrollOverflow = m_settings.pageScalePinchZoomEnabled ? m_pin chZoomViewport.applyScroll(move) : move; | 1368 gfx::Vector2dF scrollOverflow = m_settings.pageScalePinchZoomEnabled ? m_pin chZoomViewport.applyScroll(move) : move; |
1342 rootScrollLayer()->scrollBy(scrollOverflow); | 1369 rootScrollLayer()->scrollBy(scrollOverflow); |
1343 | 1370 |
1344 if (rootScrollLayer()->scrollbarAnimationController()) | 1371 if (rootScrollLayer()->scrollbarAnimationController()) |
1345 rootScrollLayer()->scrollbarAnimationController()->didPinchGestureUpdate (); | 1372 rootScrollLayer()->scrollbarAnimationController()->didPinchGestureUpdate (); |
1346 | 1373 |
1347 m_client->setNeedsCommitOnImplThread(); | 1374 m_client->setNeedsCommitOnImplThread(); |
1348 m_client->setNeedsRedrawOnImplThread(); | 1375 m_client->setNeedsRedrawOnImplThread(); |
1376 setNeedsUpdateDrawProperties(); | |
1349 } | 1377 } |
1350 | 1378 |
1351 void LayerTreeHostImpl::pinchGestureEnd() | 1379 void LayerTreeHostImpl::pinchGestureEnd() |
1352 { | 1380 { |
1353 m_pinchGestureActive = false; | 1381 m_pinchGestureActive = false; |
1354 | 1382 |
1355 if (rootScrollLayer() && rootScrollLayer()->scrollbarAnimationController()) | 1383 if (rootScrollLayer() && rootScrollLayer()->scrollbarAnimationController()) |
1356 rootScrollLayer()->scrollbarAnimationController()->didPinchGestureEnd(); | 1384 rootScrollLayer()->scrollbarAnimationController()->didPinchGestureEnd(); |
1357 | 1385 |
1358 m_client->setNeedsCommitOnImplThread(); | 1386 m_client->setNeedsCommitOnImplThread(); |
(...skipping 116 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
1475 double monotonicTime = (time - base::TimeTicks()).InSecondsF(); | 1503 double monotonicTime = (time - base::TimeTicks()).InSecondsF(); |
1476 gfx::Vector2dF scrollTotal = rootScrollLayer()->scrollOffset() + rootScrollL ayer()->scrollDelta(); | 1504 gfx::Vector2dF scrollTotal = rootScrollLayer()->scrollOffset() + rootScrollL ayer()->scrollDelta(); |
1477 | 1505 |
1478 setPageScaleDelta(m_pageScaleAnimation->pageScaleFactorAtTime(monotonicTime) / m_pinchZoomViewport.pageScaleFactor()); | 1506 setPageScaleDelta(m_pageScaleAnimation->pageScaleFactorAtTime(monotonicTime) / m_pinchZoomViewport.pageScaleFactor()); |
1479 gfx::Vector2dF nextScroll = m_pageScaleAnimation->scrollOffsetAtTime(monoton icTime); | 1507 gfx::Vector2dF nextScroll = m_pageScaleAnimation->scrollOffsetAtTime(monoton icTime); |
1480 | 1508 |
1481 if (!m_settings.pageScalePinchZoomEnabled) | 1509 if (!m_settings.pageScalePinchZoomEnabled) |
1482 nextScroll.Scale(m_pinchZoomViewport.pageScaleFactor()); | 1510 nextScroll.Scale(m_pinchZoomViewport.pageScaleFactor()); |
1483 rootScrollLayer()->scrollBy(nextScroll - scrollTotal); | 1511 rootScrollLayer()->scrollBy(nextScroll - scrollTotal); |
1484 m_client->setNeedsRedrawOnImplThread(); | 1512 m_client->setNeedsRedrawOnImplThread(); |
1513 setNeedsUpdateDrawProperties(); | |
1485 | 1514 |
1486 if (m_pageScaleAnimation->isAnimationCompleteAtTime(monotonicTime)) { | 1515 if (m_pageScaleAnimation->isAnimationCompleteAtTime(monotonicTime)) { |
1487 m_pageScaleAnimation.reset(); | 1516 m_pageScaleAnimation.reset(); |
1488 m_client->setNeedsCommitOnImplThread(); | 1517 m_client->setNeedsCommitOnImplThread(); |
1489 } | 1518 } |
1490 } | 1519 } |
1491 | 1520 |
1492 void LayerTreeHostImpl::animateLayers(base::TimeTicks monotonicTime, base::Time wallClockTime) | 1521 void LayerTreeHostImpl::animateLayers(base::TimeTicks monotonicTime, base::Time wallClockTime) |
1493 { | 1522 { |
1494 if (!m_settings.acceleratedAnimationEnabled || m_activeAnimationControllers. empty() || !rootLayer()) | 1523 if (!m_settings.acceleratedAnimationEnabled || m_activeAnimationControllers. empty() || !rootLayer()) |
1495 return; | 1524 return; |
1496 | 1525 |
1497 TRACE_EVENT0("cc", "LayerTreeHostImpl::animateLayers"); | 1526 TRACE_EVENT0("cc", "LayerTreeHostImpl::animateLayers"); |
1498 | 1527 |
1499 double monotonicSeconds = (monotonicTime - base::TimeTicks()).InSecondsF(); | 1528 double monotonicSeconds = (monotonicTime - base::TimeTicks()).InSecondsF(); |
1500 | 1529 |
1501 scoped_ptr<AnimationEventsVector> events(make_scoped_ptr(new AnimationEvents Vector)); | 1530 scoped_ptr<AnimationEventsVector> events(make_scoped_ptr(new AnimationEvents Vector)); |
1502 AnimationControllerSet copy = m_activeAnimationControllers; | 1531 AnimationControllerSet copy = m_activeAnimationControllers; |
1503 for (AnimationControllerSet::iterator iter = copy.begin(); iter != copy.end( ); ++iter) | 1532 for (AnimationControllerSet::iterator iter = copy.begin(); iter != copy.end( ); ++iter) |
1504 (*iter)->animate(monotonicSeconds, events.get()); | 1533 (*iter)->animate(monotonicSeconds, events.get()); |
1505 | 1534 |
1535 | |
danakj
2012/12/07 23:12:49
extra \n
enne (OOO)
2012/12/07 23:25:05
Done.
| |
1506 if (!events->empty()) | 1536 if (!events->empty()) |
1507 m_client->postAnimationEventsToMainThreadOnImplThread(events.Pass(), wal lClockTime); | 1537 m_client->postAnimationEventsToMainThreadOnImplThread(events.Pass(), wal lClockTime); |
1508 | 1538 |
1539 setNeedsUpdateDrawProperties(); | |
1509 m_client->setNeedsRedrawOnImplThread(); | 1540 m_client->setNeedsRedrawOnImplThread(); |
1510 setBackgroundTickingEnabled(!m_visible && !m_activeAnimationControllers.empt y()); | 1541 setBackgroundTickingEnabled(!m_visible && !m_activeAnimationControllers.empt y()); |
1511 } | 1542 } |
1512 | 1543 |
1513 base::TimeDelta LayerTreeHostImpl::lowFrequencyAnimationInterval() const | 1544 base::TimeDelta LayerTreeHostImpl::lowFrequencyAnimationInterval() const |
1514 { | 1545 { |
1515 return base::TimeDelta::FromSeconds(1); | 1546 return base::TimeDelta::FromSeconds(1); |
1516 } | 1547 } |
1517 | 1548 |
1518 void LayerTreeHostImpl::sendDidLoseOutputSurfaceRecursive(LayerImpl* current) | 1549 void LayerTreeHostImpl::sendDidLoseOutputSurfaceRecursive(LayerImpl* current) |
(...skipping 13 matching lines...) Expand all Loading... | |
1532 DCHECK(current); | 1563 DCHECK(current); |
1533 for (size_t i = 0; i < current->children().size(); ++i) | 1564 for (size_t i = 0; i < current->children().size(); ++i) |
1534 clearRenderSurfacesOnLayerImplRecursive(current->children()[i]); | 1565 clearRenderSurfacesOnLayerImplRecursive(current->children()[i]); |
1535 current->clearRenderSurface(); | 1566 current->clearRenderSurface(); |
1536 } | 1567 } |
1537 | 1568 |
1538 void LayerTreeHostImpl::clearRenderSurfaces() | 1569 void LayerTreeHostImpl::clearRenderSurfaces() |
1539 { | 1570 { |
1540 clearRenderSurfacesOnLayerImplRecursive(rootLayer()); | 1571 clearRenderSurfacesOnLayerImplRecursive(rootLayer()); |
1541 m_renderSurfaceLayerList.clear(); | 1572 m_renderSurfaceLayerList.clear(); |
1573 setNeedsUpdateDrawProperties(); | |
1542 } | 1574 } |
1543 | 1575 |
1544 std::string LayerTreeHostImpl::layerTreeAsText() const | 1576 std::string LayerTreeHostImpl::layerTreeAsText() const |
1545 { | 1577 { |
1546 std::string str; | 1578 std::string str; |
1547 if (rootLayer()) { | 1579 if (rootLayer()) { |
1548 str = rootLayer()->layerTreeAsText(); | 1580 str = rootLayer()->layerTreeAsText(); |
1549 str += "RenderSurfaces:\n"; | 1581 str += "RenderSurfaces:\n"; |
1550 dumpRenderSurfaces(&str, 1, rootLayer()); | 1582 dumpRenderSurfaces(&str, 1, rootLayer()); |
1551 } | 1583 } |
(...skipping 62 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
1614 | 1646 |
1615 void LayerTreeHostImpl::UnregisterAnimationController(LayerAnimationController* controller) { | 1647 void LayerTreeHostImpl::UnregisterAnimationController(LayerAnimationController* controller) { |
1616 #if !defined(NDEBUG) | 1648 #if !defined(NDEBUG) |
1617 if (ContainsKey(m_allAnimationControllers, controller)) | 1649 if (ContainsKey(m_allAnimationControllers, controller)) |
1618 m_allAnimationControllers.erase(controller); | 1650 m_allAnimationControllers.erase(controller); |
1619 #endif | 1651 #endif |
1620 DidDeactivateAnimationController(controller); | 1652 DidDeactivateAnimationController(controller); |
1621 } | 1653 } |
1622 | 1654 |
1623 } // namespace cc | 1655 } // namespace cc |
OLD | NEW |