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 185 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
196 } | 196 } |
197 | 197 |
198 scoped_ptr<LayerTreeHostImpl> LayerTreeHostImpl::create(const LayerTreeSettings&
settings, LayerTreeHostImplClient* client, Proxy* proxy) | 198 scoped_ptr<LayerTreeHostImpl> LayerTreeHostImpl::create(const LayerTreeSettings&
settings, LayerTreeHostImplClient* client, Proxy* proxy) |
199 { | 199 { |
200 return make_scoped_ptr(new LayerTreeHostImpl(settings, client, proxy)); | 200 return make_scoped_ptr(new LayerTreeHostImpl(settings, client, proxy)); |
201 } | 201 } |
202 | 202 |
203 LayerTreeHostImpl::LayerTreeHostImpl(const LayerTreeSettings& settings, LayerTre
eHostImplClient* client, Proxy* proxy) | 203 LayerTreeHostImpl::LayerTreeHostImpl(const LayerTreeSettings& settings, LayerTre
eHostImplClient* client, Proxy* proxy) |
204 : m_client(client) | 204 : m_client(client) |
205 , m_proxy(proxy) | 205 , m_proxy(proxy) |
206 , m_sourceFrameNumber(-1) | |
207 , m_rootScrollLayerImpl(0) | |
208 , m_currentlyScrollingLayerImpl(0) | |
209 , m_hudLayerImpl(0) | |
210 , m_scrollingLayerIdFromPreviousTree(-1) | |
211 , m_scrollDeltaIsInViewportSpace(false) | 206 , m_scrollDeltaIsInViewportSpace(false) |
212 , m_settings(settings) | 207 , m_settings(settings) |
213 , m_debugState(settings.initialDebugState) | 208 , m_debugState(settings.initialDebugState) |
214 , m_deviceScaleFactor(1) | 209 , m_deviceScaleFactor(1) |
215 , m_visible(true) | 210 , m_visible(true) |
216 , m_contentsTexturesPurged(false) | 211 , m_contentsTexturesPurged(false) |
217 , m_managedMemoryPolicy(PrioritizedResourceManager::defaultMemoryAllocationL
imit(), | 212 , m_managedMemoryPolicy(PrioritizedResourceManager::defaultMemoryAllocationL
imit(), |
218 PriorityCalculator::allowEverythingCutoff(), | 213 PriorityCalculator::allowEverythingCutoff(), |
219 0, | 214 0, |
220 PriorityCalculator::allowNothingCutoff()) | 215 PriorityCalculator::allowNothingCutoff()) |
221 , m_backgroundColor(0) | 216 , m_backgroundColor(0) |
222 , m_hasTransparentBackground(false) | 217 , m_hasTransparentBackground(false) |
223 , m_needsAnimateLayers(false) | 218 , m_needsAnimateLayers(false) |
224 , m_pinchGestureActive(false) | 219 , m_pinchGestureActive(false) |
225 , m_fpsCounter(FrameRateCounter::create(m_proxy->hasImplThread())) | 220 , m_fpsCounter(FrameRateCounter::create(m_proxy->hasImplThread())) |
226 , m_debugRectHistory(DebugRectHistory::create()) | 221 , m_debugRectHistory(DebugRectHistory::create()) |
227 , m_numImplThreadScrolls(0) | 222 , m_numImplThreadScrolls(0) |
228 , m_numMainThreadScrolls(0) | 223 , m_numMainThreadScrolls(0) |
229 , m_cumulativeNumLayersDrawn(0) | 224 , m_cumulativeNumLayersDrawn(0) |
230 { | 225 { |
231 DCHECK(m_proxy->isImplThread()); | 226 DCHECK(m_proxy->isImplThread()); |
232 didVisibilityChange(this, m_visible); | 227 didVisibilityChange(this, m_visible); |
| 228 |
| 229 // TODO(nduca): For now, assume we have an active tree. This will be removed |
| 230 // in future patches. |
| 231 m_activeTree = LayerTreeImpl::create(this); |
233 } | 232 } |
234 | 233 |
235 LayerTreeHostImpl::~LayerTreeHostImpl() | 234 LayerTreeHostImpl::~LayerTreeHostImpl() |
236 { | 235 { |
237 DCHECK(m_proxy->isImplThread()); | 236 DCHECK(m_proxy->isImplThread()); |
238 TRACE_EVENT0("cc", "LayerTreeHostImpl::~LayerTreeHostImpl()"); | 237 TRACE_EVENT0("cc", "LayerTreeHostImpl::~LayerTreeHostImpl()"); |
239 | 238 |
240 if (m_rootLayerImpl) | 239 if (rootLayer()) |
241 clearRenderSurfaces(); | 240 clearRenderSurfaces(); |
242 } | 241 } |
243 | 242 |
244 void LayerTreeHostImpl::beginCommit() | 243 void LayerTreeHostImpl::beginCommit() |
245 { | 244 { |
246 } | 245 } |
247 | 246 |
248 void LayerTreeHostImpl::commitComplete() | 247 void LayerTreeHostImpl::commitComplete() |
249 { | 248 { |
250 TRACE_EVENT0("cc", "LayerTreeHostImpl::commitComplete"); | 249 TRACE_EVENT0("cc", "LayerTreeHostImpl::commitComplete"); |
251 // Recompute max scroll position; must be after layer content bounds are | 250 // Recompute max scroll position; must be after layer content bounds are |
252 // updated. | 251 // updated. |
253 updateMaxScrollOffset(); | 252 updateMaxScrollOffset(); |
254 m_client->sendManagedMemoryStats(); | 253 m_client->sendManagedMemoryStats(); |
255 } | 254 } |
256 | 255 |
257 bool LayerTreeHostImpl::canDraw() | 256 bool LayerTreeHostImpl::canDraw() |
258 { | 257 { |
259 // Note: If you are changing this function or any other function that might | 258 // 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 | 259 // affect the result of canDraw, make sure to call m_client->onCanDrawStateC
hanged |
261 // in the proper places and update the notifyIfCanDrawChanged test. | 260 // in the proper places and update the notifyIfCanDrawChanged test. |
262 | 261 |
263 if (!m_rootLayerImpl) { | 262 if (!rootLayer()) { |
264 TRACE_EVENT_INSTANT0("cc", "LayerTreeHostImpl::canDraw no root layer"); | 263 TRACE_EVENT_INSTANT0("cc", "LayerTreeHostImpl::canDraw no root layer"); |
265 return false; | 264 return false; |
266 } | 265 } |
267 if (deviceViewportSize().IsEmpty()) { | 266 if (deviceViewportSize().IsEmpty()) { |
268 TRACE_EVENT_INSTANT0("cc", "LayerTreeHostImpl::canDraw empty viewport"); | 267 TRACE_EVENT_INSTANT0("cc", "LayerTreeHostImpl::canDraw empty viewport"); |
269 return false; | 268 return false; |
270 } | 269 } |
271 if (!m_renderer) { | 270 if (!m_renderer) { |
272 TRACE_EVENT_INSTANT0("cc", "LayerTreeHostImpl::canDraw no renderer"); | 271 TRACE_EVENT_INSTANT0("cc", "LayerTreeHostImpl::canDraw no renderer"); |
273 return false; | 272 return false; |
(...skipping 18 matching lines...) Expand all Loading... |
292 } | 291 } |
293 | 292 |
294 void LayerTreeHostImpl::manageTiles() | 293 void LayerTreeHostImpl::manageTiles() |
295 { | 294 { |
296 DCHECK(m_tileManager); | 295 DCHECK(m_tileManager); |
297 m_tileManager->ManageTiles(); | 296 m_tileManager->ManageTiles(); |
298 } | 297 } |
299 | 298 |
300 void LayerTreeHostImpl::startPageScaleAnimation(gfx::Vector2d targetOffset, bool
anchorPoint, float pageScale, base::TimeTicks startTime, base::TimeDelta durati
on) | 299 void LayerTreeHostImpl::startPageScaleAnimation(gfx::Vector2d targetOffset, bool
anchorPoint, float pageScale, base::TimeTicks startTime, base::TimeDelta durati
on) |
301 { | 300 { |
302 if (!m_rootScrollLayerImpl) | 301 if (!rootScrollLayer()) |
303 return; | 302 return; |
304 | 303 |
305 gfx::Vector2dF scrollTotal = m_rootScrollLayerImpl->scrollOffset() + m_rootS
crollLayerImpl->scrollDelta(); | 304 gfx::Vector2dF scrollTotal = rootScrollLayer()->scrollOffset() + rootScrollL
ayer()->scrollDelta(); |
306 gfx::SizeF scaledContentSize = contentSize(); | 305 gfx::SizeF scaledContentSize = contentSize(); |
307 if (!m_settings.pageScalePinchZoomEnabled) { | 306 if (!m_settings.pageScalePinchZoomEnabled) { |
308 scrollTotal.Scale(1 / m_pinchZoomViewport.pageScaleFactor()); | 307 scrollTotal.Scale(1 / m_pinchZoomViewport.pageScaleFactor()); |
309 scaledContentSize.Scale(1 / m_pinchZoomViewport.pageScaleFactor()); | 308 scaledContentSize.Scale(1 / m_pinchZoomViewport.pageScaleFactor()); |
310 } | 309 } |
311 gfx::SizeF viewportSize = gfx::ScaleSize(m_deviceViewportSize, 1 / m_deviceS
caleFactor); | 310 gfx::SizeF viewportSize = gfx::ScaleSize(m_deviceViewportSize, 1 / m_deviceS
caleFactor); |
312 | 311 |
313 double startTimeSeconds = (startTime - base::TimeTicks()).InSecondsF(); | 312 double startTimeSeconds = (startTime - base::TimeTicks()).InSecondsF(); |
314 m_pageScaleAnimation = PageScaleAnimation::create(scrollTotal, m_pinchZoomVi
ewport.totalPageScaleFactor(), viewportSize, scaledContentSize, startTimeSeconds
); | 313 m_pageScaleAnimation = PageScaleAnimation::create(scrollTotal, m_pinchZoomVi
ewport.totalPageScaleFactor(), viewportSize, scaledContentSize, startTimeSeconds
); |
315 | 314 |
(...skipping 42 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
358 for (int surfaceIndex = renderSurfaceLayerList.size() - 1; surfaceIndex >= 0
; --surfaceIndex) { | 357 for (int surfaceIndex = renderSurfaceLayerList.size() - 1; surfaceIndex >= 0
; --surfaceIndex) { |
359 LayerImpl* renderSurfaceLayer = renderSurfaceLayerList[surfaceIndex]; | 358 LayerImpl* renderSurfaceLayer = renderSurfaceLayerList[surfaceIndex]; |
360 RenderSurfaceImpl* renderSurface = renderSurfaceLayer->renderSurface(); | 359 RenderSurfaceImpl* renderSurface = renderSurfaceLayer->renderSurface(); |
361 DCHECK(renderSurface); | 360 DCHECK(renderSurface); |
362 renderSurface->damageTracker()->updateDamageTrackingState(renderSurface-
>layerList(), renderSurfaceLayer->id(), renderSurface->surfacePropertyChangedOnl
yFromDescendant(), renderSurface->contentRect(), renderSurfaceLayer->maskLayer()
, renderSurfaceLayer->filters(), renderSurfaceLayer->filter().get()); | 361 renderSurface->damageTracker()->updateDamageTrackingState(renderSurface-
>layerList(), renderSurfaceLayer->id(), renderSurface->surfacePropertyChangedOnl
yFromDescendant(), renderSurface->contentRect(), renderSurfaceLayer->maskLayer()
, renderSurfaceLayer->filters(), renderSurfaceLayer->filter().get()); |
363 } | 362 } |
364 } | 363 } |
365 | 364 |
366 void LayerTreeHostImpl::updateRootScrollLayerImplTransform() | 365 void LayerTreeHostImpl::updateRootScrollLayerImplTransform() |
367 { | 366 { |
368 if (m_rootScrollLayerImpl) { | 367 if (rootScrollLayer()) { |
369 m_rootScrollLayerImpl->setImplTransform(implTransform()); | 368 rootScrollLayer()->setImplTransform(implTransform()); |
370 } | 369 } |
371 } | 370 } |
372 | 371 |
373 void LayerTreeHostImpl::calculateRenderSurfaceLayerList(LayerList& renderSurface
LayerList) | 372 void LayerTreeHostImpl::calculateRenderSurfaceLayerList(LayerList& renderSurface
LayerList) |
374 { | 373 { |
375 DCHECK(renderSurfaceLayerList.empty()); | 374 DCHECK(renderSurfaceLayerList.empty()); |
376 DCHECK(m_rootLayerImpl); | 375 DCHECK(rootLayer()); |
377 DCHECK(m_renderer); // For maxTextureSize. | 376 DCHECK(m_renderer); // For maxTextureSize. |
378 | 377 |
379 { | 378 { |
380 updateRootScrollLayerImplTransform(); | 379 updateRootScrollLayerImplTransform(); |
381 | 380 |
382 TRACE_EVENT0("cc", "LayerTreeHostImpl::calcDrawEtc"); | 381 TRACE_EVENT0("cc", "LayerTreeHostImpl::calcDrawEtc"); |
383 float pageScaleFactor = m_pinchZoomViewport.pageScaleFactor(); | 382 float pageScaleFactor = m_pinchZoomViewport.pageScaleFactor(); |
384 LayerTreeHostCommon::calculateDrawProperties(m_rootLayerImpl.get(), devi
ceViewportSize(), m_deviceScaleFactor, pageScaleFactor, &m_layerSorter, renderer
Capabilities().maxTextureSize, renderSurfaceLayerList); | 383 LayerTreeHostCommon::calculateDrawProperties(rootLayer(), deviceViewport
Size(), m_deviceScaleFactor, pageScaleFactor, &m_layerSorter, rendererCapabiliti
es().maxTextureSize, renderSurfaceLayerList); |
385 | 384 |
386 trackDamageForAllSurfaces(m_rootLayerImpl.get(), renderSurfaceLayerList)
; | 385 trackDamageForAllSurfaces(rootLayer(), renderSurfaceLayerList); |
387 } | 386 } |
388 } | 387 } |
389 | 388 |
390 void LayerTreeHostImpl::FrameData::appendRenderPass(scoped_ptr<RenderPass> rende
rPass) | 389 void LayerTreeHostImpl::FrameData::appendRenderPass(scoped_ptr<RenderPass> rende
rPass) |
391 { | 390 { |
392 RenderPass* pass = renderPass.get(); | 391 RenderPass* pass = renderPass.get(); |
393 renderPasses.push_back(pass); | 392 renderPasses.push_back(pass); |
394 renderPassesById.set(pass->id, renderPass.Pass()); | 393 renderPassesById.set(pass->id, renderPass.Pass()); |
395 } | 394 } |
396 | 395 |
(...skipping 90 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
487 | 486 |
488 TRACE_EVENT1("cc", "LayerTreeHostImpl::calculateRenderPasses", "renderSurfac
eLayerList.size()", static_cast<long long unsigned>(frame.renderSurfaceLayerList
->size())); | 487 TRACE_EVENT1("cc", "LayerTreeHostImpl::calculateRenderPasses", "renderSurfac
eLayerList.size()", static_cast<long long unsigned>(frame.renderSurfaceLayerList
->size())); |
489 | 488 |
490 // Create the render passes in dependency order. | 489 // Create the render passes in dependency order. |
491 for (int surfaceIndex = frame.renderSurfaceLayerList->size() - 1; surfaceInd
ex >= 0 ; --surfaceIndex) { | 490 for (int surfaceIndex = frame.renderSurfaceLayerList->size() - 1; surfaceInd
ex >= 0 ; --surfaceIndex) { |
492 LayerImpl* renderSurfaceLayer = (*frame.renderSurfaceLayerList)[surfaceI
ndex]; | 491 LayerImpl* renderSurfaceLayer = (*frame.renderSurfaceLayerList)[surfaceI
ndex]; |
493 renderSurfaceLayer->renderSurface()->appendRenderPasses(frame); | 492 renderSurfaceLayer->renderSurface()->appendRenderPasses(frame); |
494 } | 493 } |
495 | 494 |
496 bool recordMetricsForFrame = m_settings.showOverdrawInTracing && base::debug
::TraceLog::GetInstance() && base::debug::TraceLog::GetInstance()->IsEnabled(); | 495 bool recordMetricsForFrame = m_settings.showOverdrawInTracing && base::debug
::TraceLog::GetInstance() && base::debug::TraceLog::GetInstance()->IsEnabled(); |
497 OcclusionTrackerImpl occlusionTracker(m_rootLayerImpl->renderSurface()->cont
entRect(), recordMetricsForFrame); | 496 OcclusionTrackerImpl occlusionTracker(rootLayer()->renderSurface()->contentR
ect(), recordMetricsForFrame); |
498 occlusionTracker.setMinimumTrackingSize(m_settings.minimumOcclusionTrackingS
ize); | 497 occlusionTracker.setMinimumTrackingSize(m_settings.minimumOcclusionTrackingS
ize); |
499 | 498 |
500 if (m_debugState.showOccludingRects) | 499 if (m_debugState.showOccludingRects) |
501 occlusionTracker.setOccludingScreenSpaceRectsContainer(&frame.occludingS
creenSpaceRects); | 500 occlusionTracker.setOccludingScreenSpaceRectsContainer(&frame.occludingS
creenSpaceRects); |
502 if (m_debugState.showNonOccludingRects) | 501 if (m_debugState.showNonOccludingRects) |
503 occlusionTracker.setNonOccludingScreenSpaceRectsContainer(&frame.nonOccl
udingScreenSpaceRects); | 502 occlusionTracker.setNonOccludingScreenSpaceRectsContainer(&frame.nonOccl
udingScreenSpaceRects); |
504 | 503 |
505 // Add quads to the Render passes in FrontToBack order to allow for testing
occlusion and performing culling during the tree walk. | 504 // Add quads to the Render passes in FrontToBack order to allow for testing
occlusion and performing culling during the tree walk. |
506 typedef LayerIterator<LayerImpl, std::vector<LayerImpl*>, RenderSurfaceImpl,
LayerIteratorActions::FrontToBack> LayerIteratorType; | 505 typedef LayerIterator<LayerImpl, std::vector<LayerImpl*>, RenderSurfaceImpl,
LayerIteratorActions::FrontToBack> LayerIteratorType; |
507 | 506 |
(...skipping 57 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
565 #ifndef NDEBUG | 564 #ifndef NDEBUG |
566 for (size_t i = 0; i < frame.renderPasses.size(); ++i) { | 565 for (size_t i = 0; i < frame.renderPasses.size(); ++i) { |
567 for (size_t j = 0; j < frame.renderPasses[i]->quad_list.size(); ++j) | 566 for (size_t j = 0; j < frame.renderPasses[i]->quad_list.size(); ++j) |
568 DCHECK(frame.renderPasses[i]->quad_list[j]->shared_quad_state); | 567 DCHECK(frame.renderPasses[i]->quad_list[j]->shared_quad_state); |
569 DCHECK(frame.renderPassesById.contains(frame.renderPasses[i]->id)); | 568 DCHECK(frame.renderPassesById.contains(frame.renderPasses[i]->id)); |
570 } | 569 } |
571 #endif | 570 #endif |
572 | 571 |
573 if (!m_hasTransparentBackground) { | 572 if (!m_hasTransparentBackground) { |
574 frame.renderPasses.back()->has_transparent_background = false; | 573 frame.renderPasses.back()->has_transparent_background = false; |
575 appendQuadsToFillScreen(frame.renderPasses.back(), m_rootLayerImpl.get()
, m_backgroundColor, occlusionTracker); | 574 appendQuadsToFillScreen(frame.renderPasses.back(), rootLayer(), m_backgr
oundColor, occlusionTracker); |
576 } | 575 } |
577 | 576 |
578 if (drawFrame) | 577 if (drawFrame) |
579 occlusionTracker.overdrawMetrics().recordMetrics(this); | 578 occlusionTracker.overdrawMetrics().recordMetrics(this); |
580 | 579 |
581 removeRenderPasses(CullRenderPassesWithNoQuads(), frame); | 580 removeRenderPasses(CullRenderPassesWithNoQuads(), frame); |
582 m_renderer->decideRenderPassAllocationsForFrame(frame.renderPasses); | 581 m_renderer->decideRenderPassAllocationsForFrame(frame.renderPasses); |
583 removeRenderPasses(CullRenderPassesWithCachedTextures(*m_renderer), frame); | 582 removeRenderPasses(CullRenderPassesWithCachedTextures(*m_renderer), frame); |
584 | 583 |
585 return drawFrame; | 584 return drawFrame; |
(...skipping 34 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
620 if (!m_timeSourceClientAdapter) | 619 if (!m_timeSourceClientAdapter) |
621 m_timeSourceClientAdapter = LayerTreeHostImplTimeSourceAdapter::create(t
his, DelayBasedTimeSource::create(lowFrequencyAnimationInterval(), m_proxy->curr
entThread())); | 620 m_timeSourceClientAdapter = LayerTreeHostImplTimeSourceAdapter::create(t
his, DelayBasedTimeSource::create(lowFrequencyAnimationInterval(), m_proxy->curr
entThread())); |
622 | 621 |
623 m_timeSourceClientAdapter->setActive(enabled); | 622 m_timeSourceClientAdapter->setActive(enabled); |
624 } | 623 } |
625 | 624 |
626 gfx::Size LayerTreeHostImpl::contentSize() const | 625 gfx::Size LayerTreeHostImpl::contentSize() const |
627 { | 626 { |
628 // TODO(aelias): Hardcoding the first child here is weird. Think of | 627 // TODO(aelias): Hardcoding the first child here is weird. Think of |
629 // a cleaner way to get the contentBounds on the Impl side. | 628 // a cleaner way to get the contentBounds on the Impl side. |
630 if (!m_rootScrollLayerImpl || m_rootScrollLayerImpl->children().isEmpty()) | 629 if (!rootScrollLayer() || rootScrollLayer()->children().isEmpty()) |
631 return gfx::Size(); | 630 return gfx::Size(); |
632 return m_rootScrollLayerImpl->children()[0]->contentBounds(); | 631 return rootScrollLayer()->children()[0]->contentBounds(); |
633 } | 632 } |
634 | 633 |
635 static inline RenderPass* findRenderPassById(RenderPass::Id renderPassId, const
LayerTreeHostImpl::FrameData& frame) | 634 static inline RenderPass* findRenderPassById(RenderPass::Id renderPassId, const
LayerTreeHostImpl::FrameData& frame) |
636 { | 635 { |
637 RenderPassIdHashMap::const_iterator it = frame.renderPassesById.find(renderP
assId); | 636 RenderPassIdHashMap::const_iterator it = frame.renderPassesById.find(renderP
assId); |
638 DCHECK(it != frame.renderPassesById.end()); | 637 DCHECK(it != frame.renderPassesById.end()); |
639 return it->second; | 638 return it->second; |
640 } | 639 } |
641 | 640 |
642 static void removeRenderPassesRecursive(RenderPass::Id removeRenderPassId, Layer
TreeHostImpl::FrameData& frame) | 641 static void removeRenderPassesRecursive(RenderPass::Id removeRenderPassId, Layer
TreeHostImpl::FrameData& frame) |
(...skipping 166 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
809 m_client->setNeedsCommitOnImplThread(); | 808 m_client->setNeedsCommitOnImplThread(); |
810 } | 809 } |
811 | 810 |
812 void LayerTreeHostImpl::onVSyncParametersChanged(double monotonicTimebase, doubl
e intervalInSeconds) | 811 void LayerTreeHostImpl::onVSyncParametersChanged(double monotonicTimebase, doubl
e intervalInSeconds) |
813 { | 812 { |
814 base::TimeTicks timebase = base::TimeTicks::FromInternalValue(monotonicTimeb
ase * base::Time::kMicrosecondsPerSecond); | 813 base::TimeTicks timebase = base::TimeTicks::FromInternalValue(monotonicTimeb
ase * base::Time::kMicrosecondsPerSecond); |
815 base::TimeDelta interval = base::TimeDelta::FromMicroseconds(intervalInSecon
ds * base::Time::kMicrosecondsPerSecond); | 814 base::TimeDelta interval = base::TimeDelta::FromMicroseconds(intervalInSecon
ds * base::Time::kMicrosecondsPerSecond); |
816 m_client->onVSyncParametersChanged(timebase, interval); | 815 m_client->onVSyncParametersChanged(timebase, interval); |
817 } | 816 } |
818 | 817 |
| 818 void LayerTreeHostImpl::OnCanDrawStateChangedForTree(LayerTreeImpl*) |
| 819 { |
| 820 m_client->onCanDrawStateChanged(canDraw()); |
| 821 } |
| 822 |
819 void LayerTreeHostImpl::drawLayers(FrameData& frame) | 823 void LayerTreeHostImpl::drawLayers(FrameData& frame) |
820 { | 824 { |
821 TRACE_EVENT0("cc", "LayerTreeHostImpl::drawLayers"); | 825 TRACE_EVENT0("cc", "LayerTreeHostImpl::drawLayers"); |
822 DCHECK(canDraw()); | 826 DCHECK(canDraw()); |
823 DCHECK(!frame.renderPasses.empty()); | 827 DCHECK(!frame.renderPasses.empty()); |
824 | 828 |
825 // FIXME: use the frame begin time from the overall compositor scheduler. | 829 // FIXME: use the frame begin time from the overall compositor scheduler. |
826 // This value is currently inaccessible because it is up in Chromium's | 830 // This value is currently inaccessible because it is up in Chromium's |
827 // RenderWidget. | 831 // RenderWidget. |
828 m_fpsCounter->markBeginningOfFrame(base::TimeTicks::Now()); | 832 m_fpsCounter->markBeginningOfFrame(base::TimeTicks::Now()); |
829 | 833 |
830 if (m_debugState.showHudRects()) | 834 if (m_debugState.showHudRects()) |
831 m_debugRectHistory->saveDebugRectsForCurrentFrame(m_rootLayerImpl.get(),
*frame.renderSurfaceLayerList, frame.occludingScreenSpaceRects, frame.nonOcclud
ingScreenSpaceRects, m_debugState); | 835 m_debugRectHistory->saveDebugRectsForCurrentFrame(rootLayer(), *frame.re
nderSurfaceLayerList, frame.occludingScreenSpaceRects, frame.nonOccludingScreenS
paceRects, m_debugState); |
832 | 836 |
833 // Because the contents of the HUD depend on everything else in the frame, t
he contents | 837 // Because the contents of the HUD depend on everything else in the frame, t
he contents |
834 // of its texture are updated as the last thing before the frame is drawn. | 838 // of its texture are updated as the last thing before the frame is drawn. |
835 if (m_hudLayerImpl) | 839 if (m_activeTree->hud_layer()) |
836 m_hudLayerImpl->updateHudTexture(m_resourceProvider.get()); | 840 m_activeTree->hud_layer()->updateHudTexture(m_resourceProvider.get()); |
837 | 841 |
838 m_renderer->drawFrame(frame.renderPasses, frame.renderPassesById); | 842 m_renderer->drawFrame(frame.renderPasses, frame.renderPassesById); |
839 | 843 |
840 // The render passes should be consumed by the renderer. | 844 // The render passes should be consumed by the renderer. |
841 DCHECK(frame.renderPasses.empty()); | 845 DCHECK(frame.renderPasses.empty()); |
842 DCHECK(frame.renderPassesById.empty()); | 846 DCHECK(frame.renderPassesById.empty()); |
843 | 847 |
844 // The next frame should start by assuming nothing has changed, and changes
are noted as they occur. | 848 // The next frame should start by assuming nothing has changed, and changes
are noted as they occur. |
845 for (unsigned int i = 0; i < frame.renderSurfaceLayerList->size(); i++) | 849 for (unsigned int i = 0; i < frame.renderSurfaceLayerList->size(); i++) |
846 (*frame.renderSurfaceLayerList)[i]->renderSurface()->damageTracker()->di
dDrawDamagedArea(); | 850 (*frame.renderSurfaceLayerList)[i]->renderSurface()->damageTracker()->di
dDrawDamagedArea(); |
847 m_rootLayerImpl->resetAllChangeTrackingForSubtree(); | 851 rootLayer()->resetAllChangeTrackingForSubtree(); |
848 } | 852 } |
849 | 853 |
850 void LayerTreeHostImpl::didDrawAllLayers(const FrameData& frame) | 854 void LayerTreeHostImpl::didDrawAllLayers(const FrameData& frame) |
851 { | 855 { |
852 for (size_t i = 0; i < frame.willDrawLayers.size(); ++i) | 856 for (size_t i = 0; i < frame.willDrawLayers.size(); ++i) |
853 frame.willDrawLayers[i]->didDraw(m_resourceProvider.get()); | 857 frame.willDrawLayers[i]->didDraw(m_resourceProvider.get()); |
854 | 858 |
855 // Once all layers have been drawn, pending texture uploads should no | 859 // Once all layers have been drawn, pending texture uploads should no |
856 // longer block future uploads. | 860 // longer block future uploads. |
857 m_resourceProvider->markPendingUploadsAsNonBlocking(); | 861 m_resourceProvider->markPendingUploadsAsNonBlocking(); |
(...skipping 42 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
900 { | 904 { |
901 m_client->onSwapBuffersCompleteOnImplThread(); | 905 m_client->onSwapBuffersCompleteOnImplThread(); |
902 } | 906 } |
903 | 907 |
904 void LayerTreeHostImpl::readback(void* pixels, const gfx::Rect& rect) | 908 void LayerTreeHostImpl::readback(void* pixels, const gfx::Rect& rect) |
905 { | 909 { |
906 DCHECK(m_renderer); | 910 DCHECK(m_renderer); |
907 m_renderer->getFramebufferPixels(pixels, rect); | 911 m_renderer->getFramebufferPixels(pixels, rect); |
908 } | 912 } |
909 | 913 |
910 static LayerImpl* findRootScrollLayer(LayerImpl* layer) | |
911 { | |
912 if (!layer) | |
913 return 0; | |
914 | |
915 if (layer->scrollable()) | |
916 return layer; | |
917 | |
918 for (size_t i = 0; i < layer->children().size(); ++i) { | |
919 LayerImpl* found = findRootScrollLayer(layer->children()[i]); | |
920 if (found) | |
921 return found; | |
922 } | |
923 | |
924 return 0; | |
925 } | |
926 | |
927 // Content layers can be either directly scrollable or contained in an outer | 914 // Content layers can be either directly scrollable or contained in an outer |
928 // scrolling layer which applies the scroll transform. Given a content layer, | 915 // scrolling layer which applies the scroll transform. Given a content layer, |
929 // this function returns the associated scroll layer if any. | 916 // this function returns the associated scroll layer if any. |
930 static LayerImpl* findScrollLayerForContentLayer(LayerImpl* layerImpl) | 917 static LayerImpl* findScrollLayerForContentLayer(LayerImpl* layerImpl) |
931 { | 918 { |
932 if (!layerImpl) | 919 if (!layerImpl) |
933 return 0; | 920 return 0; |
934 | 921 |
935 if (layerImpl->scrollable()) | 922 if (layerImpl->scrollable()) |
936 return layerImpl; | 923 return layerImpl; |
937 | 924 |
938 if (layerImpl->drawsContent() && layerImpl->parent() && layerImpl->parent()-
>scrollable()) | 925 if (layerImpl->drawsContent() && layerImpl->parent() && layerImpl->parent()-
>scrollable()) |
939 return layerImpl->parent(); | 926 return layerImpl->parent(); |
940 | 927 |
941 return 0; | 928 return 0; |
942 } | 929 } |
943 | 930 |
944 void LayerTreeHostImpl::setRootLayer(scoped_ptr<LayerImpl> layer) | 931 void LayerTreeHostImpl::setRootLayer(scoped_ptr<LayerImpl> layer) |
945 { | 932 { |
946 m_rootLayerImpl = layer.Pass(); | 933 m_activeTree->SetRootLayer(layer.Pass()); |
947 m_rootScrollLayerImpl = findRootScrollLayer(m_rootLayerImpl.get()); | |
948 m_currentlyScrollingLayerImpl = 0; | |
949 | |
950 if (m_rootLayerImpl && m_scrollingLayerIdFromPreviousTree != -1) | |
951 m_currentlyScrollingLayerImpl = LayerTreeHostCommon::findLayerInSubtree(
m_rootLayerImpl.get(), m_scrollingLayerIdFromPreviousTree); | |
952 | |
953 m_scrollingLayerIdFromPreviousTree = -1; | |
954 | |
955 m_client->onCanDrawStateChanged(canDraw()); | |
956 } | 934 } |
957 | 935 |
958 scoped_ptr<LayerImpl> LayerTreeHostImpl::detachLayerTree() | 936 scoped_ptr<LayerImpl> LayerTreeHostImpl::detachLayerTree() |
959 { | 937 { |
960 // Clear all data structures that have direct references to the layer tree. | 938 scoped_ptr<LayerImpl> layer = m_activeTree->DetachLayerTree(); |
961 m_scrollingLayerIdFromPreviousTree = m_currentlyScrollingLayerImpl ? m_curre
ntlyScrollingLayerImpl->id() : -1; | 939 m_renderSurfaceLayerList.clear(); |
962 m_currentlyScrollingLayerImpl = 0; | 940 return layer.Pass(); |
963 m_renderSurfaceLayerList.clear(); | |
964 | |
965 return m_rootLayerImpl.Pass(); | |
966 } | 941 } |
967 | 942 |
968 void LayerTreeHostImpl::setVisible(bool visible) | 943 void LayerTreeHostImpl::setVisible(bool visible) |
969 { | 944 { |
970 DCHECK(m_proxy->isImplThread()); | 945 DCHECK(m_proxy->isImplThread()); |
971 | 946 |
972 if (m_visible == visible) | 947 if (m_visible == visible) |
973 return; | 948 return; |
974 m_visible = visible; | 949 m_visible = visible; |
975 didVisibilityChange(this, m_visible); | 950 didVisibilityChange(this, m_visible); |
976 enforceManagedMemoryPolicy(m_managedMemoryPolicy); | 951 enforceManagedMemoryPolicy(m_managedMemoryPolicy); |
977 | 952 |
978 if (!m_renderer) | 953 if (!m_renderer) |
979 return; | 954 return; |
980 | 955 |
981 m_renderer->setVisible(visible); | 956 m_renderer->setVisible(visible); |
982 | 957 |
983 setBackgroundTickingEnabled(!m_visible && m_needsAnimateLayers); | 958 setBackgroundTickingEnabled(!m_visible && m_needsAnimateLayers); |
984 } | 959 } |
985 | 960 |
986 bool LayerTreeHostImpl::initializeRenderer(scoped_ptr<OutputSurface> outputSurfa
ce) | 961 bool LayerTreeHostImpl::initializeRenderer(scoped_ptr<OutputSurface> outputSurfa
ce) |
987 { | 962 { |
988 // Since we will create a new resource provider, we cannot continue to use | 963 // Since we will create a new resource provider, we cannot continue to use |
989 // the old resources (i.e. renderSurfaces and texture IDs). Clear them | 964 // the old resources (i.e. renderSurfaces and texture IDs). Clear them |
990 // before we destroy the old resource provider. | 965 // before we destroy the old resource provider. |
991 if (m_rootLayerImpl) { | 966 if (rootLayer()) { |
992 clearRenderSurfaces(); | 967 clearRenderSurfaces(); |
993 sendDidLoseOutputSurfaceRecursive(m_rootLayerImpl.get()); | 968 sendDidLoseOutputSurfaceRecursive(rootLayer()); |
994 } | 969 } |
995 // Note: order is important here. | 970 // Note: order is important here. |
996 m_renderer.reset(); | 971 m_renderer.reset(); |
997 m_tileManager.reset(); | 972 m_tileManager.reset(); |
998 m_resourceProvider.reset(); | 973 m_resourceProvider.reset(); |
999 m_outputSurface.reset(); | 974 m_outputSurface.reset(); |
1000 | 975 |
1001 if (!outputSurface->bindToClient(this)) | 976 if (!outputSurface->bindToClient(this)) |
1002 return false; | 977 return false; |
1003 | 978 |
(...skipping 86 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1090 void LayerTreeHostImpl::setPageScaleFactorAndLimits(float pageScaleFactor, float
minPageScaleFactor, float maxPageScaleFactor) | 1065 void LayerTreeHostImpl::setPageScaleFactorAndLimits(float pageScaleFactor, float
minPageScaleFactor, float maxPageScaleFactor) |
1091 { | 1066 { |
1092 if (!pageScaleFactor) | 1067 if (!pageScaleFactor) |
1093 return; | 1068 return; |
1094 | 1069 |
1095 float pageScaleChange = pageScaleFactor / m_pinchZoomViewport.pageScaleFacto
r(); | 1070 float pageScaleChange = pageScaleFactor / m_pinchZoomViewport.pageScaleFacto
r(); |
1096 m_pinchZoomViewport.setPageScaleFactorAndLimits(pageScaleFactor, minPageScal
eFactor, maxPageScaleFactor); | 1071 m_pinchZoomViewport.setPageScaleFactorAndLimits(pageScaleFactor, minPageScal
eFactor, maxPageScaleFactor); |
1097 | 1072 |
1098 if (!m_settings.pageScalePinchZoomEnabled) { | 1073 if (!m_settings.pageScalePinchZoomEnabled) { |
1099 if (pageScaleChange != 1) | 1074 if (pageScaleChange != 1) |
1100 adjustScrollsForPageScaleChange(m_rootScrollLayerImpl, pageScaleChan
ge); | 1075 adjustScrollsForPageScaleChange(rootScrollLayer(), pageScaleChange); |
1101 } | 1076 } |
1102 | 1077 |
1103 // Clamp delta to limits and refresh display matrix. | 1078 // Clamp delta to limits and refresh display matrix. |
1104 setPageScaleDelta(m_pinchZoomViewport.pageScaleDelta() / m_pinchZoomViewport
.sentPageScaleDelta()); | 1079 setPageScaleDelta(m_pinchZoomViewport.pageScaleDelta() / m_pinchZoomViewport
.sentPageScaleDelta()); |
1105 m_pinchZoomViewport.setSentPageScaleDelta(1); | 1080 m_pinchZoomViewport.setSentPageScaleDelta(1); |
1106 } | 1081 } |
1107 | 1082 |
1108 void LayerTreeHostImpl::setPageScaleDelta(float delta) | 1083 void LayerTreeHostImpl::setPageScaleDelta(float delta) |
1109 { | 1084 { |
1110 m_pinchZoomViewport.setPageScaleDelta(delta); | 1085 m_pinchZoomViewport.setPageScaleDelta(delta); |
1111 | 1086 |
1112 updateMaxScrollOffset(); | 1087 updateMaxScrollOffset(); |
1113 } | 1088 } |
1114 | 1089 |
1115 void LayerTreeHostImpl::updateMaxScrollOffset() | 1090 void LayerTreeHostImpl::updateMaxScrollOffset() |
1116 { | 1091 { |
1117 if (!m_rootScrollLayerImpl || !m_rootScrollLayerImpl->children().size()) | 1092 if (!rootScrollLayer() || !rootScrollLayer()->children().size()) |
1118 return; | 1093 return; |
1119 | 1094 |
1120 gfx::SizeF viewBounds = m_deviceViewportSize; | 1095 gfx::SizeF viewBounds = m_deviceViewportSize; |
1121 if (LayerImpl* clipLayer = m_rootScrollLayerImpl->parent()) { | 1096 if (LayerImpl* clipLayer = rootScrollLayer()->parent()) { |
1122 // Compensate for non-overlay scrollbars. | 1097 // Compensate for non-overlay scrollbars. |
1123 if (clipLayer->masksToBounds()) | 1098 if (clipLayer->masksToBounds()) |
1124 viewBounds = gfx::ScaleSize(clipLayer->bounds(), m_deviceScaleFactor
); | 1099 viewBounds = gfx::ScaleSize(clipLayer->bounds(), m_deviceScaleFactor
); |
1125 } | 1100 } |
1126 | 1101 |
1127 gfx::Size contentBounds = contentSize(); | 1102 gfx::Size contentBounds = contentSize(); |
1128 if (m_settings.pageScalePinchZoomEnabled) { | 1103 if (m_settings.pageScalePinchZoomEnabled) { |
1129 // Pinch with pageScale scrolls entirely in layout space. contentSize | 1104 // Pinch with pageScale scrolls entirely in layout space. contentSize |
1130 // returns the bounds including the page scale factor, so calculate the | 1105 // returns the bounds including the page scale factor, so calculate the |
1131 // pre page-scale layout size here. | 1106 // pre page-scale layout size here. |
1132 float pageScaleFactor = m_pinchZoomViewport.pageScaleFactor(); | 1107 float pageScaleFactor = m_pinchZoomViewport.pageScaleFactor(); |
1133 contentBounds.set_width(contentBounds.width() / pageScaleFactor); | 1108 contentBounds.set_width(contentBounds.width() / pageScaleFactor); |
1134 contentBounds.set_height(contentBounds.height() / pageScaleFactor); | 1109 contentBounds.set_height(contentBounds.height() / pageScaleFactor); |
1135 } else { | 1110 } else { |
1136 viewBounds.Scale(1 / m_pinchZoomViewport.pageScaleDelta()); | 1111 viewBounds.Scale(1 / m_pinchZoomViewport.pageScaleDelta()); |
1137 } | 1112 } |
1138 | 1113 |
1139 gfx::Vector2dF maxScroll = gfx::Rect(contentBounds).bottom_right() - gfx::Re
ctF(viewBounds).bottom_right(); | 1114 gfx::Vector2dF maxScroll = gfx::Rect(contentBounds).bottom_right() - gfx::Re
ctF(viewBounds).bottom_right(); |
1140 maxScroll.Scale(1 / m_deviceScaleFactor); | 1115 maxScroll.Scale(1 / m_deviceScaleFactor); |
1141 | 1116 |
1142 // The viewport may be larger than the contents in some cases, such as | 1117 // The viewport may be larger than the contents in some cases, such as |
1143 // having a vertical scrollbar but no horizontal overflow. | 1118 // having a vertical scrollbar but no horizontal overflow. |
1144 maxScroll.ClampToMin(gfx::Vector2dF()); | 1119 maxScroll.ClampToMin(gfx::Vector2dF()); |
1145 | 1120 |
1146 m_rootScrollLayerImpl->setMaxScrollOffset(gfx::ToFlooredVector2d(maxScroll))
; | 1121 rootScrollLayer()->setMaxScrollOffset(gfx::ToFlooredVector2d(maxScroll)); |
1147 } | 1122 } |
1148 | 1123 |
1149 void LayerTreeHostImpl::setNeedsRedraw() | 1124 void LayerTreeHostImpl::setNeedsRedraw() |
1150 { | 1125 { |
1151 m_client->setNeedsRedrawOnImplThread(); | 1126 m_client->setNeedsRedrawOnImplThread(); |
1152 } | 1127 } |
1153 | 1128 |
1154 bool LayerTreeHostImpl::ensureRenderSurfaceLayerList() | 1129 bool LayerTreeHostImpl::ensureRenderSurfaceLayerList() |
1155 { | 1130 { |
1156 if (!m_rootLayerImpl) | 1131 if (!rootLayer()) |
1157 return false; | 1132 return false; |
1158 if (!m_renderer) | 1133 if (!m_renderer) |
1159 return false; | 1134 return false; |
1160 | 1135 |
1161 // We need both a non-empty render surface layer list and a root render | 1136 // 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. | 1137 // surface to be able to iterate over the visible layers. |
1163 if (m_renderSurfaceLayerList.size() && m_rootLayerImpl->renderSurface()) | 1138 if (m_renderSurfaceLayerList.size() && rootLayer()->renderSurface()) |
1164 return true; | 1139 return true; |
1165 | 1140 |
1166 // If we are called after setRootLayer() but before prepareToDraw(), we need | 1141 // If we are called after setRootLayer() but before prepareToDraw(), we need |
1167 // to recalculate the visible layers. This prevents being unable to scroll | 1142 // to recalculate the visible layers. This prevents being unable to scroll |
1168 // during part of a commit. | 1143 // during part of a commit. |
1169 m_renderSurfaceLayerList.clear(); | 1144 m_renderSurfaceLayerList.clear(); |
1170 calculateRenderSurfaceLayerList(m_renderSurfaceLayerList); | 1145 calculateRenderSurfaceLayerList(m_renderSurfaceLayerList); |
1171 | 1146 |
1172 return m_renderSurfaceLayerList.size(); | 1147 return m_renderSurfaceLayerList.size(); |
1173 } | 1148 } |
1174 | 1149 |
1175 InputHandlerClient::ScrollStatus LayerTreeHostImpl::scrollBegin(gfx::Point viewp
ortPoint, InputHandlerClient::ScrollInputType type) | 1150 InputHandlerClient::ScrollStatus LayerTreeHostImpl::scrollBegin(gfx::Point viewp
ortPoint, InputHandlerClient::ScrollInputType type) |
1176 { | 1151 { |
1177 TRACE_EVENT0("cc", "LayerTreeHostImpl::scrollBegin"); | 1152 TRACE_EVENT0("cc", "LayerTreeHostImpl::scrollBegin"); |
1178 | 1153 |
1179 DCHECK(!m_currentlyScrollingLayerImpl); | 1154 DCHECK(!currentlyScrollingLayer()); |
1180 clearCurrentlyScrollingLayer(); | 1155 clearCurrentlyScrollingLayer(); |
1181 | 1156 |
1182 if (!ensureRenderSurfaceLayerList()) | 1157 if (!ensureRenderSurfaceLayerList()) |
1183 return ScrollIgnored; | 1158 return ScrollIgnored; |
1184 | 1159 |
1185 gfx::PointF deviceViewportPoint = gfx::ScalePoint(viewportPoint, m_deviceSca
leFactor); | 1160 gfx::PointF deviceViewportPoint = gfx::ScalePoint(viewportPoint, m_deviceSca
leFactor); |
1186 | 1161 |
1187 // First find out which layer was hit from the saved list of visible layers | 1162 // First find out which layer was hit from the saved list of visible layers |
1188 // in the most recent frame. | 1163 // in the most recent frame. |
1189 LayerImpl* layerImpl = LayerTreeHostCommon::findLayerThatIsHitByPoint(device
ViewportPoint, m_renderSurfaceLayerList); | 1164 LayerImpl* layerImpl = LayerTreeHostCommon::findLayerThatIsHitByPoint(device
ViewportPoint, m_renderSurfaceLayerList); |
(...skipping 17 matching lines...) Expand all Loading... |
1207 if (status == ScrollOnMainThread) { | 1182 if (status == ScrollOnMainThread) { |
1208 m_numMainThreadScrolls++; | 1183 m_numMainThreadScrolls++; |
1209 return ScrollOnMainThread; | 1184 return ScrollOnMainThread; |
1210 } | 1185 } |
1211 | 1186 |
1212 if (status == ScrollStarted && !potentiallyScrollingLayerImpl) | 1187 if (status == ScrollStarted && !potentiallyScrollingLayerImpl) |
1213 potentiallyScrollingLayerImpl = scrollLayerImpl; | 1188 potentiallyScrollingLayerImpl = scrollLayerImpl; |
1214 } | 1189 } |
1215 | 1190 |
1216 if (potentiallyScrollingLayerImpl) { | 1191 if (potentiallyScrollingLayerImpl) { |
1217 m_currentlyScrollingLayerImpl = potentiallyScrollingLayerImpl; | 1192 m_activeTree->set_currently_scrolling_layer(potentiallyScrollingLayerImp
l); |
1218 // Gesture events need to be transformed from viewport coordinates to lo
cal layer coordinates | 1193 // 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 | 1194 // 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. | 1195 // events are already in local layer coordinates so we can just apply th
em directly. |
1221 m_scrollDeltaIsInViewportSpace = (type == Gesture); | 1196 m_scrollDeltaIsInViewportSpace = (type == Gesture); |
1222 m_numImplThreadScrolls++; | 1197 m_numImplThreadScrolls++; |
1223 return ScrollStarted; | 1198 return ScrollStarted; |
1224 } | 1199 } |
1225 return ScrollIgnored; | 1200 return ScrollIgnored; |
1226 } | 1201 } |
1227 | 1202 |
(...skipping 53 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1281 { | 1256 { |
1282 gfx::Vector2dF previousDelta(layerImpl.scrollDelta()); | 1257 gfx::Vector2dF previousDelta(layerImpl.scrollDelta()); |
1283 layerImpl.scrollBy(localDelta); | 1258 layerImpl.scrollBy(localDelta); |
1284 return layerImpl.scrollDelta() - previousDelta; | 1259 return layerImpl.scrollDelta() - previousDelta; |
1285 } | 1260 } |
1286 | 1261 |
1287 bool LayerTreeHostImpl::scrollBy(const gfx::Point& viewportPoint, | 1262 bool LayerTreeHostImpl::scrollBy(const gfx::Point& viewportPoint, |
1288 const gfx::Vector2d& scrollDelta) | 1263 const gfx::Vector2d& scrollDelta) |
1289 { | 1264 { |
1290 TRACE_EVENT0("cc", "LayerTreeHostImpl::scrollBy"); | 1265 TRACE_EVENT0("cc", "LayerTreeHostImpl::scrollBy"); |
1291 if (!m_currentlyScrollingLayerImpl) | 1266 if (!currentlyScrollingLayer()) |
1292 return false; | 1267 return false; |
1293 | 1268 |
1294 gfx::Vector2dF pendingDelta = scrollDelta; | 1269 gfx::Vector2dF pendingDelta = scrollDelta; |
1295 bool didScroll = false; | 1270 bool didScroll = false; |
1296 | 1271 |
1297 for (LayerImpl* layerImpl = m_currentlyScrollingLayerImpl; layerImpl; layerI
mpl = layerImpl->parent()) { | 1272 for (LayerImpl* layerImpl = currentlyScrollingLayer(); layerImpl; layerImpl
= layerImpl->parent()) { |
1298 if (!layerImpl->scrollable()) | 1273 if (!layerImpl->scrollable()) |
1299 continue; | 1274 continue; |
1300 | 1275 |
1301 PinchZoomViewport* viewport = NULL; | 1276 PinchZoomViewport* viewport = NULL; |
1302 if (m_settings.pageScalePinchZoomEnabled && layerImpl == m_rootScrollLay
erImpl) | 1277 if (m_settings.pageScalePinchZoomEnabled && layerImpl == rootScrollLayer
()) |
1303 viewport = &m_pinchZoomViewport; | 1278 viewport = &m_pinchZoomViewport; |
1304 gfx::Vector2dF appliedDelta; | 1279 gfx::Vector2dF appliedDelta; |
1305 if (m_scrollDeltaIsInViewportSpace) { | 1280 if (m_scrollDeltaIsInViewportSpace) { |
1306 float scaleFromViewportToScreenSpace = m_deviceScaleFactor; | 1281 float scaleFromViewportToScreenSpace = m_deviceScaleFactor; |
1307 appliedDelta = scrollLayerWithViewportSpaceDelta(viewport, *layerImp
l, scaleFromViewportToScreenSpace, viewportPoint, pendingDelta); | 1282 appliedDelta = scrollLayerWithViewportSpaceDelta(viewport, *layerImp
l, scaleFromViewportToScreenSpace, viewportPoint, pendingDelta); |
1308 } else | 1283 } else |
1309 appliedDelta = scrollLayerWithLocalDelta(*layerImpl, pendingDelta); | 1284 appliedDelta = scrollLayerWithLocalDelta(*layerImpl, pendingDelta); |
1310 | 1285 |
1311 // If the layer wasn't able to move, try the next one in the hierarchy. | 1286 // If the layer wasn't able to move, try the next one in the hierarchy. |
1312 float moveThresholdSquared = 0.1f * 0.1f; | 1287 float moveThresholdSquared = 0.1f * 0.1f; |
(...skipping 20 matching lines...) Expand all Loading... |
1333 | 1308 |
1334 if (didScroll) { | 1309 if (didScroll) { |
1335 m_client->setNeedsCommitOnImplThread(); | 1310 m_client->setNeedsCommitOnImplThread(); |
1336 m_client->setNeedsRedrawOnImplThread(); | 1311 m_client->setNeedsRedrawOnImplThread(); |
1337 } | 1312 } |
1338 return didScroll; | 1313 return didScroll; |
1339 } | 1314 } |
1340 | 1315 |
1341 void LayerTreeHostImpl::clearCurrentlyScrollingLayer() | 1316 void LayerTreeHostImpl::clearCurrentlyScrollingLayer() |
1342 { | 1317 { |
1343 m_currentlyScrollingLayerImpl = 0; | 1318 m_activeTree->ClearCurrentlyScrollingLayer(); |
1344 m_scrollingLayerIdFromPreviousTree = -1; | |
1345 } | 1319 } |
1346 | 1320 |
1347 void LayerTreeHostImpl::scrollEnd() | 1321 void LayerTreeHostImpl::scrollEnd() |
1348 { | 1322 { |
1349 clearCurrentlyScrollingLayer(); | 1323 clearCurrentlyScrollingLayer(); |
1350 } | 1324 } |
1351 | 1325 |
1352 void LayerTreeHostImpl::pinchGestureBegin() | 1326 void LayerTreeHostImpl::pinchGestureBegin() |
1353 { | 1327 { |
1354 m_pinchGestureActive = true; | 1328 m_pinchGestureActive = true; |
1355 m_previousPinchAnchor = gfx::Point(); | 1329 m_previousPinchAnchor = gfx::Point(); |
1356 | 1330 |
1357 if (m_rootScrollLayerImpl && m_rootScrollLayerImpl->scrollbarAnimationContro
ller()) | 1331 if (rootScrollLayer() && rootScrollLayer()->scrollbarAnimationController()) |
1358 m_rootScrollLayerImpl->scrollbarAnimationController()->didPinchGestureBe
gin(); | 1332 rootScrollLayer()->scrollbarAnimationController()->didPinchGestureBegin(
); |
1359 } | 1333 } |
1360 | 1334 |
1361 void LayerTreeHostImpl::pinchGestureUpdate(float magnifyDelta, gfx::Point anchor
) | 1335 void LayerTreeHostImpl::pinchGestureUpdate(float magnifyDelta, gfx::Point anchor
) |
1362 { | 1336 { |
1363 TRACE_EVENT0("cc", "LayerTreeHostImpl::pinchGestureUpdate"); | 1337 TRACE_EVENT0("cc", "LayerTreeHostImpl::pinchGestureUpdate"); |
1364 | 1338 |
1365 if (!m_rootScrollLayerImpl) | 1339 if (!rootScrollLayer()) |
1366 return; | 1340 return; |
1367 | 1341 |
1368 // Keep the center-of-pinch anchor specified by (x, y) in a stable | 1342 // Keep the center-of-pinch anchor specified by (x, y) in a stable |
1369 // position over the course of the magnify. | 1343 // position over the course of the magnify. |
1370 float pageScaleDelta = m_pinchZoomViewport.pageScaleDelta(); | 1344 float pageScaleDelta = m_pinchZoomViewport.pageScaleDelta(); |
1371 gfx::PointF previousScaleAnchor = gfx::ScalePoint(anchor, 1 / pageScaleDelta
); | 1345 gfx::PointF previousScaleAnchor = gfx::ScalePoint(anchor, 1 / pageScaleDelta
); |
1372 setPageScaleDelta(pageScaleDelta * magnifyDelta); | 1346 setPageScaleDelta(pageScaleDelta * magnifyDelta); |
1373 pageScaleDelta = m_pinchZoomViewport.pageScaleDelta(); | 1347 pageScaleDelta = m_pinchZoomViewport.pageScaleDelta(); |
1374 gfx::PointF newScaleAnchor = gfx::ScalePoint(anchor, 1 / pageScaleDelta); | 1348 gfx::PointF newScaleAnchor = gfx::ScalePoint(anchor, 1 / pageScaleDelta); |
1375 gfx::Vector2dF move = previousScaleAnchor - newScaleAnchor; | 1349 gfx::Vector2dF move = previousScaleAnchor - newScaleAnchor; |
1376 | 1350 |
1377 m_previousPinchAnchor = anchor; | 1351 m_previousPinchAnchor = anchor; |
1378 | 1352 |
1379 if (m_settings.pageScalePinchZoomEnabled) { | 1353 if (m_settings.pageScalePinchZoomEnabled) { |
1380 // Compute the application of the delta with respect to the current page
zoom of the page. | 1354 // Compute the application of the delta with respect to the current page
zoom of the page. |
1381 move.Scale(1 / m_pinchZoomViewport.pageScaleFactor()); | 1355 move.Scale(1 / m_pinchZoomViewport.pageScaleFactor()); |
1382 } | 1356 } |
1383 | 1357 |
1384 gfx::Vector2dF scrollOverflow = m_settings.pageScalePinchZoomEnabled ? m_pin
chZoomViewport.applyScroll(move) : move; | 1358 gfx::Vector2dF scrollOverflow = m_settings.pageScalePinchZoomEnabled ? m_pin
chZoomViewport.applyScroll(move) : move; |
1385 m_rootScrollLayerImpl->scrollBy(scrollOverflow); | 1359 rootScrollLayer()->scrollBy(scrollOverflow); |
1386 | 1360 |
1387 if (m_rootScrollLayerImpl->scrollbarAnimationController()) | 1361 if (rootScrollLayer()->scrollbarAnimationController()) |
1388 m_rootScrollLayerImpl->scrollbarAnimationController()->didPinchGestureUp
date(); | 1362 rootScrollLayer()->scrollbarAnimationController()->didPinchGestureUpdate
(); |
1389 | 1363 |
1390 m_client->setNeedsCommitOnImplThread(); | 1364 m_client->setNeedsCommitOnImplThread(); |
1391 m_client->setNeedsRedrawOnImplThread(); | 1365 m_client->setNeedsRedrawOnImplThread(); |
1392 } | 1366 } |
1393 | 1367 |
1394 void LayerTreeHostImpl::pinchGestureEnd() | 1368 void LayerTreeHostImpl::pinchGestureEnd() |
1395 { | 1369 { |
1396 m_pinchGestureActive = false; | 1370 m_pinchGestureActive = false; |
1397 | 1371 |
1398 if (m_rootScrollLayerImpl && m_rootScrollLayerImpl->scrollbarAnimationContro
ller()) | 1372 if (rootScrollLayer() && rootScrollLayer()->scrollbarAnimationController()) |
1399 m_rootScrollLayerImpl->scrollbarAnimationController()->didPinchGestureEn
d(); | 1373 rootScrollLayer()->scrollbarAnimationController()->didPinchGestureEnd(); |
1400 | 1374 |
1401 m_client->setNeedsCommitOnImplThread(); | 1375 m_client->setNeedsCommitOnImplThread(); |
1402 } | 1376 } |
1403 | 1377 |
1404 void LayerTreeHostImpl::computeDoubleTapZoomDeltas(ScrollAndScaleSet* scrollInfo
) | 1378 void LayerTreeHostImpl::computeDoubleTapZoomDeltas(ScrollAndScaleSet* scrollInfo
) |
1405 { | 1379 { |
1406 gfx::Vector2dF scaledScrollOffset = m_pageScaleAnimation->targetScrollOffset
(); | 1380 gfx::Vector2dF scaledScrollOffset = m_pageScaleAnimation->targetScrollOffset
(); |
1407 if (!m_settings.pageScalePinchZoomEnabled) | 1381 if (!m_settings.pageScalePinchZoomEnabled) |
1408 scaledScrollOffset.Scale(m_pinchZoomViewport.pageScaleFactor()); | 1382 scaledScrollOffset.Scale(m_pinchZoomViewport.pageScaleFactor()); |
1409 makeScrollAndScaleSet(scrollInfo, ToFlooredVector2d(scaledScrollOffset), m_p
ageScaleAnimation->targetPageScaleFactor()); | 1383 makeScrollAndScaleSet(scrollInfo, ToFlooredVector2d(scaledScrollOffset), m_p
ageScaleAnimation->targetPageScaleFactor()); |
1410 } | 1384 } |
1411 | 1385 |
1412 void LayerTreeHostImpl::computePinchZoomDeltas(ScrollAndScaleSet* scrollInfo) | 1386 void LayerTreeHostImpl::computePinchZoomDeltas(ScrollAndScaleSet* scrollInfo) |
1413 { | 1387 { |
1414 if (!m_rootScrollLayerImpl) | 1388 if (!rootScrollLayer()) |
1415 return; | 1389 return; |
1416 | 1390 |
1417 // Only send fake scroll/zoom deltas if we're pinch zooming out by a | 1391 // Only send fake scroll/zoom deltas if we're pinch zooming out by a |
1418 // significant amount. This also ensures only one fake delta set will be | 1392 // significant amount. This also ensures only one fake delta set will be |
1419 // sent. | 1393 // sent. |
1420 const float pinchZoomOutSensitivity = 0.95f; | 1394 const float pinchZoomOutSensitivity = 0.95f; |
1421 if (m_pinchZoomViewport.pageScaleDelta() > pinchZoomOutSensitivity) | 1395 if (m_pinchZoomViewport.pageScaleDelta() > pinchZoomOutSensitivity) |
1422 return; | 1396 return; |
1423 | 1397 |
1424 // Compute where the scroll offset/page scale would be if fully pinch-zoomed | 1398 // Compute where the scroll offset/page scale would be if fully pinch-zoomed |
1425 // out from the anchor point. | 1399 // out from the anchor point. |
1426 gfx::Vector2dF scrollBegin = m_rootScrollLayerImpl->scrollOffset() + m_rootS
crollLayerImpl->scrollDelta(); | 1400 gfx::Vector2dF scrollBegin = rootScrollLayer()->scrollOffset() + rootScrollL
ayer()->scrollDelta(); |
1427 scrollBegin.Scale(m_pinchZoomViewport.pageScaleDelta()); | 1401 scrollBegin.Scale(m_pinchZoomViewport.pageScaleDelta()); |
1428 float scaleBegin = m_pinchZoomViewport.totalPageScaleFactor(); | 1402 float scaleBegin = m_pinchZoomViewport.totalPageScaleFactor(); |
1429 float pageScaleDeltaToSend = m_pinchZoomViewport.minPageScaleFactor() / m_pi
nchZoomViewport.pageScaleFactor(); | 1403 float pageScaleDeltaToSend = m_pinchZoomViewport.minPageScaleFactor() / m_pi
nchZoomViewport.pageScaleFactor(); |
1430 gfx::SizeF scaledContentsSize = gfx::ScaleSize(contentSize(), pageScaleDelta
ToSend); | 1404 gfx::SizeF scaledContentsSize = gfx::ScaleSize(contentSize(), pageScaleDelta
ToSend); |
1431 | 1405 |
1432 gfx::Vector2d anchorOffset = m_previousPinchAnchor.OffsetFromOrigin(); | 1406 gfx::Vector2d anchorOffset = m_previousPinchAnchor.OffsetFromOrigin(); |
1433 gfx::Vector2dF scrollEnd = scrollBegin + anchorOffset; | 1407 gfx::Vector2dF scrollEnd = scrollBegin + anchorOffset; |
1434 scrollEnd.Scale(m_pinchZoomViewport.minPageScaleFactor() / scaleBegin); | 1408 scrollEnd.Scale(m_pinchZoomViewport.minPageScaleFactor() / scaleBegin); |
1435 scrollEnd -= anchorOffset; | 1409 scrollEnd -= anchorOffset; |
1436 scrollEnd.ClampToMax(gfx::RectF(scaledContentsSize).bottom_right() - gfx::Re
ct(m_deviceViewportSize).bottom_right()); | 1410 scrollEnd.ClampToMax(gfx::RectF(scaledContentsSize).bottom_right() - gfx::Re
ct(m_deviceViewportSize).bottom_right()); |
1437 scrollEnd.ClampToMin(gfx::Vector2d()); | 1411 scrollEnd.ClampToMin(gfx::Vector2d()); |
1438 scrollEnd.Scale(1 / pageScaleDeltaToSend); | 1412 scrollEnd.Scale(1 / pageScaleDeltaToSend); |
1439 scrollEnd.Scale(m_deviceScaleFactor); | 1413 scrollEnd.Scale(m_deviceScaleFactor); |
1440 | 1414 |
1441 makeScrollAndScaleSet(scrollInfo, gfx::ToRoundedVector2d(scrollEnd), m_pinch
ZoomViewport.minPageScaleFactor()); | 1415 makeScrollAndScaleSet(scrollInfo, gfx::ToRoundedVector2d(scrollEnd), m_pinch
ZoomViewport.minPageScaleFactor()); |
1442 } | 1416 } |
1443 | 1417 |
1444 void LayerTreeHostImpl::makeScrollAndScaleSet(ScrollAndScaleSet* scrollInfo, gfx
::Vector2d scrollOffset, float pageScale) | 1418 void LayerTreeHostImpl::makeScrollAndScaleSet(ScrollAndScaleSet* scrollInfo, gfx
::Vector2d scrollOffset, float pageScale) |
1445 { | 1419 { |
1446 if (!m_rootScrollLayerImpl) | 1420 if (!rootScrollLayer()) |
1447 return; | 1421 return; |
1448 | 1422 |
1449 LayerTreeHostCommon::ScrollUpdateInfo scroll; | 1423 LayerTreeHostCommon::ScrollUpdateInfo scroll; |
1450 scroll.layerId = m_rootScrollLayerImpl->id(); | 1424 scroll.layerId = rootScrollLayer()->id(); |
1451 scroll.scrollDelta = scrollOffset - m_rootScrollLayerImpl->scrollOffset(); | 1425 scroll.scrollDelta = scrollOffset - rootScrollLayer()->scrollOffset(); |
1452 scrollInfo->scrolls.push_back(scroll); | 1426 scrollInfo->scrolls.push_back(scroll); |
1453 m_rootScrollLayerImpl->setSentScrollDelta(scroll.scrollDelta); | 1427 rootScrollLayer()->setSentScrollDelta(scroll.scrollDelta); |
1454 scrollInfo->pageScaleDelta = pageScale / m_pinchZoomViewport.pageScaleFactor
(); | 1428 scrollInfo->pageScaleDelta = pageScale / m_pinchZoomViewport.pageScaleFactor
(); |
1455 m_pinchZoomViewport.setSentPageScaleDelta(scrollInfo->pageScaleDelta); | 1429 m_pinchZoomViewport.setSentPageScaleDelta(scrollInfo->pageScaleDelta); |
1456 } | 1430 } |
1457 | 1431 |
1458 static void collectScrollDeltas(ScrollAndScaleSet* scrollInfo, LayerImpl* layerI
mpl) | 1432 static void collectScrollDeltas(ScrollAndScaleSet* scrollInfo, LayerImpl* layerI
mpl) |
1459 { | 1433 { |
1460 if (!layerImpl) | 1434 if (!layerImpl) |
1461 return; | 1435 return; |
1462 | 1436 |
1463 if (!layerImpl->scrollDelta().IsZero()) { | 1437 if (!layerImpl->scrollDelta().IsZero()) { |
(...skipping 18 matching lines...) Expand all Loading... |
1482 m_pinchZoomViewport.setSentPageScaleDelta(1); | 1456 m_pinchZoomViewport.setSentPageScaleDelta(1); |
1483 // FIXME(aelias): Make pinch-zoom painting optimization compatible with | 1457 // FIXME(aelias): Make pinch-zoom painting optimization compatible with |
1484 // compositor-side scaling. | 1458 // compositor-side scaling. |
1485 if (!m_settings.pageScalePinchZoomEnabled && m_pinchGestureActive) | 1459 if (!m_settings.pageScalePinchZoomEnabled && m_pinchGestureActive) |
1486 computePinchZoomDeltas(scrollInfo.get()); | 1460 computePinchZoomDeltas(scrollInfo.get()); |
1487 else if (m_pageScaleAnimation.get()) | 1461 else if (m_pageScaleAnimation.get()) |
1488 computeDoubleTapZoomDeltas(scrollInfo.get()); | 1462 computeDoubleTapZoomDeltas(scrollInfo.get()); |
1489 return scrollInfo.Pass(); | 1463 return scrollInfo.Pass(); |
1490 } | 1464 } |
1491 | 1465 |
1492 collectScrollDeltas(scrollInfo.get(), m_rootLayerImpl.get()); | 1466 collectScrollDeltas(scrollInfo.get(), rootLayer()); |
1493 scrollInfo->pageScaleDelta = m_pinchZoomViewport.pageScaleDelta(); | 1467 scrollInfo->pageScaleDelta = m_pinchZoomViewport.pageScaleDelta(); |
1494 m_pinchZoomViewport.setSentPageScaleDelta(scrollInfo->pageScaleDelta); | 1468 m_pinchZoomViewport.setSentPageScaleDelta(scrollInfo->pageScaleDelta); |
1495 | 1469 |
1496 return scrollInfo.Pass(); | 1470 return scrollInfo.Pass(); |
1497 } | 1471 } |
1498 | 1472 |
1499 gfx::Transform LayerTreeHostImpl::implTransform() const | 1473 gfx::Transform LayerTreeHostImpl::implTransform() const |
1500 { | 1474 { |
1501 return m_pinchZoomViewport.implTransform(m_settings.pageScalePinchZoomEnable
d); | 1475 return m_pinchZoomViewport.implTransform(m_settings.pageScalePinchZoomEnable
d); |
1502 } | 1476 } |
1503 | 1477 |
1504 void LayerTreeHostImpl::setFullRootLayerDamage() | 1478 void LayerTreeHostImpl::setFullRootLayerDamage() |
1505 { | 1479 { |
1506 if (m_rootLayerImpl) { | 1480 if (rootLayer()) { |
1507 RenderSurfaceImpl* renderSurface = m_rootLayerImpl->renderSurface(); | 1481 RenderSurfaceImpl* renderSurface = rootLayer()->renderSurface(); |
1508 if (renderSurface) | 1482 if (renderSurface) |
1509 renderSurface->damageTracker()->forceFullDamageNextUpdate(); | 1483 renderSurface->damageTracker()->forceFullDamageNextUpdate(); |
1510 } | 1484 } |
1511 } | 1485 } |
1512 | 1486 |
1513 void LayerTreeHostImpl::animatePageScale(base::TimeTicks time) | 1487 void LayerTreeHostImpl::animatePageScale(base::TimeTicks time) |
1514 { | 1488 { |
1515 if (!m_pageScaleAnimation || !m_rootScrollLayerImpl) | 1489 if (!m_pageScaleAnimation || !rootScrollLayer()) |
1516 return; | 1490 return; |
1517 | 1491 |
1518 double monotonicTime = (time - base::TimeTicks()).InSecondsF(); | 1492 double monotonicTime = (time - base::TimeTicks()).InSecondsF(); |
1519 gfx::Vector2dF scrollTotal = m_rootScrollLayerImpl->scrollOffset() + m_rootS
crollLayerImpl->scrollDelta(); | 1493 gfx::Vector2dF scrollTotal = rootScrollLayer()->scrollOffset() + rootScrollL
ayer()->scrollDelta(); |
1520 | 1494 |
1521 setPageScaleDelta(m_pageScaleAnimation->pageScaleFactorAtTime(monotonicTime)
/ m_pinchZoomViewport.pageScaleFactor()); | 1495 setPageScaleDelta(m_pageScaleAnimation->pageScaleFactorAtTime(monotonicTime)
/ m_pinchZoomViewport.pageScaleFactor()); |
1522 gfx::Vector2dF nextScroll = m_pageScaleAnimation->scrollOffsetAtTime(monoton
icTime); | 1496 gfx::Vector2dF nextScroll = m_pageScaleAnimation->scrollOffsetAtTime(monoton
icTime); |
1523 | 1497 |
1524 if (!m_settings.pageScalePinchZoomEnabled) | 1498 if (!m_settings.pageScalePinchZoomEnabled) |
1525 nextScroll.Scale(m_pinchZoomViewport.pageScaleFactor()); | 1499 nextScroll.Scale(m_pinchZoomViewport.pageScaleFactor()); |
1526 m_rootScrollLayerImpl->scrollBy(nextScroll - scrollTotal); | 1500 rootScrollLayer()->scrollBy(nextScroll - scrollTotal); |
1527 m_client->setNeedsRedrawOnImplThread(); | 1501 m_client->setNeedsRedrawOnImplThread(); |
1528 | 1502 |
1529 if (m_pageScaleAnimation->isAnimationCompleteAtTime(monotonicTime)) { | 1503 if (m_pageScaleAnimation->isAnimationCompleteAtTime(monotonicTime)) { |
1530 m_pageScaleAnimation.reset(); | 1504 m_pageScaleAnimation.reset(); |
1531 m_client->setNeedsCommitOnImplThread(); | 1505 m_client->setNeedsCommitOnImplThread(); |
1532 } | 1506 } |
1533 } | 1507 } |
1534 | 1508 |
1535 void LayerTreeHostImpl::animateLayers(base::TimeTicks monotonicTime, base::Time
wallClockTime) | 1509 void LayerTreeHostImpl::animateLayers(base::TimeTicks monotonicTime, base::Time
wallClockTime) |
1536 { | 1510 { |
1537 if (!m_settings.acceleratedAnimationEnabled || !m_needsAnimateLayers || !m_r
ootLayerImpl) | 1511 if (!m_settings.acceleratedAnimationEnabled || !m_needsAnimateLayers || !roo
tLayer()) |
1538 return; | 1512 return; |
1539 | 1513 |
1540 TRACE_EVENT0("cc", "LayerTreeHostImpl::animateLayers"); | 1514 TRACE_EVENT0("cc", "LayerTreeHostImpl::animateLayers"); |
1541 | 1515 |
1542 scoped_ptr<AnimationEventsVector> events(make_scoped_ptr(new AnimationEvents
Vector)); | 1516 scoped_ptr<AnimationEventsVector> events(make_scoped_ptr(new AnimationEvents
Vector)); |
1543 | 1517 |
1544 bool didAnimate = false; | 1518 bool didAnimate = false; |
1545 animateLayersRecursive(m_rootLayerImpl.get(), monotonicTime, wallClockTime,
events.get(), didAnimate, m_needsAnimateLayers); | 1519 animateLayersRecursive(rootLayer(), monotonicTime, wallClockTime, events.get
(), didAnimate, m_needsAnimateLayers); |
1546 | 1520 |
1547 if (!events->empty()) | 1521 if (!events->empty()) |
1548 m_client->postAnimationEventsToMainThreadOnImplThread(events.Pass(), wal
lClockTime); | 1522 m_client->postAnimationEventsToMainThreadOnImplThread(events.Pass(), wal
lClockTime); |
1549 | 1523 |
1550 if (didAnimate) | 1524 if (didAnimate) |
1551 m_client->setNeedsRedrawOnImplThread(); | 1525 m_client->setNeedsRedrawOnImplThread(); |
1552 | 1526 |
1553 setBackgroundTickingEnabled(!m_visible && m_needsAnimateLayers); | 1527 setBackgroundTickingEnabled(!m_visible && m_needsAnimateLayers); |
1554 } | 1528 } |
1555 | 1529 |
(...skipping 17 matching lines...) Expand all Loading... |
1573 static void clearRenderSurfacesOnLayerImplRecursive(LayerImpl* current) | 1547 static void clearRenderSurfacesOnLayerImplRecursive(LayerImpl* current) |
1574 { | 1548 { |
1575 DCHECK(current); | 1549 DCHECK(current); |
1576 for (size_t i = 0; i < current->children().size(); ++i) | 1550 for (size_t i = 0; i < current->children().size(); ++i) |
1577 clearRenderSurfacesOnLayerImplRecursive(current->children()[i]); | 1551 clearRenderSurfacesOnLayerImplRecursive(current->children()[i]); |
1578 current->clearRenderSurface(); | 1552 current->clearRenderSurface(); |
1579 } | 1553 } |
1580 | 1554 |
1581 void LayerTreeHostImpl::clearRenderSurfaces() | 1555 void LayerTreeHostImpl::clearRenderSurfaces() |
1582 { | 1556 { |
1583 clearRenderSurfacesOnLayerImplRecursive(m_rootLayerImpl.get()); | 1557 clearRenderSurfacesOnLayerImplRecursive(rootLayer()); |
1584 m_renderSurfaceLayerList.clear(); | 1558 m_renderSurfaceLayerList.clear(); |
1585 } | 1559 } |
1586 | 1560 |
1587 std::string LayerTreeHostImpl::layerTreeAsText() const | 1561 std::string LayerTreeHostImpl::layerTreeAsText() const |
1588 { | 1562 { |
1589 std::string str; | 1563 std::string str; |
1590 if (m_rootLayerImpl) { | 1564 if (rootLayer()) { |
1591 str = m_rootLayerImpl->layerTreeAsText(); | 1565 str = rootLayer()->layerTreeAsText(); |
1592 str += "RenderSurfaces:\n"; | 1566 str += "RenderSurfaces:\n"; |
1593 dumpRenderSurfaces(&str, 1, m_rootLayerImpl.get()); | 1567 dumpRenderSurfaces(&str, 1, rootLayer()); |
1594 } | 1568 } |
1595 return str; | 1569 return str; |
1596 } | 1570 } |
1597 | 1571 |
1598 void LayerTreeHostImpl::dumpRenderSurfaces(std::string* str, int indent, const L
ayerImpl* layer) const | 1572 void LayerTreeHostImpl::dumpRenderSurfaces(std::string* str, int indent, const L
ayerImpl* layer) const |
1599 { | 1573 { |
1600 if (layer->renderSurface()) | 1574 if (layer->renderSurface()) |
1601 layer->renderSurface()->dumpSurface(str, indent); | 1575 layer->renderSurface()->dumpSurface(str, indent); |
1602 | 1576 |
1603 for (size_t i = 0; i < layer->children().size(); ++i) | 1577 for (size_t i = 0; i < layer->children().size(); ++i) |
(...skipping 12 matching lines...) Expand all Loading... |
1616 stats->numImplThreadScrolls = m_numImplThreadScrolls; | 1590 stats->numImplThreadScrolls = m_numImplThreadScrolls; |
1617 stats->numMainThreadScrolls = m_numMainThreadScrolls; | 1591 stats->numMainThreadScrolls = m_numMainThreadScrolls; |
1618 stats->numLayersDrawn = m_cumulativeNumLayersDrawn; | 1592 stats->numLayersDrawn = m_cumulativeNumLayersDrawn; |
1619 | 1593 |
1620 if (m_tileManager) | 1594 if (m_tileManager) |
1621 m_tileManager->renderingStats(stats); | 1595 m_tileManager->renderingStats(stats); |
1622 } | 1596 } |
1623 | 1597 |
1624 void LayerTreeHostImpl::animateScrollbars(base::TimeTicks time) | 1598 void LayerTreeHostImpl::animateScrollbars(base::TimeTicks time) |
1625 { | 1599 { |
1626 animateScrollbarsRecursive(m_rootLayerImpl.get(), time); | 1600 animateScrollbarsRecursive(rootLayer(), time); |
1627 } | 1601 } |
1628 | 1602 |
1629 void LayerTreeHostImpl::animateScrollbarsRecursive(LayerImpl* layer, base::TimeT
icks time) | 1603 void LayerTreeHostImpl::animateScrollbarsRecursive(LayerImpl* layer, base::TimeT
icks time) |
1630 { | 1604 { |
1631 if (!layer) | 1605 if (!layer) |
1632 return; | 1606 return; |
1633 | 1607 |
1634 ScrollbarAnimationController* scrollbarController = layer->scrollbarAnimatio
nController(); | 1608 ScrollbarAnimationController* scrollbarController = layer->scrollbarAnimatio
nController(); |
1635 double monotonicTime = (time - base::TimeTicks()).InSecondsF(); | 1609 double monotonicTime = (time - base::TimeTicks()).InSecondsF(); |
1636 if (scrollbarController && scrollbarController->animate(monotonicTime)) | 1610 if (scrollbarController && scrollbarController->animate(monotonicTime)) |
1637 m_client->setNeedsRedrawOnImplThread(); | 1611 m_client->setNeedsRedrawOnImplThread(); |
1638 | 1612 |
1639 for (size_t i = 0; i < layer->children().size(); ++i) | 1613 for (size_t i = 0; i < layer->children().size(); ++i) |
1640 animateScrollbarsRecursive(layer->children()[i], time); | 1614 animateScrollbarsRecursive(layer->children()[i], time); |
1641 } | 1615 } |
1642 | 1616 |
1643 } // namespace cc | 1617 } // namespace cc |
OLD | NEW |