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

Side by Side Diff: cc/CCThreadProxy.cpp

Issue 10919320: Integrate r128344 and r128253 from WebKit (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 8 years, 3 months 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
« cc/CCPrioritizedTextureTest.cpp ('K') | « cc/CCThreadProxy.h ('k') | no next file » | 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 "CCThreadProxy.h" 7 #include "CCThreadProxy.h"
8 8
9 #include "CCDelayBasedTimeSource.h" 9 #include "CCDelayBasedTimeSource.h"
10 #include "CCDrawQuad.h" 10 #include "CCDrawQuad.h"
(...skipping 333 matching lines...) Expand 10 before | Expand all | Expand 10 after
344 m_schedulerOnImplThread->setNeedsForcedCommit(); 344 m_schedulerOnImplThread->setNeedsForcedCommit();
345 } 345 }
346 346
347 void CCThreadProxy::postAnimationEventsToMainThreadOnImplThread(PassOwnPtr<CCAni mationEventsVector> events, double wallClockTime) 347 void CCThreadProxy::postAnimationEventsToMainThreadOnImplThread(PassOwnPtr<CCAni mationEventsVector> events, double wallClockTime)
348 { 348 {
349 ASSERT(isImplThread()); 349 ASSERT(isImplThread());
350 TRACE_EVENT0("cc", "CCThreadProxy::postAnimationEventsToMainThreadOnImplThre ad"); 350 TRACE_EVENT0("cc", "CCThreadProxy::postAnimationEventsToMainThreadOnImplThre ad");
351 m_mainThreadProxy->postTask(createCCThreadTask(this, &CCThreadProxy::setAnim ationEvents, events, wallClockTime)); 351 m_mainThreadProxy->postTask(createCCThreadTask(this, &CCThreadProxy::setAnim ationEvents, events, wallClockTime));
352 } 352 }
353 353
354 void CCThreadProxy::releaseContentsTexturesOnImplThread()
355 {
356 ASSERT(isImplThread());
357 m_layerTreeHost->reduceContentsTexturesMemoryOnImplThread(0, m_layerTreeHost Impl->resourceProvider());
358 // Make sure that we get a new commit before drawing again.
359 m_resetContentsTexturesPurgedAfterCommitOnImplThread = false;
360 // The texture upload queue may reference textures that were just purged, so clear it.
361 m_currentTextureUpdateControllerOnImplThread.clear();
362 }
363
354 void CCThreadProxy::setNeedsRedraw() 364 void CCThreadProxy::setNeedsRedraw()
355 { 365 {
356 ASSERT(isMainThread()); 366 ASSERT(isMainThread());
357 TRACE_EVENT0("cc", "CCThreadProxy::setNeedsRedraw"); 367 TRACE_EVENT0("cc", "CCThreadProxy::setNeedsRedraw");
358 CCProxy::implThread()->postTask(createCCThreadTask(this, &CCThreadProxy::set FullRootLayerDamageOnImplThread)); 368 CCProxy::implThread()->postTask(createCCThreadTask(this, &CCThreadProxy::set FullRootLayerDamageOnImplThread));
359 CCProxy::implThread()->postTask(createCCThreadTask(this, &CCThreadProxy::set NeedsRedrawOnImplThread)); 369 CCProxy::implThread()->postTask(createCCThreadTask(this, &CCThreadProxy::set NeedsRedrawOnImplThread));
360 } 370 }
361 371
362 bool CCThreadProxy::commitRequested() const 372 bool CCThreadProxy::commitRequested() const
363 { 373 {
(...skipping 82 matching lines...) Expand 10 before | Expand all | Expand 10 after
446 setNeedsForcedCommitOnImplThread(); 456 setNeedsForcedCommitOnImplThread();
447 } 457 }
448 458
449 void CCThreadProxy::scheduledActionBeginFrame() 459 void CCThreadProxy::scheduledActionBeginFrame()
450 { 460 {
451 TRACE_EVENT0("cc", "CCThreadProxy::scheduledActionBeginFrame"); 461 TRACE_EVENT0("cc", "CCThreadProxy::scheduledActionBeginFrame");
452 ASSERT(!m_pendingBeginFrameRequest); 462 ASSERT(!m_pendingBeginFrameRequest);
453 m_pendingBeginFrameRequest = adoptPtr(new BeginFrameAndCommitState()); 463 m_pendingBeginFrameRequest = adoptPtr(new BeginFrameAndCommitState());
454 m_pendingBeginFrameRequest->monotonicFrameBeginTime = monotonicallyIncreasin gTime(); 464 m_pendingBeginFrameRequest->monotonicFrameBeginTime = monotonicallyIncreasin gTime();
455 m_pendingBeginFrameRequest->scrollInfo = m_layerTreeHostImpl->processScrollD eltas(); 465 m_pendingBeginFrameRequest->scrollInfo = m_layerTreeHostImpl->processScrollD eltas();
456 m_pendingBeginFrameRequest->contentsTexturesWereDeleted = m_layerTreeHostImp l->contentsTexturesPurged();
457 m_pendingBeginFrameRequest->memoryAllocationLimitBytes = m_layerTreeHostImpl ->memoryAllocationLimitBytes(); 466 m_pendingBeginFrameRequest->memoryAllocationLimitBytes = m_layerTreeHostImpl ->memoryAllocationLimitBytes();
467 m_layerTreeHost->getEvictedContentTexturesBackings(m_pendingBeginFrameReques t->evictedContentsTexturesBackings);
458 468
459 m_mainThreadProxy->postTask(createCCThreadTask(this, &CCThreadProxy::beginFr ame)); 469 m_mainThreadProxy->postTask(createCCThreadTask(this, &CCThreadProxy::beginFr ame));
460 470
461 if (m_beginFrameCompletionEventOnImplThread) { 471 if (m_beginFrameCompletionEventOnImplThread) {
462 m_beginFrameCompletionEventOnImplThread->signal(); 472 m_beginFrameCompletionEventOnImplThread->signal();
463 m_beginFrameCompletionEventOnImplThread = 0; 473 m_beginFrameCompletionEventOnImplThread = 0;
464 } 474 }
465 } 475 }
466 476
467 void CCThreadProxy::beginFrame() 477 void CCThreadProxy::beginFrame()
(...skipping 50 matching lines...) Expand 10 before | Expand all | Expand 10 after
518 // updateLayers. 528 // updateLayers.
519 m_commitRequested = false; 529 m_commitRequested = false;
520 m_commitRequestSentToImplThread = false; 530 m_commitRequestSentToImplThread = false;
521 m_forcedCommitRequested = false; 531 m_forcedCommitRequested = false;
522 532
523 if (!m_layerTreeHost->initializeRendererIfNeeded()) { 533 if (!m_layerTreeHost->initializeRendererIfNeeded()) {
524 TRACE_EVENT0("cc", "EarlyOut_InitializeFailed"); 534 TRACE_EVENT0("cc", "EarlyOut_InitializeFailed");
525 return; 535 return;
526 } 536 }
527 537
528 if (request->contentsTexturesWereDeleted) 538 m_layerTreeHost->unlinkEvictedContentTexturesBackings(request->evictedConten tsTexturesBackings);
529 m_layerTreeHost->unlinkAllContentTextures();
530 539
531 OwnPtr<CCTextureUpdateQueue> queue = adoptPtr(new CCTextureUpdateQueue); 540 OwnPtr<CCTextureUpdateQueue> queue = adoptPtr(new CCTextureUpdateQueue);
532 m_layerTreeHost->updateLayers(*(queue.get()), request->memoryAllocationLimit Bytes); 541 m_layerTreeHost->updateLayers(*(queue.get()), request->memoryAllocationLimit Bytes);
533 542
534 // Once single buffered layers are committed, they cannot be modified until 543 // Once single buffered layers are committed, they cannot be modified until
535 // they are drawn by the impl thread. 544 // they are drawn by the impl thread.
536 m_texturesAcquired = false; 545 m_texturesAcquired = false;
537 546
538 m_layerTreeHost->willCommit(); 547 m_layerTreeHost->willCommit();
539 // Before applying scrolls and calling animate, we set m_animateRequested to 548 // Before applying scrolls and calling animate, we set m_animateRequested to
540 // false. If it is true now, it means setNeedAnimate was called again, but 549 // false. If it is true now, it means setNeedAnimate was called again, but
541 // during a state when m_commitRequestSentToImplThread = true. We need to 550 // during a state when m_commitRequestSentToImplThread = true. We need to
542 // force that call to happen again now so that the commit request is sent to 551 // force that call to happen again now so that the commit request is sent to
543 // the impl thread. 552 // the impl thread.
544 if (m_animateRequested) { 553 if (m_animateRequested) {
545 // Forces setNeedsAnimate to consider posting a commit task. 554 // Forces setNeedsAnimate to consider posting a commit task.
546 m_animateRequested = false; 555 m_animateRequested = false;
547 setNeedsAnimate(); 556 setNeedsAnimate();
548 } 557 }
549 558
550 // Notify the impl thread that the beginFrame has completed. This will 559 // Notify the impl thread that the beginFrame has completed. This will
551 // begin the commit process, which is blocking from the main thread's 560 // begin the commit process, which is blocking from the main thread's
552 // point of view, but asynchronously performed on the impl thread, 561 // point of view, but asynchronously performed on the impl thread,
553 // coordinated by the CCScheduler. 562 // coordinated by the CCScheduler.
554 { 563 {
555 TRACE_EVENT0("cc", "commit"); 564 TRACE_EVENT0("cc", "commit");
556 DebugScopedSetMainThreadBlocked mainThreadBlocked; 565 DebugScopedSetMainThreadBlocked mainThreadBlocked;
557 566
558 CCCompletionEvent completion; 567 CCCompletionEvent completion;
559 CCProxy::implThread()->postTask(createCCThreadTask(this, &CCThreadProxy: :beginFrameCompleteOnImplThread, &completion, queue.release(), request->contents TexturesWereDeleted)); 568 CCProxy::implThread()->postTask(createCCThreadTask(this, &CCThreadProxy: :beginFrameCompleteOnImplThread, &completion, queue.release()));
560 completion.wait(); 569 completion.wait();
561 } 570 }
562 571
563 m_layerTreeHost->commitComplete(); 572 m_layerTreeHost->commitComplete();
564 m_layerTreeHost->didBeginFrame(); 573 m_layerTreeHost->didBeginFrame();
565 } 574 }
566 575
567 void CCThreadProxy::beginFrameCompleteOnImplThread(CCCompletionEvent* completion , PassOwnPtr<CCTextureUpdateQueue> queue, bool contentsTexturesWereDeleted) 576 void CCThreadProxy::beginFrameCompleteOnImplThread(CCCompletionEvent* completion , PassOwnPtr<CCTextureUpdateQueue> queue)
568 { 577 {
569 TRACE_EVENT0("cc", "CCThreadProxy::beginFrameCompleteOnImplThread"); 578 TRACE_EVENT0("cc", "CCThreadProxy::beginFrameCompleteOnImplThread");
570 ASSERT(!m_commitCompletionEventOnImplThread); 579 ASSERT(!m_commitCompletionEventOnImplThread);
571 ASSERT(isImplThread() && isMainThreadBlocked()); 580 ASSERT(isImplThread() && isMainThreadBlocked());
572 ASSERT(m_schedulerOnImplThread); 581 ASSERT(m_schedulerOnImplThread);
573 ASSERT(m_schedulerOnImplThread->commitPending()); 582 ASSERT(m_schedulerOnImplThread->commitPending());
574 583
575 if (!m_layerTreeHostImpl) { 584 if (!m_layerTreeHostImpl) {
576 TRACE_EVENT0("cc", "EarlyOut_NoLayerTree"); 585 TRACE_EVENT0("cc", "EarlyOut_NoLayerTree");
577 completion->signal(); 586 completion->signal();
578 return; 587 return;
579 } 588 }
580 589
581 if (contentsTexturesWereDeleted) { 590 // If we unlinked evicted textures on the main thread, delete them now.
582 ASSERT(m_layerTreeHostImpl->contentsTexturesPurged()); 591 if (m_layerTreeHost->deleteEvictedContentTexturesBackings()) {
583 // We unlinked all textures on the main thread, delete them now. 592
584 m_layerTreeHost->deleteUnlinkedTextures(); 593 // Deleting the evicted textures' backings resulted in some textures in the
585 // Mark that we can start drawing again when this commit is complete. 594 // layer tree being invalidated (unliked from their backings). The uploa d queue
586 m_resetContentsTexturesPurgedAfterCommitOnImplThread = true; 595 // may contain references to these textures, so clear the queue and kick off
587 } else if (m_layerTreeHostImpl->contentsTexturesPurged()) { 596 // another commit to fill them again.
588 // We purged the content textures on the impl thread between the time we
589 // posted the beginFrame task and now, meaning we have a bunch of
590 // uploads that are now invalid. Clear the uploads (they all go to
591 // content textures), and kick another commit to fill them again.
592 queue->clearUploads(); 597 queue->clearUploads();
593 setNeedsCommitOnImplThread(); 598 setNeedsCommitOnImplThread();
599 } else {
600 // The layer tree does not reference evicted textures, so mark that we
601 // can draw this tree once this commit is complete.
602 if (m_layerTreeHostImpl->contentsTexturesPurged())
603 m_resetContentsTexturesPurgedAfterCommitOnImplThread = true;
594 } 604 }
595 605
596 bool hasResourceUpdates = queue->hasMoreUpdates(); 606 bool hasResourceUpdates = queue->hasMoreUpdates();
597 if (hasResourceUpdates) 607 if (hasResourceUpdates)
598 m_currentTextureUpdateControllerOnImplThread = CCTextureUpdateController ::create(this, CCProxy::implThread(), queue, m_layerTreeHostImpl->resourceProvid er(), m_layerTreeHostImpl->renderer()->textureCopier(), m_layerTreeHostImpl->ren derer()->textureUploader()); 608 m_currentTextureUpdateControllerOnImplThread = CCTextureUpdateController ::create(this, CCProxy::implThread(), queue, m_layerTreeHostImpl->resourceProvid er(), m_layerTreeHostImpl->renderer()->textureCopier(), m_layerTreeHostImpl->ren derer()->textureUploader());
599 m_commitCompletionEventOnImplThread = completion; 609 m_commitCompletionEventOnImplThread = completion;
600 610
601 m_schedulerOnImplThread->beginFrameComplete(hasResourceUpdates); 611 m_schedulerOnImplThread->beginFrameComplete(hasResourceUpdates);
602 } 612 }
603 613
(...skipping 268 matching lines...) Expand 10 before | Expand all | Expand 10 after
872 capabilities->usingSwapCompleteCallback); 882 capabilities->usingSwapCompleteCallback);
873 } 883 }
874 884
875 completion->signal(); 885 completion->signal();
876 } 886 }
877 887
878 void CCThreadProxy::layerTreeHostClosedOnImplThread(CCCompletionEvent* completio n) 888 void CCThreadProxy::layerTreeHostClosedOnImplThread(CCCompletionEvent* completio n)
879 { 889 {
880 TRACE_EVENT0("cc", "CCThreadProxy::layerTreeHostClosedOnImplThread"); 890 TRACE_EVENT0("cc", "CCThreadProxy::layerTreeHostClosedOnImplThread");
881 ASSERT(isImplThread()); 891 ASSERT(isImplThread());
882 if (!m_layerTreeHostImpl->contentsTexturesPurged()) 892 m_layerTreeHost->deleteContentsTexturesOnImplThread(m_layerTreeHostImpl->res ourceProvider());
883 m_layerTreeHost->deleteContentsTexturesOnImplThread(m_layerTreeHostImpl- >resourceProvider());
884 m_inputHandlerOnImplThread.clear(); 893 m_inputHandlerOnImplThread.clear();
885 m_layerTreeHostImpl.clear(); 894 m_layerTreeHostImpl.clear();
886 m_schedulerOnImplThread.clear(); 895 m_schedulerOnImplThread.clear();
887 completion->signal(); 896 completion->signal();
888 } 897 }
889 898
890 void CCThreadProxy::setFullRootLayerDamageOnImplThread() 899 void CCThreadProxy::setFullRootLayerDamageOnImplThread()
891 { 900 {
892 ASSERT(isImplThread()); 901 ASSERT(isImplThread());
893 m_layerTreeHostImpl->setFullRootLayerDamage(); 902 m_layerTreeHostImpl->setFullRootLayerDamage();
894 } 903 }
895 904
896 size_t CCThreadProxy::maxPartialTextureUpdates() const 905 size_t CCThreadProxy::maxPartialTextureUpdates() const
897 { 906 {
898 return CCTextureUpdateController::maxPartialTextureUpdates(); 907 return CCTextureUpdateController::maxPartialTextureUpdates();
899 } 908 }
900 909
901 void CCThreadProxy::recreateContextOnImplThread(CCCompletionEvent* completion, C CGraphicsContext* contextPtr, bool* recreateSucceeded, RendererCapabilities* cap abilities) 910 void CCThreadProxy::recreateContextOnImplThread(CCCompletionEvent* completion, C CGraphicsContext* contextPtr, bool* recreateSucceeded, RendererCapabilities* cap abilities)
902 { 911 {
903 TRACE_EVENT0("cc", "CCThreadProxy::recreateContextOnImplThread"); 912 TRACE_EVENT0("cc", "CCThreadProxy::recreateContextOnImplThread");
904 ASSERT(isImplThread()); 913 ASSERT(isImplThread());
905 if (!m_layerTreeHostImpl->contentsTexturesPurged()) 914 m_layerTreeHost->deleteContentsTexturesOnImplThread(m_layerTreeHostImpl->res ourceProvider());
906 m_layerTreeHost->deleteContentsTexturesOnImplThread(m_layerTreeHostImpl- >resourceProvider());
907 *recreateSucceeded = m_layerTreeHostImpl->initializeRenderer(adoptPtr(contex tPtr), textureUploader); 915 *recreateSucceeded = m_layerTreeHostImpl->initializeRenderer(adoptPtr(contex tPtr), textureUploader);
908 if (*recreateSucceeded) { 916 if (*recreateSucceeded) {
909 *capabilities = m_layerTreeHostImpl->rendererCapabilities(); 917 *capabilities = m_layerTreeHostImpl->rendererCapabilities();
910 m_schedulerOnImplThread->didRecreateContext(); 918 m_schedulerOnImplThread->didRecreateContext();
911 } 919 }
912 completion->signal(); 920 completion->signal();
913 } 921 }
914 922
915 void CCThreadProxy::implSideRenderingStatsOnImplThread(CCCompletionEvent* comple tion, CCRenderingStats* stats) 923 void CCThreadProxy::implSideRenderingStatsOnImplThread(CCCompletionEvent* comple tion, CCRenderingStats* stats)
916 { 924 {
917 ASSERT(isImplThread()); 925 ASSERT(isImplThread());
918 m_layerTreeHostImpl->renderingStats(*stats); 926 m_layerTreeHostImpl->renderingStats(*stats);
919 completion->signal(); 927 completion->signal();
920 } 928 }
921 929
922 } // namespace cc 930 } // namespace cc
OLDNEW
« cc/CCPrioritizedTextureTest.cpp ('K') | « cc/CCThreadProxy.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698