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/thread_proxy.h" | 7 #include "cc/thread_proxy.h" |
8 | 8 |
9 #include "base/debug/trace_event.h" | 9 #include "base/debug/trace_event.h" |
10 #include "cc/delay_based_time_source.h" | 10 #include "cc/delay_based_time_source.h" |
(...skipping 35 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
46 , m_texturesAcquired(true) | 46 , m_texturesAcquired(true) |
47 , m_inCompositeAndReadback(false) | 47 , m_inCompositeAndReadback(false) |
48 , m_mainThreadProxy(ScopedThreadProxy::create(Proxy::mainThread())) | 48 , m_mainThreadProxy(ScopedThreadProxy::create(Proxy::mainThread())) |
49 , m_beginFrameCompletionEventOnImplThread(0) | 49 , m_beginFrameCompletionEventOnImplThread(0) |
50 , m_readbackRequestOnImplThread(0) | 50 , m_readbackRequestOnImplThread(0) |
51 , m_commitCompletionEventOnImplThread(0) | 51 , m_commitCompletionEventOnImplThread(0) |
52 , m_textureAcquisitionCompletionEventOnImplThread(0) | 52 , m_textureAcquisitionCompletionEventOnImplThread(0) |
53 , m_nextFrameIsNewlyCommittedFrameOnImplThread(false) | 53 , m_nextFrameIsNewlyCommittedFrameOnImplThread(false) |
54 , m_renderVSyncEnabled(layerTreeHost->settings().renderVSyncEnabled) | 54 , m_renderVSyncEnabled(layerTreeHost->settings().renderVSyncEnabled) |
55 , m_totalCommitCount(0) | 55 , m_totalCommitCount(0) |
| 56 , m_deferCommits(false) |
| 57 , m_deferredCommitPending(false) |
56 { | 58 { |
57 TRACE_EVENT0("cc", "ThreadProxy::ThreadProxy"); | 59 TRACE_EVENT0("cc", "ThreadProxy::ThreadProxy"); |
58 DCHECK(isMainThread()); | 60 DCHECK(isMainThread()); |
59 } | 61 } |
60 | 62 |
61 ThreadProxy::~ThreadProxy() | 63 ThreadProxy::~ThreadProxy() |
62 { | 64 { |
63 TRACE_EVENT0("cc", "ThreadProxy::~ThreadProxy"); | 65 TRACE_EVENT0("cc", "ThreadProxy::~ThreadProxy"); |
64 DCHECK(isMainThread()); | 66 DCHECK(isMainThread()); |
65 DCHECK(!m_started); | 67 DCHECK(!m_started); |
66 } | 68 } |
67 | 69 |
68 bool ThreadProxy::compositeAndReadback(void *pixels, const IntRect& rect) | 70 bool ThreadProxy::compositeAndReadback(void *pixels, const IntRect& rect) |
69 { | 71 { |
70 TRACE_EVENT0("cc", "ThreadPRoxy::compositeAndReadback"); | 72 TRACE_EVENT0("cc", "ThreadPRoxy::compositeAndReadback"); |
71 DCHECK(isMainThread()); | 73 DCHECK(isMainThread()); |
72 DCHECK(m_layerTreeHost); | 74 DCHECK(m_layerTreeHost); |
| 75 DCHECK(!m_deferCommits); |
73 | 76 |
74 if (!m_layerTreeHost->initializeRendererIfNeeded()) { | 77 if (!m_layerTreeHost->initializeRendererIfNeeded()) { |
75 TRACE_EVENT0("cc", "compositeAndReadback_EarlyOut_LR_Uninitialized"); | 78 TRACE_EVENT0("cc", "compositeAndReadback_EarlyOut_LR_Uninitialized"); |
76 return false; | 79 return false; |
77 } | 80 } |
78 | 81 |
79 | 82 |
80 // Perform a synchronous commit. | 83 // Perform a synchronous commit. |
81 { | 84 { |
82 DebugScopedSetMainThreadBlocked mainThreadBlocked; | 85 DebugScopedSetMainThreadBlocked mainThreadBlocked; |
(...skipping 41 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
124 void ThreadProxy::requestStartPageScaleAnimationOnImplThread(IntSize targetPosit
ion, bool useAnchor, float scale, double duration) | 127 void ThreadProxy::requestStartPageScaleAnimationOnImplThread(IntSize targetPosit
ion, bool useAnchor, float scale, double duration) |
125 { | 128 { |
126 DCHECK(Proxy::isImplThread()); | 129 DCHECK(Proxy::isImplThread()); |
127 if (m_layerTreeHostImpl.get()) | 130 if (m_layerTreeHostImpl.get()) |
128 m_layerTreeHostImpl->startPageScaleAnimation(targetPosition, useAnchor,
scale, monotonicallyIncreasingTime(), duration); | 131 m_layerTreeHostImpl->startPageScaleAnimation(targetPosition, useAnchor,
scale, monotonicallyIncreasingTime(), duration); |
129 } | 132 } |
130 | 133 |
131 void ThreadProxy::finishAllRendering() | 134 void ThreadProxy::finishAllRendering() |
132 { | 135 { |
133 DCHECK(Proxy::isMainThread()); | 136 DCHECK(Proxy::isMainThread()); |
| 137 DCHECK(!m_deferCommits); |
134 | 138 |
135 // Make sure all GL drawing is finished on the impl thread. | 139 // Make sure all GL drawing is finished on the impl thread. |
136 DebugScopedSetMainThreadBlocked mainThreadBlocked; | 140 DebugScopedSetMainThreadBlocked mainThreadBlocked; |
137 CompletionEvent completion; | 141 CompletionEvent completion; |
138 Proxy::implThread()->postTask(createThreadTask(this, &ThreadProxy::finishAll
RenderingOnImplThread, &completion)); | 142 Proxy::implThread()->postTask(createThreadTask(this, &ThreadProxy::finishAll
RenderingOnImplThread, &completion)); |
139 completion.wait(); | 143 completion.wait(); |
140 } | 144 } |
141 | 145 |
142 bool ThreadProxy::isStarted() const | 146 bool ThreadProxy::isStarted() const |
143 { | 147 { |
(...skipping 235 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
379 } | 383 } |
380 | 384 |
381 void ThreadProxy::setNeedsRedraw() | 385 void ThreadProxy::setNeedsRedraw() |
382 { | 386 { |
383 DCHECK(isMainThread()); | 387 DCHECK(isMainThread()); |
384 TRACE_EVENT0("cc", "ThreadProxy::setNeedsRedraw"); | 388 TRACE_EVENT0("cc", "ThreadProxy::setNeedsRedraw"); |
385 Proxy::implThread()->postTask(createThreadTask(this, &ThreadProxy::setFullRo
otLayerDamageOnImplThread)); | 389 Proxy::implThread()->postTask(createThreadTask(this, &ThreadProxy::setFullRo
otLayerDamageOnImplThread)); |
386 Proxy::implThread()->postTask(createThreadTask(this, &ThreadProxy::setNeedsR
edrawOnImplThread)); | 390 Proxy::implThread()->postTask(createThreadTask(this, &ThreadProxy::setNeedsR
edrawOnImplThread)); |
387 } | 391 } |
388 | 392 |
| 393 void ThreadProxy::setDeferCommits(bool deferCommits) |
| 394 { |
| 395 DCHECK(isMainThread()); |
| 396 DCHECK_NE(m_deferCommits, deferCommits); |
| 397 m_deferCommits = deferCommits; |
| 398 |
| 399 if (m_deferCommits) |
| 400 TRACE_EVENT_ASYNC_BEGIN0("cc", "ThreadProxy::setDeferCommits", this); |
| 401 else |
| 402 TRACE_EVENT_ASYNC_END0("cc", "ThreadProxy::setDeferCommits", this); |
| 403 |
| 404 if (!m_deferCommits && m_deferredCommitPending) { |
| 405 m_deferredCommitPending = false; |
| 406 m_mainThreadProxy->postTask(createThreadTask(this, &ThreadProxy::beginFr
ame)); |
| 407 } |
| 408 } |
| 409 |
389 bool ThreadProxy::commitRequested() const | 410 bool ThreadProxy::commitRequested() const |
390 { | 411 { |
391 DCHECK(isMainThread()); | 412 DCHECK(isMainThread()); |
392 return m_commitRequested; | 413 return m_commitRequested; |
393 } | 414 } |
394 | 415 |
395 void ThreadProxy::setNeedsRedrawOnImplThread() | 416 void ThreadProxy::setNeedsRedrawOnImplThread() |
396 { | 417 { |
397 DCHECK(isImplThread()); | 418 DCHECK(isImplThread()); |
398 TRACE_EVENT0("cc", "ThreadProxy::setNeedsRedrawOnImplThread"); | 419 TRACE_EVENT0("cc", "ThreadProxy::setNeedsRedrawOnImplThread"); |
(...skipping 94 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
493 } | 514 } |
494 } | 515 } |
495 | 516 |
496 void ThreadProxy::beginFrame() | 517 void ThreadProxy::beginFrame() |
497 { | 518 { |
498 TRACE_EVENT0("cc", "ThreadProxy::beginFrame"); | 519 TRACE_EVENT0("cc", "ThreadProxy::beginFrame"); |
499 DCHECK(isMainThread()); | 520 DCHECK(isMainThread()); |
500 if (!m_layerTreeHost) | 521 if (!m_layerTreeHost) |
501 return; | 522 return; |
502 | 523 |
| 524 if (m_deferCommits) { |
| 525 m_deferredCommitPending = true; |
| 526 m_layerTreeHost->didDeferCommit(); |
| 527 TRACE_EVENT0("cc", "EarlyOut_DeferCommits"); |
| 528 return; |
| 529 } |
| 530 |
503 if (!m_pendingBeginFrameRequest) { | 531 if (!m_pendingBeginFrameRequest) { |
504 TRACE_EVENT0("cc", "EarlyOut_StaleBeginFrameMessage"); | 532 TRACE_EVENT0("cc", "EarlyOut_StaleBeginFrameMessage"); |
505 return; | 533 return; |
506 } | 534 } |
507 | 535 |
508 if (m_layerTreeHost->needsSharedContext() && !WebSharedGraphicsContext3D::ha
veCompositorThreadContext()) | 536 if (m_layerTreeHost->needsSharedContext() && !WebSharedGraphicsContext3D::ha
veCompositorThreadContext()) |
509 WebSharedGraphicsContext3D::createCompositorThreadContext(); | 537 WebSharedGraphicsContext3D::createCompositorThreadContext(); |
510 | 538 |
511 scoped_ptr<BeginFrameAndCommitState> request(m_pendingBeginFrameRequest.Pass
()); | 539 scoped_ptr<BeginFrameAndCommitState> request(m_pendingBeginFrameRequest.Pass
()); |
512 | 540 |
(...skipping 460 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
973 ThreadProxy::BeginFrameAndCommitState::BeginFrameAndCommitState() | 1001 ThreadProxy::BeginFrameAndCommitState::BeginFrameAndCommitState() |
974 : monotonicFrameBeginTime(0) | 1002 : monotonicFrameBeginTime(0) |
975 { | 1003 { |
976 } | 1004 } |
977 | 1005 |
978 ThreadProxy::BeginFrameAndCommitState::~BeginFrameAndCommitState() | 1006 ThreadProxy::BeginFrameAndCommitState::~BeginFrameAndCommitState() |
979 { | 1007 { |
980 } | 1008 } |
981 | 1009 |
982 } // namespace cc | 1010 } // namespace cc |
OLD | NEW |