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

Side by Side Diff: cc/thread_proxy.cc

Issue 11411251: Use a lock to deal with concurrent access to the m_evictedBackings (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Incorporate review feedback Created 8 years 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
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 "cc/thread_proxy.h" 5 #include "cc/thread_proxy.h"
6 6
7 #include "base/bind.h" 7 #include "base/bind.h"
8 #include "base/debug/trace_event.h" 8 #include "base/debug/trace_event.h"
9 #include "cc/delay_based_time_source.h" 9 #include "cc/delay_based_time_source.h"
10 #include "cc/draw_quad.h" 10 #include "cc/draw_quad.h"
(...skipping 498 matching lines...) Expand 10 before | Expand all | Expand 10 after
509 509
510 void ThreadProxy::scheduledActionBeginFrame() 510 void ThreadProxy::scheduledActionBeginFrame()
511 { 511 {
512 TRACE_EVENT0("cc", "ThreadProxy::scheduledActionBeginFrame"); 512 TRACE_EVENT0("cc", "ThreadProxy::scheduledActionBeginFrame");
513 scoped_ptr<BeginFrameAndCommitState> beginFrameState(new BeginFrameAndCommit State); 513 scoped_ptr<BeginFrameAndCommitState> beginFrameState(new BeginFrameAndCommit State);
514 beginFrameState->monotonicFrameBeginTime = base::TimeTicks::Now(); 514 beginFrameState->monotonicFrameBeginTime = base::TimeTicks::Now();
515 beginFrameState->scrollInfo = m_layerTreeHostImpl->processScrollDeltas(); 515 beginFrameState->scrollInfo = m_layerTreeHostImpl->processScrollDeltas();
516 beginFrameState->implTransform = m_layerTreeHostImpl->implTransform(); 516 beginFrameState->implTransform = m_layerTreeHostImpl->implTransform();
517 DCHECK_GT(m_layerTreeHostImpl->memoryAllocationLimitBytes(), 0u); 517 DCHECK_GT(m_layerTreeHostImpl->memoryAllocationLimitBytes(), 0u);
518 beginFrameState->memoryAllocationLimitBytes = m_layerTreeHostImpl->memoryAll ocationLimitBytes(); 518 beginFrameState->memoryAllocationLimitBytes = m_layerTreeHostImpl->memoryAll ocationLimitBytes();
519 if (m_layerTreeHost->contentsTextureManager())
520 m_layerTreeHost->contentsTextureManager()->getEvictedBackings(beginFrame State->evictedContentsTexturesBackings);
521
522 m_mainThreadProxy->postTask(FROM_HERE, base::Bind(&ThreadProxy::beginFrame, base::Unretained(this), base::Passed(beginFrameState.Pass()))); 519 m_mainThreadProxy->postTask(FROM_HERE, base::Bind(&ThreadProxy::beginFrame, base::Unretained(this), base::Passed(beginFrameState.Pass())));
523 520
524 if (m_beginFrameCompletionEventOnImplThread) { 521 if (m_beginFrameCompletionEventOnImplThread) {
525 m_beginFrameCompletionEventOnImplThread->signal(); 522 m_beginFrameCompletionEventOnImplThread->signal();
526 m_beginFrameCompletionEventOnImplThread = 0; 523 m_beginFrameCompletionEventOnImplThread = 0;
527 } 524 }
528 } 525 }
529 526
530 void ThreadProxy::beginFrame(scoped_ptr<BeginFrameAndCommitState> beginFrameStat e) 527 void ThreadProxy::beginFrame(scoped_ptr<BeginFrameAndCommitState> beginFrameStat e)
531 { 528 {
532 TRACE_EVENT0("cc", "ThreadProxy::beginFrame"); 529 TRACE_EVENT0("cc", "ThreadProxy::beginFrame");
533 DCHECK(isMainThread()); 530 DCHECK(isMainThread());
534 if (!m_layerTreeHost) 531 if (!m_layerTreeHost)
535 return; 532 return;
536 533
537 // Be sure to never early-out of unlinking evicted textures whenever, so tha t
538 // the each evicted backing is sent to the main thread exactly once.
539 if (beginFrameState && !beginFrameState->evictedContentsTexturesBackings.emp ty()) {
540 DCHECK(m_layerTreeHost->contentsTextureManager());
541 m_layerTreeHost->contentsTextureManager()->unlinkEvictedBackings(beginFr ameState->evictedContentsTexturesBackings);
542 }
543
544 if (m_deferCommits) { 534 if (m_deferCommits) {
545 m_pendingDeferredCommit = beginFrameState.Pass(); 535 m_pendingDeferredCommit = beginFrameState.Pass();
546 m_layerTreeHost->didDeferCommit(); 536 m_layerTreeHost->didDeferCommit();
547 TRACE_EVENT0("cc", "EarlyOut_DeferCommits"); 537 TRACE_EVENT0("cc", "EarlyOut_DeferCommits");
548 return; 538 return;
549 } 539 }
550 540
551 if (m_layerTreeHost->needsSharedContext() && !WebSharedGraphicsContext3D::ha veCompositorThreadContext()) 541 if (m_layerTreeHost->needsSharedContext() && !WebSharedGraphicsContext3D::ha veCompositorThreadContext())
552 WebSharedGraphicsContext3D::createCompositorThreadContext(); 542 WebSharedGraphicsContext3D::createCompositorThreadContext();
553 543
(...skipping 34 matching lines...) Expand 10 before | Expand all | Expand 10 after
588 // layout when painted will trigger another setNeedsCommit inside 578 // layout when painted will trigger another setNeedsCommit inside
589 // updateLayers. 579 // updateLayers.
590 m_commitRequested = false; 580 m_commitRequested = false;
591 m_commitRequestSentToImplThread = false; 581 m_commitRequestSentToImplThread = false;
592 582
593 if (!m_layerTreeHost->initializeRendererIfNeeded()) { 583 if (!m_layerTreeHost->initializeRendererIfNeeded()) {
594 TRACE_EVENT0("cc", "EarlyOut_InitializeFailed"); 584 TRACE_EVENT0("cc", "EarlyOut_InitializeFailed");
595 return; 585 return;
596 } 586 }
597 587
588 // Unlink any backings that the impl thread has evicted, so that we know to re-paint
589 // them in updateLayers.
590 m_layerTreeHost->contentsTextureManager()->unlinkAndClearEvictedBackings();
591
598 scoped_ptr<ResourceUpdateQueue> queue = make_scoped_ptr(new ResourceUpdateQu eue); 592 scoped_ptr<ResourceUpdateQueue> queue = make_scoped_ptr(new ResourceUpdateQu eue);
599 m_layerTreeHost->updateLayers(*(queue.get()), beginFrameState ? beginFrameSt ate->memoryAllocationLimitBytes : 0); 593 m_layerTreeHost->updateLayers(*(queue.get()), beginFrameState ? beginFrameSt ate->memoryAllocationLimitBytes : 0);
600 594
601 // Once single buffered layers are committed, they cannot be modified until 595 // Once single buffered layers are committed, they cannot be modified until
602 // they are drawn by the impl thread. 596 // they are drawn by the impl thread.
603 m_texturesAcquired = false; 597 m_texturesAcquired = false;
604 598
605 m_layerTreeHost->willCommit(); 599 m_layerTreeHost->willCommit();
606 // Before applying scrolls and calling animate, we set m_animateRequested to 600 // Before applying scrolls and calling animate, we set m_animateRequested to
607 // false. If it is true now, it means setNeedAnimate was called again, but 601 // false. If it is true now, it means setNeedAnimate was called again, but
(...skipping 369 matching lines...) Expand 10 before | Expand all | Expand 10 after
977 ThreadProxy::BeginFrameAndCommitState::BeginFrameAndCommitState() 971 ThreadProxy::BeginFrameAndCommitState::BeginFrameAndCommitState()
978 : memoryAllocationLimitBytes(0) 972 : memoryAllocationLimitBytes(0)
979 { 973 {
980 } 974 }
981 975
982 ThreadProxy::BeginFrameAndCommitState::~BeginFrameAndCommitState() 976 ThreadProxy::BeginFrameAndCommitState::~BeginFrameAndCommitState()
983 { 977 {
984 } 978 }
985 979
986 } // namespace cc 980 } // namespace cc
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698