Bug 958596 - Print the APZC tree for debugging. r=kats
authorBotond Ballo <botond@mozilla.com>
Wed, 22 Jan 2014 15:09:03 -0500
changeset 171549 12eceba2ed2b61fe8d9055016240851da4ac47c5
parent 171548 3da14f8555f751001940f61bca5e6926f7bb2ab3
child 171550 62b54b8fa885be299d138034b2ff7470317db429
push id26328
push userryanvm@gmail.com
push dateMon, 03 Mar 2014 21:52:32 +0000
treeherdermozilla-central@93443ede8152 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewerskats
bugs958596
milestone30.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
Bug 958596 - Print the APZC tree for debugging. r=kats
gfx/layers/composite/APZCTreeManager.cpp
gfx/layers/composite/APZCTreeManager.h
--- a/gfx/layers/composite/APZCTreeManager.cpp
+++ b/gfx/layers/composite/APZCTreeManager.cpp
@@ -31,21 +31,23 @@ namespace layers {
 
 float APZCTreeManager::sDPI = 160.0;
 
 // Pref that enables printing of the APZC tree for debugging.
 static bool gPrintApzcTree = false;
 
 APZCTreeManager::APZCTreeManager()
     : mTreeLock("APZCTreeLock"),
-      mTouchCount(0)
+      mTouchCount(0),
+      mApzcTreeLog("apzctree")
 {
   MOZ_ASSERT(NS_IsMainThread());
   AsyncPanZoomController::InitializeGlobalState();
   Preferences::AddBoolVarCache(&gPrintApzcTree, "apz.printtree", gPrintApzcTree);
+  mApzcTreeLog.ConditionOnPref(&gPrintApzcTree);
 }
 
 APZCTreeManager::~APZCTreeManager()
 {
 }
 
 void
 APZCTreeManager::GetAllowedTouchBehavior(WidgetInputEvent* aEvent,
@@ -116,23 +118,25 @@ APZCTreeManager::UpdatePanZoomController
   // we are sure that the layer was removed and not just transplanted elsewhere. Doing that
   // as part of a recursive tree walk is hard and so maintaining a list and removing
   // APZCs that are still alive is much simpler.
   nsTArray< nsRefPtr<AsyncPanZoomController> > apzcsToDestroy;
   Collect(mRootApzc, &apzcsToDestroy);
   mRootApzc = nullptr;
 
   if (aRoot) {
+    mApzcTreeLog << "[start]\n";
     UpdatePanZoomControllerTree(aCompositor,
                                 aRoot,
                                 // aCompositor is null in gtest scenarios
                                 aCompositor ? aCompositor->RootLayerTreeId() : 0,
                                 gfx3DMatrix(), nullptr, nullptr,
                                 aIsFirstPaint, aFirstPaintLayersId,
                                 &apzcsToDestroy);
+    mApzcTreeLog << "[end]\n";
   }
 
   for (size_t i = 0; i < apzcsToDestroy.Length(); i++) {
     APZC_LOG("Destroying APZC at %p\n", apzcsToDestroy[i].get());
     apzcsToDestroy[i]->Destroy();
   }
 }
 
@@ -144,16 +148,17 @@ APZCTreeManager::UpdatePanZoomController
                                              AsyncPanZoomController* aNextSibling,
                                              bool aIsFirstPaint, uint64_t aFirstPaintLayersId,
                                              nsTArray< nsRefPtr<AsyncPanZoomController> >* aApzcsToDestroy)
 {
   mTreeLock.AssertCurrentThreadOwns();
 
   ContainerLayer* container = aLayer->AsContainerLayer();
   AsyncPanZoomController* apzc = nullptr;
+  mApzcTreeLog << aLayer->Name() << '\t';
   if (container) {
     if (container->GetFrameMetrics().IsScrollable()) {
       const CompositorParent::LayerTreeState* state = CompositorParent::GetIndirectShadowTree(aLayersId);
       if (state && state->mController.get()) {
         // If we get here, aLayer is a scrollable container layer and somebody
         // has registered a GeckoContentController for it, so we need to ensure
         // it has an APZC instance to manage its scrolling.
 
@@ -222,16 +227,21 @@ APZCTreeManager::UpdatePanZoomController
         gfx3DMatrix transform;
         gfx::To3DMatrix(aLayer->GetTransform(), transform);
 
         apzc->SetLayerHitTestData(visible, aTransform, transform);
         APZC_LOG("Setting rect(%f %f %f %f) as visible region for APZC %p\n", visible.x, visible.y,
                                                                               visible.width, visible.height,
                                                                               apzc);
 
+        mApzcTreeLog << "APZC "
+                     << "\tcb=" << visible
+                     << "\tsr=" << container->GetFrameMetrics().mScrollableRect
+                     << "\t" << container->GetFrameMetrics().GetContentDescription();
+
         // Bind the APZC instance into the tree of APZCs
         if (aNextSibling) {
           aNextSibling->SetPrevSibling(apzc);
         } else if (aParent) {
           aParent->SetLastChild(apzc);
         } else {
           mRootApzc = apzc;
         }
@@ -256,16 +266,17 @@ APZCTreeManager::UpdatePanZoomController
             apzc->UpdateZoomConstraints(apzc->GetParent()->GetZoomConstraints());
           }
         }
       }
     }
 
     container->SetAsyncPanZoomController(apzc);
   }
+  mApzcTreeLog << '\n';
 
   // Accumulate the CSS transform between layers that have an APZC, but exclude any
   // any layers that do have an APZC, and reset the accumulation at those layers.
   if (apzc) {
     aTransform = gfx3DMatrix();
   } else {
     // Multiply child layer transforms on the left so they get applied first
     gfx3DMatrix matrix;
@@ -273,16 +284,17 @@ APZCTreeManager::UpdatePanZoomController
     aTransform = matrix * aTransform;
   }
 
   uint64_t childLayersId = (aLayer->AsRefLayer() ? aLayer->AsRefLayer()->GetReferentId() : aLayersId);
   // If there's no APZC at this level, any APZCs for our child layers will
   // have our siblings as siblings.
   AsyncPanZoomController* next = apzc ? nullptr : aNextSibling;
   for (Layer* child = aLayer->GetLastChild(); child; child = child->GetPrevSibling()) {
+    gfx::TreeAutoIndent indent(mApzcTreeLog);
     next = UpdatePanZoomControllerTree(aCompositor, child, childLayersId, aTransform, aParent, next,
                                        aIsFirstPaint, aFirstPaintLayersId, aApzcsToDestroy);
   }
 
   // Return the APZC that should be the sibling of other APZCs as we continue
   // moving towards the first child at this depth in the layer tree.
   // If this layer doesn't have an APZC, we promote any APZCs in the subtree
   // upwards. Otherwise we fall back to the aNextSibling that was passed in.
--- a/gfx/layers/composite/APZCTreeManager.h
+++ b/gfx/layers/composite/APZCTreeManager.h
@@ -14,16 +14,17 @@
 #include "mozilla/Assertions.h"         // for MOZ_ASSERT_HELPER2
 #include "mozilla/EventForwards.h"      // for WidgetInputEvent, nsEventStatus
 #include "mozilla/Monitor.h"            // for Monitor
 #include "nsAutoPtr.h"                  // for nsRefPtr
 #include "nsCOMPtr.h"                   // for already_AddRefed
 #include "nsISupportsImpl.h"            // for MOZ_COUNT_CTOR, etc
 #include "mozilla/Vector.h"             // for mozilla::Vector
 #include "nsTArray.h"                   // for nsTArray, nsTArray_Impl, etc
+#include "mozilla/gfx/Logging.h"        // for gfx::TreeLog
 
 class gfx3DMatrix;
 template <class E> class nsTArray;
 
 namespace mozilla {
 class InputData;
 
 namespace layers {
@@ -335,16 +336,19 @@ private:
    */
   gfx3DMatrix mCachedTransformToApzcForInputBlock;
   /* The chain of APZCs that will handle pans for the current touch input
    * block, in the order in which they will be scrolled. When one APZC has
    * been scrolled as far as it can, any overscroll will be handed off to
    * the next APZC in the chain.
    */
   Vector< nsRefPtr<AsyncPanZoomController> > mOverscrollHandoffChain;
+  /* For logging the APZC tree for debugging (enabled by the apz.printtree
+   * pref). */
+  gfx::TreeLog mApzcTreeLog;
 
   static float sDPI;
 };
 
 }
 }
 
 #endif // mozilla_layers_PanZoomController_h