Bug 1519546, part 8 - Also gather EffectsInfo for remote browsers with WebRender. r=jrmuizel
authorRyan Hunt <rhunt@eqrion.net>
Fri, 24 May 2019 09:28:34 -0500
changeset 476565 ac0ad5d8e9a57c716e392c59b655853a728911b4
parent 476564 b81cf35a573e1e3054dd792b8ab1ee0824139435
child 476566 6d71d3ca012438d7eac6e8f9471e198a10eabc70
push id36100
push userapavel@mozilla.com
push dateSun, 02 Jun 2019 22:10:35 +0000
treeherdermozilla-central@6d71d3ca0124 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersjrmuizel
bugs1519546
milestone69.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 1519546, part 8 - Also gather EffectsInfo for remote browsers with WebRender. r=jrmuizel The nsDisplayListBuilder bits were added in the previous commit. Differential Revision: https://phabricator.services.mozilla.com/D32477
gfx/layers/wr/WebRenderUserData.cpp
gfx/layers/wr/WebRenderUserData.h
layout/ipc/RenderFrame.cpp
--- a/gfx/layers/wr/WebRenderUserData.cpp
+++ b/gfx/layers/wr/WebRenderUserData.cpp
@@ -367,16 +367,26 @@ WebRenderCanvasRendererAsync* WebRenderC
   return mCanvasRenderer.get();
 }
 
 WebRenderCanvasRendererAsync* WebRenderCanvasData::CreateCanvasRenderer() {
   mCanvasRenderer = MakeUnique<WebRenderCanvasRendererAsync>(mManager);
   return mCanvasRenderer.get();
 }
 
+WebRenderRemoteData::WebRenderRemoteData(RenderRootStateManager* aManager,
+                                         nsDisplayItem* aItem)
+    : WebRenderUserData(aManager, aItem) {}
+
+WebRenderRemoteData::~WebRenderRemoteData() {
+  if (mRemoteBrowser) {
+    mRemoteBrowser->UpdateEffects(mozilla::dom::EffectsInfo::FullyHidden());
+  }
+}
+
 WebRenderRenderRootData::WebRenderRenderRootData(
     RenderRootStateManager* aManager, nsDisplayItem* aItem)
     : WebRenderUserData(aManager, aItem) {}
 
 RenderRootBoundary& WebRenderRenderRootData::EnsureHasBoundary(
     wr::RenderRoot aChildType) {
   if (mBoundary) {
     MOZ_ASSERT(mBoundary->GetChildType() == aChildType);
--- a/gfx/layers/wr/WebRenderUserData.h
+++ b/gfx/layers/wr/WebRenderUserData.h
@@ -8,16 +8,17 @@
 #define GFX_WEBRENDERUSERDATA_H
 
 #include <vector>
 #include "BasicLayers.h"  // for BasicLayerManager
 #include "mozilla/layers/StackingContextHelper.h"
 #include "mozilla/webrender/WebRenderAPI.h"
 #include "mozilla/layers/AnimationInfo.h"
 #include "mozilla/layers/RenderRootBoundary.h"
+#include "mozilla/dom/RemoteBrowser.h"
 #include "nsIFrame.h"
 #include "ImageTypes.h"
 
 class nsDisplayItemGeometry;
 
 namespace mozilla {
 namespace wr {
 class IpcResourceUpdateQueue;
@@ -73,16 +74,17 @@ class WebRenderUserData {
   virtual WebRenderCanvasData* AsCanvasData() { return nullptr; }
   virtual WebRenderGroupData* AsGroupData() { return nullptr; }
 
   enum class UserDataType {
     eImage,
     eFallback,
     eAnimation,
     eCanvas,
+    eRemote,
     eGroup,
     eMask,
     eRenderRoot,
   };
 
   virtual UserDataType GetType() = 0;
   bool IsUsed() { return mUsed; }
   void SetUsed(bool aUsed) { mUsed = aUsed; }
@@ -243,16 +245,32 @@ class WebRenderCanvasData : public WebRe
   void ClearCanvasRenderer();
   WebRenderCanvasRendererAsync* GetCanvasRenderer();
   WebRenderCanvasRendererAsync* CreateCanvasRenderer();
 
  protected:
   UniquePtr<WebRenderCanvasRendererAsync> mCanvasRenderer;
 };
 
+class WebRenderRemoteData : public WebRenderUserData {
+ public:
+  WebRenderRemoteData(RenderRootStateManager* aManager, nsDisplayItem* aItem);
+  virtual ~WebRenderRemoteData();
+
+  UserDataType GetType() override { return UserDataType::eRemote; }
+  static UserDataType Type() { return UserDataType::eRemote; }
+
+  void SetRemoteBrowser(dom::RemoteBrowser* aBrowser) {
+    mRemoteBrowser = aBrowser;
+  }
+
+ protected:
+  RefPtr<dom::RemoteBrowser> mRemoteBrowser;
+};
+
 class WebRenderRenderRootData : public WebRenderUserData {
  public:
   WebRenderRenderRootData(RenderRootStateManager* aManager,
                           nsDisplayItem* aItem);
   virtual ~WebRenderRenderRootData();
 
   UserDataType GetType() override { return UserDataType::eRenderRoot; }
   static UserDataType Type() { return UserDataType::eRenderRoot; }
--- a/layout/ipc/RenderFrame.cpp
+++ b/layout/ipc/RenderFrame.cpp
@@ -273,16 +273,31 @@ bool nsDisplayRemote::CreateWebRenderCom
     mozilla::wr::IpcResourceUpdateQueue& aResources,
     const StackingContextHelper& aSc,
     mozilla::layers::RenderRootStateManager* aManager,
     nsDisplayListBuilder* aDisplayListBuilder) {
   if (!mLayersId.IsValid()) {
     return true;
   }
 
+  if (RefPtr<RemoteBrowser> remoteBrowser =
+          GetFrameLoader()->GetRemoteBrowser()) {
+    // Generate an effects update notifying the browser it is visible
+    aDisplayListBuilder->AddEffectUpdate(remoteBrowser,
+                                         EffectsInfo::FullyVisible());
+
+    // Create a WebRenderRemoteData to notify the RemoteBrowser when it is no
+    // longer visible
+    RefPtr<WebRenderRemoteData> userData =
+        aManager->CommandBuilder()
+            .CreateOrRecycleWebRenderUserData<WebRenderRemoteData>(
+                this, aBuilder.GetRenderRoot(), nullptr);
+    userData->SetRemoteBrowser(remoteBrowser);
+  }
+
   mOffset = GetContentRectLayerOffset(mFrame, aDisplayListBuilder);
 
   LayoutDeviceRect rect = LayoutDeviceRect::FromAppUnits(
       mFrame->GetContentRectRelativeToSelf(),
       mFrame->PresContext()->AppUnitsPerDevPixel());
   rect += mOffset;
 
   aBuilder.PushIFrame(mozilla::wr::ToRoundedLayoutRect(rect),