Bug 1470528 - Add IsRootWebrenderBridgeParent method. r=kats
☠☠ backed out by 6e5891e3bbd2 ☠ ☠
authorRyan Hunt <rhunt@eqrion.net>
Tue, 26 Jun 2018 13:37:31 -0500
changeset 424923 f859daf8d8d9356eb2c51811d724403d56574639
parent 424922 be73fc773100823d69c1330bbcb8f5e593f65e9d
child 424924 e438548991db2848923dddd391912141814752c7
push id34227
push userrgurzau@mozilla.com
push dateWed, 04 Jul 2018 09:59:03 +0000
treeherdermozilla-central@cc3401e78e8b [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewerskats
bugs1470528
milestone63.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 1470528 - Add IsRootWebrenderBridgeParent method. r=kats This commit adds a helper function for determining if the WebRenderBridgeParent is for a content process and replaces uses with it appropriately. MozReview-Commit-ID: 6YZhjYEYS3P
gfx/layers/wr/WebRenderBridgeParent.cpp
gfx/layers/wr/WebRenderBridgeParent.h
--- a/gfx/layers/wr/WebRenderBridgeParent.cpp
+++ b/gfx/layers/wr/WebRenderBridgeParent.cpp
@@ -178,17 +178,17 @@ WebRenderBridgeParent::WebRenderBridgePa
   , mPaused(false)
   , mDestroyed(false)
   , mForceRendering(false)
   , mReceivedDisplayList(false)
 {
   MOZ_ASSERT(mAsyncImageManager);
   MOZ_ASSERT(mAnimStorage);
   mAsyncImageManager->AddPipeline(mPipelineId);
-  if (mWidget) {
+  if (IsRootWebRenderBridgeParent()) {
     MOZ_ASSERT(!mCompositorScheduler);
     mCompositorScheduler = new CompositorVsyncScheduler(this, mWidget);
   }
 }
 
 WebRenderBridgeParent::WebRenderBridgeParent(const wr::PipelineId& aPipelineId)
   : mCompositorBridge(nullptr)
   , mPipelineId(aPipelineId)
@@ -496,24 +496,30 @@ WebRenderBridgeParent::RemoveEpochDataPr
       } else {
         NS_ERROR("Tried to delete invalid animation");
       }
     }
     mCompositorAnimationsToDelete.pop();
   }
 }
 
+bool
+WebRenderBridgeParent::IsRootWebRenderBridgeParent() const
+{
+  return !!mWidget;
+}
+
 CompositorBridgeParent*
 WebRenderBridgeParent::GetRootCompositorBridgeParent() const
 {
   if (!mCompositorBridge) {
     return nullptr;
   }
 
-  if (mWidget) {
+  if (IsRootWebRenderBridgeParent()) {
     // This WebRenderBridgeParent is attached to the root
     // CompositorBridgeParent.
     return static_cast<CompositorBridgeParent*>(mCompositorBridge);
   }
 
   // Otherwise, this WebRenderBridgeParent is attached to a
   // CrossProcessCompositorBridgeParent so we have an extra level of
   // indirection to unravel.
@@ -653,17 +659,17 @@ WebRenderBridgeParent::RecvSetDisplayLis
   UpdateAPZScrollData(wrEpoch, std::move(const_cast<WebRenderScrollData&>(aScrollData)));
 
   wr::Vec<uint8_t> dlData(std::move(dl));
 
   // If id namespaces do not match, it means the command is obsolete, probably
   // because the tab just moved to a new window.
   // In that case do not send the commands to webrender.
   if (mIdNamespace == aIdNamespace) {
-    if (mWidget) {
+    if (IsRootWebRenderBridgeParent()) {
       LayoutDeviceIntSize widgetSize = mWidget->GetClientSize();
       LayoutDeviceIntRect docRect(LayoutDeviceIntPoint(), widgetSize);
       txn.SetWindowParameters(widgetSize, docRect);
     }
     gfx::Color clearColor(0.f, 0.f, 0.f, 0.f);
     txn.SetDisplayList(clearColor, wrEpoch, LayerSize(aSize.width, aSize.height),
                        mPipelineId, aContentSize,
                        dlDesc, dlData);
@@ -889,17 +895,17 @@ WebRenderBridgeParent::FlushSceneBuilds(
     ScheduleGenerateFrame();
   }
 }
 
 void
 WebRenderBridgeParent::FlushFrameGeneration()
 {
   MOZ_ASSERT(CompositorThreadHolder::IsInCompositorThread());
-  MOZ_ASSERT(mWidget); // This function is only useful on the root WRBP
+  MOZ_ASSERT(IsRootWebRenderBridgeParent()); // This function is only useful on the root WRBP
 
   // This forces a new GenerateFrame transaction to be sent to the render
   // backend thread, if one is pending. This doesn't block on any other threads.
   mForceRendering = true;
   mCompositorScheduler->FlushPendingComposite();
   mForceRendering = false;
 }
 
@@ -924,17 +930,17 @@ WebRenderBridgeParent::RecvGetSnapshot(P
   }
   MOZ_ASSERT(!mPaused);
 
   // This function should only get called in the root WRBP. If this function
   // gets called in a non-root WRBP, we will set mForceRendering in this WRBP
   // but it will have no effect because CompositeToTarget (which reads the
   // flag) only gets invoked in the root WRBP. So we assert that this is the
   // root WRBP (i.e. has a non-null mWidget) to catch violations of this rule.
-  MOZ_ASSERT(mWidget);
+  MOZ_ASSERT(IsRootWebRenderBridgeParent());
 
   RefPtr<TextureHost> texture = TextureHost::AsTextureHost(aTexture);
   if (!texture) {
     // We kill the content process rather than have it continue with an invalid
     // snapshot, that may be too harsh and we could decide to return some sort
     // of error to the child process and let it deal with it...
     return IPC_FAIL_NO_REASON(this);
   }
@@ -1119,17 +1125,17 @@ WebRenderBridgeParent::RecvClearCachedRe
 
 void
 WebRenderBridgeParent::UpdateWebRender(CompositorVsyncScheduler* aScheduler,
                                        wr::WebRenderAPI* aApi,
                                        AsyncImagePipelineManager* aImageMgr,
                                        CompositorAnimationStorage* aAnimStorage,
                                        const TextureFactoryIdentifier& aTextureFactoryIdentifier)
 {
-  MOZ_ASSERT(!mWidget);
+  MOZ_ASSERT(!IsRootWebRenderBridgeParent());
   MOZ_ASSERT(aScheduler);
   MOZ_ASSERT(aApi);
   MOZ_ASSERT(aImageMgr);
   MOZ_ASSERT(aAnimStorage);
 
   if (mDestroyed) {
     return;
   }
@@ -1373,17 +1379,17 @@ WebRenderBridgeParent::SampleAnimations(
 
   return isAnimating;
 }
 
 void
 WebRenderBridgeParent::CompositeToTarget(gfx::DrawTarget* aTarget, const gfx::IntRect* aRect)
 {
   // This function should only get called in the root WRBP
-  MOZ_ASSERT(mWidget);
+  MOZ_ASSERT(IsRootWebRenderBridgeParent());
 
   // The two arguments are part of the CompositorVsyncSchedulerOwner API but in
   // this implementation they should never be non-null.
   MOZ_ASSERT(aTarget == nullptr);
   MOZ_ASSERT(aRect == nullptr);
 
   AUTO_PROFILER_TRACING("Paint", "CompositeToTraget");
   if (mPaused || !mReceivedDisplayList) {
@@ -1547,32 +1553,32 @@ WebRenderBridgeParent::FlushRenderingAsy
   }
 
   mCompositorScheduler->FlushPendingComposite();
 }
 
 void
 WebRenderBridgeParent::Pause()
 {
-  MOZ_ASSERT(mWidget);
+  MOZ_ASSERT(IsRootWebRenderBridgeParent());
 #ifdef MOZ_WIDGET_ANDROID
-  if (!mWidget || mDestroyed) {
+  if (!IsRootWebRenderBridgeParent() || mDestroyed) {
     return;
   }
   mApi->Pause();
 #endif
   mPaused = true;
 }
 
 bool
 WebRenderBridgeParent::Resume()
 {
-  MOZ_ASSERT(mWidget);
+  MOZ_ASSERT(IsRootWebRenderBridgeParent());
 #ifdef MOZ_WIDGET_ANDROID
-  if (!mWidget || mDestroyed) {
+  if (!IsRootWebRenderBridgeParent() || mDestroyed) {
     return false;
   }
 
   if (!mApi->Resume()) {
     return false;
   }
 #endif
   mPaused = false;
@@ -1618,17 +1624,17 @@ WebRenderBridgeParent::ClearResources()
   mApi->SendTransaction(txn);
 
   for (std::unordered_set<uint64_t>::iterator iter = mActiveAnimations.begin(); iter != mActiveAnimations.end(); iter++) {
     mAnimStorage->ClearById(*iter);
   }
   mActiveAnimations.clear();
   std::queue<CompositorAnimationIdsForEpoch>().swap(mCompositorAnimationsToDelete); // clear queue
 
-  if (mWidget) {
+  if (IsRootWebRenderBridgeParent()) {
     mCompositorScheduler->Destroy();
   }
 
   // Before tearing down mApi we should make sure the above transaction has been
   // flushed back to the render backend thread. Otherwise the cleanup messages
   // that the WebRenderAPI destructor triggers can race ahead of the transaction
   // (because it goes directly to the RB thread, bypassing the scene builder
   // thread) and clear caches etc. that are still in use.
@@ -1734,17 +1740,17 @@ WebRenderBridgeParent::GetNextWrEpoch()
   MOZ_RELEASE_ASSERT(mWrEpoch.mHandle != UINT32_MAX);
   mWrEpoch.mHandle++;
   return mWrEpoch;
 }
 
 void
 WebRenderBridgeParent::ExtractImageCompositeNotifications(nsTArray<ImageCompositeNotificationInfo>* aNotifications)
 {
-  MOZ_ASSERT(mWidget);
+  MOZ_ASSERT(IsRootWebRenderBridgeParent());
   if (mDestroyed) {
     return;
   }
   mAsyncImageManager->FlushImageNotifications(aNotifications);
 }
 
 } // namespace layers
 } // namespace mozilla
--- a/gfx/layers/wr/WebRenderBridgeParent.h
+++ b/gfx/layers/wr/WebRenderBridgeParent.h
@@ -225,16 +225,18 @@ private:
   mozilla::ipc::IPCResult HandleShutdown();
 
   // Returns true if there is any animation (including animations in delay
   // phase).
   bool AdvanceAnimations();
   bool SampleAnimations(nsTArray<wr::WrOpacityProperty>& aOpacityArray,
                         nsTArray<wr::WrTransformProperty>& aTransformArray);
 
+  bool IsRootWebRenderBridgeParent() const;
+
   CompositorBridgeParent* GetRootCompositorBridgeParent() const;
 
   RefPtr<WebRenderBridgeParent> GetRootWebRenderBridgeParent() const;
 
   // Tell APZ what the subsequent sampling's timestamp should be.
   void SetAPZSampleTime();
 
   wr::Epoch GetNextWrEpoch();