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 454 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 465 occlusionTracker.setNonOccludingScreenSpaceRectsContainer(&frame.nonOccl udingScreenSpaceRects); | 465 occlusionTracker.setNonOccludingScreenSpaceRectsContainer(&frame.nonOccl udingScreenSpaceRects); |
| 466 | 466 |
| 467 // Add quads to the Render passes in FrontToBack order to allow for testing occlusion and performing culling during the tree walk. | 467 // Add quads to the Render passes in FrontToBack order to allow for testing occlusion and performing culling during the tree walk. |
| 468 typedef LayerIterator<LayerImpl, std::vector<LayerImpl*>, RenderSurfaceImpl, LayerIteratorActions::FrontToBack> LayerIteratorType; | 468 typedef LayerIterator<LayerImpl, std::vector<LayerImpl*>, RenderSurfaceImpl, LayerIteratorActions::FrontToBack> LayerIteratorType; |
| 469 | 469 |
| 470 // Typically when we are missing a texture and use a checkerboard quad, we s till draw the frame. However when the layer being | 470 // Typically when we are missing a texture and use a checkerboard quad, we s till draw the frame. However when the layer being |
| 471 // checkerboarded is moving due to an impl-animation, we drop the frame to a void flashing due to the texture suddenly appearing | 471 // checkerboarded is moving due to an impl-animation, we drop the frame to a void flashing due to the texture suddenly appearing |
| 472 // in the future. | 472 // in the future. |
| 473 bool drawFrame = true; | 473 bool drawFrame = true; |
| 474 | 474 |
| 475 // Make sure we have the most recent info regarding which textures have been uploaded. | |
| 476 checkForCompletedSetPixels(); | |
| 477 | |
| 478 LayerIteratorType end = LayerIteratorType::end(frame.renderSurfaceLayerList) ; | 475 LayerIteratorType end = LayerIteratorType::end(frame.renderSurfaceLayerList) ; |
| 479 for (LayerIteratorType it = LayerIteratorType::begin(frame.renderSurfaceLaye rList); it != end; ++it) { | 476 for (LayerIteratorType it = LayerIteratorType::begin(frame.renderSurfaceLaye rList); it != end; ++it) { |
| 480 RenderPass::Id targetRenderPassId = it.targetRenderSurfaceLayer()->rende rSurface()->renderPassId(); | 477 RenderPass::Id targetRenderPassId = it.targetRenderSurfaceLayer()->rende rSurface()->renderPassId(); |
| 481 RenderPass* targetRenderPass = frame.renderPassesById[targetRenderPassId ]; | 478 RenderPass* targetRenderPass = frame.renderPassesById[targetRenderPassId ]; |
| 482 | 479 |
| 483 occlusionTracker.enterLayer(it); | 480 occlusionTracker.enterLayer(it); |
| 484 | 481 |
| 485 AppendQuadsData appendQuadsData(targetRenderPass->id); | 482 AppendQuadsData appendQuadsData(targetRenderPass->id); |
| 486 | 483 |
| 487 if (it.representsContributingRenderSurface()) { | 484 if (it.representsContributingRenderSurface()) { |
| (...skipping 227 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 715 { | 712 { |
| 716 return m_proxy->hasImplThread(); | 713 return m_proxy->hasImplThread(); |
| 717 } | 714 } |
| 718 | 715 |
| 719 void LayerTreeHostImpl::ScheduleManageTiles() | 716 void LayerTreeHostImpl::ScheduleManageTiles() |
| 720 { | 717 { |
| 721 if (m_client) | 718 if (m_client) |
| 722 m_client->setNeedsManageTilesOnImplThread(); | 719 m_client->setNeedsManageTilesOnImplThread(); |
| 723 } | 720 } |
| 724 | 721 |
| 722 void LayerTreeHostImpl::DidUploadVisibleHighResolutionTile() | |
| 723 { | |
| 724 if (m_client) | |
| 725 m_client->didUploadVisibleHighResolutionTileOnImplTread(); | |
| 726 } | |
| 727 | |
| 725 bool LayerTreeHostImpl::shouldClearRootRenderPass() const | 728 bool LayerTreeHostImpl::shouldClearRootRenderPass() const |
| 726 { | 729 { |
| 727 return m_settings.shouldClearRootRenderPass; | 730 return m_settings.shouldClearRootRenderPass; |
| 728 } | 731 } |
| 729 | 732 |
| 730 void LayerTreeHostImpl::setManagedMemoryPolicy(const ManagedMemoryPolicy& policy ) | 733 void LayerTreeHostImpl::setManagedMemoryPolicy(const ManagedMemoryPolicy& policy ) |
| 731 { | 734 { |
| 732 if (m_managedMemoryPolicy == policy) | 735 if (m_managedMemoryPolicy == policy) |
| 733 return; | 736 return; |
| 734 | 737 |
| (...skipping 106 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 841 } | 844 } |
| 842 | 845 |
| 843 const RendererCapabilities& LayerTreeHostImpl::rendererCapabilities() const | 846 const RendererCapabilities& LayerTreeHostImpl::rendererCapabilities() const |
| 844 { | 847 { |
| 845 return m_renderer->capabilities(); | 848 return m_renderer->capabilities(); |
| 846 } | 849 } |
| 847 | 850 |
| 848 bool LayerTreeHostImpl::swapBuffers() | 851 bool LayerTreeHostImpl::swapBuffers() |
| 849 { | 852 { |
| 850 DCHECK(m_renderer); | 853 DCHECK(m_renderer); |
| 851 return m_renderer->swapBuffers(); | 854 bool result = m_renderer->swapBuffers(); |
| 855 | |
| 856 if (m_settings.implSidePainting && | |
| 857 !activeTree()->AreVisibleResourcesReady()) { | |
| 858 m_client->didSwapUseIncompleteTextureOnImplThread(); | |
| 859 } | |
| 860 | |
| 861 return result; | |
| 852 } | 862 } |
| 853 | 863 |
| 854 const gfx::Size& LayerTreeHostImpl::deviceViewportSize() const | 864 const gfx::Size& LayerTreeHostImpl::deviceViewportSize() const |
| 855 { | 865 { |
| 856 return m_deviceViewportSize; | 866 return m_deviceViewportSize; |
| 857 } | 867 } |
| 858 | 868 |
| 859 const LayerTreeSettings& LayerTreeHostImpl::settings() const | 869 const LayerTreeSettings& LayerTreeHostImpl::settings() const |
| 860 { | 870 { |
| 861 return m_settings; | 871 return m_settings; |
| (...skipping 53 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 915 } | 925 } |
| 916 | 926 |
| 917 void LayerTreeHostImpl::createPendingTree() | 927 void LayerTreeHostImpl::createPendingTree() |
| 918 { | 928 { |
| 919 CHECK(!m_pendingTree); | 929 CHECK(!m_pendingTree); |
| 920 m_pendingTree = LayerTreeImpl::create(this); | 930 m_pendingTree = LayerTreeImpl::create(this); |
| 921 m_client->onCanDrawStateChanged(canDraw()); | 931 m_client->onCanDrawStateChanged(canDraw()); |
| 922 m_client->onHasPendingTreeStateChanged(pendingTree()); | 932 m_client->onHasPendingTreeStateChanged(pendingTree()); |
| 923 } | 933 } |
| 924 | 934 |
| 935 // This function should not be called from within a draw, as it can trigger | |
| 936 // as spurious draw if a new visible tile gets upload. | |
| 925 void LayerTreeHostImpl::checkForCompletedSetPixels() | 937 void LayerTreeHostImpl::checkForCompletedSetPixels() |
| 926 { | 938 { |
|
nduca
2013/01/17 22:05:18
Please add a member bool inside_draw_ and then do
brianderson
2013/01/18 00:08:18
Decided to add and use LayerTreeHostImplClient::is
| |
| 927 if (m_tileManager) | 939 if (m_tileManager) |
| 928 m_tileManager->CheckForCompletedSetPixels(); | 940 m_tileManager->CheckForCompletedSetPixels(); |
| 929 } | 941 } |
| 930 | 942 |
| 931 void LayerTreeHostImpl::activatePendingTreeIfNeeded() | 943 void LayerTreeHostImpl::activatePendingTreeIfNeeded() |
| 932 { | 944 { |
| 933 if (!pendingTree()) | 945 if (!pendingTree()) |
| 934 return; | 946 return; |
| 935 | 947 |
| 936 checkForCompletedSetPixels(); | |
| 937 | |
| 938 // It's always fine to activate to an empty tree. Otherwise, only | 948 // It's always fine to activate to an empty tree. Otherwise, only |
| 939 // activate once all visible resources in pending tree are ready. | 949 // activate once all visible resources in pending tree are ready. |
| 940 if (activeTree()->RootLayer() && | 950 if (activeTree()->RootLayer() && |
| 941 !pendingTree()->AreVisibleResourcesReady()) | 951 !pendingTree()->AreVisibleResourcesReady()) |
| 942 return; | 952 return; |
| 943 | 953 |
| 944 activatePendingTree(); | 954 activatePendingTree(); |
| 945 } | 955 } |
| 946 | 956 |
| 947 void LayerTreeHostImpl::activatePendingTree() | 957 void LayerTreeHostImpl::activatePendingTree() |
| (...skipping 723 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 1671 } | 1681 } |
| 1672 | 1682 |
| 1673 skia::RefPtr<SkPicture> LayerTreeHostImpl::capturePicture() | 1683 skia::RefPtr<SkPicture> LayerTreeHostImpl::capturePicture() |
| 1674 { | 1684 { |
| 1675 LayerTreeImpl* tree = pendingTree() ? pendingTree() : activeTree(); | 1685 LayerTreeImpl* tree = pendingTree() ? pendingTree() : activeTree(); |
| 1676 LayerImpl* layer = getNonCompositedContentLayerRecursive(tree->RootLayer()); | 1686 LayerImpl* layer = getNonCompositedContentLayerRecursive(tree->RootLayer()); |
| 1677 return layer ? layer->getPicture() : skia::RefPtr<SkPicture>(); | 1687 return layer ? layer->getPicture() : skia::RefPtr<SkPicture>(); |
| 1678 } | 1688 } |
| 1679 | 1689 |
| 1680 } // namespace cc | 1690 } // namespace cc |
| OLD | NEW |