Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(739)

Side by Side Diff: cc/layer_tree_host_impl.cc

Issue 11447028: cc: Split out calcDrawEtc from drawLayers (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Clean up unnecessary test changes Created 8 years ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
OLDNEW
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 203 matching lines...) Expand 10 before | Expand all | Expand 10 after
214 , m_deviceScaleFactor(1) 214 , m_deviceScaleFactor(1)
215 , m_visible(true) 215 , m_visible(true)
216 , m_contentsTexturesPurged(false) 216 , m_contentsTexturesPurged(false)
217 , m_managedMemoryPolicy(PrioritizedResourceManager::defaultMemoryAllocationL imit(), 217 , m_managedMemoryPolicy(PrioritizedResourceManager::defaultMemoryAllocationL imit(),
218 PriorityCalculator::allowEverythingCutoff(), 218 PriorityCalculator::allowEverythingCutoff(),
219 0, 219 0,
220 PriorityCalculator::allowNothingCutoff()) 220 PriorityCalculator::allowNothingCutoff())
221 , m_backgroundColor(0) 221 , m_backgroundColor(0)
222 , m_hasTransparentBackground(false) 222 , m_hasTransparentBackground(false)
223 , m_needsAnimateLayers(false) 223 , m_needsAnimateLayers(false)
224 , m_needsUpdateDrawProperties(false)
224 , m_pinchGestureActive(false) 225 , m_pinchGestureActive(false)
225 , m_fpsCounter(FrameRateCounter::create(m_proxy->hasImplThread())) 226 , m_fpsCounter(FrameRateCounter::create(m_proxy->hasImplThread()))
226 , m_debugRectHistory(DebugRectHistory::create()) 227 , m_debugRectHistory(DebugRectHistory::create())
227 , m_numImplThreadScrolls(0) 228 , m_numImplThreadScrolls(0)
228 , m_numMainThreadScrolls(0) 229 , m_numMainThreadScrolls(0)
229 , m_cumulativeNumLayersDrawn(0) 230 , m_cumulativeNumLayersDrawn(0)
230 { 231 {
231 DCHECK(m_proxy->isImplThread()); 232 DCHECK(m_proxy->isImplThread());
232 didVisibilityChange(this, m_visible); 233 didVisibilityChange(this, m_visible);
233 } 234 }
234 235
235 LayerTreeHostImpl::~LayerTreeHostImpl() 236 LayerTreeHostImpl::~LayerTreeHostImpl()
236 { 237 {
237 DCHECK(m_proxy->isImplThread()); 238 DCHECK(m_proxy->isImplThread());
238 TRACE_EVENT0("cc", "LayerTreeHostImpl::~LayerTreeHostImpl()"); 239 TRACE_EVENT0("cc", "LayerTreeHostImpl::~LayerTreeHostImpl()");
239 240
240 if (m_rootLayerImpl) 241 if (m_rootLayerImpl)
241 clearRenderSurfaces(); 242 clearRenderSurfaces();
242 } 243 }
243 244
244 void LayerTreeHostImpl::beginCommit() 245 void LayerTreeHostImpl::beginCommit()
245 { 246 {
246 } 247 }
247 248
248 void LayerTreeHostImpl::commitComplete() 249 void LayerTreeHostImpl::commitComplete()
249 { 250 {
250 TRACE_EVENT0("cc", "LayerTreeHostImpl::commitComplete"); 251 TRACE_EVENT0("cc", "LayerTreeHostImpl::commitComplete");
252
253 // Impl-side painting needs an update immediately post-commit to have the
254 // opportunity to create tilings. Other paths can call updateDrawProperties
255 // more lazily when needed prior to drawing.
256 setNeedsUpdateDrawProperties();
257 if (m_settings.implSidePainting)
258 updateDrawProperties();
259
251 // Recompute max scroll position; must be after layer content bounds are 260 // Recompute max scroll position; must be after layer content bounds are
252 // updated. 261 // updated.
253 updateMaxScrollOffset(); 262 updateMaxScrollOffset();
254 m_client->sendManagedMemoryStats(); 263 m_client->sendManagedMemoryStats();
255 } 264 }
256 265
257 bool LayerTreeHostImpl::canDraw() 266 bool LayerTreeHostImpl::canDraw()
258 { 267 {
259 // Note: If you are changing this function or any other function that might 268 // Note: If you are changing this function or any other function that might
260 // affect the result of canDraw, make sure to call m_client->onCanDrawStateC hanged 269 // 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
318 if (!m_settings.pageScalePinchZoomEnabled) 327 if (!m_settings.pageScalePinchZoomEnabled)
319 anchor.Scale(1 / pageScale); 328 anchor.Scale(1 / pageScale);
320 m_pageScaleAnimation->zoomWithAnchor(anchor, pageScale, duration.InSecon dsF()); 329 m_pageScaleAnimation->zoomWithAnchor(anchor, pageScale, duration.InSecon dsF());
321 } else { 330 } else {
322 gfx::Vector2dF scaledTargetOffset = targetOffset; 331 gfx::Vector2dF scaledTargetOffset = targetOffset;
323 if (!m_settings.pageScalePinchZoomEnabled) 332 if (!m_settings.pageScalePinchZoomEnabled)
324 scaledTargetOffset.Scale(1 / pageScale); 333 scaledTargetOffset.Scale(1 / pageScale);
325 m_pageScaleAnimation->zoomTo(scaledTargetOffset, pageScale, duration.InS econdsF()); 334 m_pageScaleAnimation->zoomTo(scaledTargetOffset, pageScale, duration.InS econdsF());
326 } 335 }
327 336
337 setNeedsUpdateDrawProperties();
328 m_client->setNeedsRedrawOnImplThread(); 338 m_client->setNeedsRedrawOnImplThread();
329 m_client->setNeedsCommitOnImplThread(); 339 m_client->setNeedsCommitOnImplThread();
330 } 340 }
331 341
332 void LayerTreeHostImpl::scheduleAnimation() 342 void LayerTreeHostImpl::scheduleAnimation()
333 { 343 {
334 m_client->setNeedsRedrawOnImplThread(); 344 m_client->setNeedsRedrawOnImplThread();
335 } 345 }
336 346
337 bool LayerTreeHostImpl::haveTouchEventHandlersAt(const gfx::Point& viewportPoint ) 347 bool LayerTreeHostImpl::haveTouchEventHandlersAt(const gfx::Point& viewportPoint )
(...skipping 25 matching lines...) Expand all
363 } 373 }
364 } 374 }
365 375
366 void LayerTreeHostImpl::updateRootScrollLayerImplTransform() 376 void LayerTreeHostImpl::updateRootScrollLayerImplTransform()
367 { 377 {
368 if (m_rootScrollLayerImpl) { 378 if (m_rootScrollLayerImpl) {
369 m_rootScrollLayerImpl->setImplTransform(implTransform()); 379 m_rootScrollLayerImpl->setImplTransform(implTransform());
370 } 380 }
371 } 381 }
372 382
383 void LayerTreeHostImpl::updateDrawProperties()
384 {
385 if (!needsUpdateDrawProperties())
386 return;
387
388 m_renderSurfaceLayerList.clear();
389 m_needsUpdateDrawProperties = false;
390
391 if (!m_rootLayerImpl)
392 return;
393
394 calculateRenderSurfaceLayerList(m_renderSurfaceLayerList);
395 }
396
373 void LayerTreeHostImpl::calculateRenderSurfaceLayerList(LayerList& renderSurface LayerList) 397 void LayerTreeHostImpl::calculateRenderSurfaceLayerList(LayerList& renderSurface LayerList)
374 { 398 {
375 DCHECK(renderSurfaceLayerList.empty()); 399 DCHECK(renderSurfaceLayerList.empty());
376 DCHECK(m_rootLayerImpl); 400 DCHECK(m_rootLayerImpl);
377 DCHECK(m_renderer); // For maxTextureSize. 401 DCHECK(m_renderer); // For maxTextureSize.
378
379 { 402 {
380 updateRootScrollLayerImplTransform(); 403 updateRootScrollLayerImplTransform();
381 404
382 TRACE_EVENT0("cc", "LayerTreeHostImpl::calcDrawEtc"); 405 TRACE_EVENT0("cc", "LayerTreeHostImpl::calcDrawEtc");
383 float pageScaleFactor = m_pinchZoomViewport.pageScaleFactor(); 406 float pageScaleFactor = m_pinchZoomViewport.pageScaleFactor();
384 LayerTreeHostCommon::calculateDrawProperties(m_rootLayerImpl.get(), devi ceViewportSize(), m_deviceScaleFactor, pageScaleFactor, &m_layerSorter, renderer Capabilities().maxTextureSize, renderSurfaceLayerList); 407 LayerTreeHostCommon::calculateDrawProperties(m_rootLayerImpl.get(), devi ceViewportSize(), m_deviceScaleFactor, pageScaleFactor, &m_layerSorter, renderer Capabilities().maxTextureSize, renderSurfaceLayerList);
385 408
386 trackDamageForAllSurfaces(m_rootLayerImpl.get(), renderSurfaceLayerList) ;
387 } 409 }
388 } 410 }
389 411
390 void LayerTreeHostImpl::FrameData::appendRenderPass(scoped_ptr<RenderPass> rende rPass) 412 void LayerTreeHostImpl::FrameData::appendRenderPass(scoped_ptr<RenderPass> rende rPass)
391 { 413 {
392 RenderPass* pass = renderPass.get(); 414 RenderPass* pass = renderPass.get();
393 renderPasses.push_back(pass); 415 renderPasses.push_back(pass);
394 renderPassesById.set(pass->id, renderPass.Pass()); 416 renderPassesById.set(pass->id, renderPass.Pass());
395 } 417 }
396 418
(...skipping 79 matching lines...) Expand 10 before | Expand all | Expand 10 after
476 scoped_ptr<SolidColorDrawQuad> quad = SolidColorDrawQuad::Create(); 498 scoped_ptr<SolidColorDrawQuad> quad = SolidColorDrawQuad::Create();
477 quad->SetNew(sharedQuadState, layerRect, screenBackgroundColor); 499 quad->SetNew(sharedQuadState, layerRect, screenBackgroundColor);
478 quadCuller.append(quad.PassAs<DrawQuad>(), appendQuadsData); 500 quadCuller.append(quad.PassAs<DrawQuad>(), appendQuadsData);
479 } 501 }
480 } 502 }
481 503
482 bool LayerTreeHostImpl::calculateRenderPasses(FrameData& frame) 504 bool LayerTreeHostImpl::calculateRenderPasses(FrameData& frame)
483 { 505 {
484 DCHECK(frame.renderPasses.empty()); 506 DCHECK(frame.renderPasses.empty());
485 507
486 calculateRenderSurfaceLayerList(*frame.renderSurfaceLayerList); 508 trackDamageForAllSurfaces(m_rootLayerImpl.get(), *frame.renderSurfaceLayerLi st);
487 509
488 TRACE_EVENT1("cc", "LayerTreeHostImpl::calculateRenderPasses", "renderSurfac eLayerList.size()", static_cast<long long unsigned>(frame.renderSurfaceLayerList ->size())); 510 TRACE_EVENT1("cc", "LayerTreeHostImpl::calculateRenderPasses", "renderSurfac eLayerList.size()", static_cast<long long unsigned>(frame.renderSurfaceLayerList ->size()));
489 511
490 // Create the render passes in dependency order. 512 // Create the render passes in dependency order.
491 for (int surfaceIndex = frame.renderSurfaceLayerList->size() - 1; surfaceInd ex >= 0 ; --surfaceIndex) { 513 for (int surfaceIndex = frame.renderSurfaceLayerList->size() - 1; surfaceInd ex >= 0 ; --surfaceIndex) {
492 LayerImpl* renderSurfaceLayer = (*frame.renderSurfaceLayerList)[surfaceI ndex]; 514 LayerImpl* renderSurfaceLayer = (*frame.renderSurfaceLayerList)[surfaceI ndex];
493 renderSurfaceLayer->renderSurface()->appendRenderPasses(frame); 515 renderSurfaceLayer->renderSurface()->appendRenderPasses(frame);
494 } 516 }
495 517
496 bool recordMetricsForFrame = m_settings.showOverdrawInTracing && base::debug ::TraceLog::GetInstance() && base::debug::TraceLog::GetInstance()->IsEnabled(); 518 bool recordMetricsForFrame = m_settings.showOverdrawInTracing && base::debug ::TraceLog::GetInstance() && base::debug::TraceLog::GetInstance()->IsEnabled();
(...skipping 25 matching lines...) Expand all
522 if (it.representsContributingRenderSurface()) { 544 if (it.representsContributingRenderSurface()) {
523 RenderPass::Id contributingRenderPassId = it->renderSurface()->rende rPassId(); 545 RenderPass::Id contributingRenderPassId = it->renderSurface()->rende rPassId();
524 RenderPass* contributingRenderPass = frame.renderPassesById.get(cont ributingRenderPassId); 546 RenderPass* contributingRenderPass = frame.renderPassesById.get(cont ributingRenderPassId);
525 appendQuadsForRenderSurfaceLayer(targetRenderPass, *it, contributing RenderPass, occlusionTracker, appendQuadsData); 547 appendQuadsForRenderSurfaceLayer(targetRenderPass, *it, contributing RenderPass, occlusionTracker, appendQuadsData);
526 } else if (it.representsItself() && !it->visibleContentRect().IsEmpty()) { 548 } else if (it.representsItself() && !it->visibleContentRect().IsEmpty()) {
527 bool hasOcclusionFromOutsideTargetSurface; 549 bool hasOcclusionFromOutsideTargetSurface;
528 bool implDrawTransformIsUnknown = false; 550 bool implDrawTransformIsUnknown = false;
529 if (occlusionTracker.occluded(it->renderTarget(), it->visibleContent Rect(), it->drawTransform(), implDrawTransformIsUnknown, it->drawableContentRect (), &hasOcclusionFromOutsideTargetSurface)) 551 if (occlusionTracker.occluded(it->renderTarget(), it->visibleContent Rect(), it->drawTransform(), implDrawTransformIsUnknown, it->drawableContentRect (), &hasOcclusionFromOutsideTargetSurface))
530 appendQuadsData.hadOcclusionFromOutsideTargetSurface |= hasOcclu sionFromOutsideTargetSurface; 552 appendQuadsData.hadOcclusionFromOutsideTargetSurface |= hasOcclu sionFromOutsideTargetSurface;
531 else { 553 else {
554 DCHECK(it->layerTreeHostImpl());
danakj 2012/12/06 19:12:10 Should this DCHECK the layerTreeHostImpl() == this
enne (OOO) 2012/12/06 19:25:42 Done.
532 it->willDraw(m_resourceProvider.get()); 555 it->willDraw(m_resourceProvider.get());
533 frame.willDrawLayers.push_back(*it); 556 frame.willDrawLayers.push_back(*it);
534 557
535 if (it->hasContributingDelegatedRenderPasses()) { 558 if (it->hasContributingDelegatedRenderPasses()) {
536 RenderPass::Id contributingRenderPassId = it->firstContribut ingRenderPassId(); 559 RenderPass::Id contributingRenderPassId = it->firstContribut ingRenderPassId();
537 while (frame.renderPassesById.contains(contributingRenderPas sId)) { 560 while (frame.renderPassesById.contains(contributingRenderPas sId)) {
538 RenderPass* renderPass = frame.renderPassesById.get(cont ributingRenderPassId); 561 RenderPass* renderPass = frame.renderPassesById.get(cont ributingRenderPassId);
539 562
540 AppendQuadsData appendQuadsData(renderPass->id); 563 AppendQuadsData appendQuadsData(renderPass->id);
541 appendQuadsForLayer(renderPass, *it, occlusionTracker, a ppendQuadsData); 564 appendQuadsForLayer(renderPass, *it, occlusionTracker, a ppendQuadsData);
(...skipping 188 matching lines...) Expand 10 before | Expand all | Expand 10 after
730 DCHECK(it >= 0); 753 DCHECK(it >= 0);
731 } 754 }
732 } 755 }
733 } 756 }
734 757
735 bool LayerTreeHostImpl::prepareToDraw(FrameData& frame) 758 bool LayerTreeHostImpl::prepareToDraw(FrameData& frame)
736 { 759 {
737 TRACE_EVENT0("cc", "LayerTreeHostImpl::prepareToDraw"); 760 TRACE_EVENT0("cc", "LayerTreeHostImpl::prepareToDraw");
738 DCHECK(canDraw()); 761 DCHECK(canDraw());
739 762
763 updateDrawProperties();
danakj 2012/12/06 19:12:10 I'm not clear why this moved out of calcRenderPass
enne (OOO) 2012/12/06 19:25:42 Moved back.
740 frame.renderSurfaceLayerList = &m_renderSurfaceLayerList; 764 frame.renderSurfaceLayerList = &m_renderSurfaceLayerList;
741 frame.renderPasses.clear(); 765 frame.renderPasses.clear();
742 frame.renderPassesById.clear(); 766 frame.renderPassesById.clear();
743 frame.renderSurfaceLayerList->clear();
744 frame.willDrawLayers.clear(); 767 frame.willDrawLayers.clear();
745 768
746 if (!calculateRenderPasses(frame)) 769 if (!calculateRenderPasses(frame))
747 return false; 770 return false;
748 771
749 // If we return true, then we expect drawLayers() to be called before this f unction is called again. 772 // If we return true, then we expect drawLayers() to be called before this f unction is called again.
750 return true; 773 return true;
751 } 774 }
752 775
753 void LayerTreeHostImpl::enforceManagedMemoryPolicy(const ManagedMemoryPolicy& po licy) 776 void LayerTreeHostImpl::enforceManagedMemoryPolicy(const ManagedMemoryPolicy& po licy)
(...skipping 183 matching lines...) Expand 10 before | Expand all | Expand 10 after
937 960
938 if (layerImpl->drawsContent() && layerImpl->parent() && layerImpl->parent()- >scrollable()) 961 if (layerImpl->drawsContent() && layerImpl->parent() && layerImpl->parent()- >scrollable())
939 return layerImpl->parent(); 962 return layerImpl->parent();
940 963
941 return 0; 964 return 0;
942 } 965 }
943 966
944 void LayerTreeHostImpl::setRootLayer(scoped_ptr<LayerImpl> layer) 967 void LayerTreeHostImpl::setRootLayer(scoped_ptr<LayerImpl> layer)
945 { 968 {
946 m_rootLayerImpl = layer.Pass(); 969 m_rootLayerImpl = layer.Pass();
970 if (m_rootLayerImpl)
971 m_rootLayerImpl->setLayerTreeHostImpl(this);
947 m_rootScrollLayerImpl = findRootScrollLayer(m_rootLayerImpl.get()); 972 m_rootScrollLayerImpl = findRootScrollLayer(m_rootLayerImpl.get());
948 m_currentlyScrollingLayerImpl = 0; 973 m_currentlyScrollingLayerImpl = 0;
974 setNeedsUpdateDrawProperties();
949 975
950 if (m_rootLayerImpl && m_scrollingLayerIdFromPreviousTree != -1) 976 if (m_rootLayerImpl && m_scrollingLayerIdFromPreviousTree != -1)
951 m_currentlyScrollingLayerImpl = LayerTreeHostCommon::findLayerInSubtree( m_rootLayerImpl.get(), m_scrollingLayerIdFromPreviousTree); 977 m_currentlyScrollingLayerImpl = LayerTreeHostCommon::findLayerInSubtree( m_rootLayerImpl.get(), m_scrollingLayerIdFromPreviousTree);
952 978
953 m_scrollingLayerIdFromPreviousTree = -1; 979 m_scrollingLayerIdFromPreviousTree = -1;
954 980
955 m_client->onCanDrawStateChanged(canDraw()); 981 m_client->onCanDrawStateChanged(canDraw());
956 } 982 }
957 983
958 scoped_ptr<LayerImpl> LayerTreeHostImpl::detachLayerTree() 984 scoped_ptr<LayerImpl> LayerTreeHostImpl::detachLayerTree()
959 { 985 {
960 // Clear all data structures that have direct references to the layer tree. 986 // Clear all data structures that have direct references to the layer tree.
961 m_scrollingLayerIdFromPreviousTree = m_currentlyScrollingLayerImpl ? m_curre ntlyScrollingLayerImpl->id() : -1; 987 m_scrollingLayerIdFromPreviousTree = m_currentlyScrollingLayerImpl ? m_curre ntlyScrollingLayerImpl->id() : -1;
962 m_currentlyScrollingLayerImpl = 0; 988 m_currentlyScrollingLayerImpl = 0;
963 m_renderSurfaceLayerList.clear(); 989 m_renderSurfaceLayerList.clear();
990 setNeedsUpdateDrawProperties();
964 991
965 return m_rootLayerImpl.Pass(); 992 return m_rootLayerImpl.Pass();
966 } 993 }
967 994
968 void LayerTreeHostImpl::setVisible(bool visible) 995 void LayerTreeHostImpl::setVisible(bool visible)
969 { 996 {
970 DCHECK(m_proxy->isImplThread()); 997 DCHECK(m_proxy->isImplThread());
971 998
972 if (m_visible == visible) 999 if (m_visible == visible)
973 return; 1000 return;
(...skipping 114 matching lines...) Expand 10 before | Expand all | Expand 10 after
1088 } 1115 }
1089 1116
1090 void LayerTreeHostImpl::setPageScaleFactorAndLimits(float pageScaleFactor, float minPageScaleFactor, float maxPageScaleFactor) 1117 void LayerTreeHostImpl::setPageScaleFactorAndLimits(float pageScaleFactor, float minPageScaleFactor, float maxPageScaleFactor)
1091 { 1118 {
1092 if (!pageScaleFactor) 1119 if (!pageScaleFactor)
1093 return; 1120 return;
1094 1121
1095 float pageScaleChange = pageScaleFactor / m_pinchZoomViewport.pageScaleFacto r(); 1122 float pageScaleChange = pageScaleFactor / m_pinchZoomViewport.pageScaleFacto r();
1096 m_pinchZoomViewport.setPageScaleFactorAndLimits(pageScaleFactor, minPageScal eFactor, maxPageScaleFactor); 1123 m_pinchZoomViewport.setPageScaleFactorAndLimits(pageScaleFactor, minPageScal eFactor, maxPageScaleFactor);
1097 1124
1098 if (!m_settings.pageScalePinchZoomEnabled) { 1125 if (!m_settings.pageScalePinchZoomEnabled && pageScaleChange != 1) {
danakj 2012/12/06 19:12:10 don't need the {} now
1099 if (pageScaleChange != 1) 1126 adjustScrollsForPageScaleChange(m_rootScrollLayerImpl, pageScaleChange);
1100 adjustScrollsForPageScaleChange(m_rootScrollLayerImpl, pageScaleChan ge);
1101 } 1127 }
1102 1128
1103 // Clamp delta to limits and refresh display matrix. 1129 // Clamp delta to limits and refresh display matrix.
1104 setPageScaleDelta(m_pinchZoomViewport.pageScaleDelta() / m_pinchZoomViewport .sentPageScaleDelta()); 1130 setPageScaleDelta(m_pinchZoomViewport.pageScaleDelta() / m_pinchZoomViewport .sentPageScaleDelta());
1105 m_pinchZoomViewport.setSentPageScaleDelta(1); 1131 m_pinchZoomViewport.setSentPageScaleDelta(1);
1106 } 1132 }
1107 1133
1108 void LayerTreeHostImpl::setPageScaleDelta(float delta) 1134 void LayerTreeHostImpl::setPageScaleDelta(float delta)
1109 { 1135 {
1110 m_pinchZoomViewport.setPageScaleDelta(delta); 1136 m_pinchZoomViewport.setPageScaleDelta(delta);
(...skipping 42 matching lines...) Expand 10 before | Expand all | Expand 10 after
1153 1179
1154 bool LayerTreeHostImpl::ensureRenderSurfaceLayerList() 1180 bool LayerTreeHostImpl::ensureRenderSurfaceLayerList()
1155 { 1181 {
1156 if (!m_rootLayerImpl) 1182 if (!m_rootLayerImpl)
1157 return false; 1183 return false;
1158 if (!m_renderer) 1184 if (!m_renderer)
1159 return false; 1185 return false;
1160 1186
1161 // We need both a non-empty render surface layer list and a root render 1187 // We need both a non-empty render surface layer list and a root render
1162 // surface to be able to iterate over the visible layers. 1188 // surface to be able to iterate over the visible layers.
1163 if (m_renderSurfaceLayerList.size() && m_rootLayerImpl->renderSurface()) 1189 if (m_renderSurfaceLayerList.size() && m_rootLayerImpl->renderSurface())
danakj 2012/12/06 19:12:10 should this line turn into if (!needsUpdateDrawPro
enne (OOO) 2012/12/06 19:25:42 See reply below.
1164 return true; 1190 return true;
1165 1191
1166 // If we are called after setRootLayer() but before prepareToDraw(), we need 1192 // If we are called after setRootLayer() but before prepareToDraw(), we need
1167 // to recalculate the visible layers. This prevents being unable to scroll 1193 // to recalculate the visible layers. This prevents being unable to scroll
1168 // during part of a commit. 1194 // during part of a commit.
1169 m_renderSurfaceLayerList.clear(); 1195 setNeedsUpdateDrawProperties();
danakj 2012/12/06 19:12:10 why the set here?
enne (OOO) 2012/12/06 19:25:42 LayerTreeHostImplTest.clearRootRenderSurfaceAndScr
danakj 2012/12/06 19:56:22 it's a bug to clear the render surface and not set
enne (OOO) 2012/12/06 20:37:51 It kind of is now. I could change the test to cle
1170 calculateRenderSurfaceLayerList(m_renderSurfaceLayerList); 1196 updateDrawProperties();
1171 1197
1172 return m_renderSurfaceLayerList.size(); 1198 return m_renderSurfaceLayerList.size();
1173 } 1199 }
1174 1200
1175 InputHandlerClient::ScrollStatus LayerTreeHostImpl::scrollBegin(gfx::Point viewp ortPoint, InputHandlerClient::ScrollInputType type) 1201 InputHandlerClient::ScrollStatus LayerTreeHostImpl::scrollBegin(gfx::Point viewp ortPoint, InputHandlerClient::ScrollInputType type)
1176 { 1202 {
1177 TRACE_EVENT0("cc", "LayerTreeHostImpl::scrollBegin"); 1203 TRACE_EVENT0("cc", "LayerTreeHostImpl::scrollBegin");
1178 1204
1179 DCHECK(!m_currentlyScrollingLayerImpl); 1205 DCHECK(!m_currentlyScrollingLayerImpl);
1180 clearCurrentlyScrollingLayer(); 1206 clearCurrentlyScrollingLayer();
(...skipping 32 matching lines...) Expand 10 before | Expand all | Expand 10 after
1213 potentiallyScrollingLayerImpl = scrollLayerImpl; 1239 potentiallyScrollingLayerImpl = scrollLayerImpl;
1214 } 1240 }
1215 1241
1216 if (potentiallyScrollingLayerImpl) { 1242 if (potentiallyScrollingLayerImpl) {
1217 m_currentlyScrollingLayerImpl = potentiallyScrollingLayerImpl; 1243 m_currentlyScrollingLayerImpl = potentiallyScrollingLayerImpl;
1218 // Gesture events need to be transformed from viewport coordinates to lo cal layer coordinates 1244 // Gesture events need to be transformed from viewport coordinates to lo cal layer coordinates
1219 // so that the scrolling contents exactly follow the user's finger. In c ontrast, wheel 1245 // so that the scrolling contents exactly follow the user's finger. In c ontrast, wheel
1220 // events are already in local layer coordinates so we can just apply th em directly. 1246 // events are already in local layer coordinates so we can just apply th em directly.
1221 m_scrollDeltaIsInViewportSpace = (type == Gesture); 1247 m_scrollDeltaIsInViewportSpace = (type == Gesture);
1222 m_numImplThreadScrolls++; 1248 m_numImplThreadScrolls++;
1249 setNeedsUpdateDrawProperties();
1223 return ScrollStarted; 1250 return ScrollStarted;
1224 } 1251 }
1225 return ScrollIgnored; 1252 return ScrollIgnored;
1226 } 1253 }
1227 1254
1228 static gfx::Vector2dF scrollLayerWithViewportSpaceDelta(PinchZoomViewport* viewp ort, LayerImpl& layerImpl, float scaleFromViewportToScreenSpace, gfx::PointF vie wportPoint, gfx::Vector2dF viewportDelta) 1255 static gfx::Vector2dF scrollLayerWithViewportSpaceDelta(PinchZoomViewport* viewp ort, LayerImpl& layerImpl, float scaleFromViewportToScreenSpace, gfx::PointF vie wportPoint, gfx::Vector2dF viewportDelta)
1229 { 1256 {
1230 // Layers with non-invertible screen space transforms should not have passed the scroll hit 1257 // Layers with non-invertible screen space transforms should not have passed the scroll hit
1231 // test in the first place. 1258 // test in the first place.
1232 DCHECK(layerImpl.screenSpaceTransform().IsInvertible()); 1259 DCHECK(layerImpl.screenSpaceTransform().IsInvertible());
(...skipping 92 matching lines...) Expand 10 before | Expand all | Expand 10 after
1325 gfx::Vector2dF perpendicularAxis(-appliedDelta.y(), appliedDelta.x()); 1352 gfx::Vector2dF perpendicularAxis(-appliedDelta.y(), appliedDelta.x());
1326 pendingDelta = MathUtil::projectVector(pendingDelta, perpendicularAxis); 1353 pendingDelta = MathUtil::projectVector(pendingDelta, perpendicularAxis);
1327 1354
1328 if (gfx::ToFlooredVector2d(pendingDelta).IsZero()) 1355 if (gfx::ToFlooredVector2d(pendingDelta).IsZero())
1329 break; 1356 break;
1330 } 1357 }
1331 1358
1332 if (didScroll) { 1359 if (didScroll) {
1333 m_client->setNeedsCommitOnImplThread(); 1360 m_client->setNeedsCommitOnImplThread();
1334 m_client->setNeedsRedrawOnImplThread(); 1361 m_client->setNeedsRedrawOnImplThread();
1362 setNeedsUpdateDrawProperties();
1335 } 1363 }
1336 return didScroll; 1364 return didScroll;
1337 } 1365 }
1338 1366
1339 void LayerTreeHostImpl::clearCurrentlyScrollingLayer() 1367 void LayerTreeHostImpl::clearCurrentlyScrollingLayer()
1340 { 1368 {
1341 m_currentlyScrollingLayerImpl = 0; 1369 m_currentlyScrollingLayerImpl = 0;
1342 m_scrollingLayerIdFromPreviousTree = -1; 1370 m_scrollingLayerIdFromPreviousTree = -1;
1343 } 1371 }
1344 1372
(...skipping 35 matching lines...) Expand 10 before | Expand all | Expand 10 after
1380 } 1408 }
1381 1409
1382 gfx::Vector2dF scrollOverflow = m_settings.pageScalePinchZoomEnabled ? m_pin chZoomViewport.applyScroll(move) : move; 1410 gfx::Vector2dF scrollOverflow = m_settings.pageScalePinchZoomEnabled ? m_pin chZoomViewport.applyScroll(move) : move;
1383 m_rootScrollLayerImpl->scrollBy(scrollOverflow); 1411 m_rootScrollLayerImpl->scrollBy(scrollOverflow);
1384 1412
1385 if (m_rootScrollLayerImpl->scrollbarAnimationController()) 1413 if (m_rootScrollLayerImpl->scrollbarAnimationController())
1386 m_rootScrollLayerImpl->scrollbarAnimationController()->didPinchGestureUp date(); 1414 m_rootScrollLayerImpl->scrollbarAnimationController()->didPinchGestureUp date();
1387 1415
1388 m_client->setNeedsCommitOnImplThread(); 1416 m_client->setNeedsCommitOnImplThread();
1389 m_client->setNeedsRedrawOnImplThread(); 1417 m_client->setNeedsRedrawOnImplThread();
1418 setNeedsUpdateDrawProperties();
1390 } 1419 }
1391 1420
1392 void LayerTreeHostImpl::pinchGestureEnd() 1421 void LayerTreeHostImpl::pinchGestureEnd()
1393 { 1422 {
1394 m_pinchGestureActive = false; 1423 m_pinchGestureActive = false;
1395 1424
1396 if (m_rootScrollLayerImpl && m_rootScrollLayerImpl->scrollbarAnimationContro ller()) 1425 if (m_rootScrollLayerImpl && m_rootScrollLayerImpl->scrollbarAnimationContro ller())
1397 m_rootScrollLayerImpl->scrollbarAnimationController()->didPinchGestureEn d(); 1426 m_rootScrollLayerImpl->scrollbarAnimationController()->didPinchGestureEn d();
1398 1427
1399 m_client->setNeedsCommitOnImplThread(); 1428 m_client->setNeedsCommitOnImplThread();
(...skipping 116 matching lines...) Expand 10 before | Expand all | Expand 10 after
1516 double monotonicTime = (time - base::TimeTicks()).InSecondsF(); 1545 double monotonicTime = (time - base::TimeTicks()).InSecondsF();
1517 gfx::Vector2dF scrollTotal = m_rootScrollLayerImpl->scrollOffset() + m_rootS crollLayerImpl->scrollDelta(); 1546 gfx::Vector2dF scrollTotal = m_rootScrollLayerImpl->scrollOffset() + m_rootS crollLayerImpl->scrollDelta();
1518 1547
1519 setPageScaleDelta(m_pageScaleAnimation->pageScaleFactorAtTime(monotonicTime) / m_pinchZoomViewport.pageScaleFactor()); 1548 setPageScaleDelta(m_pageScaleAnimation->pageScaleFactorAtTime(monotonicTime) / m_pinchZoomViewport.pageScaleFactor());
1520 gfx::Vector2dF nextScroll = m_pageScaleAnimation->scrollOffsetAtTime(monoton icTime); 1549 gfx::Vector2dF nextScroll = m_pageScaleAnimation->scrollOffsetAtTime(monoton icTime);
1521 1550
1522 if (!m_settings.pageScalePinchZoomEnabled) 1551 if (!m_settings.pageScalePinchZoomEnabled)
1523 nextScroll.Scale(m_pinchZoomViewport.pageScaleFactor()); 1552 nextScroll.Scale(m_pinchZoomViewport.pageScaleFactor());
1524 m_rootScrollLayerImpl->scrollBy(nextScroll - scrollTotal); 1553 m_rootScrollLayerImpl->scrollBy(nextScroll - scrollTotal);
1525 m_client->setNeedsRedrawOnImplThread(); 1554 m_client->setNeedsRedrawOnImplThread();
1555 setNeedsUpdateDrawProperties();
1526 1556
1527 if (m_pageScaleAnimation->isAnimationCompleteAtTime(monotonicTime)) { 1557 if (m_pageScaleAnimation->isAnimationCompleteAtTime(monotonicTime)) {
1528 m_pageScaleAnimation.reset(); 1558 m_pageScaleAnimation.reset();
1529 m_client->setNeedsCommitOnImplThread(); 1559 m_client->setNeedsCommitOnImplThread();
1530 } 1560 }
1531 } 1561 }
1532 1562
1533 void LayerTreeHostImpl::animateLayers(base::TimeTicks monotonicTime, base::Time wallClockTime) 1563 void LayerTreeHostImpl::animateLayers(base::TimeTicks monotonicTime, base::Time wallClockTime)
1534 { 1564 {
1535 if (!m_settings.acceleratedAnimationEnabled || !m_needsAnimateLayers || !m_r ootLayerImpl) 1565 if (!m_settings.acceleratedAnimationEnabled || !m_needsAnimateLayers || !m_r ootLayerImpl)
1536 return; 1566 return;
1537 1567
1538 TRACE_EVENT0("cc", "LayerTreeHostImpl::animateLayers"); 1568 TRACE_EVENT0("cc", "LayerTreeHostImpl::animateLayers");
1539 1569
1540 scoped_ptr<AnimationEventsVector> events(make_scoped_ptr(new AnimationEvents Vector)); 1570 scoped_ptr<AnimationEventsVector> events(make_scoped_ptr(new AnimationEvents Vector));
1541 1571
1542 bool didAnimate = false; 1572 bool didAnimate = false;
1543 animateLayersRecursive(m_rootLayerImpl.get(), monotonicTime, wallClockTime, events.get(), didAnimate, m_needsAnimateLayers); 1573 animateLayersRecursive(m_rootLayerImpl.get(), monotonicTime, wallClockTime, events.get(), didAnimate, m_needsAnimateLayers);
1544 1574
1545 if (!events->empty()) 1575 if (!events->empty())
1546 m_client->postAnimationEventsToMainThreadOnImplThread(events.Pass(), wal lClockTime); 1576 m_client->postAnimationEventsToMainThreadOnImplThread(events.Pass(), wal lClockTime);
1547 1577
1548 if (didAnimate) 1578 if (didAnimate) {
1549 m_client->setNeedsRedrawOnImplThread(); 1579 m_client->setNeedsRedrawOnImplThread();
1580 setNeedsUpdateDrawProperties();
1581 }
1550 1582
1551 setBackgroundTickingEnabled(!m_visible && m_needsAnimateLayers); 1583 setBackgroundTickingEnabled(!m_visible && m_needsAnimateLayers);
1552 } 1584 }
1553 1585
1554 base::TimeDelta LayerTreeHostImpl::lowFrequencyAnimationInterval() const 1586 base::TimeDelta LayerTreeHostImpl::lowFrequencyAnimationInterval() const
1555 { 1587 {
1556 return base::TimeDelta::FromSeconds(1); 1588 return base::TimeDelta::FromSeconds(1);
1557 } 1589 }
1558 1590
1559 void LayerTreeHostImpl::sendDidLoseContextRecursive(LayerImpl* current) 1591 void LayerTreeHostImpl::sendDidLoseContextRecursive(LayerImpl* current)
(...skipping 13 matching lines...) Expand all
1573 DCHECK(current); 1605 DCHECK(current);
1574 for (size_t i = 0; i < current->children().size(); ++i) 1606 for (size_t i = 0; i < current->children().size(); ++i)
1575 clearRenderSurfacesOnLayerImplRecursive(current->children()[i]); 1607 clearRenderSurfacesOnLayerImplRecursive(current->children()[i]);
1576 current->clearRenderSurface(); 1608 current->clearRenderSurface();
1577 } 1609 }
1578 1610
1579 void LayerTreeHostImpl::clearRenderSurfaces() 1611 void LayerTreeHostImpl::clearRenderSurfaces()
1580 { 1612 {
1581 clearRenderSurfacesOnLayerImplRecursive(m_rootLayerImpl.get()); 1613 clearRenderSurfacesOnLayerImplRecursive(m_rootLayerImpl.get());
1582 m_renderSurfaceLayerList.clear(); 1614 m_renderSurfaceLayerList.clear();
1615 setNeedsUpdateDrawProperties();
1583 } 1616 }
1584 1617
1585 std::string LayerTreeHostImpl::layerTreeAsText() const 1618 std::string LayerTreeHostImpl::layerTreeAsText() const
1586 { 1619 {
1587 std::string str; 1620 std::string str;
1588 if (m_rootLayerImpl) { 1621 if (m_rootLayerImpl) {
1589 str = m_rootLayerImpl->layerTreeAsText(); 1622 str = m_rootLayerImpl->layerTreeAsText();
1590 str += "RenderSurfaces:\n"; 1623 str += "RenderSurfaces:\n";
1591 dumpRenderSurfaces(&str, 1, m_rootLayerImpl.get()); 1624 dumpRenderSurfaces(&str, 1, m_rootLayerImpl.get());
1592 } 1625 }
(...skipping 39 matching lines...) Expand 10 before | Expand all | Expand 10 after
1632 ScrollbarAnimationController* scrollbarController = layer->scrollbarAnimatio nController(); 1665 ScrollbarAnimationController* scrollbarController = layer->scrollbarAnimatio nController();
1633 double monotonicTime = (time - base::TimeTicks()).InSecondsF(); 1666 double monotonicTime = (time - base::TimeTicks()).InSecondsF();
1634 if (scrollbarController && scrollbarController->animate(monotonicTime)) 1667 if (scrollbarController && scrollbarController->animate(monotonicTime))
1635 m_client->setNeedsRedrawOnImplThread(); 1668 m_client->setNeedsRedrawOnImplThread();
1636 1669
1637 for (size_t i = 0; i < layer->children().size(); ++i) 1670 for (size_t i = 0; i < layer->children().size(); ++i)
1638 animateScrollbarsRecursive(layer->children()[i], time); 1671 animateScrollbarsRecursive(layer->children()[i], time);
1639 } 1672 }
1640 1673
1641 } // namespace cc 1674 } // namespace cc
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698