| 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 "config.h" | 5 #include "config.h" |
| 6 | 6 |
| 7 #include "cc/single_thread_proxy.h" | 7 #include "cc/single_thread_proxy.h" |
| 8 | 8 |
| 9 #include "base/debug/trace_event.h" | 9 #include "base/debug/trace_event.h" |
| 10 #include "cc/draw_quad.h" | 10 #include "cc/draw_quad.h" |
| 11 #include "cc/graphics_context.h" | 11 #include "cc/graphics_context.h" |
| 12 #include "cc/layer_tree_host.h" | 12 #include "cc/layer_tree_host.h" |
| 13 #include "cc/resource_update_controller.h" | 13 #include "cc/resource_update_controller.h" |
| 14 #include "cc/timer.h" | 14 #include "cc/timer.h" |
| 15 #include <wtf/CurrentTime.h> | |
| 16 | 15 |
| 17 namespace cc { | 16 namespace cc { |
| 18 | 17 |
| 19 scoped_ptr<Proxy> SingleThreadProxy::create(LayerTreeHost* layerTreeHost) | 18 scoped_ptr<Proxy> SingleThreadProxy::create(LayerTreeHost* layerTreeHost) |
| 20 { | 19 { |
| 21 return make_scoped_ptr(new SingleThreadProxy(layerTreeHost)).PassAs<Proxy>()
; | 20 return make_scoped_ptr(new SingleThreadProxy(layerTreeHost)).PassAs<Proxy>()
; |
| 22 } | 21 } |
| 23 | 22 |
| 24 SingleThreadProxy::SingleThreadProxy(LayerTreeHost* layerTreeHost) | 23 SingleThreadProxy::SingleThreadProxy(LayerTreeHost* layerTreeHost) |
| 25 : m_layerTreeHost(layerTreeHost) | 24 : m_layerTreeHost(layerTreeHost) |
| (...skipping 31 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 57 | 56 |
| 58 if (m_layerTreeHostImpl->isContextLost()) | 57 if (m_layerTreeHostImpl->isContextLost()) |
| 59 return false; | 58 return false; |
| 60 | 59 |
| 61 m_layerTreeHostImpl->swapBuffers(); | 60 m_layerTreeHostImpl->swapBuffers(); |
| 62 didSwapFrame(); | 61 didSwapFrame(); |
| 63 | 62 |
| 64 return true; | 63 return true; |
| 65 } | 64 } |
| 66 | 65 |
| 67 void SingleThreadProxy::startPageScaleAnimation(const IntSize& targetPosition, b
ool useAnchor, float scale, double duration) | 66 void SingleThreadProxy::startPageScaleAnimation(const IntSize& targetPosition, b
ool useAnchor, float scale, base::TimeDelta duration) |
| 68 { | 67 { |
| 69 m_layerTreeHostImpl->startPageScaleAnimation(targetPosition, useAnchor, scal
e, monotonicallyIncreasingTime(), duration); | 68 m_layerTreeHostImpl->startPageScaleAnimation(targetPosition, useAnchor, scal
e, base::TimeTicks::Now(), duration); |
| 70 } | 69 } |
| 71 | 70 |
| 72 void SingleThreadProxy::finishAllRendering() | 71 void SingleThreadProxy::finishAllRendering() |
| 73 { | 72 { |
| 74 DCHECK(Proxy::isMainThread()); | 73 DCHECK(Proxy::isMainThread()); |
| 75 { | 74 { |
| 76 DebugScopedSetImplThread impl; | 75 DebugScopedSetImplThread impl; |
| 77 m_layerTreeHostImpl->finishAllRendering(); | 76 m_layerTreeHostImpl->finishAllRendering(); |
| 78 } | 77 } |
| 79 } | 78 } |
| (...skipping 189 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 269 void SingleThreadProxy::setNeedsRedrawOnImplThread() | 268 void SingleThreadProxy::setNeedsRedrawOnImplThread() |
| 270 { | 269 { |
| 271 m_layerTreeHost->scheduleComposite(); | 270 m_layerTreeHost->scheduleComposite(); |
| 272 } | 271 } |
| 273 | 272 |
| 274 void SingleThreadProxy::setNeedsCommitOnImplThread() | 273 void SingleThreadProxy::setNeedsCommitOnImplThread() |
| 275 { | 274 { |
| 276 m_layerTreeHost->scheduleComposite(); | 275 m_layerTreeHost->scheduleComposite(); |
| 277 } | 276 } |
| 278 | 277 |
| 279 void SingleThreadProxy::postAnimationEventsToMainThreadOnImplThread(scoped_ptr<A
nimationEventsVector> events, double wallClockTime) | 278 void SingleThreadProxy::postAnimationEventsToMainThreadOnImplThread(scoped_ptr<A
nimationEventsVector> events, base::Time wallClockTime) |
| 280 { | 279 { |
| 281 DCHECK(Proxy::isImplThread()); | 280 DCHECK(Proxy::isImplThread()); |
| 282 DebugScopedSetMainThread main; | 281 DebugScopedSetMainThread main; |
| 283 m_layerTreeHost->setAnimationEvents(events.Pass(), wallClockTime); | 282 m_layerTreeHost->setAnimationEvents(events.Pass(), wallClockTime); |
| 284 } | 283 } |
| 285 | 284 |
| 286 bool SingleThreadProxy::reduceContentsTextureMemoryOnImplThread(size_t limitByte
s, int priorityCutoff) | 285 bool SingleThreadProxy::reduceContentsTextureMemoryOnImplThread(size_t limitByte
s, int priorityCutoff) |
| 287 { | 286 { |
| 288 DCHECK(isImplThread()); | 287 DCHECK(isImplThread()); |
| 289 if (!m_layerTreeHost->contentsTextureManager()) | 288 if (!m_layerTreeHost->contentsTextureManager()) |
| (...skipping 65 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 355 | 354 |
| 356 bool SingleThreadProxy::doComposite() | 355 bool SingleThreadProxy::doComposite() |
| 357 { | 356 { |
| 358 DCHECK(!m_contextLost); | 357 DCHECK(!m_contextLost); |
| 359 { | 358 { |
| 360 DebugScopedSetImplThread impl; | 359 DebugScopedSetImplThread impl; |
| 361 | 360 |
| 362 if (!m_layerTreeHostImpl->visible()) | 361 if (!m_layerTreeHostImpl->visible()) |
| 363 return false; | 362 return false; |
| 364 | 363 |
| 365 double monotonicTime = monotonicallyIncreasingTime(); | 364 m_layerTreeHostImpl->animate(base::TimeTicks::Now(), base::Time::Now()); |
| 366 double wallClockTime = currentTime(); | |
| 367 m_layerTreeHostImpl->animate(monotonicTime, wallClockTime); | |
| 368 | 365 |
| 369 // We guard prepareToDraw() with canDraw() because it always returns a v
alid frame, so can only | 366 // We guard prepareToDraw() with canDraw() because it always returns a v
alid frame, so can only |
| 370 // be used when such a frame is possible. Since drawLayers() depends on
the result of | 367 // be used when such a frame is possible. Since drawLayers() depends on
the result of |
| 371 // prepareToDraw(), it is guarded on canDraw() as well. | 368 // prepareToDraw(), it is guarded on canDraw() as well. |
| 372 if (!m_layerTreeHostImpl->canDraw()) | 369 if (!m_layerTreeHostImpl->canDraw()) |
| 373 return false; | 370 return false; |
| 374 | 371 |
| 375 LayerTreeHostImpl::FrameData frame; | 372 LayerTreeHostImpl::FrameData frame; |
| 376 m_layerTreeHostImpl->prepareToDraw(frame); | 373 m_layerTreeHostImpl->prepareToDraw(frame); |
| 377 m_layerTreeHostImpl->drawLayers(frame); | 374 m_layerTreeHostImpl->drawLayers(frame); |
| (...skipping 11 matching lines...) Expand all Loading... |
| 389 | 386 |
| 390 void SingleThreadProxy::didSwapFrame() | 387 void SingleThreadProxy::didSwapFrame() |
| 391 { | 388 { |
| 392 if (m_nextFrameIsNewlyCommittedFrame) { | 389 if (m_nextFrameIsNewlyCommittedFrame) { |
| 393 m_nextFrameIsNewlyCommittedFrame = false; | 390 m_nextFrameIsNewlyCommittedFrame = false; |
| 394 m_layerTreeHost->didCommitAndDrawFrame(); | 391 m_layerTreeHost->didCommitAndDrawFrame(); |
| 395 } | 392 } |
| 396 } | 393 } |
| 397 | 394 |
| 398 } | 395 } |
| OLD | NEW |