aura: Drop unnecessary composites
During a composite pass, there are many commits that occur. The results of these commits will be visible immediately, so we can cull the scheduleComposite() calls that occur.
BUG=131059
TEST=manual: run with --force-compositing-mode; go to google.com; observe only one draw per cursor blink via chrome://tracing
Review URL: https://chromiumcodereview.appspot.com/10537028
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@140876 0039d316-1c4b-4281-b951-d872f2087c98
diff --git a/ui/compositor/compositor.cc b/ui/compositor/compositor.cc
index 6d5e1f1..5dc991e 100644
--- a/ui/compositor/compositor.cc
+++ b/ui/compositor/compositor.cc
@@ -131,7 +131,10 @@
widget_(widget),
root_web_layer_(WebKit::WebLayer::create()),
swap_posted_(false),
- device_scale_factor_(0.0f) {
+ device_scale_factor_(0.0f),
+ last_started_frame_(0),
+ last_ended_frame_(0),
+ disable_schedule_composite_(false) {
WebKit::WebLayerTreeView::Settings settings;
CommandLine* command_line = CommandLine::ForCurrentProcess();
settings.showFPSCounter =
@@ -204,6 +207,8 @@
if (!root_layer_)
return;
+ last_started_frame_++;
+
// TODO(nduca): Temporary while compositor calls
// compositeImmediately() directly.
layout();
@@ -290,8 +295,12 @@
}
void Compositor::layout() {
+ // We're sending damage that will be addressed during this composite
+ // cycle, so we don't need to schedule another composite to address it.
+ disable_schedule_composite_ = true;
if (root_layer_)
root_layer_->SendDamagedRects();
+ disable_schedule_composite_ = false;
}
void Compositor::applyScrollAndScale(const WebKit::WebSize& scrollDelta,
@@ -323,7 +332,8 @@
}
void Compositor::scheduleComposite() {
- ScheduleDraw();
+ if (!disable_schedule_composite_)
+ ScheduleDraw();
}
void Compositor::SwizzleRGBAToBGRAAndFlip(unsigned char* pixels,
@@ -350,6 +360,7 @@
}
void Compositor::NotifyEnd() {
+ last_ended_frame_++;
FOR_EACH_OBSERVER(CompositorObserver,
observer_list_,
OnCompositingEnded(this));