| 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 201 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 212 , m_deviceScaleFactor(1) | 212 , m_deviceScaleFactor(1) |
| 213 , m_visible(true) | 213 , m_visible(true) |
| 214 , m_contentsTexturesPurged(false) | 214 , m_contentsTexturesPurged(false) |
| 215 , m_managedMemoryPolicy(PrioritizedResourceManager::defaultMemoryAllocationL
imit(), | 215 , m_managedMemoryPolicy(PrioritizedResourceManager::defaultMemoryAllocationL
imit(), |
| 216 PriorityCalculator::allowEverythingCutoff(), | 216 PriorityCalculator::allowEverythingCutoff(), |
| 217 0, | 217 0, |
| 218 PriorityCalculator::allowNothingCutoff()) | 218 PriorityCalculator::allowNothingCutoff()) |
| 219 , m_backgroundColor(0) | 219 , m_backgroundColor(0) |
| 220 , m_hasTransparentBackground(false) | 220 , m_hasTransparentBackground(false) |
| 221 , m_needsAnimateLayers(false) | 221 , m_needsAnimateLayers(false) |
| 222 , m_needsUpdateDrawProperties(false) |
| 222 , m_pinchGestureActive(false) | 223 , m_pinchGestureActive(false) |
| 223 , m_fpsCounter(FrameRateCounter::create(m_proxy->hasImplThread())) | 224 , m_fpsCounter(FrameRateCounter::create(m_proxy->hasImplThread())) |
| 224 , m_debugRectHistory(DebugRectHistory::create()) | 225 , m_debugRectHistory(DebugRectHistory::create()) |
| 225 , m_numImplThreadScrolls(0) | 226 , m_numImplThreadScrolls(0) |
| 226 , m_numMainThreadScrolls(0) | 227 , m_numMainThreadScrolls(0) |
| 227 , m_cumulativeNumLayersDrawn(0) | 228 , m_cumulativeNumLayersDrawn(0) |
| 228 , m_cumulativeNumMissingTiles(0) | 229 , m_cumulativeNumMissingTiles(0) |
| 229 , m_lastSentMemoryVisibleBytes(0) | 230 , m_lastSentMemoryVisibleBytes(0) |
| 230 , m_lastSentMemoryVisibleAndNearbyBytes(0) | 231 , m_lastSentMemoryVisibleAndNearbyBytes(0) |
| 231 , m_lastSentMemoryUseBytes(0) | 232 , m_lastSentMemoryUseBytes(0) |
| (...skipping 15 matching lines...) Expand all Loading... |
| 247 clearRenderSurfaces(); | 248 clearRenderSurfaces(); |
| 248 } | 249 } |
| 249 | 250 |
| 250 void LayerTreeHostImpl::beginCommit() | 251 void LayerTreeHostImpl::beginCommit() |
| 251 { | 252 { |
| 252 } | 253 } |
| 253 | 254 |
| 254 void LayerTreeHostImpl::commitComplete() | 255 void LayerTreeHostImpl::commitComplete() |
| 255 { | 256 { |
| 256 TRACE_EVENT0("cc", "LayerTreeHostImpl::commitComplete"); | 257 TRACE_EVENT0("cc", "LayerTreeHostImpl::commitComplete"); |
| 258 |
| 259 // Impl-side painting needs an update immediately post-commit to have the |
| 260 // opportunity to create tilings. Other paths can call updateDrawProperties |
| 261 // more lazily when needed prior to drawing. |
| 262 setNeedsUpdateDrawProperties(); |
| 263 if (m_settings.implSidePainting) |
| 264 updateDrawProperties(); |
| 265 |
| 257 // Recompute max scroll position; must be after layer content bounds are | 266 // Recompute max scroll position; must be after layer content bounds are |
| 258 // updated. | 267 // updated. |
| 259 updateMaxScrollOffset(); | 268 updateMaxScrollOffset(); |
| 260 m_client->sendManagedMemoryStats(); | 269 m_client->sendManagedMemoryStats(); |
| 261 } | 270 } |
| 262 | 271 |
| 263 bool LayerTreeHostImpl::canDraw() | 272 bool LayerTreeHostImpl::canDraw() |
| 264 { | 273 { |
| 265 // Note: If you are changing this function or any other function that might | 274 // Note: If you are changing this function or any other function that might |
| 266 // affect the result of canDraw, make sure to call m_client->onCanDrawStateC
hanged | 275 // 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... |
| 324 if (!m_settings.pageScalePinchZoomEnabled) | 333 if (!m_settings.pageScalePinchZoomEnabled) |
| 325 anchor.Scale(1 / pageScale); | 334 anchor.Scale(1 / pageScale); |
| 326 m_pageScaleAnimation->zoomWithAnchor(anchor, pageScale, duration.InSecon
dsF()); | 335 m_pageScaleAnimation->zoomWithAnchor(anchor, pageScale, duration.InSecon
dsF()); |
| 327 } else { | 336 } else { |
| 328 gfx::Vector2dF scaledTargetOffset = targetOffset; | 337 gfx::Vector2dF scaledTargetOffset = targetOffset; |
| 329 if (!m_settings.pageScalePinchZoomEnabled) | 338 if (!m_settings.pageScalePinchZoomEnabled) |
| 330 scaledTargetOffset.Scale(1 / pageScale); | 339 scaledTargetOffset.Scale(1 / pageScale); |
| 331 m_pageScaleAnimation->zoomTo(scaledTargetOffset, pageScale, duration.InS
econdsF()); | 340 m_pageScaleAnimation->zoomTo(scaledTargetOffset, pageScale, duration.InS
econdsF()); |
| 332 } | 341 } |
| 333 | 342 |
| 343 setNeedsUpdateDrawProperties(); |
| 334 m_client->setNeedsRedrawOnImplThread(); | 344 m_client->setNeedsRedrawOnImplThread(); |
| 335 m_client->setNeedsCommitOnImplThread(); | 345 m_client->setNeedsCommitOnImplThread(); |
| 336 } | 346 } |
| 337 | 347 |
| 338 void LayerTreeHostImpl::scheduleAnimation() | 348 void LayerTreeHostImpl::scheduleAnimation() |
| 339 { | 349 { |
| 340 m_client->setNeedsRedrawOnImplThread(); | 350 m_client->setNeedsRedrawOnImplThread(); |
| 341 } | 351 } |
| 342 | 352 |
| 343 bool LayerTreeHostImpl::haveTouchEventHandlersAt(const gfx::Point& viewportPoint
) | 353 bool LayerTreeHostImpl::haveTouchEventHandlersAt(const gfx::Point& viewportPoint
) |
| (...skipping 25 matching lines...) Expand all Loading... |
| 369 } | 379 } |
| 370 } | 380 } |
| 371 | 381 |
| 372 void LayerTreeHostImpl::updateRootScrollLayerImplTransform() | 382 void LayerTreeHostImpl::updateRootScrollLayerImplTransform() |
| 373 { | 383 { |
| 374 if (rootScrollLayer()) { | 384 if (rootScrollLayer()) { |
| 375 rootScrollLayer()->setImplTransform(implTransform()); | 385 rootScrollLayer()->setImplTransform(implTransform()); |
| 376 } | 386 } |
| 377 } | 387 } |
| 378 | 388 |
| 389 void LayerTreeHostImpl::updateDrawProperties() |
| 390 { |
| 391 if (!needsUpdateDrawProperties()) |
| 392 return; |
| 393 |
| 394 m_renderSurfaceLayerList.clear(); |
| 395 m_needsUpdateDrawProperties = false; |
| 396 |
| 397 if (!rootLayer()) |
| 398 return; |
| 399 |
| 400 calculateRenderSurfaceLayerList(m_renderSurfaceLayerList); |
| 401 } |
| 402 |
| 379 void LayerTreeHostImpl::calculateRenderSurfaceLayerList(LayerList& renderSurface
LayerList) | 403 void LayerTreeHostImpl::calculateRenderSurfaceLayerList(LayerList& renderSurface
LayerList) |
| 380 { | 404 { |
| 381 DCHECK(renderSurfaceLayerList.empty()); | 405 DCHECK(renderSurfaceLayerList.empty()); |
| 382 DCHECK(rootLayer()); | 406 DCHECK(rootLayer()); |
| 383 DCHECK(m_renderer); // For maxTextureSize. | 407 DCHECK(m_renderer); // For maxTextureSize. |
| 384 | |
| 385 { | 408 { |
| 386 updateRootScrollLayerImplTransform(); | 409 updateRootScrollLayerImplTransform(); |
| 387 | 410 |
| 388 TRACE_EVENT0("cc", "LayerTreeHostImpl::calcDrawEtc"); | 411 TRACE_EVENT0("cc", "LayerTreeHostImpl::calcDrawEtc"); |
| 389 float pageScaleFactor = m_pinchZoomViewport.pageScaleFactor(); | 412 float pageScaleFactor = m_pinchZoomViewport.pageScaleFactor(); |
| 390 LayerTreeHostCommon::calculateDrawProperties(rootLayer(), deviceViewport
Size(), m_deviceScaleFactor, pageScaleFactor, rendererCapabilities().maxTextureS
ize, renderSurfaceLayerList); | 413 LayerTreeHostCommon::calculateDrawProperties(rootLayer(), deviceViewport
Size(), m_deviceScaleFactor, pageScaleFactor, rendererCapabilities().maxTextureS
ize, renderSurfaceLayerList); |
| 391 | |
| 392 trackDamageForAllSurfaces(rootLayer(), renderSurfaceLayerList); | |
| 393 } | 414 } |
| 394 } | 415 } |
| 395 | 416 |
| 396 void LayerTreeHostImpl::FrameData::appendRenderPass(scoped_ptr<RenderPass> rende
rPass) | 417 void LayerTreeHostImpl::FrameData::appendRenderPass(scoped_ptr<RenderPass> rende
rPass) |
| 397 { | 418 { |
| 398 RenderPass* pass = renderPass.get(); | 419 RenderPass* pass = renderPass.get(); |
| 399 renderPasses.push_back(pass); | 420 renderPasses.push_back(pass); |
| 400 renderPassesById.set(pass->id, renderPass.Pass()); | 421 renderPassesById.set(pass->id, renderPass.Pass()); |
| 401 } | 422 } |
| 402 | 423 |
| (...skipping 79 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 482 scoped_ptr<SolidColorDrawQuad> quad = SolidColorDrawQuad::Create(); | 503 scoped_ptr<SolidColorDrawQuad> quad = SolidColorDrawQuad::Create(); |
| 483 quad->SetNew(sharedQuadState, layerRect, screenBackgroundColor); | 504 quad->SetNew(sharedQuadState, layerRect, screenBackgroundColor); |
| 484 quadCuller.append(quad.PassAs<DrawQuad>(), appendQuadsData); | 505 quadCuller.append(quad.PassAs<DrawQuad>(), appendQuadsData); |
| 485 } | 506 } |
| 486 } | 507 } |
| 487 | 508 |
| 488 bool LayerTreeHostImpl::calculateRenderPasses(FrameData& frame) | 509 bool LayerTreeHostImpl::calculateRenderPasses(FrameData& frame) |
| 489 { | 510 { |
| 490 DCHECK(frame.renderPasses.empty()); | 511 DCHECK(frame.renderPasses.empty()); |
| 491 | 512 |
| 492 calculateRenderSurfaceLayerList(*frame.renderSurfaceLayerList); | 513 updateDrawProperties(); |
| 514 trackDamageForAllSurfaces(rootLayer(), *frame.renderSurfaceLayerList); |
| 493 | 515 |
| 494 TRACE_EVENT1("cc", "LayerTreeHostImpl::calculateRenderPasses", "renderSurfac
eLayerList.size()", static_cast<long long unsigned>(frame.renderSurfaceLayerList
->size())); | 516 TRACE_EVENT1("cc", "LayerTreeHostImpl::calculateRenderPasses", "renderSurfac
eLayerList.size()", static_cast<long long unsigned>(frame.renderSurfaceLayerList
->size())); |
| 495 | 517 |
| 496 // Create the render passes in dependency order. | 518 // Create the render passes in dependency order. |
| 497 for (int surfaceIndex = frame.renderSurfaceLayerList->size() - 1; surfaceInd
ex >= 0 ; --surfaceIndex) { | 519 for (int surfaceIndex = frame.renderSurfaceLayerList->size() - 1; surfaceInd
ex >= 0 ; --surfaceIndex) { |
| 498 LayerImpl* renderSurfaceLayer = (*frame.renderSurfaceLayerList)[surfaceI
ndex]; | 520 LayerImpl* renderSurfaceLayer = (*frame.renderSurfaceLayerList)[surfaceI
ndex]; |
| 499 renderSurfaceLayer->renderSurface()->appendRenderPasses(frame); | 521 renderSurfaceLayer->renderSurface()->appendRenderPasses(frame); |
| 500 } | 522 } |
| 501 | 523 |
| 502 bool recordMetricsForFrame = m_settings.showOverdrawInTracing && base::debug
::TraceLog::GetInstance() && base::debug::TraceLog::GetInstance()->IsEnabled(); | 524 bool recordMetricsForFrame = m_settings.showOverdrawInTracing && base::debug
::TraceLog::GetInstance() && base::debug::TraceLog::GetInstance()->IsEnabled(); |
| (...skipping 25 matching lines...) Expand all Loading... |
| 528 if (it.representsContributingRenderSurface()) { | 550 if (it.representsContributingRenderSurface()) { |
| 529 RenderPass::Id contributingRenderPassId = it->renderSurface()->rende
rPassId(); | 551 RenderPass::Id contributingRenderPassId = it->renderSurface()->rende
rPassId(); |
| 530 RenderPass* contributingRenderPass = frame.renderPassesById.get(cont
ributingRenderPassId); | 552 RenderPass* contributingRenderPass = frame.renderPassesById.get(cont
ributingRenderPassId); |
| 531 appendQuadsForRenderSurfaceLayer(targetRenderPass, *it, contributing
RenderPass, occlusionTracker, appendQuadsData); | 553 appendQuadsForRenderSurfaceLayer(targetRenderPass, *it, contributing
RenderPass, occlusionTracker, appendQuadsData); |
| 532 } else if (it.representsItself() && !it->visibleContentRect().IsEmpty())
{ | 554 } else if (it.representsItself() && !it->visibleContentRect().IsEmpty())
{ |
| 533 bool hasOcclusionFromOutsideTargetSurface; | 555 bool hasOcclusionFromOutsideTargetSurface; |
| 534 bool implDrawTransformIsUnknown = false; | 556 bool implDrawTransformIsUnknown = false; |
| 535 if (occlusionTracker.occluded(it->renderTarget(), it->visibleContent
Rect(), it->drawTransform(), implDrawTransformIsUnknown, it->drawableContentRect
(), &hasOcclusionFromOutsideTargetSurface)) | 557 if (occlusionTracker.occluded(it->renderTarget(), it->visibleContent
Rect(), it->drawTransform(), implDrawTransformIsUnknown, it->drawableContentRect
(), &hasOcclusionFromOutsideTargetSurface)) |
| 536 appendQuadsData.hadOcclusionFromOutsideTargetSurface |= hasOcclu
sionFromOutsideTargetSurface; | 558 appendQuadsData.hadOcclusionFromOutsideTargetSurface |= hasOcclu
sionFromOutsideTargetSurface; |
| 537 else { | 559 else { |
| 560 DCHECK_EQ(this, it->layerTreeHostImpl()); |
| 538 it->willDraw(m_resourceProvider.get()); | 561 it->willDraw(m_resourceProvider.get()); |
| 539 frame.willDrawLayers.push_back(*it); | 562 frame.willDrawLayers.push_back(*it); |
| 540 | 563 |
| 541 if (it->hasContributingDelegatedRenderPasses()) { | 564 if (it->hasContributingDelegatedRenderPasses()) { |
| 542 RenderPass::Id contributingRenderPassId = it->firstContribut
ingRenderPassId(); | 565 RenderPass::Id contributingRenderPassId = it->firstContribut
ingRenderPassId(); |
| 543 while (frame.renderPassesById.contains(contributingRenderPas
sId)) { | 566 while (frame.renderPassesById.contains(contributingRenderPas
sId)) { |
| 544 RenderPass* renderPass = frame.renderPassesById.get(cont
ributingRenderPassId); | 567 RenderPass* renderPass = frame.renderPassesById.get(cont
ributingRenderPassId); |
| 545 | 568 |
| 546 AppendQuadsData appendQuadsData(renderPass->id); | 569 AppendQuadsData appendQuadsData(renderPass->id); |
| 547 appendQuadsForLayer(renderPass, *it, occlusionTracker, a
ppendQuadsData); | 570 appendQuadsForLayer(renderPass, *it, occlusionTracker, a
ppendQuadsData); |
| (...skipping 195 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 743 { | 766 { |
| 744 TRACE_EVENT0("cc", "LayerTreeHostImpl::prepareToDraw"); | 767 TRACE_EVENT0("cc", "LayerTreeHostImpl::prepareToDraw"); |
| 745 DCHECK(canDraw()); | 768 DCHECK(canDraw()); |
| 746 | 769 |
| 747 if (m_tileManager) | 770 if (m_tileManager) |
| 748 m_tileManager->CheckForCompletedSetPixels(); | 771 m_tileManager->CheckForCompletedSetPixels(); |
| 749 | 772 |
| 750 frame.renderSurfaceLayerList = &m_renderSurfaceLayerList; | 773 frame.renderSurfaceLayerList = &m_renderSurfaceLayerList; |
| 751 frame.renderPasses.clear(); | 774 frame.renderPasses.clear(); |
| 752 frame.renderPassesById.clear(); | 775 frame.renderPassesById.clear(); |
| 753 frame.renderSurfaceLayerList->clear(); | |
| 754 frame.willDrawLayers.clear(); | 776 frame.willDrawLayers.clear(); |
| 755 | 777 |
| 756 if (!calculateRenderPasses(frame)) | 778 if (!calculateRenderPasses(frame)) |
| 757 return false; | 779 return false; |
| 758 | 780 |
| 759 // If we return true, then we expect drawLayers() to be called before this f
unction is called again. | 781 // If we return true, then we expect drawLayers() to be called before this f
unction is called again. |
| 760 return true; | 782 return true; |
| 761 } | 783 } |
| 762 | 784 |
| 763 void LayerTreeHostImpl::enforceManagedMemoryPolicy(const ManagedMemoryPolicy& po
licy) | 785 void LayerTreeHostImpl::enforceManagedMemoryPolicy(const ManagedMemoryPolicy& po
licy) |
| (...skipping 181 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 945 return layerImpl; | 967 return layerImpl; |
| 946 | 968 |
| 947 if (layerImpl->drawsContent() && layerImpl->parent() && layerImpl->parent()-
>scrollable()) | 969 if (layerImpl->drawsContent() && layerImpl->parent() && layerImpl->parent()-
>scrollable()) |
| 948 return layerImpl->parent(); | 970 return layerImpl->parent(); |
| 949 | 971 |
| 950 return 0; | 972 return 0; |
| 951 } | 973 } |
| 952 | 974 |
| 953 void LayerTreeHostImpl::setRootLayer(scoped_ptr<LayerImpl> layer) | 975 void LayerTreeHostImpl::setRootLayer(scoped_ptr<LayerImpl> layer) |
| 954 { | 976 { |
| 955 m_activeTree->SetRootLayer(layer.Pass()); | 977 m_activeTree->SetRootLayer(layer.Pass()); |
| 978 setNeedsUpdateDrawProperties(); |
| 956 } | 979 } |
| 957 | 980 |
| 958 scoped_ptr<LayerImpl> LayerTreeHostImpl::detachLayerTree() | 981 scoped_ptr<LayerImpl> LayerTreeHostImpl::detachLayerTree() |
| 959 { | 982 { |
| 960 scoped_ptr<LayerImpl> layer = m_activeTree->DetachLayerTree(); | 983 scoped_ptr<LayerImpl> layer = m_activeTree->DetachLayerTree(); |
| 961 m_renderSurfaceLayerList.clear(); | 984 m_renderSurfaceLayerList.clear(); |
| 962 return layer.Pass(); | 985 setNeedsUpdateDrawProperties(); |
| 986 return layer.Pass(); |
| 963 } | 987 } |
| 964 | 988 |
| 965 void LayerTreeHostImpl::setVisible(bool visible) | 989 void LayerTreeHostImpl::setVisible(bool visible) |
| 966 { | 990 { |
| 967 DCHECK(m_proxy->isImplThread()); | 991 DCHECK(m_proxy->isImplThread()); |
| 968 | 992 |
| 969 if (m_visible == visible) | 993 if (m_visible == visible) |
| 970 return; | 994 return; |
| 971 m_visible = visible; | 995 m_visible = visible; |
| 972 didVisibilityChange(this, m_visible); | 996 didVisibilityChange(this, m_visible); |
| (...skipping 114 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1087 } | 1111 } |
| 1088 | 1112 |
| 1089 void LayerTreeHostImpl::setPageScaleFactorAndLimits(float pageScaleFactor, float
minPageScaleFactor, float maxPageScaleFactor) | 1113 void LayerTreeHostImpl::setPageScaleFactorAndLimits(float pageScaleFactor, float
minPageScaleFactor, float maxPageScaleFactor) |
| 1090 { | 1114 { |
| 1091 if (!pageScaleFactor) | 1115 if (!pageScaleFactor) |
| 1092 return; | 1116 return; |
| 1093 | 1117 |
| 1094 float pageScaleChange = pageScaleFactor / m_pinchZoomViewport.pageScaleFacto
r(); | 1118 float pageScaleChange = pageScaleFactor / m_pinchZoomViewport.pageScaleFacto
r(); |
| 1095 m_pinchZoomViewport.setPageScaleFactorAndLimits(pageScaleFactor, minPageScal
eFactor, maxPageScaleFactor); | 1119 m_pinchZoomViewport.setPageScaleFactorAndLimits(pageScaleFactor, minPageScal
eFactor, maxPageScaleFactor); |
| 1096 | 1120 |
| 1097 if (!m_settings.pageScalePinchZoomEnabled) { | 1121 if (!m_settings.pageScalePinchZoomEnabled && pageScaleChange != 1) |
| 1098 if (pageScaleChange != 1) | 1122 adjustScrollsForPageScaleChange(rootScrollLayer(), pageScaleChange); |
| 1099 adjustScrollsForPageScaleChange(rootScrollLayer(), pageScaleChange); | |
| 1100 } | |
| 1101 | 1123 |
| 1102 // Clamp delta to limits and refresh display matrix. | 1124 // Clamp delta to limits and refresh display matrix. |
| 1103 setPageScaleDelta(m_pinchZoomViewport.pageScaleDelta() / m_pinchZoomViewport
.sentPageScaleDelta()); | 1125 setPageScaleDelta(m_pinchZoomViewport.pageScaleDelta() / m_pinchZoomViewport
.sentPageScaleDelta()); |
| 1104 m_pinchZoomViewport.setSentPageScaleDelta(1); | 1126 m_pinchZoomViewport.setSentPageScaleDelta(1); |
| 1105 } | 1127 } |
| 1106 | 1128 |
| 1107 void LayerTreeHostImpl::setPageScaleDelta(float delta) | 1129 void LayerTreeHostImpl::setPageScaleDelta(float delta) |
| 1108 { | 1130 { |
| 1109 m_pinchZoomViewport.setPageScaleDelta(delta); | 1131 m_pinchZoomViewport.setPageScaleDelta(delta); |
| 1110 | 1132 |
| (...skipping 34 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1145 rootScrollLayer()->setMaxScrollOffset(gfx::ToFlooredVector2d(maxScroll)); | 1167 rootScrollLayer()->setMaxScrollOffset(gfx::ToFlooredVector2d(maxScroll)); |
| 1146 } | 1168 } |
| 1147 | 1169 |
| 1148 void LayerTreeHostImpl::setNeedsRedraw() | 1170 void LayerTreeHostImpl::setNeedsRedraw() |
| 1149 { | 1171 { |
| 1150 m_client->setNeedsRedrawOnImplThread(); | 1172 m_client->setNeedsRedrawOnImplThread(); |
| 1151 } | 1173 } |
| 1152 | 1174 |
| 1153 bool LayerTreeHostImpl::ensureRenderSurfaceLayerList() | 1175 bool LayerTreeHostImpl::ensureRenderSurfaceLayerList() |
| 1154 { | 1176 { |
| 1177 // TODO(enne): See http://crbug.com/164949. This function should really |
| 1178 // just call updateDrawProperties(), but that breaks a number of |
| 1179 // impl transform tests that don't expect the tree to be updated. |
| 1155 if (!rootLayer()) | 1180 if (!rootLayer()) |
| 1156 return false; | 1181 return false; |
| 1157 if (!m_renderer) | 1182 if (!m_renderer) |
| 1158 return false; | 1183 return false; |
| 1159 | 1184 |
| 1160 // We need both a non-empty render surface layer list and a root render | 1185 // We need both a non-empty render surface layer list and a root render |
| 1161 // surface to be able to iterate over the visible layers. | 1186 // surface to be able to iterate over the visible layers. |
| 1162 if (m_renderSurfaceLayerList.size() && rootLayer()->renderSurface()) | 1187 if (m_renderSurfaceLayerList.size() && rootLayer()->renderSurface()) |
| 1163 return true; | 1188 return true; |
| 1164 | 1189 |
| 1165 // If we are called after setRootLayer() but before prepareToDraw(), we need | 1190 // If we are called after setRootLayer() but before prepareToDraw(), we need |
| 1166 // to recalculate the visible layers. This prevents being unable to scroll | 1191 // to recalculate the visible layers. This prevents being unable to scroll |
| 1167 // during part of a commit. | 1192 // during part of a commit. |
| 1168 m_renderSurfaceLayerList.clear(); | 1193 setNeedsUpdateDrawProperties(); |
| 1169 calculateRenderSurfaceLayerList(m_renderSurfaceLayerList); | 1194 updateDrawProperties(); |
| 1170 | 1195 |
| 1171 return m_renderSurfaceLayerList.size(); | 1196 return m_renderSurfaceLayerList.size(); |
| 1172 } | 1197 } |
| 1173 | 1198 |
| 1174 InputHandlerClient::ScrollStatus LayerTreeHostImpl::scrollBegin(gfx::Point viewp
ortPoint, InputHandlerClient::ScrollInputType type) | 1199 InputHandlerClient::ScrollStatus LayerTreeHostImpl::scrollBegin(gfx::Point viewp
ortPoint, InputHandlerClient::ScrollInputType type) |
| 1175 { | 1200 { |
| 1176 TRACE_EVENT0("cc", "LayerTreeHostImpl::scrollBegin"); | 1201 TRACE_EVENT0("cc", "LayerTreeHostImpl::scrollBegin"); |
| 1177 | 1202 |
| 1178 DCHECK(!currentlyScrollingLayer()); | 1203 DCHECK(!currentlyScrollingLayer()); |
| 1179 clearCurrentlyScrollingLayer(); | 1204 clearCurrentlyScrollingLayer(); |
| (...skipping 32 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1212 potentiallyScrollingLayerImpl = scrollLayerImpl; | 1237 potentiallyScrollingLayerImpl = scrollLayerImpl; |
| 1213 } | 1238 } |
| 1214 | 1239 |
| 1215 if (potentiallyScrollingLayerImpl) { | 1240 if (potentiallyScrollingLayerImpl) { |
| 1216 m_activeTree->set_currently_scrolling_layer(potentiallyScrollingLayerImp
l); | 1241 m_activeTree->set_currently_scrolling_layer(potentiallyScrollingLayerImp
l); |
| 1217 // Gesture events need to be transformed from viewport coordinates to lo
cal layer coordinates | 1242 // Gesture events need to be transformed from viewport coordinates to lo
cal layer coordinates |
| 1218 // so that the scrolling contents exactly follow the user's finger. In c
ontrast, wheel | 1243 // so that the scrolling contents exactly follow the user's finger. In c
ontrast, wheel |
| 1219 // events are already in local layer coordinates so we can just apply th
em directly. | 1244 // events are already in local layer coordinates so we can just apply th
em directly. |
| 1220 m_scrollDeltaIsInViewportSpace = (type == Gesture); | 1245 m_scrollDeltaIsInViewportSpace = (type == Gesture); |
| 1221 m_numImplThreadScrolls++; | 1246 m_numImplThreadScrolls++; |
| 1247 setNeedsUpdateDrawProperties(); |
| 1222 return ScrollStarted; | 1248 return ScrollStarted; |
| 1223 } | 1249 } |
| 1224 return ScrollIgnored; | 1250 return ScrollIgnored; |
| 1225 } | 1251 } |
| 1226 | 1252 |
| 1227 static gfx::Vector2dF scrollLayerWithViewportSpaceDelta(PinchZoomViewport* viewp
ort, LayerImpl& layerImpl, float scaleFromViewportToScreenSpace, gfx::PointF vie
wportPoint, gfx::Vector2dF viewportDelta) | 1253 static gfx::Vector2dF scrollLayerWithViewportSpaceDelta(PinchZoomViewport* viewp
ort, LayerImpl& layerImpl, float scaleFromViewportToScreenSpace, gfx::PointF vie
wportPoint, gfx::Vector2dF viewportDelta) |
| 1228 { | 1254 { |
| 1229 // Layers with non-invertible screen space transforms should not have passed
the scroll hit | 1255 // Layers with non-invertible screen space transforms should not have passed
the scroll hit |
| 1230 // test in the first place. | 1256 // test in the first place. |
| 1231 DCHECK(layerImpl.screenSpaceTransform().IsInvertible()); | 1257 DCHECK(layerImpl.screenSpaceTransform().IsInvertible()); |
| (...skipping 94 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1326 gfx::Vector2dF perpendicularAxis(-appliedDelta.y(), appliedDelta.x()); | 1352 gfx::Vector2dF perpendicularAxis(-appliedDelta.y(), appliedDelta.x()); |
| 1327 pendingDelta = MathUtil::projectVector(pendingDelta, perpendicularAxis); | 1353 pendingDelta = MathUtil::projectVector(pendingDelta, perpendicularAxis); |
| 1328 | 1354 |
| 1329 if (gfx::ToFlooredVector2d(pendingDelta).IsZero()) | 1355 if (gfx::ToFlooredVector2d(pendingDelta).IsZero()) |
| 1330 break; | 1356 break; |
| 1331 } | 1357 } |
| 1332 | 1358 |
| 1333 if (didScroll) { | 1359 if (didScroll) { |
| 1334 m_client->setNeedsCommitOnImplThread(); | 1360 m_client->setNeedsCommitOnImplThread(); |
| 1335 m_client->setNeedsRedrawOnImplThread(); | 1361 m_client->setNeedsRedrawOnImplThread(); |
| 1362 setNeedsUpdateDrawProperties(); |
| 1336 } | 1363 } |
| 1337 return didScroll; | 1364 return didScroll; |
| 1338 } | 1365 } |
| 1339 | 1366 |
| 1340 void LayerTreeHostImpl::clearCurrentlyScrollingLayer() | 1367 void LayerTreeHostImpl::clearCurrentlyScrollingLayer() |
| 1341 { | 1368 { |
| 1342 m_activeTree->ClearCurrentlyScrollingLayer(); | 1369 m_activeTree->ClearCurrentlyScrollingLayer(); |
| 1343 } | 1370 } |
| 1344 | 1371 |
| 1345 void LayerTreeHostImpl::scrollEnd() | 1372 void LayerTreeHostImpl::scrollEnd() |
| (...skipping 34 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1380 } | 1407 } |
| 1381 | 1408 |
| 1382 gfx::Vector2dF scrollOverflow = m_settings.pageScalePinchZoomEnabled ? m_pin
chZoomViewport.applyScroll(move) : move; | 1409 gfx::Vector2dF scrollOverflow = m_settings.pageScalePinchZoomEnabled ? m_pin
chZoomViewport.applyScroll(move) : move; |
| 1383 rootScrollLayer()->scrollBy(scrollOverflow); | 1410 rootScrollLayer()->scrollBy(scrollOverflow); |
| 1384 | 1411 |
| 1385 if (rootScrollLayer()->scrollbarAnimationController()) | 1412 if (rootScrollLayer()->scrollbarAnimationController()) |
| 1386 rootScrollLayer()->scrollbarAnimationController()->didPinchGestureUpdate
(); | 1413 rootScrollLayer()->scrollbarAnimationController()->didPinchGestureUpdate
(); |
| 1387 | 1414 |
| 1388 m_client->setNeedsCommitOnImplThread(); | 1415 m_client->setNeedsCommitOnImplThread(); |
| 1389 m_client->setNeedsRedrawOnImplThread(); | 1416 m_client->setNeedsRedrawOnImplThread(); |
| 1417 setNeedsUpdateDrawProperties(); |
| 1390 } | 1418 } |
| 1391 | 1419 |
| 1392 void LayerTreeHostImpl::pinchGestureEnd() | 1420 void LayerTreeHostImpl::pinchGestureEnd() |
| 1393 { | 1421 { |
| 1394 m_pinchGestureActive = false; | 1422 m_pinchGestureActive = false; |
| 1395 | 1423 |
| 1396 if (rootScrollLayer() && rootScrollLayer()->scrollbarAnimationController()) | 1424 if (rootScrollLayer() && rootScrollLayer()->scrollbarAnimationController()) |
| 1397 rootScrollLayer()->scrollbarAnimationController()->didPinchGestureEnd(); | 1425 rootScrollLayer()->scrollbarAnimationController()->didPinchGestureEnd(); |
| 1398 | 1426 |
| 1399 m_client->setNeedsCommitOnImplThread(); | 1427 m_client->setNeedsCommitOnImplThread(); |
| (...skipping 116 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1516 double monotonicTime = (time - base::TimeTicks()).InSecondsF(); | 1544 double monotonicTime = (time - base::TimeTicks()).InSecondsF(); |
| 1517 gfx::Vector2dF scrollTotal = rootScrollLayer()->scrollOffset() + rootScrollL
ayer()->scrollDelta(); | 1545 gfx::Vector2dF scrollTotal = rootScrollLayer()->scrollOffset() + rootScrollL
ayer()->scrollDelta(); |
| 1518 | 1546 |
| 1519 setPageScaleDelta(m_pageScaleAnimation->pageScaleFactorAtTime(monotonicTime)
/ m_pinchZoomViewport.pageScaleFactor()); | 1547 setPageScaleDelta(m_pageScaleAnimation->pageScaleFactorAtTime(monotonicTime)
/ m_pinchZoomViewport.pageScaleFactor()); |
| 1520 gfx::Vector2dF nextScroll = m_pageScaleAnimation->scrollOffsetAtTime(monoton
icTime); | 1548 gfx::Vector2dF nextScroll = m_pageScaleAnimation->scrollOffsetAtTime(monoton
icTime); |
| 1521 | 1549 |
| 1522 if (!m_settings.pageScalePinchZoomEnabled) | 1550 if (!m_settings.pageScalePinchZoomEnabled) |
| 1523 nextScroll.Scale(m_pinchZoomViewport.pageScaleFactor()); | 1551 nextScroll.Scale(m_pinchZoomViewport.pageScaleFactor()); |
| 1524 rootScrollLayer()->scrollBy(nextScroll - scrollTotal); | 1552 rootScrollLayer()->scrollBy(nextScroll - scrollTotal); |
| 1525 m_client->setNeedsRedrawOnImplThread(); | 1553 m_client->setNeedsRedrawOnImplThread(); |
| 1554 setNeedsUpdateDrawProperties(); |
| 1526 | 1555 |
| 1527 if (m_pageScaleAnimation->isAnimationCompleteAtTime(monotonicTime)) { | 1556 if (m_pageScaleAnimation->isAnimationCompleteAtTime(monotonicTime)) { |
| 1528 m_pageScaleAnimation.reset(); | 1557 m_pageScaleAnimation.reset(); |
| 1529 m_client->setNeedsCommitOnImplThread(); | 1558 m_client->setNeedsCommitOnImplThread(); |
| 1530 } | 1559 } |
| 1531 } | 1560 } |
| 1532 | 1561 |
| 1533 void LayerTreeHostImpl::animateLayers(base::TimeTicks monotonicTime, base::Time
wallClockTime) | 1562 void LayerTreeHostImpl::animateLayers(base::TimeTicks monotonicTime, base::Time
wallClockTime) |
| 1534 { | 1563 { |
| 1535 if (!m_settings.acceleratedAnimationEnabled || !m_needsAnimateLayers || !roo
tLayer()) | 1564 if (!m_settings.acceleratedAnimationEnabled || !m_needsAnimateLayers || !roo
tLayer()) |
| 1536 return; | 1565 return; |
| 1537 | 1566 |
| 1538 TRACE_EVENT0("cc", "LayerTreeHostImpl::animateLayers"); | 1567 TRACE_EVENT0("cc", "LayerTreeHostImpl::animateLayers"); |
| 1539 | 1568 |
| 1540 scoped_ptr<AnimationEventsVector> events(make_scoped_ptr(new AnimationEvents
Vector)); | 1569 scoped_ptr<AnimationEventsVector> events(make_scoped_ptr(new AnimationEvents
Vector)); |
| 1541 | 1570 |
| 1542 bool didAnimate = false; | 1571 bool didAnimate = false; |
| 1543 animateLayersRecursive(rootLayer(), monotonicTime, wallClockTime, events.get
(), didAnimate, m_needsAnimateLayers); | 1572 animateLayersRecursive(rootLayer(), monotonicTime, wallClockTime, events.get
(), didAnimate, m_needsAnimateLayers); |
| 1544 | 1573 |
| 1545 if (!events->empty()) | 1574 if (!events->empty()) |
| 1546 m_client->postAnimationEventsToMainThreadOnImplThread(events.Pass(), wal
lClockTime); | 1575 m_client->postAnimationEventsToMainThreadOnImplThread(events.Pass(), wal
lClockTime); |
| 1547 | 1576 |
| 1548 if (didAnimate) | 1577 if (didAnimate) { |
| 1549 m_client->setNeedsRedrawOnImplThread(); | 1578 m_client->setNeedsRedrawOnImplThread(); |
| 1579 setNeedsUpdateDrawProperties(); |
| 1580 } |
| 1550 | 1581 |
| 1551 setBackgroundTickingEnabled(!m_visible && m_needsAnimateLayers); | 1582 setBackgroundTickingEnabled(!m_visible && m_needsAnimateLayers); |
| 1552 } | 1583 } |
| 1553 | 1584 |
| 1554 base::TimeDelta LayerTreeHostImpl::lowFrequencyAnimationInterval() const | 1585 base::TimeDelta LayerTreeHostImpl::lowFrequencyAnimationInterval() const |
| 1555 { | 1586 { |
| 1556 return base::TimeDelta::FromSeconds(1); | 1587 return base::TimeDelta::FromSeconds(1); |
| 1557 } | 1588 } |
| 1558 | 1589 |
| 1559 void LayerTreeHostImpl::sendDidLoseOutputSurfaceRecursive(LayerImpl* current) | 1590 void LayerTreeHostImpl::sendDidLoseOutputSurfaceRecursive(LayerImpl* current) |
| (...skipping 13 matching lines...) Expand all Loading... |
| 1573 DCHECK(current); | 1604 DCHECK(current); |
| 1574 for (size_t i = 0; i < current->children().size(); ++i) | 1605 for (size_t i = 0; i < current->children().size(); ++i) |
| 1575 clearRenderSurfacesOnLayerImplRecursive(current->children()[i]); | 1606 clearRenderSurfacesOnLayerImplRecursive(current->children()[i]); |
| 1576 current->clearRenderSurface(); | 1607 current->clearRenderSurface(); |
| 1577 } | 1608 } |
| 1578 | 1609 |
| 1579 void LayerTreeHostImpl::clearRenderSurfaces() | 1610 void LayerTreeHostImpl::clearRenderSurfaces() |
| 1580 { | 1611 { |
| 1581 clearRenderSurfacesOnLayerImplRecursive(rootLayer()); | 1612 clearRenderSurfacesOnLayerImplRecursive(rootLayer()); |
| 1582 m_renderSurfaceLayerList.clear(); | 1613 m_renderSurfaceLayerList.clear(); |
| 1614 setNeedsUpdateDrawProperties(); |
| 1583 } | 1615 } |
| 1584 | 1616 |
| 1585 std::string LayerTreeHostImpl::layerTreeAsText() const | 1617 std::string LayerTreeHostImpl::layerTreeAsText() const |
| 1586 { | 1618 { |
| 1587 std::string str; | 1619 std::string str; |
| 1588 if (rootLayer()) { | 1620 if (rootLayer()) { |
| 1589 str = rootLayer()->layerTreeAsText(); | 1621 str = rootLayer()->layerTreeAsText(); |
| 1590 str += "RenderSurfaces:\n"; | 1622 str += "RenderSurfaces:\n"; |
| 1591 dumpRenderSurfaces(&str, 1, rootLayer()); | 1623 dumpRenderSurfaces(&str, 1, rootLayer()); |
| 1592 } | 1624 } |
| (...skipping 79 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1672 ScrollbarAnimationController* scrollbarController = layer->scrollbarAnimatio
nController(); | 1704 ScrollbarAnimationController* scrollbarController = layer->scrollbarAnimatio
nController(); |
| 1673 double monotonicTime = (time - base::TimeTicks()).InSecondsF(); | 1705 double monotonicTime = (time - base::TimeTicks()).InSecondsF(); |
| 1674 if (scrollbarController && scrollbarController->animate(monotonicTime)) | 1706 if (scrollbarController && scrollbarController->animate(monotonicTime)) |
| 1675 m_client->setNeedsRedrawOnImplThread(); | 1707 m_client->setNeedsRedrawOnImplThread(); |
| 1676 | 1708 |
| 1677 for (size_t i = 0; i < layer->children().size(); ++i) | 1709 for (size_t i = 0; i < layer->children().size(); ++i) |
| 1678 animateScrollbarsRecursive(layer->children()[i], time); | 1710 animateScrollbarsRecursive(layer->children()[i], time); |
| 1679 } | 1711 } |
| 1680 | 1712 |
| 1681 } // namespace cc | 1713 } // namespace cc |
| OLD | NEW |