Limit composition to every 15 ms, may want to try increasing this value
authorBenoit Girard <b56girard@gmail.com>
Mon, 06 Feb 2012 13:51:33 -0500
changeset 89077 a88d4cc81de327dee03d1db307366a6ace15677a
parent 89076 ea664069a4ff505b5591a0b7edb004048991e8a5
child 89078 06a0f954ccc247b68ebd64860f499b50ddb15e77
push id22242
push userkgupta@mozilla.com
push dateWed, 14 Mar 2012 15:19:09 +0000
treeherdermozilla-central@936ef50fa498 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
milestone12.0a1
first release with
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
last release without
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
Limit composition to every 15 ms, may want to try increasing this value
gfx/layers/ipc/CompositorParent.cpp
gfx/layers/ipc/CompositorParent.h
--- a/gfx/layers/ipc/CompositorParent.cpp
+++ b/gfx/layers/ipc/CompositorParent.cpp
@@ -127,19 +127,25 @@ CompositorParent::ScheduleResumeOnCompos
 
 void
 CompositorParent::ScheduleComposition()
 {
   if (mCurrentCompositeTask) {
     return;
   }
 
+  TimeDuration delta = mozilla::TimeStamp::Now() - mLastCompose;
+
   printf_stderr("Schedule composition\n");
   mCurrentCompositeTask = NewRunnableMethod(this, &CompositorParent::Composite);
-  MessageLoop::current()->PostTask(FROM_HERE, mCurrentCompositeTask);
+  if (delta.ToMilliseconds() < 15) {
+    MessageLoop::current()->PostDelayedTask(FROM_HERE, mCurrentCompositeTask, 15 - delta.ToMilliseconds());
+  } else {
+    MessageLoop::current()->PostTask(FROM_HERE, mCurrentCompositeTask);
+  }
 
 // Test code for async scrolling.
 #ifdef OMTC_TEST_ASYNC_SCROLLING
   static bool scrollScheduled = false;
   if (!scrollScheduled) {
     CancelableTask *composeTask2 = NewRunnableMethod(this,
                                                      &CompositorParent::TestScroll);
     MessageLoop::current()->PostDelayedTask(FROM_HERE, composeTask2, 500);
@@ -172,18 +178,18 @@ CompositorParent::Composite()
   gfx3DMatrix worldTransform;
   gfxPoint3D offset(-mScrollOffset.x, -mScrollOffset.y, 0.0f);
   printf_stderr("Correcting for position fixed %i, %i\n", -mScrollOffset.x, -mScrollOffset.y);
   worldTransform.Translate(offset);
   worldTransform.Scale(mXScale, mYScale, 1.0f);
   Layer* root = mLayerManager->GetRoot();
   root->AsShadowLayer()->SetShadowTransform(worldTransform);
 
-
   mLayerManager->EndEmptyTransaction();
+  mLastCompose = mozilla::TimeStamp::Now();
 }
 
 // Go down shadow layer tree, setting properties to match their non-shadow
 // counterparts.
 static void
 SetShadowProperties(Layer* aLayer)
 {
   // FIXME: Bug 717688 -- Do these updates in ShadowLayersParent::RecvUpdate.
--- a/gfx/layers/ipc/CompositorParent.h
+++ b/gfx/layers/ipc/CompositorParent.h
@@ -126,16 +126,17 @@ private:
    * accordingly.
    */
   void RequestViewTransform();
 #endif
 
   nsRefPtr<LayerManager> mLayerManager;
   nsIWidget* mWidget;
   CancelableTask *mCurrentCompositeTask;
+  TimeStamp mLastCompose;
 
   bool mPaused;
   float mXScale;
   float mYScale;
   nsIntPoint mScrollOffset;
 
   DISALLOW_EVIL_CONSTRUCTORS(CompositorParent);
 };