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

Side by Side Diff: cc/layer_tree_host_impl.cc

Issue 11191068: Remove WTF::currentTime() / WTF::monotonicallyIncreasingTime() uses from cc (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: rebased Created 8 years, 1 month 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
« no previous file with comments | « cc/layer_tree_host_impl.h ('k') | cc/layer_tree_host_impl_unittest.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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 "config.h" 5 #include "config.h"
6 6
7 #include "cc/layer_tree_host_impl.h" 7 #include "cc/layer_tree_host_impl.h"
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 13 matching lines...) Expand all
24 #include "cc/page_scale_animation.h" 24 #include "cc/page_scale_animation.h"
25 #include "cc/prioritized_texture_manager.h" 25 #include "cc/prioritized_texture_manager.h"
26 #include "cc/render_pass_draw_quad.h" 26 #include "cc/render_pass_draw_quad.h"
27 #include "cc/rendering_stats.h" 27 #include "cc/rendering_stats.h"
28 #include "cc/scrollbar_animation_controller.h" 28 #include "cc/scrollbar_animation_controller.h"
29 #include "cc/scrollbar_layer_impl.h" 29 #include "cc/scrollbar_layer_impl.h"
30 #include "cc/settings.h" 30 #include "cc/settings.h"
31 #include "cc/single_thread_proxy.h" 31 #include "cc/single_thread_proxy.h"
32 #include "cc/software_renderer.h" 32 #include "cc/software_renderer.h"
33 #include "cc/texture_uploader.h" 33 #include "cc/texture_uploader.h"
34 #include <wtf/CurrentTime.h>
35 #include <algorithm> 34 #include <algorithm>
36 35
37 using WebKit::WebTransformationMatrix; 36 using WebKit::WebTransformationMatrix;
38 37
39 namespace { 38 namespace {
40 39
41 void didVisibilityChange(cc::LayerTreeHostImpl* id, bool visible) 40 void didVisibilityChange(cc::LayerTreeHostImpl* id, bool visible)
42 { 41 {
43 if (visible) { 42 if (visible) {
44 TRACE_EVENT_ASYNC_BEGIN1("webkit", "LayerTreeHostImpl::setVisible", id, "LayerTreeHostImpl", id); 43 TRACE_EVENT_ASYNC_BEGIN1("webkit", "LayerTreeHostImpl::setVisible", id, "LayerTreeHostImpl", id);
(...skipping 123 matching lines...) Expand 10 before | Expand all | Expand 10 after
168 m_timeSource->setActive(false); 167 m_timeSource->setActive(false);
169 } 168 }
170 169
171 virtual void onTimerTick() OVERRIDE 170 virtual void onTimerTick() OVERRIDE
172 { 171 {
173 // FIXME: We require that animate be called on the impl thread. This 172 // FIXME: We require that animate be called on the impl thread. This
174 // avoids asserts in single threaded mode. Ideally background ticking 173 // avoids asserts in single threaded mode. Ideally background ticking
175 // would be handled by the proxy/scheduler and this could be removed. 174 // would be handled by the proxy/scheduler and this could be removed.
176 DebugScopedSetImplThread impl; 175 DebugScopedSetImplThread impl;
177 176
178 m_layerTreeHostImpl->animate(monotonicallyIncreasingTime(), currentTime( )); 177 m_layerTreeHostImpl->animate(base::TimeTicks::Now(), base::Time::Now());
179 } 178 }
180 179
181 void setActive(bool active) 180 void setActive(bool active)
182 { 181 {
183 if (active != m_timeSource->active()) 182 if (active != m_timeSource->active())
184 m_timeSource->setActive(active); 183 m_timeSource->setActive(active);
185 } 184 }
186 185
187 private: 186 private:
188 LayerTreeHostImplTimeSourceAdapter(LayerTreeHostImpl* layerTreeHostImpl, sco ped_refptr<DelayBasedTimeSource> timeSource) 187 LayerTreeHostImplTimeSourceAdapter(LayerTreeHostImpl* layerTreeHostImpl, sco ped_refptr<DelayBasedTimeSource> timeSource)
(...skipping 96 matching lines...) Expand 10 before | Expand all | Expand 10 after
285 return false; 284 return false;
286 } 285 }
287 return true; 286 return true;
288 } 287 }
289 288
290 GraphicsContext* LayerTreeHostImpl::context() const 289 GraphicsContext* LayerTreeHostImpl::context() const
291 { 290 {
292 return m_context.get(); 291 return m_context.get();
293 } 292 }
294 293
295 void LayerTreeHostImpl::animate(double monotonicTime, double wallClockTime) 294 void LayerTreeHostImpl::animate(base::TimeTicks monotonicTime, base::Time wallCl ockTime)
296 { 295 {
297 animatePageScale(monotonicTime); 296 animatePageScale(monotonicTime);
298 animateLayers(monotonicTime, wallClockTime); 297 animateLayers(monotonicTime, wallClockTime);
299 animateScrollbars(monotonicTime); 298 animateScrollbars(monotonicTime);
300 } 299 }
301 300
302 void LayerTreeHostImpl::startPageScaleAnimation(const IntSize& targetPosition, b ool anchorPoint, float pageScale, double startTime, double duration) 301 void LayerTreeHostImpl::startPageScaleAnimation(const IntSize& targetPosition, b ool anchorPoint, float pageScale, base::TimeTicks startTime, base::TimeDelta dur ation)
303 { 302 {
304 if (!m_rootScrollLayerImpl) 303 if (!m_rootScrollLayerImpl)
305 return; 304 return;
306 305
307 IntSize scrollTotal = flooredIntSize(m_rootScrollLayerImpl->scrollPosition() + m_rootScrollLayerImpl->scrollDelta()); 306 IntSize scrollTotal = flooredIntSize(m_rootScrollLayerImpl->scrollPosition() + m_rootScrollLayerImpl->scrollDelta());
308 scrollTotal.scale(m_pinchZoomViewport.pageScaleDelta()); 307 scrollTotal.scale(m_pinchZoomViewport.pageScaleDelta());
309 float scaleTotal = m_pinchZoomViewport.totalPageScaleFactor(); 308 float scaleTotal = m_pinchZoomViewport.totalPageScaleFactor();
310 IntSize scaledContentSize = contentSize(); 309 IntSize scaledContentSize = contentSize();
311 scaledContentSize.scale(m_pinchZoomViewport.pageScaleDelta()); 310 scaledContentSize.scale(m_pinchZoomViewport.pageScaleDelta());
312 311
313 m_pageScaleAnimation = PageScaleAnimation::create(scrollTotal, scaleTotal, m _deviceViewportSize, scaledContentSize, startTime); 312 double startTimeSeconds = (startTime - base::TimeTicks()).InSecondsF();
313 m_pageScaleAnimation = PageScaleAnimation::create(scrollTotal, scaleTotal, m _deviceViewportSize, scaledContentSize, startTimeSeconds);
314 314
315 if (anchorPoint) { 315 if (anchorPoint) {
316 IntSize windowAnchor(targetPosition); 316 IntSize windowAnchor(targetPosition);
317 windowAnchor.scale(scaleTotal / pageScale); 317 windowAnchor.scale(scaleTotal / pageScale);
318 windowAnchor -= scrollTotal; 318 windowAnchor -= scrollTotal;
319 m_pageScaleAnimation->zoomWithAnchor(windowAnchor, pageScale, duration); 319 m_pageScaleAnimation->zoomWithAnchor(windowAnchor, pageScale, duration.I nSecondsF());
320 } else 320 } else
321 m_pageScaleAnimation->zoomTo(targetPosition, pageScale, duration); 321 m_pageScaleAnimation->zoomTo(targetPosition, pageScale, duration.InSecon dsF());
322 322
323 m_client->setNeedsRedrawOnImplThread(); 323 m_client->setNeedsRedrawOnImplThread();
324 m_client->setNeedsCommitOnImplThread(); 324 m_client->setNeedsCommitOnImplThread();
325 } 325 }
326 326
327 void LayerTreeHostImpl::scheduleAnimation() 327 void LayerTreeHostImpl::scheduleAnimation()
328 { 328 {
329 m_client->setNeedsRedrawOnImplThread(); 329 m_client->setNeedsRedrawOnImplThread();
330 } 330 }
331 331
(...skipping 136 matching lines...) Expand 10 before | Expand all | Expand 10 after
468 if (drawFrame) 468 if (drawFrame)
469 occlusionTracker.overdrawMetrics().recordMetrics(this); 469 occlusionTracker.overdrawMetrics().recordMetrics(this);
470 470
471 removeRenderPasses(CullRenderPassesWithNoQuads(), frame); 471 removeRenderPasses(CullRenderPassesWithNoQuads(), frame);
472 m_renderer->decideRenderPassAllocationsForFrame(frame.renderPasses); 472 m_renderer->decideRenderPassAllocationsForFrame(frame.renderPasses);
473 removeRenderPasses(CullRenderPassesWithCachedTextures(*m_renderer), frame); 473 removeRenderPasses(CullRenderPassesWithCachedTextures(*m_renderer), frame);
474 474
475 return drawFrame; 475 return drawFrame;
476 } 476 }
477 477
478 void LayerTreeHostImpl::animateLayersRecursive(LayerImpl* current, double monoto nicTime, double wallClockTime, AnimationEventsVector* events, bool& didAnimate, bool& needsAnimateLayers) 478 void LayerTreeHostImpl::animateLayersRecursive(LayerImpl* current, base::TimeTic ks monotonicTime, base::Time wallClockTime, AnimationEventsVector* events, bool& didAnimate, bool& needsAnimateLayers)
479 { 479 {
480 bool subtreeNeedsAnimateLayers = false; 480 bool subtreeNeedsAnimateLayers = false;
481 481
482 LayerAnimationController* currentController = current->layerAnimationControl ler(); 482 LayerAnimationController* currentController = current->layerAnimationControl ler();
483 483
484 bool hadActiveAnimation = currentController->hasActiveAnimation(); 484 bool hadActiveAnimation = currentController->hasActiveAnimation();
485 currentController->animate(monotonicTime, events); 485 double monotonicTimeSeconds = (monotonicTime - base::TimeTicks()).InSecondsF ();
486 currentController->animate(monotonicTimeSeconds, events);
486 bool startedAnimation = events->size() > 0; 487 bool startedAnimation = events->size() > 0;
487 488
488 // We animated if we either ticked a running animation, or started a new ani mation. 489 // We animated if we either ticked a running animation, or started a new ani mation.
489 if (hadActiveAnimation || startedAnimation) 490 if (hadActiveAnimation || startedAnimation)
490 didAnimate = true; 491 didAnimate = true;
491 492
492 // If the current controller still has an active animation, we must continue animating layers. 493 // If the current controller still has an active animation, we must continue animating layers.
493 if (currentController->hasActiveAnimation()) 494 if (currentController->hasActiveAnimation())
494 subtreeNeedsAnimateLayers = true; 495 subtreeNeedsAnimateLayers = true;
495 496
(...skipping 162 matching lines...) Expand 10 before | Expand all | Expand 10 after
658 return; 659 return;
659 m_managedMemoryPolicy = policy; 660 m_managedMemoryPolicy = policy;
660 enforceManagedMemoryPolicy(m_managedMemoryPolicy); 661 enforceManagedMemoryPolicy(m_managedMemoryPolicy);
661 // We always need to commit after changing the memory policy because the new 662 // We always need to commit after changing the memory policy because the new
662 // limit can result in more or less content having texture allocated for it. 663 // limit can result in more or less content having texture allocated for it.
663 m_client->setNeedsCommitOnImplThread(); 664 m_client->setNeedsCommitOnImplThread();
664 } 665 }
665 666
666 void LayerTreeHostImpl::onVSyncParametersChanged(double monotonicTimebase, doubl e intervalInSeconds) 667 void LayerTreeHostImpl::onVSyncParametersChanged(double monotonicTimebase, doubl e intervalInSeconds)
667 { 668 {
668 m_client->onVSyncParametersChanged(monotonicTimebase, intervalInSeconds); 669 base::TimeTicks timebase = base::TimeTicks::FromInternalValue(monotonicTimeb ase * base::Time::kMicrosecondsPerSecond);
670 base::TimeDelta interval = base::TimeDelta::FromMicroseconds(intervalInSecon ds * base::Time::kMicrosecondsPerSecond);
671 m_client->onVSyncParametersChanged(timebase, interval);
669 } 672 }
670 673
671 void LayerTreeHostImpl::drawLayers(const FrameData& frame) 674 void LayerTreeHostImpl::drawLayers(const FrameData& frame)
672 { 675 {
673 TRACE_EVENT0("cc", "LayerTreeHostImpl::drawLayers"); 676 TRACE_EVENT0("cc", "LayerTreeHostImpl::drawLayers");
674 DCHECK(canDraw()); 677 DCHECK(canDraw());
675 DCHECK(!frame.renderPasses.empty()); 678 DCHECK(!frame.renderPasses.empty());
676 679
677 // FIXME: use the frame begin time from the overall compositor scheduler. 680 // FIXME: use the frame begin time from the overall compositor scheduler.
678 // This value is currently inaccessible because it is up in Chromium's 681 // This value is currently inaccessible because it is up in Chromium's
(...skipping 682 matching lines...) Expand 10 before | Expand all | Expand 10 after
1361 1364
1362 void LayerTreeHostImpl::setFullRootLayerDamage() 1365 void LayerTreeHostImpl::setFullRootLayerDamage()
1363 { 1366 {
1364 if (m_rootLayerImpl) { 1367 if (m_rootLayerImpl) {
1365 RenderSurfaceImpl* renderSurface = m_rootLayerImpl->renderSurface(); 1368 RenderSurfaceImpl* renderSurface = m_rootLayerImpl->renderSurface();
1366 if (renderSurface) 1369 if (renderSurface)
1367 renderSurface->damageTracker()->forceFullDamageNextUpdate(); 1370 renderSurface->damageTracker()->forceFullDamageNextUpdate();
1368 } 1371 }
1369 } 1372 }
1370 1373
1371 void LayerTreeHostImpl::animatePageScale(double monotonicTime) 1374 void LayerTreeHostImpl::animatePageScale(base::TimeTicks time)
1372 { 1375 {
1373 if (!m_pageScaleAnimation || !m_rootScrollLayerImpl) 1376 if (!m_pageScaleAnimation || !m_rootScrollLayerImpl)
1374 return; 1377 return;
1375 1378
1379 double monotonicTime = (time - base::TimeTicks()).InSecondsF();
1376 IntSize scrollTotal = flooredIntSize(m_rootScrollLayerImpl->scrollPosition() + m_rootScrollLayerImpl->scrollDelta()); 1380 IntSize scrollTotal = flooredIntSize(m_rootScrollLayerImpl->scrollPosition() + m_rootScrollLayerImpl->scrollDelta());
1377 1381
1378 setPageScaleDelta(m_pageScaleAnimation->pageScaleAtTime(monotonicTime) / m_p inchZoomViewport.pageScaleFactor()); 1382 setPageScaleDelta(m_pageScaleAnimation->pageScaleAtTime(monotonicTime) / m_p inchZoomViewport.pageScaleFactor());
1379 IntSize nextScroll = m_pageScaleAnimation->scrollOffsetAtTime(monotonicTime) ; 1383 IntSize nextScroll = m_pageScaleAnimation->scrollOffsetAtTime(monotonicTime) ;
1380 nextScroll.scale(1 / m_pinchZoomViewport.pageScaleDelta()); 1384 nextScroll.scale(1 / m_pinchZoomViewport.pageScaleDelta());
1381 m_rootScrollLayerImpl->scrollBy(nextScroll - scrollTotal); 1385 m_rootScrollLayerImpl->scrollBy(nextScroll - scrollTotal);
1382 m_client->setNeedsRedrawOnImplThread(); 1386 m_client->setNeedsRedrawOnImplThread();
1383 1387
1384 if (m_pageScaleAnimation->isAnimationCompleteAtTime(monotonicTime)) { 1388 if (m_pageScaleAnimation->isAnimationCompleteAtTime(monotonicTime)) {
1385 m_pageScaleAnimation.reset(); 1389 m_pageScaleAnimation.reset();
1386 m_client->setNeedsCommitOnImplThread(); 1390 m_client->setNeedsCommitOnImplThread();
1387 } 1391 }
1388 } 1392 }
1389 1393
1390 void LayerTreeHostImpl::animateLayers(double monotonicTime, double wallClockTime ) 1394 void LayerTreeHostImpl::animateLayers(base::TimeTicks monotonicTime, base::Time wallClockTime)
1391 { 1395 {
1392 if (!Settings::acceleratedAnimationEnabled() || !m_needsAnimateLayers || !m_ rootLayerImpl) 1396 if (!Settings::acceleratedAnimationEnabled() || !m_needsAnimateLayers || !m_ rootLayerImpl)
1393 return; 1397 return;
1394 1398
1395 TRACE_EVENT0("cc", "LayerTreeHostImpl::animateLayers"); 1399 TRACE_EVENT0("cc", "LayerTreeHostImpl::animateLayers");
1396 1400
1397 scoped_ptr<AnimationEventsVector> events(make_scoped_ptr(new AnimationEvents Vector)); 1401 scoped_ptr<AnimationEventsVector> events(make_scoped_ptr(new AnimationEvents Vector));
1398 1402
1399 bool didAnimate = false; 1403 bool didAnimate = false;
1400 animateLayersRecursive(m_rootLayerImpl.get(), monotonicTime, wallClockTime, events.get(), didAnimate, m_needsAnimateLayers); 1404 animateLayersRecursive(m_rootLayerImpl.get(), monotonicTime, wallClockTime, events.get(), didAnimate, m_needsAnimateLayers);
(...skipping 64 matching lines...) Expand 10 before | Expand all | Expand 10 after
1465 } 1469 }
1466 1470
1467 void LayerTreeHostImpl::renderingStats(RenderingStats* stats) const 1471 void LayerTreeHostImpl::renderingStats(RenderingStats* stats) const
1468 { 1472 {
1469 stats->numFramesSentToScreen = fpsCounter()->currentFrameNumber(); 1473 stats->numFramesSentToScreen = fpsCounter()->currentFrameNumber();
1470 stats->droppedFrameCount = fpsCounter()->droppedFrameCount(); 1474 stats->droppedFrameCount = fpsCounter()->droppedFrameCount();
1471 stats->numImplThreadScrolls = m_numImplThreadScrolls; 1475 stats->numImplThreadScrolls = m_numImplThreadScrolls;
1472 stats->numMainThreadScrolls = m_numMainThreadScrolls; 1476 stats->numMainThreadScrolls = m_numMainThreadScrolls;
1473 } 1477 }
1474 1478
1475 void LayerTreeHostImpl::animateScrollbars(double monotonicTime) 1479 void LayerTreeHostImpl::animateScrollbars(base::TimeTicks time)
1476 { 1480 {
1477 animateScrollbarsRecursive(m_rootLayerImpl.get(), monotonicTime); 1481 animateScrollbarsRecursive(m_rootLayerImpl.get(), time);
1478 } 1482 }
1479 1483
1480 void LayerTreeHostImpl::animateScrollbarsRecursive(LayerImpl* layer, double mono tonicTime) 1484 void LayerTreeHostImpl::animateScrollbarsRecursive(LayerImpl* layer, base::TimeT icks time)
1481 { 1485 {
1482 if (!layer) 1486 if (!layer)
1483 return; 1487 return;
1484 1488
1485 ScrollbarAnimationController* scrollbarController = layer->scrollbarAnimatio nController(); 1489 ScrollbarAnimationController* scrollbarController = layer->scrollbarAnimatio nController();
1490 double monotonicTime = (time - base::TimeTicks()).InSecondsF();
1486 if (scrollbarController && scrollbarController->animate(monotonicTime)) 1491 if (scrollbarController && scrollbarController->animate(monotonicTime))
1487 m_client->setNeedsRedrawOnImplThread(); 1492 m_client->setNeedsRedrawOnImplThread();
1488 1493
1489 for (size_t i = 0; i < layer->children().size(); ++i) 1494 for (size_t i = 0; i < layer->children().size(); ++i)
1490 animateScrollbarsRecursive(layer->children()[i], monotonicTime); 1495 animateScrollbarsRecursive(layer->children()[i], time);
1491 } 1496 }
1492 1497
1493 } // namespace cc 1498 } // namespace cc
OLDNEW
« no previous file with comments | « cc/layer_tree_host_impl.h ('k') | cc/layer_tree_host_impl_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698