Chromium Code Reviews| 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/layer_tree_host_impl.h" | 5 #include "cc/layer_tree_host_impl.h" |
| 6 | 6 |
| 7 #include <algorithm> | 7 #include <algorithm> |
| 8 | 8 |
| 9 #include "base/basictypes.h" | 9 #include "base/basictypes.h" |
| 10 #include "base/debug/trace_event.h" | 10 #include "base/debug/trace_event.h" |
| (...skipping 446 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 457 occlusionTracker.setNonOccludingScreenSpaceRectsContainer(&frame.nonOccl udingScreenSpaceRects); | 457 occlusionTracker.setNonOccludingScreenSpaceRectsContainer(&frame.nonOccl udingScreenSpaceRects); |
| 458 | 458 |
| 459 // Add quads to the Render passes in FrontToBack order to allow for testing occlusion and performing culling during the tree walk. | 459 // Add quads to the Render passes in FrontToBack order to allow for testing occlusion and performing culling during the tree walk. |
| 460 typedef LayerIterator<LayerImpl, std::vector<LayerImpl*>, RenderSurfaceImpl, LayerIteratorActions::FrontToBack> LayerIteratorType; | 460 typedef LayerIterator<LayerImpl, std::vector<LayerImpl*>, RenderSurfaceImpl, LayerIteratorActions::FrontToBack> LayerIteratorType; |
| 461 | 461 |
| 462 // Typically when we are missing a texture and use a checkerboard quad, we s till draw the frame. However when the layer being | 462 // Typically when we are missing a texture and use a checkerboard quad, we s till draw the frame. However when the layer being |
| 463 // checkerboarded is moving due to an impl-animation, we drop the frame to a void flashing due to the texture suddenly appearing | 463 // checkerboarded is moving due to an impl-animation, we drop the frame to a void flashing due to the texture suddenly appearing |
| 464 // in the future. | 464 // in the future. |
| 465 bool drawFrame = true; | 465 bool drawFrame = true; |
| 466 | 466 |
| 467 // Make sure we have the most recent info regarding which textures have been uploaded. | |
| 468 checkForCompletedSetPixels(); | |
| 469 | |
| 470 LayerIteratorType end = LayerIteratorType::end(frame.renderSurfaceLayerList) ; | 467 LayerIteratorType end = LayerIteratorType::end(frame.renderSurfaceLayerList) ; |
| 471 for (LayerIteratorType it = LayerIteratorType::begin(frame.renderSurfaceLaye rList); it != end; ++it) { | 468 for (LayerIteratorType it = LayerIteratorType::begin(frame.renderSurfaceLaye rList); it != end; ++it) { |
| 472 RenderPass::Id targetRenderPassId = it.targetRenderSurfaceLayer()->rende rSurface()->renderPassId(); | 469 RenderPass::Id targetRenderPassId = it.targetRenderSurfaceLayer()->rende rSurface()->renderPassId(); |
| 473 RenderPass* targetRenderPass = frame.renderPassesById[targetRenderPassId ]; | 470 RenderPass* targetRenderPass = frame.renderPassesById[targetRenderPassId ]; |
| 474 | 471 |
| 475 occlusionTracker.enterLayer(it); | 472 occlusionTracker.enterLayer(it); |
| 476 | 473 |
| 477 AppendQuadsData appendQuadsData(targetRenderPass->id); | 474 AppendQuadsData appendQuadsData(targetRenderPass->id); |
| 478 | 475 |
| 479 if (it.representsContributingRenderSurface()) { | 476 if (it.representsContributingRenderSurface()) { |
| (...skipping 227 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 707 { | 704 { |
| 708 return m_proxy->hasImplThread(); | 705 return m_proxy->hasImplThread(); |
| 709 } | 706 } |
| 710 | 707 |
| 711 void LayerTreeHostImpl::ScheduleManageTiles() | 708 void LayerTreeHostImpl::ScheduleManageTiles() |
| 712 { | 709 { |
| 713 if (m_client) | 710 if (m_client) |
| 714 m_client->setNeedsManageTilesOnImplThread(); | 711 m_client->setNeedsManageTilesOnImplThread(); |
| 715 } | 712 } |
| 716 | 713 |
| 714 void LayerTreeHostImpl::DidUploadVisibleHighResolutionTile() | |
| 715 { | |
| 716 if (m_client) | |
| 717 m_client->setNeedsRedrawOnImplThread(); | |
|
nduca
2013/01/16 04:09:47
see now i dont get why this one does setNeedsRedra
brianderson
2013/01/16 20:12:22
In this case, we know we have a better frame to dr
| |
| 718 } | |
| 719 | |
| 717 bool LayerTreeHostImpl::shouldClearRootRenderPass() const | 720 bool LayerTreeHostImpl::shouldClearRootRenderPass() const |
| 718 { | 721 { |
| 719 return m_settings.shouldClearRootRenderPass; | 722 return m_settings.shouldClearRootRenderPass; |
| 720 } | 723 } |
| 721 | 724 |
| 722 void LayerTreeHostImpl::setManagedMemoryPolicy(const ManagedMemoryPolicy& policy ) | 725 void LayerTreeHostImpl::setManagedMemoryPolicy(const ManagedMemoryPolicy& policy ) |
| 723 { | 726 { |
| 724 if (m_managedMemoryPolicy == policy) | 727 if (m_managedMemoryPolicy == policy) |
| 725 return; | 728 return; |
| 726 | 729 |
| (...skipping 103 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 830 const RendererCapabilities& LayerTreeHostImpl::rendererCapabilities() const | 833 const RendererCapabilities& LayerTreeHostImpl::rendererCapabilities() const |
| 831 { | 834 { |
| 832 return m_renderer->capabilities(); | 835 return m_renderer->capabilities(); |
| 833 } | 836 } |
| 834 | 837 |
| 835 bool LayerTreeHostImpl::swapBuffers() | 838 bool LayerTreeHostImpl::swapBuffers() |
| 836 { | 839 { |
| 837 DCHECK(m_renderer); | 840 DCHECK(m_renderer); |
| 838 | 841 |
| 839 m_fpsCounter->markEndOfFrame(); | 842 m_fpsCounter->markEndOfFrame(); |
| 840 return m_renderer->swapBuffers(); | 843 bool result = m_renderer->swapBuffers(); |
| 844 | |
| 845 if (!activeTree()->AreVisibleResourcesReady()) { | |
|
nduca
2013/01/16 04:09:47
I'm confused, why are we checking this again here?
brianderson
2013/01/16 20:12:22
This checks if the active tree just drawn was inco
| |
| 846 m_client->setNeedsRedrawOnVisibleTextureUploadOnImplThread(); | |
| 847 } | |
| 848 | |
| 849 return result; | |
| 841 } | 850 } |
| 842 | 851 |
| 843 const gfx::Size& LayerTreeHostImpl::deviceViewportSize() const | 852 const gfx::Size& LayerTreeHostImpl::deviceViewportSize() const |
| 844 { | 853 { |
| 845 return m_deviceViewportSize; | 854 return m_deviceViewportSize; |
| 846 } | 855 } |
| 847 | 856 |
| 848 const LayerTreeSettings& LayerTreeHostImpl::settings() const | 857 const LayerTreeSettings& LayerTreeHostImpl::settings() const |
| 849 { | 858 { |
| 850 return m_settings; | 859 return m_settings; |
| (...skipping 48 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 899 } | 908 } |
| 900 | 909 |
| 901 void LayerTreeHostImpl::createPendingTree() | 910 void LayerTreeHostImpl::createPendingTree() |
| 902 { | 911 { |
| 903 CHECK(!m_pendingTree); | 912 CHECK(!m_pendingTree); |
| 904 m_pendingTree = LayerTreeImpl::create(this); | 913 m_pendingTree = LayerTreeImpl::create(this); |
| 905 m_client->onCanDrawStateChanged(canDraw()); | 914 m_client->onCanDrawStateChanged(canDraw()); |
| 906 m_client->onHasPendingTreeStateChanged(pendingTree()); | 915 m_client->onHasPendingTreeStateChanged(pendingTree()); |
| 907 } | 916 } |
| 908 | 917 |
| 918 // This function should not be called from within a draw, as it can trigger | |
| 919 // as spurious draw if a new visible tile gets upload. | |
| 909 void LayerTreeHostImpl::checkForCompletedSetPixels() | 920 void LayerTreeHostImpl::checkForCompletedSetPixels() |
| 910 { | 921 { |
| 911 if (m_tileManager) | 922 if (m_tileManager) |
| 912 m_tileManager->CheckForCompletedSetPixels(); | 923 m_tileManager->CheckForCompletedSetPixels(); |
| 913 } | 924 } |
| 914 | 925 |
| 915 void LayerTreeHostImpl::activatePendingTreeIfNeeded() | 926 void LayerTreeHostImpl::activatePendingTreeIfNeeded() |
| 916 { | 927 { |
| 917 if (!pendingTree()) | 928 if (!pendingTree()) |
| 918 return; | 929 return; |
| 919 | 930 |
| 920 checkForCompletedSetPixels(); | |
| 921 | |
| 922 // It's always fine to activate to an empty tree. Otherwise, only | 931 // It's always fine to activate to an empty tree. Otherwise, only |
| 923 // activate once all visible resources in pending tree are ready. | 932 // activate once all visible resources in pending tree are ready. |
| 924 if (activeTree()->RootLayer() && | 933 if (activeTree()->RootLayer() && |
| 925 !pendingTree()->AreVisibleResourcesReady()) | 934 !pendingTree()->AreVisibleResourcesReady()) |
| 926 return; | 935 return; |
| 927 | 936 |
| 928 activatePendingTree(); | 937 activatePendingTree(); |
| 929 } | 938 } |
| 930 | 939 |
| 931 void LayerTreeHostImpl::activatePendingTree() | 940 void LayerTreeHostImpl::activatePendingTree() |
| (...skipping 707 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 1639 } | 1648 } |
| 1640 | 1649 |
| 1641 skia::RefPtr<SkPicture> LayerTreeHostImpl::capturePicture() | 1650 skia::RefPtr<SkPicture> LayerTreeHostImpl::capturePicture() |
| 1642 { | 1651 { |
| 1643 LayerTreeImpl* tree = pendingTree() ? pendingTree() : activeTree(); | 1652 LayerTreeImpl* tree = pendingTree() ? pendingTree() : activeTree(); |
| 1644 LayerImpl* layer = getNonCompositedContentLayerRecursive(tree->RootLayer()); | 1653 LayerImpl* layer = getNonCompositedContentLayerRecursive(tree->RootLayer()); |
| 1645 return layer ? layer->getPicture() : skia::RefPtr<SkPicture>(); | 1654 return layer ? layer->getPicture() : skia::RefPtr<SkPicture>(); |
| 1646 } | 1655 } |
| 1647 | 1656 |
| 1648 } // namespace cc | 1657 } // namespace cc |
| OLD | NEW |