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" |
| (...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 175 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 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(); | |
|
danakj
2012/12/07 21:14:02
nit: 4 space indents
enne (OOO)
2012/12/07 23:03:00
Done.
| |
| 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 47 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 1117 return false; | 1139 return false; |
| 1118 | 1140 |
| 1119 // We need both a non-empty render surface layer list and a root render | 1141 // 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. | 1142 // surface to be able to iterate over the visible layers. |
| 1121 if (m_renderSurfaceLayerList.size() && rootLayer()->renderSurface()) | 1143 if (m_renderSurfaceLayerList.size() && rootLayer()->renderSurface()) |
| 1122 return true; | 1144 return true; |
| 1123 | 1145 |
| 1124 // If we are called after setRootLayer() but before prepareToDraw(), we need | 1146 // If we are called after setRootLayer() but before prepareToDraw(), we need |
| 1125 // to recalculate the visible layers. This prevents being unable to scroll | 1147 // to recalculate the visible layers. This prevents being unable to scroll |
| 1126 // during part of a commit. | 1148 // during part of a commit. |
| 1127 m_renderSurfaceLayerList.clear(); | 1149 setNeedsUpdateDrawProperties(); |
|
danakj
2012/12/07 21:14:02
Ok, throw a big TODO here please and file a bug. T
enne (OOO)
2012/12/07 23:03:00
Done. https://code.google.com/p/chromium/issues/d
| |
| 1128 calculateRenderSurfaceLayerList(m_renderSurfaceLayerList); | 1150 updateDrawProperties(); |
| 1129 | 1151 |
| 1130 return m_renderSurfaceLayerList.size(); | 1152 return m_renderSurfaceLayerList.size(); |
| 1131 } | 1153 } |
| 1132 | 1154 |
| 1133 InputHandlerClient::ScrollStatus LayerTreeHostImpl::scrollBegin(gfx::Point viewp ortPoint, InputHandlerClient::ScrollInputType type) | 1155 InputHandlerClient::ScrollStatus LayerTreeHostImpl::scrollBegin(gfx::Point viewp ortPoint, InputHandlerClient::ScrollInputType type) |
| 1134 { | 1156 { |
| 1135 TRACE_EVENT0("cc", "LayerTreeHostImpl::scrollBegin"); | 1157 TRACE_EVENT0("cc", "LayerTreeHostImpl::scrollBegin"); |
| 1136 | 1158 |
| 1137 DCHECK(!currentlyScrollingLayer()); | 1159 DCHECK(!currentlyScrollingLayer()); |
| 1138 clearCurrentlyScrollingLayer(); | 1160 clearCurrentlyScrollingLayer(); |
| (...skipping 32 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 1171 potentiallyScrollingLayerImpl = scrollLayerImpl; | 1193 potentiallyScrollingLayerImpl = scrollLayerImpl; |
| 1172 } | 1194 } |
| 1173 | 1195 |
| 1174 if (potentiallyScrollingLayerImpl) { | 1196 if (potentiallyScrollingLayerImpl) { |
| 1175 m_activeTree->set_currently_scrolling_layer(potentiallyScrollingLayerImp l); | 1197 m_activeTree->set_currently_scrolling_layer(potentiallyScrollingLayerImp l); |
| 1176 // Gesture events need to be transformed from viewport coordinates to lo cal layer coordinates | 1198 // 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 | 1199 // 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. | 1200 // events are already in local layer coordinates so we can just apply th em directly. |
| 1179 m_scrollDeltaIsInViewportSpace = (type == Gesture); | 1201 m_scrollDeltaIsInViewportSpace = (type == Gesture); |
| 1180 m_numImplThreadScrolls++; | 1202 m_numImplThreadScrolls++; |
| 1203 setNeedsUpdateDrawProperties(); | |
| 1181 return ScrollStarted; | 1204 return ScrollStarted; |
| 1182 } | 1205 } |
| 1183 return ScrollIgnored; | 1206 return ScrollIgnored; |
| 1184 } | 1207 } |
| 1185 | 1208 |
| 1186 static gfx::Vector2dF scrollLayerWithViewportSpaceDelta(PinchZoomViewport* viewp ort, LayerImpl& layerImpl, float scaleFromViewportToScreenSpace, gfx::PointF vie wportPoint, gfx::Vector2dF viewportDelta) | 1209 static gfx::Vector2dF scrollLayerWithViewportSpaceDelta(PinchZoomViewport* viewp ort, LayerImpl& layerImpl, float scaleFromViewportToScreenSpace, gfx::PointF vie wportPoint, gfx::Vector2dF viewportDelta) |
| 1187 { | 1210 { |
| 1188 // Layers with non-invertible screen space transforms should not have passed the scroll hit | 1211 // Layers with non-invertible screen space transforms should not have passed the scroll hit |
| 1189 // test in the first place. | 1212 // test in the first place. |
| 1190 DCHECK(layerImpl.screenSpaceTransform().IsInvertible()); | 1213 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()); | 1308 gfx::Vector2dF perpendicularAxis(-appliedDelta.y(), appliedDelta.x()); |
| 1286 pendingDelta = MathUtil::projectVector(pendingDelta, perpendicularAxis); | 1309 pendingDelta = MathUtil::projectVector(pendingDelta, perpendicularAxis); |
| 1287 | 1310 |
| 1288 if (gfx::ToFlooredVector2d(pendingDelta).IsZero()) | 1311 if (gfx::ToFlooredVector2d(pendingDelta).IsZero()) |
| 1289 break; | 1312 break; |
| 1290 } | 1313 } |
| 1291 | 1314 |
| 1292 if (didScroll) { | 1315 if (didScroll) { |
| 1293 m_client->setNeedsCommitOnImplThread(); | 1316 m_client->setNeedsCommitOnImplThread(); |
| 1294 m_client->setNeedsRedrawOnImplThread(); | 1317 m_client->setNeedsRedrawOnImplThread(); |
| 1318 setNeedsUpdateDrawProperties(); | |
| 1295 } | 1319 } |
| 1296 return didScroll; | 1320 return didScroll; |
| 1297 } | 1321 } |
| 1298 | 1322 |
| 1299 void LayerTreeHostImpl::clearCurrentlyScrollingLayer() | 1323 void LayerTreeHostImpl::clearCurrentlyScrollingLayer() |
| 1300 { | 1324 { |
| 1301 m_activeTree->ClearCurrentlyScrollingLayer(); | 1325 m_activeTree->ClearCurrentlyScrollingLayer(); |
| 1302 } | 1326 } |
| 1303 | 1327 |
| 1304 void LayerTreeHostImpl::scrollEnd() | 1328 void LayerTreeHostImpl::scrollEnd() |
| (...skipping 34 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 1339 } | 1363 } |
| 1340 | 1364 |
| 1341 gfx::Vector2dF scrollOverflow = m_settings.pageScalePinchZoomEnabled ? m_pin chZoomViewport.applyScroll(move) : move; | 1365 gfx::Vector2dF scrollOverflow = m_settings.pageScalePinchZoomEnabled ? m_pin chZoomViewport.applyScroll(move) : move; |
| 1342 rootScrollLayer()->scrollBy(scrollOverflow); | 1366 rootScrollLayer()->scrollBy(scrollOverflow); |
| 1343 | 1367 |
| 1344 if (rootScrollLayer()->scrollbarAnimationController()) | 1368 if (rootScrollLayer()->scrollbarAnimationController()) |
| 1345 rootScrollLayer()->scrollbarAnimationController()->didPinchGestureUpdate (); | 1369 rootScrollLayer()->scrollbarAnimationController()->didPinchGestureUpdate (); |
| 1346 | 1370 |
| 1347 m_client->setNeedsCommitOnImplThread(); | 1371 m_client->setNeedsCommitOnImplThread(); |
| 1348 m_client->setNeedsRedrawOnImplThread(); | 1372 m_client->setNeedsRedrawOnImplThread(); |
| 1373 setNeedsUpdateDrawProperties(); | |
| 1349 } | 1374 } |
| 1350 | 1375 |
| 1351 void LayerTreeHostImpl::pinchGestureEnd() | 1376 void LayerTreeHostImpl::pinchGestureEnd() |
| 1352 { | 1377 { |
| 1353 m_pinchGestureActive = false; | 1378 m_pinchGestureActive = false; |
| 1354 | 1379 |
| 1355 if (rootScrollLayer() && rootScrollLayer()->scrollbarAnimationController()) | 1380 if (rootScrollLayer() && rootScrollLayer()->scrollbarAnimationController()) |
| 1356 rootScrollLayer()->scrollbarAnimationController()->didPinchGestureEnd(); | 1381 rootScrollLayer()->scrollbarAnimationController()->didPinchGestureEnd(); |
| 1357 | 1382 |
| 1358 m_client->setNeedsCommitOnImplThread(); | 1383 m_client->setNeedsCommitOnImplThread(); |
| (...skipping 116 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 1475 double monotonicTime = (time - base::TimeTicks()).InSecondsF(); | 1500 double monotonicTime = (time - base::TimeTicks()).InSecondsF(); |
| 1476 gfx::Vector2dF scrollTotal = rootScrollLayer()->scrollOffset() + rootScrollL ayer()->scrollDelta(); | 1501 gfx::Vector2dF scrollTotal = rootScrollLayer()->scrollOffset() + rootScrollL ayer()->scrollDelta(); |
| 1477 | 1502 |
| 1478 setPageScaleDelta(m_pageScaleAnimation->pageScaleFactorAtTime(monotonicTime) / m_pinchZoomViewport.pageScaleFactor()); | 1503 setPageScaleDelta(m_pageScaleAnimation->pageScaleFactorAtTime(monotonicTime) / m_pinchZoomViewport.pageScaleFactor()); |
| 1479 gfx::Vector2dF nextScroll = m_pageScaleAnimation->scrollOffsetAtTime(monoton icTime); | 1504 gfx::Vector2dF nextScroll = m_pageScaleAnimation->scrollOffsetAtTime(monoton icTime); |
| 1480 | 1505 |
| 1481 if (!m_settings.pageScalePinchZoomEnabled) | 1506 if (!m_settings.pageScalePinchZoomEnabled) |
| 1482 nextScroll.Scale(m_pinchZoomViewport.pageScaleFactor()); | 1507 nextScroll.Scale(m_pinchZoomViewport.pageScaleFactor()); |
| 1483 rootScrollLayer()->scrollBy(nextScroll - scrollTotal); | 1508 rootScrollLayer()->scrollBy(nextScroll - scrollTotal); |
| 1484 m_client->setNeedsRedrawOnImplThread(); | 1509 m_client->setNeedsRedrawOnImplThread(); |
| 1510 setNeedsUpdateDrawProperties(); | |
| 1485 | 1511 |
| 1486 if (m_pageScaleAnimation->isAnimationCompleteAtTime(monotonicTime)) { | 1512 if (m_pageScaleAnimation->isAnimationCompleteAtTime(monotonicTime)) { |
| 1487 m_pageScaleAnimation.reset(); | 1513 m_pageScaleAnimation.reset(); |
| 1488 m_client->setNeedsCommitOnImplThread(); | 1514 m_client->setNeedsCommitOnImplThread(); |
| 1489 } | 1515 } |
| 1490 } | 1516 } |
| 1491 | 1517 |
| 1492 void LayerTreeHostImpl::animateLayers(base::TimeTicks monotonicTime, base::Time wallClockTime) | 1518 void LayerTreeHostImpl::animateLayers(base::TimeTicks monotonicTime, base::Time wallClockTime) |
| 1493 { | 1519 { |
| 1494 if (!m_settings.acceleratedAnimationEnabled || m_activeAnimationControllers. empty() || !rootLayer()) | 1520 if (!m_settings.acceleratedAnimationEnabled || m_activeAnimationControllers. empty() || !rootLayer()) |
| 1495 return; | 1521 return; |
| 1496 | 1522 |
| 1497 TRACE_EVENT0("cc", "LayerTreeHostImpl::animateLayers"); | 1523 TRACE_EVENT0("cc", "LayerTreeHostImpl::animateLayers"); |
| 1498 | 1524 |
| 1499 double monotonicSeconds = (monotonicTime - base::TimeTicks()).InSecondsF(); | 1525 double monotonicSeconds = (monotonicTime - base::TimeTicks()).InSecondsF(); |
| 1500 | 1526 |
| 1501 scoped_ptr<AnimationEventsVector> events(make_scoped_ptr(new AnimationEvents Vector)); | 1527 scoped_ptr<AnimationEventsVector> events(make_scoped_ptr(new AnimationEvents Vector)); |
| 1502 AnimationControllerSet copy = m_activeAnimationControllers; | 1528 AnimationControllerSet copy = m_activeAnimationControllers; |
| 1503 for (AnimationControllerSet::iterator iter = copy.begin(); iter != copy.end( ); ++iter) | 1529 for (AnimationControllerSet::iterator iter = copy.begin(); iter != copy.end( ); ++iter) |
| 1504 (*iter)->animate(monotonicSeconds, events.get()); | 1530 (*iter)->animate(monotonicSeconds, events.get()); |
| 1505 | 1531 |
| 1532 if (copy.size() > 0) | |
|
danakj
2012/12/07 21:14:02
nit: !copy.empty()
Or even better, save !m_active
enne (OOO)
2012/12/07 23:03:00
Actually, there's an early out for no active contr
| |
| 1533 m_client->setNeedsRedrawOnImplThread(); | |
|
danakj
2012/12/07 21:14:02
did you mean to setNeedsUpdateDrawProperties() her
enne (OOO)
2012/12/07 23:03:00
Done.
| |
| 1534 | |
| 1506 if (!events->empty()) | 1535 if (!events->empty()) |
| 1507 m_client->postAnimationEventsToMainThreadOnImplThread(events.Pass(), wal lClockTime); | 1536 m_client->postAnimationEventsToMainThreadOnImplThread(events.Pass(), wal lClockTime); |
| 1508 | 1537 |
| 1509 m_client->setNeedsRedrawOnImplThread(); | |
| 1510 setBackgroundTickingEnabled(!m_visible && !m_activeAnimationControllers.empt y()); | 1538 setBackgroundTickingEnabled(!m_visible && !m_activeAnimationControllers.empt y()); |
| 1511 } | 1539 } |
| 1512 | 1540 |
| 1513 base::TimeDelta LayerTreeHostImpl::lowFrequencyAnimationInterval() const | 1541 base::TimeDelta LayerTreeHostImpl::lowFrequencyAnimationInterval() const |
| 1514 { | 1542 { |
| 1515 return base::TimeDelta::FromSeconds(1); | 1543 return base::TimeDelta::FromSeconds(1); |
| 1516 } | 1544 } |
| 1517 | 1545 |
| 1518 void LayerTreeHostImpl::sendDidLoseOutputSurfaceRecursive(LayerImpl* current) | 1546 void LayerTreeHostImpl::sendDidLoseOutputSurfaceRecursive(LayerImpl* current) |
| 1519 { | 1547 { |
| (...skipping 12 matching lines...) Expand all Loading... | |
| 1532 DCHECK(current); | 1560 DCHECK(current); |
| 1533 for (size_t i = 0; i < current->children().size(); ++i) | 1561 for (size_t i = 0; i < current->children().size(); ++i) |
| 1534 clearRenderSurfacesOnLayerImplRecursive(current->children()[i]); | 1562 clearRenderSurfacesOnLayerImplRecursive(current->children()[i]); |
| 1535 current->clearRenderSurface(); | 1563 current->clearRenderSurface(); |
| 1536 } | 1564 } |
| 1537 | 1565 |
| 1538 void LayerTreeHostImpl::clearRenderSurfaces() | 1566 void LayerTreeHostImpl::clearRenderSurfaces() |
| 1539 { | 1567 { |
| 1540 clearRenderSurfacesOnLayerImplRecursive(rootLayer()); | 1568 clearRenderSurfacesOnLayerImplRecursive(rootLayer()); |
| 1541 m_renderSurfaceLayerList.clear(); | 1569 m_renderSurfaceLayerList.clear(); |
| 1570 setNeedsUpdateDrawProperties(); | |
| 1542 } | 1571 } |
| 1543 | 1572 |
| 1544 std::string LayerTreeHostImpl::layerTreeAsText() const | 1573 std::string LayerTreeHostImpl::layerTreeAsText() const |
| 1545 { | 1574 { |
| 1546 std::string str; | 1575 std::string str; |
| 1547 if (rootLayer()) { | 1576 if (rootLayer()) { |
| 1548 str = rootLayer()->layerTreeAsText(); | 1577 str = rootLayer()->layerTreeAsText(); |
| 1549 str += "RenderSurfaces:\n"; | 1578 str += "RenderSurfaces:\n"; |
| 1550 dumpRenderSurfaces(&str, 1, rootLayer()); | 1579 dumpRenderSurfaces(&str, 1, rootLayer()); |
| 1551 } | 1580 } |
| (...skipping 62 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 1614 | 1643 |
| 1615 void LayerTreeHostImpl::UnregisterAnimationController(LayerAnimationController* controller) { | 1644 void LayerTreeHostImpl::UnregisterAnimationController(LayerAnimationController* controller) { |
| 1616 #if !defined(NDEBUG) | 1645 #if !defined(NDEBUG) |
| 1617 if (ContainsKey(m_allAnimationControllers, controller)) | 1646 if (ContainsKey(m_allAnimationControllers, controller)) |
| 1618 m_allAnimationControllers.erase(controller); | 1647 m_allAnimationControllers.erase(controller); |
| 1619 #endif | 1648 #endif |
| 1620 DidDeactivateAnimationController(controller); | 1649 DidDeactivateAnimationController(controller); |
| 1621 } | 1650 } |
| 1622 | 1651 |
| 1623 } // namespace cc | 1652 } // namespace cc |
| OLD | NEW |