summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorreveman@chromium.org <reveman@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2013-01-22 03:43:17 +0000
committerreveman@chromium.org <reveman@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2013-01-22 03:43:17 +0000
commit4c0e1bbba0cf5ad73525cc658bf864479dbf8d4c (patch)
treed688aaf8d708256814495e9cb221428b4a008224
parentc8d7155f2e7523afba19912e1801174411025067 (diff)
downloadchromium_src-4c0e1bbba0cf5ad73525cc658bf864479dbf8d4c.zip
chromium_src-4c0e1bbba0cf5ad73525cc658bf864479dbf8d4c.tar.gz
chromium_src-4c0e1bbba0cf5ad73525cc658bf864479dbf8d4c.tar.bz2
cc: Have smoothness take priority during scroll and pinch zoom.
Set tree_priority member of global state that impacts tile priority to SMOOTHNESS_TAKES_PRIORITY during scroll or pinch gesture. Restore it 500 ms after last scroll or pinch event was received. BUG=166799 Review URL: https://chromiumcodereview.appspot.com/11911003 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@177975 0039d316-1c4b-4281-b951-d872f2087c98
-rw-r--r--cc/layer_tree_host_impl.cc4
-rw-r--r--cc/thread_proxy.cc44
-rw-r--r--cc/thread_proxy.h3
3 files changed, 51 insertions, 0 deletions
diff --git a/cc/layer_tree_host_impl.cc b/cc/layer_tree_host_impl.cc
index ce03f35..5f18652 100644
--- a/cc/layer_tree_host_impl.cc
+++ b/cc/layer_tree_host_impl.cc
@@ -1187,6 +1187,7 @@ InputHandlerClient::ScrollStatus LayerTreeHostImpl::scrollBegin(gfx::Point viewp
// events are already in local layer coordinates so we can just apply them directly.
m_scrollDeltaIsInViewportSpace = (type == Gesture);
m_numImplThreadScrolls++;
+ m_client->renewTreePriority();
setNeedsUpdateDrawProperties();
return ScrollStarted;
}
@@ -1310,6 +1311,7 @@ bool LayerTreeHostImpl::scrollBy(const gfx::Point& viewportPoint,
if (didScroll) {
m_client->setNeedsCommitOnImplThread();
m_client->setNeedsRedrawOnImplThread();
+ m_client->renewTreePriority();
setNeedsUpdateDrawProperties();
}
return didScroll;
@@ -1331,6 +1333,7 @@ void LayerTreeHostImpl::pinchGestureBegin()
{
m_pinchGestureActive = true;
m_previousPinchAnchor = gfx::Point();
+ m_client->renewTreePriority();
}
void LayerTreeHostImpl::pinchGestureUpdate(float magnifyDelta, gfx::Point anchor)
@@ -1364,6 +1367,7 @@ void LayerTreeHostImpl::pinchGestureUpdate(float magnifyDelta, gfx::Point anchor
m_client->setNeedsCommitOnImplThread();
m_client->setNeedsRedrawOnImplThread();
+ m_client->renewTreePriority();
setNeedsUpdateDrawProperties();
}
diff --git a/cc/thread_proxy.cc b/cc/thread_proxy.cc
index 5f371fc..4a4d136 100644
--- a/cc/thread_proxy.cc
+++ b/cc/thread_proxy.cc
@@ -26,6 +26,9 @@ namespace {
// Measured in seconds.
const double contextRecreationTickRate = 0.03;
+// Measured in seconds.
+const double smoothnessTakesPriorityExpirationDelay = 0.5;
+
} // namespace
namespace cc {
@@ -58,6 +61,7 @@ ThreadProxy::ThreadProxy(LayerTreeHost* layerTreeHost, scoped_ptr<Thread> implTh
, m_insideDraw(false)
, m_totalCommitCount(0)
, m_deferCommits(false)
+ , m_renewTreePriorityOnImplThreadPending(false)
{
TRACE_EVENT0("cc", "ThreadProxy::ThreadProxy");
DCHECK(isMainThread());
@@ -1103,15 +1107,55 @@ void ThreadProxy::capturePictureOnImplThread(CompletionEvent* completion, skia::
void ThreadProxy::renewTreePriority()
{
+ bool smoothnessTakesPriority =
+ m_layerTreeHostImpl->pinchGestureActive() ||
+ m_layerTreeHostImpl->currentlyScrollingLayer();
+
+ // Update expiration time if smoothness currently takes priority.
+ if (smoothnessTakesPriority) {
+ m_smoothnessTakesPriorityExpirationTime = base::TimeTicks::Now() +
+ base::TimeDelta::FromMilliseconds(
+ smoothnessTakesPriorityExpirationDelay * 1000);
+ }
+
// We use the same priority for both trees by default.
TreePriority priority = SAME_PRIORITY_FOR_BOTH_TREES;
+ // Smoothness takes priority if expiration time is in the future.
+ if (m_smoothnessTakesPriorityExpirationTime > base::TimeTicks::Now())
+ priority = SMOOTHNESS_TAKES_PRIORITY;
+
// 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);
+
+ // Need to make sure a delayed task is posted when we have smoothness
+ // takes priority expiration time in the future.
+ if (m_smoothnessTakesPriorityExpirationTime <= base::TimeTicks::Now())
+ return;
+ if (m_renewTreePriorityOnImplThreadPending)
+ return;
+
+ base::TimeDelta delay = m_smoothnessTakesPriorityExpirationTime -
+ base::TimeTicks::Now();
+
+ Proxy::implThread()->postDelayedTask(
+ base::Bind(&ThreadProxy::renewTreePriorityOnImplThread,
+ m_weakFactoryOnImplThread.GetWeakPtr()),
+ delay.InMilliseconds());
+
+ m_renewTreePriorityOnImplThreadPending = true;
+}
+
+void ThreadProxy::renewTreePriorityOnImplThread()
+{
+ DCHECK(m_renewTreePriorityOnImplThreadPending);
+ m_renewTreePriorityOnImplThreadPending = false;
+
+ renewTreePriority();
}
} // namespace cc
diff --git a/cc/thread_proxy.h b/cc/thread_proxy.h
index e5e41ab..4d44cd0 100644
--- a/cc/thread_proxy.h
+++ b/cc/thread_proxy.h
@@ -204,6 +204,9 @@ private:
bool m_deferCommits;
scoped_ptr<BeginFrameAndCommitState> m_pendingDeferredCommit;
+
+ base::TimeTicks m_smoothnessTakesPriorityExpirationTime;
+ bool m_renewTreePriorityOnImplThreadPending;
};
} // namespace cc