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

Side by Side Diff: Source/WebCore/platform/graphics/chromium/cc/CCThreadProxy.cpp

Issue 10377150: Merge 116587 - [chromium] Don't draw when canDraw() is false (Closed) Base URL: http://svn.webkit.org/repository/webkit/branches/chromium/1132/
Patch Set: Created 8 years, 7 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
OLDNEW
1 /* 1 /*
2 * Copyright (C) 2011 Google Inc. All rights reserved. 2 * Copyright (C) 2011 Google Inc. All rights reserved.
3 * 3 *
4 * Redistribution and use in source and binary forms, with or without 4 * Redistribution and use in source and binary forms, with or without
5 * modification, are permitted provided that the following conditions 5 * modification, are permitted provided that the following conditions
6 * are met: 6 * are met:
7 * 1. Redistributions of source code must retain the above copyright 7 * 1. Redistributions of source code must retain the above copyright
8 * notice, this list of conditions and the following disclaimer. 8 * notice, this list of conditions and the following disclaimer.
9 * 2. Redistributions in binary form must reproduce the above copyright 9 * 2. Redistributions in binary form must reproduce the above copyright
10 * notice, this list of conditions and the following disclaimer in the 10 * notice, this list of conditions and the following disclaimer in the
(...skipping 602 matching lines...) Expand 10 before | Expand all | Expand 10 after
613 ASSERT(m_layerTreeHostImpl->layerRenderer()); 613 ASSERT(m_layerTreeHostImpl->layerRenderer());
614 if (!m_layerTreeHostImpl->layerRenderer()) 614 if (!m_layerTreeHostImpl->layerRenderer())
615 return result; 615 return result;
616 616
617 // FIXME: compute the frame display time more intelligently 617 // FIXME: compute the frame display time more intelligently
618 double monotonicTime = monotonicallyIncreasingTime(); 618 double monotonicTime = monotonicallyIncreasingTime();
619 double wallClockTime = currentTime(); 619 double wallClockTime = currentTime();
620 620
621 m_inputHandlerOnImplThread->animate(monotonicTime); 621 m_inputHandlerOnImplThread->animate(monotonicTime);
622 m_layerTreeHostImpl->animate(monotonicTime, wallClockTime); 622 m_layerTreeHostImpl->animate(monotonicTime, wallClockTime);
623
624 // This method is called on a forced draw, regardless of whether we are able to produce a frame,
625 // as the calling site on main thread is blocked until its request completes , and we signal
626 // completion here. If canDraw() is false, we will indicate success=false to the caller, but we
627 // must still signal completion to avoid deadlock.
628
629 // We guard prepareToDraw() with canDraw() because it always returns a valid frame, so can only
630 // be used when such a frame is possible. Since drawLayers() depends on the result of
631 // prepareToDraw(), it is guarded on canDraw() as well.
632
623 CCLayerTreeHostImpl::FrameData frame; 633 CCLayerTreeHostImpl::FrameData frame;
624 bool drawFrame = m_layerTreeHostImpl->prepareToDraw(frame) || forcedDraw; 634 bool drawFrame = m_layerTreeHostImpl->canDraw() && (m_layerTreeHostImpl->pre pareToDraw(frame) || forcedDraw);
625 if (drawFrame) { 635 if (drawFrame) {
626 m_layerTreeHostImpl->drawLayers(frame); 636 m_layerTreeHostImpl->drawLayers(frame);
627 result.didDraw = true; 637 result.didDraw = true;
628 } 638 }
629 m_layerTreeHostImpl->didDrawAllLayers(frame); 639 m_layerTreeHostImpl->didDrawAllLayers(frame);
630 640
631 // Check for a pending compositeAndReadback. 641 // Check for a pending compositeAndReadback.
632 if (m_readbackRequestOnImplThread) { 642 if (m_readbackRequestOnImplThread) {
633 ASSERT(drawFrame); // This should be a forcedDraw 643 m_readbackRequestOnImplThread->success = false;
634 m_layerTreeHostImpl->readback(m_readbackRequestOnImplThread->pixels, m_r eadbackRequestOnImplThread->rect); 644 if (drawFrame) {
635 m_readbackRequestOnImplThread->success = !m_layerTreeHostImpl->isContext Lost(); 645 m_layerTreeHostImpl->readback(m_readbackRequestOnImplThread->pixels, m_readbackRequestOnImplThread->rect);
646 m_readbackRequestOnImplThread->success = !m_layerTreeHostImpl->isCon textLost();
647 }
636 m_readbackRequestOnImplThread->completion.signal(); 648 m_readbackRequestOnImplThread->completion.signal();
637 m_readbackRequestOnImplThread = 0; 649 m_readbackRequestOnImplThread = 0;
638 } 650 }
639 651
640 if (drawFrame) 652 if (drawFrame)
641 result.didSwap = m_layerTreeHostImpl->swapBuffers(); 653 result.didSwap = m_layerTreeHostImpl->swapBuffers();
642 654
643 // Process any finish request 655 // Process any finish request
644 if (m_finishAllRenderingCompletionEventOnImplThread) { 656 if (m_finishAllRenderingCompletionEventOnImplThread) {
645 ASSERT(drawFrame); // This should be a forcedDraw
646 m_layerTreeHostImpl->finishAllRendering(); 657 m_layerTreeHostImpl->finishAllRendering();
647 m_finishAllRenderingCompletionEventOnImplThread->signal(); 658 m_finishAllRenderingCompletionEventOnImplThread->signal();
648 m_finishAllRenderingCompletionEventOnImplThread = 0; 659 m_finishAllRenderingCompletionEventOnImplThread = 0;
649 } 660 }
650 661
651 // Tell the main thread that the the newly-commited frame was drawn. 662 // Tell the main thread that the the newly-commited frame was drawn.
652 if (m_nextFrameIsNewlyCommittedFrameOnImplThread) { 663 if (m_nextFrameIsNewlyCommittedFrameOnImplThread) {
653 m_nextFrameIsNewlyCommittedFrameOnImplThread = false; 664 m_nextFrameIsNewlyCommittedFrameOnImplThread = false;
654 m_mainThreadProxy->postTask(createCCThreadTask(this, &CCThreadProxy::did CommitAndDrawFrame)); 665 m_mainThreadProxy->postTask(createCCThreadTask(this, &CCThreadProxy::did CommitAndDrawFrame));
655 } 666 }
656 667
657 ASSERT(drawFrame || (!drawFrame && !forcedDraw));
658 return result; 668 return result;
659 } 669 }
660 670
661 void CCThreadProxy::acquireLayerTextures() 671 void CCThreadProxy::acquireLayerTextures()
662 { 672 {
663 // Called when the main thread needs to modify a layer texture that is used 673 // Called when the main thread needs to modify a layer texture that is used
664 // directly by the compositor. 674 // directly by the compositor.
665 // This method will block until the next compositor draw if there is a 675 // This method will block until the next compositor draw if there is a
666 // previously committed frame that is still undrawn. This is necessary to 676 // previously committed frame that is still undrawn. This is necessary to
667 // ensure that the main thread does not monopolize access to the textures. 677 // ensure that the main thread does not monopolize access to the textures.
(...skipping 189 matching lines...) Expand 10 before | Expand all | Expand 10 after
857 m_layerTreeHost->deleteContentsTexturesOnImplThread(m_layerTreeHostImpl->con tentsTextureAllocator()); 867 m_layerTreeHost->deleteContentsTexturesOnImplThread(m_layerTreeHostImpl->con tentsTextureAllocator());
858 *recreateSucceeded = m_layerTreeHostImpl->initializeLayerRenderer(adoptRef(c ontextPtr)); 868 *recreateSucceeded = m_layerTreeHostImpl->initializeLayerRenderer(adoptRef(c ontextPtr));
859 if (*recreateSucceeded) { 869 if (*recreateSucceeded) {
860 *capabilities = m_layerTreeHostImpl->layerRendererCapabilities(); 870 *capabilities = m_layerTreeHostImpl->layerRendererCapabilities();
861 m_schedulerOnImplThread->didRecreateContext(); 871 m_schedulerOnImplThread->didRecreateContext();
862 } 872 }
863 completion->signal(); 873 completion->signal();
864 } 874 }
865 875
866 } // namespace WebCore 876 } // namespace WebCore
OLDNEW
« no previous file with comments | « Source/WebCore/platform/graphics/chromium/cc/CCSingleThreadProxy.cpp ('k') | Source/WebKit/chromium/ChangeLog » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698