| 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/thread_proxy.h" | 5 #include "cc/thread_proxy.h" |
| 6 | 6 |
| 7 #include "base/auto_reset.h" | 7 #include "base/auto_reset.h" |
| 8 #include "base/bind.h" | 8 #include "base/bind.h" |
| 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 11 matching lines...) Expand all Loading... |
| 22 using WebKit::WebSharedGraphicsContext3D; | 22 using WebKit::WebSharedGraphicsContext3D; |
| 23 | 23 |
| 24 namespace { | 24 namespace { |
| 25 | 25 |
| 26 // Measured in seconds. | 26 // Measured in seconds. |
| 27 const double contextRecreationTickRate = 0.03; | 27 const double contextRecreationTickRate = 0.03; |
| 28 | 28 |
| 29 // Measured in seconds. | 29 // Measured in seconds. |
| 30 const double smoothnessTakesPriorityExpirationDelay = 0.25; | 30 const double smoothnessTakesPriorityExpirationDelay = 0.25; |
| 31 | 31 |
| 32 // Measured in seconds. |
| 33 const double checkForCompletedRasterTasksDelay = 0.004; |
| 34 |
| 32 } // namespace | 35 } // namespace |
| 33 | 36 |
| 34 namespace cc { | 37 namespace cc { |
| 35 | 38 |
| 36 scoped_ptr<Proxy> ThreadProxy::create(LayerTreeHost* layerTreeHost, scoped_ptr<T
hread> implThread) | 39 scoped_ptr<Proxy> ThreadProxy::create(LayerTreeHost* layerTreeHost, scoped_ptr<T
hread> implThread) |
| 37 { | 40 { |
| 38 return make_scoped_ptr(new ThreadProxy(layerTreeHost, implThread.Pass())).Pa
ssAs<Proxy>(); | 41 return make_scoped_ptr(new ThreadProxy(layerTreeHost, implThread.Pass())).Pa
ssAs<Proxy>(); |
| 39 } | 42 } |
| 40 | 43 |
| 41 ThreadProxy::ThreadProxy(LayerTreeHost* layerTreeHost, scoped_ptr<Thread> implTh
read) | 44 ThreadProxy::ThreadProxy(LayerTreeHost* layerTreeHost, scoped_ptr<Thread> implTh
read) |
| 42 : Proxy(implThread.Pass()) | 45 : Proxy(implThread.Pass()) |
| 43 , m_animateRequested(false) | 46 , m_animateRequested(false) |
| 44 , m_commitRequested(false) | 47 , m_commitRequested(false) |
| 45 , m_commitRequestSentToImplThread(false) | 48 , m_commitRequestSentToImplThread(false) |
| 46 , m_layerTreeHost(layerTreeHost) | 49 , m_layerTreeHost(layerTreeHost) |
| 47 , m_rendererInitialized(false) | 50 , m_rendererInitialized(false) |
| 48 , m_started(false) | 51 , m_started(false) |
| 49 , m_texturesAcquired(true) | 52 , m_texturesAcquired(true) |
| 50 , m_inCompositeAndReadback(false) | 53 , m_inCompositeAndReadback(false) |
| 51 , m_manageTilesPending(false) | 54 , m_manageTilesPending(false) |
| 52 , m_weakFactoryOnImplThread(ALLOW_THIS_IN_INITIALIZER_LIST(this)) | 55 , m_weakFactoryOnImplThread(ALLOW_THIS_IN_INITIALIZER_LIST(this)) |
| 53 , m_weakFactory(ALLOW_THIS_IN_INITIALIZER_LIST(this)) | 56 , m_weakFactory(ALLOW_THIS_IN_INITIALIZER_LIST(this)) |
| 57 , m_weakCheckForCompletedRasterTasksFactory( |
| 58 ALLOW_THIS_IN_INITIALIZER_LIST(this)) |
| 54 , m_beginFrameCompletionEventOnImplThread(0) | 59 , m_beginFrameCompletionEventOnImplThread(0) |
| 55 , m_readbackRequestOnImplThread(0) | 60 , m_readbackRequestOnImplThread(0) |
| 56 , m_commitCompletionEventOnImplThread(0) | 61 , m_commitCompletionEventOnImplThread(0) |
| 57 , m_completionEventForCommitHeldOnTreeActivation(0) | 62 , m_completionEventForCommitHeldOnTreeActivation(0) |
| 58 , m_textureAcquisitionCompletionEventOnImplThread(0) | 63 , m_textureAcquisitionCompletionEventOnImplThread(0) |
| 59 , m_nextFrameIsNewlyCommittedFrameOnImplThread(false) | 64 , m_nextFrameIsNewlyCommittedFrameOnImplThread(false) |
| 60 , m_renderVSyncEnabled(layerTreeHost->settings().renderVSyncEnabled) | 65 , m_renderVSyncEnabled(layerTreeHost->settings().renderVSyncEnabled) |
| 61 , m_insideDraw(false) | 66 , m_insideDraw(false) |
| 62 , m_totalCommitCount(0) | 67 , m_totalCommitCount(0) |
| 63 , m_deferCommits(false) | 68 , m_deferCommits(false) |
| 64 , m_renewTreePriorityOnImplThreadPending(false) | 69 , m_renewTreePriorityOnImplThreadPending(false) |
| 70 , m_checkForCompletedRasterTasksPending(false) |
| 65 { | 71 { |
| 66 TRACE_EVENT0("cc", "ThreadProxy::ThreadProxy"); | 72 TRACE_EVENT0("cc", "ThreadProxy::ThreadProxy"); |
| 67 DCHECK(isMainThread()); | 73 DCHECK(isMainThread()); |
| 68 } | 74 } |
| 69 | 75 |
| 70 ThreadProxy::~ThreadProxy() | 76 ThreadProxy::~ThreadProxy() |
| 71 { | 77 { |
| 72 TRACE_EVENT0("cc", "ThreadProxy::~ThreadProxy"); | 78 TRACE_EVENT0("cc", "ThreadProxy::~ThreadProxy"); |
| 73 DCHECK(isMainThread()); | 79 DCHECK(isMainThread()); |
| 74 DCHECK(!m_started); | 80 DCHECK(!m_started); |
| (...skipping 273 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 348 | 354 |
| 349 void ThreadProxy::setNeedsCommitOnImplThread() | 355 void ThreadProxy::setNeedsCommitOnImplThread() |
| 350 { | 356 { |
| 351 DCHECK(isImplThread()); | 357 DCHECK(isImplThread()); |
| 352 TRACE_EVENT0("cc", "ThreadProxy::setNeedsCommitOnImplThread"); | 358 TRACE_EVENT0("cc", "ThreadProxy::setNeedsCommitOnImplThread"); |
| 353 m_schedulerOnImplThread->setNeedsCommit(); | 359 m_schedulerOnImplThread->setNeedsCommit(); |
| 354 } | 360 } |
| 355 | 361 |
| 356 void ThreadProxy::setNeedsManageTilesOnImplThread() | 362 void ThreadProxy::setNeedsManageTilesOnImplThread() |
| 357 { | 363 { |
| 364 DCHECK(isImplThread()); |
| 358 if (m_manageTilesPending) | 365 if (m_manageTilesPending) |
| 359 return; | 366 return; |
| 360 Proxy::implThread()->postTask(base::Bind(&ThreadProxy::manageTilesOnImplThre
ad, m_implThreadWeakPtr)); | 367 Proxy::implThread()->postTask(base::Bind(&ThreadProxy::manageTilesOnImplThre
ad, m_implThreadWeakPtr)); |
| 361 m_manageTilesPending = true; | 368 m_manageTilesPending = true; |
| 362 } | 369 } |
| 363 | 370 |
| 364 void ThreadProxy::manageTilesOnImplThread() | 371 void ThreadProxy::manageTilesOnImplThread() |
| 365 { | 372 { |
| 373 DCHECK(isImplThread()); |
| 366 // TODO(nduca): If needed, move this into CCSchedulerStateMachine. | 374 // TODO(nduca): If needed, move this into CCSchedulerStateMachine. |
| 367 m_manageTilesPending = false; | 375 m_manageTilesPending = false; |
| 368 if (m_layerTreeHostImpl) | 376 if (m_layerTreeHostImpl) |
| 369 m_layerTreeHostImpl->manageTiles(); | 377 m_layerTreeHostImpl->manageTiles(); |
| 370 } | 378 } |
| 371 | 379 |
| 380 void ThreadProxy::setNeedsCheckForCompletedRasterTasksOnImplThread() |
| 381 { |
| 382 DCHECK(isImplThread()); |
| 383 if (m_checkForCompletedRasterTasksPending) |
| 384 return; |
| 385 Proxy::implThread()->postDelayedTask( |
| 386 base::Bind(&ThreadProxy::checkForCompletedRasterTasksOnImplThread, |
| 387 m_weakCheckForCompletedRasterTasksFactory.GetWeakPtr()), |
| 388 checkForCompletedRasterTasksDelay * 1000); |
| 389 m_checkForCompletedRasterTasksPending = true; |
| 390 } |
| 391 |
| 392 void ThreadProxy::checkForCompletedRasterTasksOnImplThread() |
| 393 { |
| 394 DCHECK(isImplThread()); |
| 395 m_checkForCompletedRasterTasksPending = false; |
| 396 if (m_layerTreeHostImpl) |
| 397 m_layerTreeHostImpl->checkForCompletedRasterTasks(); |
| 398 } |
| 399 |
| 372 void ThreadProxy::setNeedsForcedCommitOnImplThread() | 400 void ThreadProxy::setNeedsForcedCommitOnImplThread() |
| 373 { | 401 { |
| 374 DCHECK(isImplThread()); | 402 DCHECK(isImplThread()); |
| 375 TRACE_EVENT0("cc", "ThreadProxy::setNeedsForcedCommitOnImplThread"); | 403 TRACE_EVENT0("cc", "ThreadProxy::setNeedsForcedCommitOnImplThread"); |
| 376 m_schedulerOnImplThread->setNeedsForcedCommit(); | 404 m_schedulerOnImplThread->setNeedsForcedCommit(); |
| 377 } | 405 } |
| 378 | 406 |
| 379 void ThreadProxy::postAnimationEventsToMainThreadOnImplThread(scoped_ptr<Animati
onEventsVector> events, base::Time wallClockTime) | 407 void ThreadProxy::postAnimationEventsToMainThreadOnImplThread(scoped_ptr<Animati
onEventsVector> events, base::Time wallClockTime) |
| 380 { | 408 { |
| 381 DCHECK(isImplThread()); | 409 DCHECK(isImplThread()); |
| (...skipping 97 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 479 m_schedulerOnImplThread->didSwapUseIncompleteTile(); | 507 m_schedulerOnImplThread->didSwapUseIncompleteTile(); |
| 480 } | 508 } |
| 481 | 509 |
| 482 void ThreadProxy::didUploadVisibleHighResolutionTileOnImplThread() | 510 void ThreadProxy::didUploadVisibleHighResolutionTileOnImplThread() |
| 483 { | 511 { |
| 484 DCHECK(isImplThread()); | 512 DCHECK(isImplThread()); |
| 485 TRACE_EVENT0("cc", "ThreadProxy::didUploadVisibleHighResolutionTileOnImplThre
ad"); | 513 TRACE_EVENT0("cc", "ThreadProxy::didUploadVisibleHighResolutionTileOnImplThre
ad"); |
| 486 m_schedulerOnImplThread->setNeedsRedraw(); | 514 m_schedulerOnImplThread->setNeedsRedraw(); |
| 487 } | 515 } |
| 488 | 516 |
| 517 void ThreadProxy::didDetectIdleRasterOnImplThread() |
| 518 { |
| 519 DCHECK(isImplThread()); |
| 520 TRACE_EVENT0("cc", "ThreadProxy::didDetectIdleRasterOnImplThread"); |
| 521 |
| 522 // Cancel pending check. |
| 523 m_weakCheckForCompletedRasterTasksFactory.InvalidateWeakPtrs(); |
| 524 m_checkForCompletedRasterTasksPending = false; |
| 525 |
| 526 // Perform immediate check. |
| 527 if (m_layerTreeHostImpl) |
| 528 m_layerTreeHostImpl->checkForCompletedRasterTasks(); |
| 529 } |
| 530 |
| 489 void ThreadProxy::mainThreadHasStoppedFlinging() | 531 void ThreadProxy::mainThreadHasStoppedFlinging() |
| 490 { | 532 { |
| 491 if (m_inputHandlerOnImplThread) | 533 if (m_inputHandlerOnImplThread) |
| 492 m_inputHandlerOnImplThread->mainThreadHasStoppedFlinging(); | 534 m_inputHandlerOnImplThread->mainThreadHasStoppedFlinging(); |
| 493 } | 535 } |
| 494 | 536 |
| 495 void ThreadProxy::start() | 537 void ThreadProxy::start() |
| 496 { | 538 { |
| 497 DCHECK(isMainThread()); | 539 DCHECK(isMainThread()); |
| 498 DCHECK(Proxy::implThread()); | 540 DCHECK(Proxy::implThread()); |
| (...skipping 539 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1038 | 1080 |
| 1039 void ThreadProxy::layerTreeHostClosedOnImplThread(CompletionEvent* completion) | 1081 void ThreadProxy::layerTreeHostClosedOnImplThread(CompletionEvent* completion) |
| 1040 { | 1082 { |
| 1041 TRACE_EVENT0("cc", "ThreadProxy::layerTreeHostClosedOnImplThread"); | 1083 TRACE_EVENT0("cc", "ThreadProxy::layerTreeHostClosedOnImplThread"); |
| 1042 DCHECK(isImplThread()); | 1084 DCHECK(isImplThread()); |
| 1043 m_layerTreeHost->deleteContentsTexturesOnImplThread(m_layerTreeHostImpl->res
ourceProvider()); | 1085 m_layerTreeHost->deleteContentsTexturesOnImplThread(m_layerTreeHostImpl->res
ourceProvider()); |
| 1044 m_inputHandlerOnImplThread.reset(); | 1086 m_inputHandlerOnImplThread.reset(); |
| 1045 m_layerTreeHostImpl.reset(); | 1087 m_layerTreeHostImpl.reset(); |
| 1046 m_schedulerOnImplThread.reset(); | 1088 m_schedulerOnImplThread.reset(); |
| 1047 m_weakFactoryOnImplThread.InvalidateWeakPtrs(); | 1089 m_weakFactoryOnImplThread.InvalidateWeakPtrs(); |
| 1090 m_weakCheckForCompletedRasterTasksFactory.InvalidateWeakPtrs(); |
| 1048 completion->signal(); | 1091 completion->signal(); |
| 1049 } | 1092 } |
| 1050 | 1093 |
| 1051 void ThreadProxy::setFullRootLayerDamageOnImplThread() | 1094 void ThreadProxy::setFullRootLayerDamageOnImplThread() |
| 1052 { | 1095 { |
| 1053 DCHECK(isImplThread()); | 1096 DCHECK(isImplThread()); |
| 1054 m_layerTreeHostImpl->setFullRootLayerDamage(); | 1097 m_layerTreeHostImpl->setFullRootLayerDamage(); |
| 1055 } | 1098 } |
| 1056 | 1099 |
| 1057 size_t ThreadProxy::maxPartialTextureUpdates() const | 1100 size_t ThreadProxy::maxPartialTextureUpdates() const |
| (...skipping 153 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1211 | 1254 |
| 1212 void ThreadProxy::renewTreePriorityOnImplThread() | 1255 void ThreadProxy::renewTreePriorityOnImplThread() |
| 1213 { | 1256 { |
| 1214 DCHECK(m_renewTreePriorityOnImplThreadPending); | 1257 DCHECK(m_renewTreePriorityOnImplThreadPending); |
| 1215 m_renewTreePriorityOnImplThreadPending = false; | 1258 m_renewTreePriorityOnImplThreadPending = false; |
| 1216 | 1259 |
| 1217 renewTreePriority(); | 1260 renewTreePriority(); |
| 1218 } | 1261 } |
| 1219 | 1262 |
| 1220 } // namespace cc | 1263 } // namespace cc |
| OLD | NEW |