Bug 1369840 - Support content-side APZ test data in WebRenderLayerManager. r=botond
☠☠ backed out by ec5dcacaf5a9 ☠ ☠
authorKartikaya Gupta <kgupta@mozilla.com>
Fri, 02 Jun 2017 16:19:33 -0400
changeset 410250 b7bcbc5c1b924d4c29813bbd3927ab1eb323b0bb
parent 410249 581ca67895db0353380f0661bf62effdc410031c
child 410251 53d308821554ae7ccda0379847137416b1e758dc
push id7391
push usermtabara@mozilla.com
push dateMon, 12 Jun 2017 13:08:53 +0000
treeherdermozilla-beta@2191d7f87e2e [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersbotond
bugs1369840
milestone55.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 1369840 - Support content-side APZ test data in WebRenderLayerManager. r=botond This mostly just copies the functional parts of the APZTestData code from ClientLayerManager into WebRenderLayerManager, and propagates the paint sequence number over to the compositor using the existing WebRenderScrollData machinery. MozReview-Commit-ID: 6GD5Sl3dSJp
dom/base/nsDOMWindowUtils.cpp
gfx/layers/wr/WebRenderBridgeParent.cpp
gfx/layers/wr/WebRenderLayerManager.cpp
gfx/layers/wr/WebRenderLayerManager.h
gfx/layers/wr/WebRenderScrollData.cpp
gfx/layers/wr/WebRenderScrollData.h
layout/base/nsLayoutUtils.cpp
--- a/dom/base/nsDOMWindowUtils.cpp
+++ b/dom/base/nsDOMWindowUtils.cpp
@@ -3888,16 +3888,20 @@ nsDOMWindowUtils::GetContentAPZTestData(
     RefPtr<LayerManager> lm = widget->GetLayerManager();
     if (!lm) {
       return NS_OK;
     }
     if (ClientLayerManager* clm = lm->AsClientLayerManager()) {
       if (!clm->GetAPZTestData().ToJS(aOutContentTestData, aContext)) {
         return NS_ERROR_FAILURE;
       }
+    } else if (WebRenderLayerManager* wrlm = lm->AsWebRenderLayerManager()) {
+      if (!wrlm->GetAPZTestData().ToJS(aOutContentTestData, aContext)) {
+        return NS_ERROR_FAILURE;
+      }
     }
   }
 
   return NS_OK;
 }
 
 NS_IMETHODIMP
 nsDOMWindowUtils::GetCompositorAPZTestData(JSContext* aContext,
--- a/gfx/layers/wr/WebRenderBridgeParent.cpp
+++ b/gfx/layers/wr/WebRenderBridgeParent.cpp
@@ -366,17 +366,17 @@ WebRenderBridgeParent::UpdateAPZ()
   uint64_t rootLayersId = cbp->RootLayerTreeId();
   RefPtr<WebRenderBridgeParent> rootWrbp = cbp->GetWebRenderBridgeParent();
   if (!rootWrbp) {
     return;
   }
   if (RefPtr<APZCTreeManager> apzc = cbp->GetAPZCTreeManager()) {
     apzc->UpdateHitTestingTree(rootLayersId, rootWrbp->GetScrollData(),
         mScrollData.IsFirstPaint(), GetLayersId(),
-        /* TODO: propagate paint sequence number */ 0);
+        mScrollData.GetPaintSequenceNumber());
   }
 }
 
 bool
 WebRenderBridgeParent::PushAPZStateToWR(nsTArray<WrTransformProperty>& aTransformArray)
 {
   CompositorBridgeParent* cbp = GetRootCompositorBridgeParent();
   if (!cbp) {
--- a/gfx/layers/wr/WebRenderLayerManager.cpp
+++ b/gfx/layers/wr/WebRenderLayerManager.cpp
@@ -27,16 +27,17 @@ using namespace gfx;
 namespace layers {
 
 WebRenderLayerManager::WebRenderLayerManager(nsIWidget* aWidget)
   : mWidget(aWidget)
   , mLatestTransactionId(0)
   , mNeedsComposite(false)
   , mIsFirstPaint(false)
   , mTarget(nullptr)
+  , mPaintSequenceNumber(0)
 {
   MOZ_COUNT_CTOR(WebRenderLayerManager);
 }
 
 KnowsCompositor*
 WebRenderLayerManager::AsKnowsCompositor()
 {
   return mWrChild;
@@ -119,16 +120,23 @@ WebRenderLayerManager::BeginTransactionW
 {
   mTarget = aTarget;
   return BeginTransaction();
 }
 
 bool
 WebRenderLayerManager::BeginTransaction()
 {
+  // Increment the paint sequence number even if test logging isn't
+  // enabled in this process; it may be enabled in the parent process,
+  // and the parent process expects unique sequence numbers.
+  ++mPaintSequenceNumber;
+  if (gfxPrefs::APZTestLoggingEnabled()) {
+    mApzTestData.StartNewPaint(mPaintSequenceNumber);
+  }
   return true;
 }
 
 bool
 WebRenderLayerManager::EndEmptyTransaction(EndTransactionFlags aFlags)
 {
   if (!mRoot) {
     return false;
@@ -204,16 +212,17 @@ WebRenderLayerManager::EndTransactionInt
   }
 
   WebRenderScrollData scrollData;
   if (AsyncPanZoomEnabled()) {
     if (mIsFirstPaint) {
       scrollData.SetIsFirstPaint();
       mIsFirstPaint = false;
     }
+    scrollData.SetPaintSequenceNumber(mPaintSequenceNumber);
     if (mRoot) {
       PopulateScrollData(scrollData, mRoot.get());
     }
   }
 
   bool sync = mTarget != nullptr;
   mLatestTransactionId = mTransactionIdAllocator->GetTransactionId();
 
--- a/gfx/layers/wr/WebRenderLayerManager.h
+++ b/gfx/layers/wr/WebRenderLayerManager.h
@@ -3,16 +3,17 @@
  * License, v. 2.0. If a copy of the MPL was not distributed with this
  * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
 
 #ifndef GFX_WEBRENDERLAYERMANAGER_H
 #define GFX_WEBRENDERLAYERMANAGER_H
 
 #include "Layers.h"
 #include "mozilla/MozPromise.h"
+#include "mozilla/layers/APZTestData.h"
 #include "mozilla/layers/TransactionIdAllocator.h"
 #include "mozilla/webrender/WebRenderTypes.h"
 
 class nsIWidget;
 
 namespace mozilla {
 namespace layers {
 
@@ -121,16 +122,26 @@ public:
 
   virtual void Mutated(Layer* aLayer) override;
   virtual void MutatedSimple(Layer* aLayer) override;
 
   void Hold(Layer* aLayer);
   void SetTransactionIncomplete() { mTransactionIncomplete = true; }
   bool IsMutatedLayer(Layer* aLayer);
 
+  // See equivalent function in ClientLayerManager
+  void LogTestDataForCurrentPaint(FrameMetrics::ViewID aScrollId,
+                                  const std::string& aKey,
+                                  const std::string& aValue) {
+    mApzTestData.LogTestDataForPaint(mPaintSequenceNumber, aScrollId, aKey, aValue);
+  }
+  // See equivalent function in ClientLayerManager
+  const APZTestData& GetAPZTestData() const
+  { return mApzTestData; }
+
 private:
   /**
    * Take a snapshot of the parent context, and copy
    * it into mTarget.
    */
   void MakeSnapshotIfRequired(LayoutDeviceIntSize aSize);
 
   void ClearLayer(Layer* aLayer);
@@ -173,14 +184,19 @@ private:
  // When we're doing a transaction in order to draw to a non-default
  // target, the layers transaction is only performed in order to send
  // a PLayers:Update.  We save the original non-default target to
  // mTarget, and then perform the transaction. After the transaction ends,
  // we send a message to our remote side to capture the actual pixels
  // being drawn to the default target, and then copy those pixels
  // back to mTarget.
  RefPtr<gfxContext> mTarget;
+
+  // See equivalent field in ClientLayerManager
+  uint32_t mPaintSequenceNumber;
+  // See equivalent field in ClientLayerManager
+  APZTestData mApzTestData;
 };
 
 } // namespace layers
 } // namespace mozilla
 
 #endif /* GFX_WEBRENDERLAYERMANAGER_H */
--- a/gfx/layers/wr/WebRenderScrollData.cpp
+++ b/gfx/layers/wr/WebRenderScrollData.cpp
@@ -75,16 +75,17 @@ WebRenderLayerScrollData::GetScrollMetad
 CSSTransformMatrix
 WebRenderLayerScrollData::GetTransformTyped() const
 {
   return ViewAs<CSSTransformMatrix>(GetTransform());
 }
 
 WebRenderScrollData::WebRenderScrollData()
   : mIsFirstPaint(false)
+  , mPaintSequenceNumber(0)
 {
 }
 
 WebRenderScrollData::~WebRenderScrollData()
 {
 }
 
 size_t
@@ -146,10 +147,22 @@ WebRenderScrollData::SetIsFirstPaint()
 }
 
 bool
 WebRenderScrollData::IsFirstPaint() const
 {
   return mIsFirstPaint;
 }
 
+void
+WebRenderScrollData::SetPaintSequenceNumber(uint32_t aPaintSequenceNumber)
+{
+  mPaintSequenceNumber = aPaintSequenceNumber;
+}
+
+uint32_t
+WebRenderScrollData::GetPaintSequenceNumber() const
+{
+  return mPaintSequenceNumber;
+}
+
 } // namespace layers
 } // namespace mozilla
--- a/gfx/layers/wr/WebRenderScrollData.h
+++ b/gfx/layers/wr/WebRenderScrollData.h
@@ -116,16 +116,18 @@ public:
   // as the pointer may be invalidated if this WebRenderScrollData is mutated.
   WebRenderLayerScrollData* GetLayerDataMutable(size_t aIndex);
   const WebRenderLayerScrollData* GetLayerData(size_t aIndex) const;
 
   const ScrollMetadata& GetScrollMetadata(size_t aIndex) const;
 
   void SetIsFirstPaint();
   bool IsFirstPaint() const;
+  void SetPaintSequenceNumber(uint32_t aPaintSequenceNumber);
+  uint32_t GetPaintSequenceNumber() const;
 
   friend struct IPC::ParamTraits<WebRenderScrollData>;
 
 private:
   // Internal data structure used to maintain uniqueness of mScrollMetadatas.
   // This is not serialized/deserialized over IPC because there's no need for it,
   // as the parent side doesn't need this at all. Also because we don't have any
   // IPC-friendly hashtable implementation lying around.
@@ -141,16 +143,17 @@ private:
   // pre-order, last-to-first traversal of the layer tree (i.e. a recursive
   // traversal where a node N first pushes itself, followed by its children in
   // last-to-first order). Each layer's scroll data object knows how many
   // descendants that layer had, which allows reconstructing the traversal on the
   // other side.
   nsTArray<WebRenderLayerScrollData> mLayerScrollData;
 
   bool mIsFirstPaint;
+  uint32_t mPaintSequenceNumber;
 };
 
 } // namespace layers
 } // namespace mozilla
 
 namespace IPC {
 
 // When ScrollThumbData is stored on the layer tree, it's part of
@@ -214,22 +217,24 @@ struct ParamTraits<mozilla::layers::WebR
   typedef mozilla::layers::WebRenderScrollData paramType;
 
   static void
   Write(Message* aMsg, const paramType& aParam)
   {
     WriteParam(aMsg, aParam.mScrollMetadatas);
     WriteParam(aMsg, aParam.mLayerScrollData);
     WriteParam(aMsg, aParam.mIsFirstPaint);
+    WriteParam(aMsg, aParam.mPaintSequenceNumber);
   }
 
   static bool
   Read(const Message* aMsg, PickleIterator* aIter, paramType* aResult)
   {
     return ReadParam(aMsg, aIter, &aResult->mScrollMetadatas)
         && ReadParam(aMsg, aIter, &aResult->mLayerScrollData)
-        && ReadParam(aMsg, aIter, &aResult->mIsFirstPaint);
+        && ReadParam(aMsg, aIter, &aResult->mIsFirstPaint)
+        && ReadParam(aMsg, aIter, &aResult->mPaintSequenceNumber);
   }
 };
 
 } // namespace IPC
 
 #endif /* GFX_WEBRENDERSCROLLDATA_H */
--- a/layout/base/nsLayoutUtils.cpp
+++ b/layout/base/nsLayoutUtils.cpp
@@ -117,16 +117,17 @@
 #include "mozilla/EventStateManager.h"
 #include "mozilla/RuleNodeCacheConditions.h"
 #include "mozilla/StyleAnimationValue.h"
 #include "mozilla/StyleSetHandle.h"
 #include "mozilla/StyleSetHandleInlines.h"
 #include "RegionBuilder.h"
 #include "SVGSVGElement.h"
 #include "DisplayItemClip.h"
+#include "mozilla/layers/WebRenderLayerManager.h"
 
 #ifdef MOZ_XUL
 #include "nsXULPopupManager.h"
 #endif
 
 #include "GeckoProfiler.h"
 #include "nsAnimationManager.h"
 #include "nsTransitionManager.h"
@@ -8503,16 +8504,18 @@ nsLayoutUtils::CalculateExpandedScrollab
 /* static */ void
 nsLayoutUtils::DoLogTestDataForPaint(LayerManager* aManager,
                                      ViewID aScrollId,
                                      const std::string& aKey,
                                      const std::string& aValue)
 {
   if (ClientLayerManager* mgr = aManager->AsClientLayerManager()) {
     mgr->LogTestDataForCurrentPaint(aScrollId, aKey, aValue);
+  } else if (WebRenderLayerManager* wrlm = aManager->AsWebRenderLayerManager()) {
+    wrlm->LogTestDataForCurrentPaint(aScrollId, aKey, aValue);
   }
 }
 
 /* static */ bool
 nsLayoutUtils::IsAPZTestLoggingEnabled()
 {
   return gfxPrefs::APZTestLoggingEnabled();
 }