Bug 1384181 - Build WebRenderLayerScrollData instances for remote layer trees. r=jrmuizel
authorKartikaya Gupta <kgupta@mozilla.com>
Wed, 26 Jul 2017 14:47:48 -0400
changeset 371233 3a1dfb72b22525011e741e4c51700151155932a7
parent 371232 b298cd21c0f1850caabd581b3d34b003d05384b8
child 371234 691af1e600e06fcee33478a39d03c43a24c5d2e8
push id93049
push usercbook@mozilla.com
push dateThu, 27 Jul 2017 09:30:07 +0000
treeherdermozilla-inbound@5e9f7561c2eb [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersjrmuizel
bugs1384181
milestone56.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 1384181 - Build WebRenderLayerScrollData instances for remote layer trees. r=jrmuizel This adds handling for nsDisplayRemote frames, so that we create a WebRenderLayerScrollData item for each nsDisplayRemote frame that we encounter. This is the equivalent of a "ref layer" in a normal layer tree, and allows the APZ side to glue together the scroll data from different processes into a full tree. MozReview-Commit-ID: 3lgsqtCKQya
gfx/layers/wr/WebRenderLayerManager.cpp
gfx/layers/wr/WebRenderScrollData.cpp
layout/ipc/RenderFrameParent.cpp
layout/ipc/RenderFrameParent.h
--- a/gfx/layers/wr/WebRenderLayerManager.cpp
+++ b/gfx/layers/wr/WebRenderLayerManager.cpp
@@ -240,16 +240,17 @@ WebRenderLayerManager::CreateWebRenderCo
     if (apzEnabled) {
       bool forceNewLayerData = false;
 
       // For some types of display items we want to force a new
       // WebRenderLayerScrollData object, to ensure we preserve the APZ-relevant
       // data that is in the display item.
       switch (itemType) {
       case nsDisplayItem::TYPE_SCROLL_INFO_LAYER:
+      case nsDisplayItem::TYPE_REMOTE:
         forceNewLayerData = true;
         break;
       default:
         break;
       }
 
       // Anytime the ASR changes we also want to force a new layer data because
       // the stack of scroll metadata is going to be different for this
--- a/gfx/layers/wr/WebRenderScrollData.cpp
+++ b/gfx/layers/wr/WebRenderScrollData.cpp
@@ -1,18 +1,18 @@
 /* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*-
  * This Source Code Form is subject to the terms of the Mozilla Public
  * 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/. */
 
 #include "mozilla/layers/WebRenderScrollData.h"
 
 #include "Layers.h"
+#include "mozilla/layout/RenderFrameParent.h"
 #include "mozilla/Unused.h"
-#include "Layers.h"
 #include "nsTArray.h"
 #include "UnitTransforms.h"
 
 namespace mozilla {
 namespace layers {
 
 WebRenderLayerScrollData::WebRenderLayerScrollData()
   : mDescendantCount(-1)
@@ -68,23 +68,33 @@ WebRenderLayerScrollData::InitializeRoot
 
 void
 WebRenderLayerScrollData::Initialize(WebRenderScrollData& aOwner,
                                      nsDisplayItem* aItem)
 {
   mDescendantCount = 0;
 
   MOZ_ASSERT(aItem);
-  if (aItem->GetType() == nsDisplayItem::TYPE_SCROLL_INFO_LAYER) {
+  switch (aItem->GetType()) {
+  case nsDisplayItem::TYPE_SCROLL_INFO_LAYER: {
     nsDisplayScrollInfoLayer* info = static_cast<nsDisplayScrollInfoLayer*>(aItem);
     UniquePtr<ScrollMetadata> metadata = info->ComputeScrollMetadata(
         nullptr, ContainerLayerParameters());
     MOZ_ASSERT(metadata);
     MOZ_ASSERT(metadata->GetMetrics().IsScrollInfoLayer());
     mScrollIds.AppendElement(aOwner.AddMetadata(*metadata));
+    break;
+  }
+  case nsDisplayItem::TYPE_REMOTE: {
+    nsDisplayRemote* remote = static_cast<nsDisplayRemote*>(aItem);
+    mReferentId = Some(remote->GetRemoteLayersId());
+    break;
+  }
+  default:
+    break;
   }
   for (const ActiveScrolledRoot* asr = aItem->GetActiveScrolledRoot();
        asr;
        asr = asr->mParent) {
     Maybe<ScrollMetadata> metadata = asr->mScrollableFrame->ComputeScrollMetadata(
         nullptr, aItem->ReferenceFrame(), ContainerLayerParameters(), nullptr);
     MOZ_ASSERT(metadata);
     mScrollIds.AppendElement(aOwner.AddMetadata(metadata.ref()));
--- a/layout/ipc/RenderFrameParent.cpp
+++ b/layout/ipc/RenderFrameParent.cpp
@@ -390,12 +390,18 @@ nsDisplayRemote::CreateWebRenderCommands
 {
   MOZ_ASSERT(aManager->IsLayersFreeTransaction());
 
   mozilla::LayoutDeviceRect visible = mozilla::LayoutDeviceRect::FromAppUnits(
       GetVisibleRect(), mFrame->PresContext()->AppUnitsPerDevPixel());
   visible += mozilla::layout::GetContentRectLayerOffset(mFrame, aDisplayListBuilder);
 
   aBuilder.PushIFrame(aSc.ToRelativeLayoutRect(visible),
-      mozilla::wr::AsPipelineId(mRemoteFrame->GetLayersId()));
+      mozilla::wr::AsPipelineId(GetRemoteLayersId()));
 
   return true;
 }
+
+uint64_t
+nsDisplayRemote::GetRemoteLayersId() const
+{
+  return mRemoteFrame->GetLayersId();
+}
--- a/layout/ipc/RenderFrameParent.h
+++ b/layout/ipc/RenderFrameParent.h
@@ -162,16 +162,17 @@ public:
   BuildLayer(nsDisplayListBuilder* aBuilder, LayerManager* aManager,
              const ContainerLayerParameters& aContainerParameters) override;
 
   virtual bool CreateWebRenderCommands(mozilla::wr::DisplayListBuilder& aBuilder,
                                        const StackingContextHelper& aSc,
                                        nsTArray<WebRenderParentCommand>& aParentCommands,
                                        mozilla::layers::WebRenderLayerManager* aManager,
                                        nsDisplayListBuilder* aDisplayListBuilder) override;
+  uint64_t GetRemoteLayersId() const;
 
   NS_DISPLAY_DECL_NAME("Remote", TYPE_REMOTE)
 
 private:
   RenderFrameParent* mRemoteFrame;
   mozilla::layers::EventRegionsOverride mEventRegionsOverride;
 };