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

Unified Diff: cc/layer_tree_host.cc

Issue 11273029: Throttle prepaints to avoid colliding with post-load work (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: rebased Created 8 years, 2 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « cc/layer_tree_host.h ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: cc/layer_tree_host.cc
diff --git a/cc/layer_tree_host.cc b/cc/layer_tree_host.cc
index 80e9e35fe7379f8ef169436d322282d6499f8114..200f8e64b5a6656b13bfdb46aaea159131da2941 100644
--- a/cc/layer_tree_host.cc
+++ b/cc/layer_tree_host.cc
@@ -8,6 +8,7 @@
#include "Region.h"
#include "base/debug/trace_event.h"
+#include "base/message_loop.h"
#include "cc/font_atlas.h"
#include "cc/graphics_context.h"
#include "cc/heads_up_display_layer.h"
@@ -364,6 +365,10 @@ void LayerTreeHost::setNeedsAnimate()
void LayerTreeHost::setNeedsCommit()
{
+ if (!m_prepaintCallback.IsCancelled()) {
+ TRACE_EVENT_INSTANT0("cc", "LayerTreeHost::setNeedsCommit::cancel prepaint");
+ m_prepaintCallback.Cancel();
+ }
m_proxy->setNeedsCommit();
}
@@ -535,13 +540,24 @@ void LayerTreeHost::updateLayers(Layer* rootLayer, TextureUpdateQueue& queue)
m_partialTextureUpdateRequests = 0;
bool needMoreUpdates = paintLayerContents(updateList, queue);
- if (m_triggerIdleUpdates && needMoreUpdates)
- setNeedsCommit();
+ if (m_triggerIdleUpdates && needMoreUpdates) {
+ TRACE_EVENT0("cc", "LayerTreeHost::updateLayers::posting prepaint task");
+ m_prepaintCallback.Reset(base::Bind(&LayerTreeHost::triggerPrepaint, base::Unretained(this)));
+ static base::TimeDelta prepaintDelay = base::TimeDelta::FromMilliseconds(100);
+ MessageLoop::current()->PostDelayedTask(FROM_HERE, m_prepaintCallback.callback(), prepaintDelay);
+ }
for (size_t i = 0; i < updateList.size(); ++i)
updateList[i]->clearRenderSurface();
}
+void LayerTreeHost::triggerPrepaint()
+{
+ m_prepaintCallback.Cancel();
+ TRACE_EVENT0("cc", "LayerTreeHost::triggerPrepaint");
+ setNeedsCommit();
+}
+
void LayerTreeHost::setPrioritiesForSurfaces(size_t surfaceMemoryBytes)
{
// Surfaces have a place holder for their memory since they are managed
« no previous file with comments | « cc/layer_tree_host.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698