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 225 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
369 } | 373 } |
370 | 374 |
371 void ThreadProxy::setNeedsRedraw() | 375 void ThreadProxy::setNeedsRedraw() |
372 { | 376 { |
373 DCHECK(isMainThread()); | 377 DCHECK(isMainThread()); |
374 TRACE_EVENT0("cc", "ThreadProxy::setNeedsRedraw"); | 378 TRACE_EVENT0("cc", "ThreadProxy::setNeedsRedraw"); |
375 Proxy::implThread()->postTask(createThreadTask(this, &ThreadProxy::setFullRo
otLayerDamageOnImplThread)); | 379 Proxy::implThread()->postTask(createThreadTask(this, &ThreadProxy::setFullRo
otLayerDamageOnImplThread)); |
376 Proxy::implThread()->postTask(createThreadTask(this, &ThreadProxy::setNeedsR
edrawOnImplThread)); | 380 Proxy::implThread()->postTask(createThreadTask(this, &ThreadProxy::setNeedsR
edrawOnImplThread)); |
377 } | 381 } |
378 | 382 |
| 383 void ThreadProxy::setDeferCommits(bool deferCommits) |
| 384 { |
| 385 DCHECK(isMainThread()); |
| 386 DCHECK_NE(m_deferCommits, deferCommits); |
| 387 m_deferCommits = deferCommits; |
| 388 |
| 389 if (m_deferCommits) |
| 390 TRACE_EVENT_ASYNC_BEGIN0("cc", "ThreadProxy::setDeferCommits", this); |
| 391 else |
| 392 TRACE_EVENT_ASYNC_END0("cc", "ThreadProxy::setDeferCommits", this); |
| 393 |
| 394 if (!m_deferCommits && m_deferredCommitPending) { |
| 395 m_deferredCommitPending = false; |
| 396 m_mainThreadProxy->postTask(createThreadTask(this, &ThreadProxy::beginFr
ame)); |
| 397 } |
| 398 } |
| 399 |
379 bool ThreadProxy::commitRequested() const | 400 bool ThreadProxy::commitRequested() const |
380 { | 401 { |
381 DCHECK(isMainThread()); | 402 DCHECK(isMainThread()); |
382 return m_commitRequested; | 403 return m_commitRequested; |
383 } | 404 } |
384 | 405 |
385 void ThreadProxy::setNeedsRedrawOnImplThread() | 406 void ThreadProxy::setNeedsRedrawOnImplThread() |
386 { | 407 { |
387 DCHECK(isImplThread()); | 408 DCHECK(isImplThread()); |
388 TRACE_EVENT0("cc", "ThreadProxy::setNeedsRedrawOnImplThread"); | 409 TRACE_EVENT0("cc", "ThreadProxy::setNeedsRedrawOnImplThread"); |
(...skipping 94 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
483 } | 504 } |
484 } | 505 } |
485 | 506 |
486 void ThreadProxy::beginFrame() | 507 void ThreadProxy::beginFrame() |
487 { | 508 { |
488 TRACE_EVENT0("cc", "ThreadProxy::beginFrame"); | 509 TRACE_EVENT0("cc", "ThreadProxy::beginFrame"); |
489 DCHECK(isMainThread()); | 510 DCHECK(isMainThread()); |
490 if (!m_layerTreeHost) | 511 if (!m_layerTreeHost) |
491 return; | 512 return; |
492 | 513 |
| 514 if (m_deferCommits) { |
| 515 m_deferredCommitPending = true; |
| 516 m_layerTreeHost->didDeferCommit(); |
| 517 TRACE_EVENT0("cc", "EarlyOut_DeferCommits"); |
| 518 return; |
| 519 } |
| 520 |
493 if (!m_pendingBeginFrameRequest) { | 521 if (!m_pendingBeginFrameRequest) { |
494 TRACE_EVENT0("cc", "EarlyOut_StaleBeginFrameMessage"); | 522 TRACE_EVENT0("cc", "EarlyOut_StaleBeginFrameMessage"); |
495 return; | 523 return; |
496 } | 524 } |
497 | 525 |
498 if (m_layerTreeHost->needsSharedContext() && !WebSharedGraphicsContext3D::ha
veCompositorThreadContext()) | 526 if (m_layerTreeHost->needsSharedContext() && !WebSharedGraphicsContext3D::ha
veCompositorThreadContext()) |
499 WebSharedGraphicsContext3D::createCompositorThreadContext(); | 527 WebSharedGraphicsContext3D::createCompositorThreadContext(); |
500 | 528 |
501 scoped_ptr<BeginFrameAndCommitState> request(m_pendingBeginFrameRequest.Pass
()); | 529 scoped_ptr<BeginFrameAndCommitState> request(m_pendingBeginFrameRequest.Pass
()); |
502 | 530 |
(...skipping 460 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
963 ThreadProxy::BeginFrameAndCommitState::BeginFrameAndCommitState() | 991 ThreadProxy::BeginFrameAndCommitState::BeginFrameAndCommitState() |
964 : monotonicFrameBeginTime(0) | 992 : monotonicFrameBeginTime(0) |
965 { | 993 { |
966 } | 994 } |
967 | 995 |
968 ThreadProxy::BeginFrameAndCommitState::~BeginFrameAndCommitState() | 996 ThreadProxy::BeginFrameAndCommitState::~BeginFrameAndCommitState() |
969 { | 997 { |
970 } | 998 } |
971 | 999 |
972 } // namespace cc | 1000 } // namespace cc |
OLD | NEW |