Bug 961289 - Client-side instance of APZ test data and utilities for writing to it. r=tn,kats
authorBotond Ballo <botond@mozilla.com>
Mon, 21 Apr 2014 19:48:54 -0400
changeset 195754 f31cefaf8494d6b6ad6cc9cb65600a3878198ad2
parent 195753 c200536ef0c0be1ef466c9522442a946bb260076
child 195755 24d6ed0f3d7eb2b7958b62c12827294dff915ba4
push id5990
push userasasaki@mozilla.com
push dateMon, 09 Jun 2014 21:40:24 +0000
treeherdermozilla-aurora@0796197efbc9 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewerstn, kats
bugs961289
milestone32.0a1
Bug 961289 - Client-side instance of APZ test data and utilities for writing to it. r=tn,kats
gfx/layers/client/ClientLayerManager.cpp
gfx/layers/client/ClientLayerManager.h
layout/base/nsLayoutUtils.cpp
layout/base/nsLayoutUtils.h
--- a/gfx/layers/client/ClientLayerManager.cpp
+++ b/gfx/layers/client/ClientLayerManager.cpp
@@ -159,16 +159,17 @@ ClientLayerManager::BeginTransactionWith
   // to it. This will happen at the end of the transaction.
   if (aTarget && XRE_GetProcessType() == GeckoProcessType_Default) {
     mShadowTarget = aTarget;
   }
 
   // If this is a new paint, increment the paint sequence number.
   if (!mIsRepeatTransaction) {
     ++mPaintSequenceNumber;
+    mApzTestData.StartNewPaint(mPaintSequenceNumber);
   }
 }
 
 void
 ClientLayerManager::BeginTransaction()
 {
   mInTransaction = true;
   BeginTransactionWithTarget(nullptr);
--- a/gfx/layers/client/ClientLayerManager.h
+++ b/gfx/layers/client/ClientLayerManager.h
@@ -11,16 +11,17 @@
 #include "gfxContext.h"                 // for gfxContext
 #include "mozilla/Attributes.h"         // for MOZ_OVERRIDE
 #include "mozilla/LinkedList.h"         // For LinkedList
 #include "mozilla/WidgetUtils.h"        // for ScreenRotation
 #include "mozilla/gfx/Rect.h"           // for Rect
 #include "mozilla/layers/CompositorTypes.h"
 #include "mozilla/layers/LayersTypes.h"  // for BufferMode, LayersBackend, etc
 #include "mozilla/layers/ShadowLayers.h"  // for ShadowLayerForwarder, etc
+#include "mozilla/layers/APZTestData.h" // for APZTestData
 #include "nsAutoPtr.h"                  // for nsRefPtr
 #include "nsCOMPtr.h"                   // for already_AddRefed
 #include "nsDebug.h"                    // for NS_ABORT_IF_FALSE
 #include "nsISupportsImpl.h"            // for Layer::Release, etc
 #include "nsRect.h"                     // for nsIntRect
 #include "nsTArray.h"                   // for nsTArray
 #include "nscore.h"                     // for nsAString
 
@@ -167,16 +168,41 @@ public:
 
   virtual void DidComposite();
 
   virtual bool SupportsMixBlendModes(EnumSet<gfx::CompositionOp>& aMixBlendModes) MOZ_OVERRIDE
   {
    return (GetTextureFactoryIdentifier().mSupportedBlendModes & aMixBlendModes) == aMixBlendModes;
   }
 
+  // Log APZ test data for the current paint. We supply the paint sequence
+  // number ourselves, and take care of calling APZTestData::StartNewPaint()
+  // when a new paint is started.
+  void LogTestDataForCurrentPaint(FrameMetrics::ViewID aScrollId,
+                                  const std::string& aKey,
+                                  const std::string& aValue)
+  {
+    mApzTestData.LogTestDataForPaint(mPaintSequenceNumber, aScrollId, aKey, aValue);
+  }
+
+  // Log APZ test data for a repaint request. The sequence number must be
+  // passed in from outside, and APZTestData::StartNewRepaintRequest() needs
+  // to be called from the outside as well when a new repaint request is started.
+  void StartNewRepaintRequest(SequenceNumber aSequenceNumber)
+  {
+    mApzTestData.StartNewRepaintRequest(aSequenceNumber);
+  }
+  void LogTestDataForRepaintRequest(SequenceNumber aSequenceNumber,
+                                    FrameMetrics::ViewID aScrollId,
+                                    const std::string& aKey,
+                                    const std::string& aValue)
+  {
+    mApzTestData.LogTestDataForRepaintRequest(aSequenceNumber, aScrollId, aKey, aValue);
+  }
+
 protected:
   enum TransactionPhase {
     PHASE_NONE, PHASE_CONSTRUCTION, PHASE_DRAWING, PHASE_FORWARD
   };
   TransactionPhase mPhase;
 
 private:
   /**
@@ -231,16 +257,18 @@ private:
   bool mTransactionIncomplete;
   bool mCompositorMightResample;
   bool mNeedsComposite;
 
   // An incrementing sequence number for paints.
   // Incremented in BeginTransaction(), but not for repeat transactions.
   uint32_t mPaintSequenceNumber;
 
+  APZTestData mApzTestData;
+
   RefPtr<ShadowLayerForwarder> mForwarder;
   nsAutoTArray<RefPtr<TextureClientPool>,2> mTexturePools;
   nsAutoTArray<dom::OverfillCallback*,0> mOverfillCallbacks;
 
   // indexed by gfx::SurfaceFormat
   nsTArray<RefPtr<SimpleTextureClientPool> > mSimpleTilePools;
 };
 
--- a/layout/base/nsLayoutUtils.cpp
+++ b/layout/base/nsLayoutUtils.cpp
@@ -72,16 +72,17 @@
 #include "ImageContainer.h"
 #include "nsComputedDOMStyle.h"
 #include "ActiveLayerTracker.h"
 #include "mozilla/gfx/2D.h"
 #include "gfx2DGlue.h"
 #include "mozilla/LookAndFeel.h"
 #include "UnitTransforms.h"
 #include "TiledLayerBuffer.h" // For TILEDLAYERBUFFER_TILE_SIZE
+#include "ClientLayerManager.h"
 
 #include "mozilla/Preferences.h"
 
 #ifdef MOZ_XUL
 #include "nsXULPopupManager.h"
 #endif
 
 #include "GeckoProfiler.h"
@@ -6509,17 +6510,31 @@ nsLayoutUtils::WantSubAPZC()
    // TODO Turn this on for inprocess OMTC on all platforms
    bool wantSubAPZC = gfxPrefs::APZSubframeEnabled();
 #ifdef MOZ_WIDGET_GONK
    if (XRE_GetProcessType() != GeckoProcessType_Content) {
      wantSubAPZC = false;
    }
 #endif
    return wantSubAPZC;
- }
+}
+
+/* static */ void
+nsLayoutUtils::LogTestDataForPaint(nsIPresShell* aPresShell,
+                                   ViewID aScrollId,
+                                   const std::string& aKey,
+                                   const std::string& aValue)
+{
+  nsRefPtr<LayerManager> lm = aPresShell->GetPresContext()->GetRootPresContext()
+      ->GetPresShell()->GetLayerManager();
+  if (lm && lm->GetBackendType() == LayersBackend::LAYERS_CLIENT) {
+    static_cast<ClientLayerManager*>(lm.get())->LogTestDataForCurrentPaint(aScrollId, aKey, aValue);
+  }
+}
+
 
 nsLayoutUtils::SurfaceFromElementResult::SurfaceFromElementResult()
   // Use safe default values here
   : mIsWriteOnly(true)
   , mIsStillLoading(false)
   , mCORSUsed(false)
   , mIsPremultiplied(true)
 {
--- a/layout/base/nsLayoutUtils.h
+++ b/layout/base/nsLayoutUtils.h
@@ -21,16 +21,17 @@
 #include "nsCSSProperty.h"
 #include "nsStyleCoord.h"
 #include "nsStyleConsts.h"
 #include "nsGkAtoms.h"
 #include "nsRuleNode.h"
 #include "imgIContainer.h"
 #include "mozilla/gfx/2D.h"
 #include "Units.h"
+#include "mozilla/ToString.h"
 
 #include <limits>
 #include <algorithm>
 
 class nsIFormControlFrame;
 class nsPresContext;
 class nsIContent;
 class nsIAtom;
@@ -2165,16 +2166,44 @@ public:
   CalculateExpandedScrollableRect(nsIFrame* aFrame);
 
   /**
    * Return whether we want to use APZ for subframes in this process.
    * Currently we don't support APZ for the parent process on B2G.
    */
   static bool WantSubAPZC();
 
+  /**
+   * Log a key/value pair for APZ testing during a paint.
+   * @param aPresShell The pres shell that identifies where to log to. The data
+   *                   will be written to the APZTestData associated with the
+   *                   pres shell's layer manager.
+   * @param aScrollId Identifies the scroll frame to which the data pertains.
+   * @param aKey The key under which to log the data.
+   * @param aValue The value of the data to be logged.
+   */
+  static void LogTestDataForPaint(nsIPresShell* aPresShell,
+                                  ViewID aScrollId,
+                                  const std::string& aKey,
+                                  const std::string& aValue);
+
+  /**
+   * A convenience overload of LogTestDataForPaint() that accepts any type
+   * as the value, and passes it through mozilla::ToString() to obtain a string
+   * value. The type passed must support streaming to an std::ostream.
+   */
+  template <typename Value>
+  static void LogTestDataForPaint(nsIPresShell* aPresShell,
+                                  ViewID aScrollId,
+                                  const std::string& aKey,
+                                  const Value& aValue) {
+    LogTestDataForPaint(aPresShell, aScrollId, aKey,
+        mozilla::ToString(aValue));
+  }
+
  /**
    * Get the display port for |aScrollFrame|'s content. If |aScrollFrame|
    * WantsAsyncScroll() and we don't have a scrollable displayport yet (as
    * tracked by |aBuilder|), calculate and set a display port. Returns true if
    * there is (now) a displayport, and if so the displayport is returned in
    * |aOutDisplayport|.
    *
    * Note that a displayport can either be stored as a rect, or as a base