diff options
author | reveman@chromium.org <reveman@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2013-01-21 16:54:30 +0000 |
---|---|---|
committer | reveman@chromium.org <reveman@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2013-01-21 16:54:30 +0000 |
commit | 362f1e8b4d2237109ac460e0f77fff0202cf88c7 (patch) | |
tree | 02d479aa2bcf22da79396ea8a8a96d7e211f78ec | |
parent | 0f05dfd6b5da3077ee8aa09dae22f25cc5dfd9e4 (diff) | |
download | chromium_src-362f1e8b4d2237109ac460e0f77fff0202cf88c7.zip chromium_src-362f1e8b4d2237109ac460e0f77fff0202cf88c7.tar.gz chromium_src-362f1e8b4d2237109ac460e0f77fff0202cf88c7.tar.bz2 |
cc: Add "new content takes priority" setting to GlobalStateThatImpactsTilePriority.
This replaces smoothness_takes_priority field with a tree_priority enum.
Possible values are SAME_PRIORITY_FOR_BOTH_TREES, SMOOTHNESS_TAKES_PRIORITY
and NEW_CONTENT_TAKES_PRIORITY. NEW_CONTENT_TAKES_PRIORITY is used
when we need a new frame before we can draw and it makes the tile manager
favor tiles in pending tree.
BUG=171054
Review URL: https://chromiumcodereview.appspot.com/12016034
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@177936 0039d316-1c4b-4281-b951-d872f2087c98
-rw-r--r-- | cc/layer_tree_host_impl.cc | 16 | ||||
-rw-r--r-- | cc/layer_tree_host_impl.h | 3 | ||||
-rw-r--r-- | cc/layer_tree_host_impl_unittest.cc | 1 | ||||
-rw-r--r-- | cc/single_thread_proxy.h | 1 | ||||
-rw-r--r-- | cc/test/fake_layer_tree_host_impl_client.h | 1 | ||||
-rw-r--r-- | cc/thread_proxy.cc | 14 | ||||
-rw-r--r-- | cc/thread_proxy.h | 2 | ||||
-rw-r--r-- | cc/tile_manager.cc | 19 | ||||
-rw-r--r-- | cc/tile_priority.h | 11 |
9 files changed, 59 insertions, 9 deletions
diff --git a/cc/layer_tree_host_impl.cc b/cc/layer_tree_host_impl.cc index f4324bc..82e518f 100644 --- a/cc/layer_tree_host_impl.cc +++ b/cc/layer_tree_host_impl.cc @@ -695,6 +695,7 @@ void LayerTreeHostImpl::enforceManagedMemoryPolicy(const ManagedMemoryPolicy& po pendingTree()->SetContentsTexturesPurged(); m_client->setNeedsCommitOnImplThread(); m_client->onCanDrawStateChanged(canDraw()); + m_client->renewTreePriority(); } m_client->sendManagedMemoryStats(); @@ -970,6 +971,7 @@ void LayerTreeHostImpl::activatePendingTree() m_client->onCanDrawStateChanged(canDraw()); m_client->onHasPendingTreeStateChanged(pendingTree()); m_client->setNeedsRedrawOnImplThread(); + m_client->renewTreePriority(); } void LayerTreeHostImpl::setVisible(bool visible) @@ -1649,6 +1651,20 @@ void LayerTreeHostImpl::animateScrollbarsRecursive(LayerImpl* layer, base::TimeT animateScrollbarsRecursive(layer->children()[i], time); } +void LayerTreeHostImpl::setTreePriority(TreePriority priority) +{ + if (!m_tileManager) + return; + + GlobalStateThatImpactsTilePriority new_state(m_tileManager->GlobalState()); + if (new_state.tree_priority == priority) + return; + + TRACE_COUNTER_ID1("cc", "TreePriority", this, priority); + new_state.tree_priority = priority; + m_tileManager->SetGlobalState(new_state); +} + // static LayerImpl* LayerTreeHostImpl::getNonCompositedContentLayerRecursive(LayerImpl* layer) { diff --git a/cc/layer_tree_host_impl.h b/cc/layer_tree_host_impl.h index 02da353c..3a614b3 100644 --- a/cc/layer_tree_host_impl.h +++ b/cc/layer_tree_host_impl.h @@ -59,6 +59,7 @@ public: virtual bool reduceContentsTextureMemoryOnImplThread(size_t limitBytes, int priorityCutoff) = 0; virtual void sendManagedMemoryStats() = 0; virtual bool isInsideDraw() = 0; + virtual void renewTreePriority() = 0; }; // LayerTreeHostImpl owns the LayerImpl tree as well as associated rendering state @@ -260,6 +261,8 @@ public: bool pinchGestureActive() const { return m_pinchGestureActive; } + void setTreePriority(TreePriority priority); + protected: LayerTreeHostImpl(const LayerTreeSettings&, LayerTreeHostImplClient*, Proxy*); void activatePendingTree(); diff --git a/cc/layer_tree_host_impl_unittest.cc b/cc/layer_tree_host_impl_unittest.cc index ea28ae8..7dadfde 100644 --- a/cc/layer_tree_host_impl_unittest.cc +++ b/cc/layer_tree_host_impl_unittest.cc @@ -103,6 +103,7 @@ public: virtual bool reduceContentsTextureMemoryOnImplThread(size_t limitBytes, int priorityCutoff) OVERRIDE { return m_reduceMemoryResult; } virtual void sendManagedMemoryStats() OVERRIDE { } virtual bool isInsideDraw() OVERRIDE { return false; } + virtual void renewTreePriority() OVERRIDE { } void setReduceMemoryResult(bool reduceMemoryResult) { m_reduceMemoryResult = reduceMemoryResult; } diff --git a/cc/single_thread_proxy.h b/cc/single_thread_proxy.h index 155730c..e1ce142 100644 --- a/cc/single_thread_proxy.h +++ b/cc/single_thread_proxy.h @@ -62,6 +62,7 @@ public: virtual bool reduceContentsTextureMemoryOnImplThread(size_t limitBytes, int priorityCutoff) OVERRIDE; virtual void sendManagedMemoryStats() OVERRIDE; virtual bool isInsideDraw() OVERRIDE; + virtual void renewTreePriority() OVERRIDE { } // Called by the legacy path where RenderWidget does the scheduling. void compositeImmediately(); diff --git a/cc/test/fake_layer_tree_host_impl_client.h b/cc/test/fake_layer_tree_host_impl_client.h index daecdc9..45d9200 100644 --- a/cc/test/fake_layer_tree_host_impl_client.h +++ b/cc/test/fake_layer_tree_host_impl_client.h @@ -30,6 +30,7 @@ class FakeLayerTreeHostImplClient : public LayerTreeHostImplClient { virtual bool reduceContentsTextureMemoryOnImplThread(size_t, int) OVERRIDE; virtual void sendManagedMemoryStats() OVERRIDE { } virtual bool isInsideDraw() OVERRIDE; + virtual void renewTreePriority() OVERRIDE { } }; } // namespace cc diff --git a/cc/thread_proxy.cc b/cc/thread_proxy.cc index d3aac84..5f371fc 100644 --- a/cc/thread_proxy.cc +++ b/cc/thread_proxy.cc @@ -12,6 +12,7 @@ #include "cc/frame_rate_controller.h" #include "cc/input_handler.h" #include "cc/layer_tree_host.h" +#include "cc/layer_tree_impl.h" #include "cc/output_surface.h" #include "cc/prioritized_resource_manager.h" #include "cc/scheduler.h" @@ -1100,4 +1101,17 @@ void ThreadProxy::capturePictureOnImplThread(CompletionEvent* completion, skia:: completion->signal(); } +void ThreadProxy::renewTreePriority() +{ + // We use the same priority for both trees by default. + TreePriority priority = SAME_PRIORITY_FOR_BOTH_TREES; + + // New content always takes priority when we have an active tree with + // evicted resources. + if (m_layerTreeHostImpl->activeTree()->ContentsTexturesPurged()) + priority = NEW_CONTENT_TAKES_PRIORITY; + + m_layerTreeHostImpl->setTreePriority(priority); +} + } // namespace cc diff --git a/cc/thread_proxy.h b/cc/thread_proxy.h index c164539..e5e41ab 100644 --- a/cc/thread_proxy.h +++ b/cc/thread_proxy.h @@ -71,6 +71,7 @@ public: virtual bool reduceContentsTextureMemoryOnImplThread(size_t limitBytes, int priorityCutoff) OVERRIDE; virtual void sendManagedMemoryStats() OVERRIDE; virtual bool isInsideDraw() OVERRIDE; + virtual void renewTreePriority() OVERRIDE; // SchedulerClient implementation virtual void scheduledActionBeginFrame() OVERRIDE; @@ -142,6 +143,7 @@ private: void setNeedsForcedCommitOnImplThread(); void commitPendingOnImplThreadForTesting(CommitPendingRequest* request); void capturePictureOnImplThread(CompletionEvent*, skia::RefPtr<SkPicture>*); + void renewTreePriorityOnImplThread(); // Accessed on main thread only. bool m_animateRequested; // Set only when setNeedsAnimate is called. diff --git a/cc/tile_manager.cc b/cc/tile_manager.cc index 4482b36..aa4c8bd 100644 --- a/cc/tile_manager.cc +++ b/cc/tile_manager.cc @@ -179,8 +179,8 @@ void TileManager::ManageTiles() { manage_tiles_pending_ = false; ++manage_tiles_call_count_; - const bool smoothness_takes_priority = - global_state_.smoothness_takes_priority; + const TreePriority tree_priority = global_state_.tree_priority; + TRACE_COUNTER_ID1("cc", "TreePriority", this, tree_priority); // For each tree, bin into different categories of tiles. for (TileVector::iterator it = tiles_.begin(); it != tiles_.end(); ++it) { @@ -188,10 +188,17 @@ void TileManager::ManageTiles() { ManagedTileState& mts = tile->managed_state(); TilePriority prio; - if (smoothness_takes_priority) - prio = tile->priority(ACTIVE_TREE); - else - prio = tile->combined_priority(); + switch (tree_priority) { + case SAME_PRIORITY_FOR_BOTH_TREES: + prio = tile->combined_priority(); + break; + case SMOOTHNESS_TAKES_PRIORITY: + prio = tile->priority(ACTIVE_TREE); + break; + case NEW_CONTENT_TAKES_PRIORITY: + prio = tile->priority(PENDING_TREE); + break; + } mts.resolution = prio.resolution; mts.time_to_needed_in_seconds = prio.time_to_needed_in_seconds(); diff --git a/cc/tile_priority.h b/cc/tile_priority.h index 615bc75..fb90060 100644 --- a/cc/tile_priority.h +++ b/cc/tile_priority.h @@ -93,20 +93,25 @@ enum TileMemoryLimitPolicy { ALLOW_ANYTHING, // Venti. }; +enum TreePriority { + SAME_PRIORITY_FOR_BOTH_TREES, + SMOOTHNESS_TAKES_PRIORITY, + NEW_CONTENT_TAKES_PRIORITY +}; + class GlobalStateThatImpactsTilePriority { public: GlobalStateThatImpactsTilePriority() : memory_limit_policy(ALLOW_NOTHING) , memory_limit_in_bytes(0) - , smoothness_takes_priority(false) { + , tree_priority(SAME_PRIORITY_FOR_BOTH_TREES) { } TileMemoryLimitPolicy memory_limit_policy; size_t memory_limit_in_bytes; - // Set when scrolling. - bool smoothness_takes_priority; + TreePriority tree_priority; }; } // namespace cc |