Bug 1403915 - Collapse EndTransactionInternal into EndTransactionWithoutLayers. r=jrmuizel
authorKartikaya Gupta <kgupta@mozilla.com>
Tue, 03 Oct 2017 16:31:08 -0400
changeset 384230 87c152551a93293250b80e9f3840874ea2a15b7f
parent 384229 f407f597b7bf6ccfd9bfb1ec5747a7ab56d0c534
child 384306 ec43659fe0c4abfca02a5d4c7d1b5d1d8b2d48c4
push id52578
push userkgupta@mozilla.com
push dateTue, 03 Oct 2017 21:37:22 +0000
treeherderautoland@87c152551a93 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersjrmuizel
bugs1403915
milestone58.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 1403915 - Collapse EndTransactionInternal into EndTransactionWithoutLayers. r=jrmuizel MozReview-Commit-ID: 5l9LkfJTqKy
gfx/layers/wr/WebRenderLayerManager.cpp
gfx/layers/wr/WebRenderLayerManager.h
--- a/gfx/layers/wr/WebRenderLayerManager.cpp
+++ b/gfx/layers/wr/WebRenderLayerManager.cpp
@@ -176,16 +176,25 @@ WebRenderLayerManager::EndEmptyTransacti
 {
   // With the WebRenderLayerManager we reject attempts to set most kind of
   // "pending data" for empty transactions. Any place that attempts to update
   // transforms or scroll offset, for example, will get failure return values
   // back, and will fall back to a full transaction. Therefore the only piece
   // of "pending" information we need to send in an empty transaction is the
   // APZ focus state.
   WrBridge()->SendSetFocusTarget(mFocusTarget);
+
+  // We also need to update canvases that might have changed, but this code
+  // as-is causes crashes so comment it out for now.
+  //for (auto iter = mLastCanvasDatas.Iter(); !iter.Done(); iter.Next()) {
+  //  RefPtr<WebRenderCanvasData> canvasData = iter.Get()->GetKey();
+  //  WebRenderCanvasRendererAsync* canvas = canvasData->GetCanvasRenderer();
+  //  canvas->UpdateCompositableClient();
+  //}
+
   return true;
 }
 
 /*static*/ int32_t
 PopulateScrollData(WebRenderScrollData& aTarget, Layer* aLayer)
 {
   MOZ_ASSERT(aLayer);
 
@@ -349,27 +358,16 @@ WebRenderLayerManager::CreateWebRenderCo
   // with matching ASRs.
   if (!eventRegions.IsEmpty()) {
     MOZ_ASSERT(apzEnabled);
     MOZ_ASSERT(!mLayerScrollData.empty());
     mLayerScrollData.back().AddEventRegions(eventRegions);
   }
 }
 
-void
-WebRenderLayerManager::EndTransactionWithoutLayer(nsDisplayList* aDisplayList,
-                                                  nsDisplayListBuilder* aDisplayListBuilder)
-{
-  MOZ_ASSERT(aDisplayList && aDisplayListBuilder);
-  WrBridge()->RemoveExpiredFontKeys();
-  EndTransactionInternal(EndTransactionFlags::END_DEFAULT,
-                         aDisplayList,
-                         aDisplayListBuilder);
-}
-
 Maybe<wr::ImageKey>
 WebRenderLayerManager::CreateImageKey(nsDisplayItem* aItem,
                                       ImageContainer* aContainer,
                                       mozilla::wr::DisplayListBuilder& aBuilder,
                                       mozilla::wr::IpcResourceUpdateQueue& aResources,
                                       const StackingContextHelper& aSc,
                                       gfx::IntSize& aSize)
 {
@@ -701,45 +699,45 @@ WebRenderLayerManager::EndTransaction(Dr
                                       void* aCallbackData,
                                       EndTransactionFlags aFlags)
 {
   // This should never get called, all callers should use
   // EndTransactionWithoutLayer instead.
   MOZ_ASSERT(false);
 }
 
-bool
-WebRenderLayerManager::EndTransactionInternal(EndTransactionFlags aFlags,
-                                              nsDisplayList* aDisplayList,
-                                              nsDisplayListBuilder* aDisplayListBuilder)
+void
+WebRenderLayerManager::EndTransactionWithoutLayer(nsDisplayList* aDisplayList,
+                                                  nsDisplayListBuilder* aDisplayListBuilder)
 {
+  MOZ_ASSERT(aDisplayList && aDisplayListBuilder);
+  WrBridge()->RemoveExpiredFontKeys();
+
   AutoProfilerTracing tracing("Paint", "RenderLayers");
   mTransactionIncomplete = false;
 
   if (gfxPrefs::LayersDump()) {
     this->Dump();
   }
 
   // Since we don't do repeat transactions right now, just set the time
   mAnimationReadyTime = TimeStamp::Now();
 
   LayoutDeviceIntSize size = mWidget->GetClientSize();
   if (!WrBridge()->BeginTransaction(size.ToUnknownSize())) {
-    return false;
+    return;
   }
   DiscardCompositorAnimations();
 
   wr::LayoutSize contentSize { (float)size.width, (float)size.height };
   wr::DisplayListBuilder builder(WrBridge()->GetPipeline(), contentSize);
   wr::IpcResourceUpdateQueue resourceUpdates(WrBridge()->GetShmemAllocator());
 
-  // aDisplayList being null here means this is an empty transaction following a layers-free
-  // transaction, so we reuse the previously built displaylist and scroll
-  // metadata information
-  if (aDisplayList && aDisplayListBuilder) {
+  { // scoping for StackingContextHelper RAII
+
     StackingContextHelper sc;
     mParentCommands.Clear();
     mScrollData = WebRenderScrollData();
     MOZ_ASSERT(mLayerScrollData.empty());
     mLastCanvasDatas.Clear();
     mLastAsr = nullptr;
 
     CreateWebRenderCommandsFromDisplayList(aDisplayList, aDisplayListBuilder, sc, builder, resourceUpdates);
@@ -770,37 +768,31 @@ WebRenderLayerManager::EndTransactionInt
       mScrollData.AddLayerData(*i);
     }
     mLayerScrollData.clear();
     mClipIdCache.clear();
 
     // Remove the user data those are not displayed on the screen and
     // also reset the data to unused for next transaction.
     RemoveUnusedAndResetWebRenderUserData();
-  } else {
-    for (auto iter = mLastCanvasDatas.Iter(); !iter.Done(); iter.Next()) {
-      RefPtr<WebRenderCanvasData> canvasData = iter.Get()->GetKey();
-      WebRenderCanvasRendererAsync* canvas = canvasData->GetCanvasRenderer();
-      canvas->UpdateCompositableClient();
-    }
   }
 
   builder.PushBuiltDisplayList(mBuiltDisplayList);
   WrBridge()->AddWebRenderParentCommands(mParentCommands);
 
   mWidget->AddWindowOverlayWebRenderCommands(WrBridge(), builder, resourceUpdates);
   WrBridge()->ClearReadLocks();
 
   // We can't finish this transaction so return. This usually
   // happens in an empty transaction where we can't repaint a painted layer.
   // In this case, leave the transaction open and let a full transaction happen.
   if (mTransactionIncomplete) {
     DiscardLocalImages();
     WrBridge()->ProcessWebRenderParentCommands();
-    return false;
+    return;
   }
 
   if (AsyncPanZoomEnabled()) {
     mScrollData.SetFocusTarget(mFocusTarget);
     mFocusTarget = FocusTarget();
 
     if (mIsFirstPaint) {
       mScrollData.SetIsFirstPaint();
@@ -833,18 +825,16 @@ WebRenderLayerManager::EndTransactionInt
     WrBridge()->EndTransaction(builder, resourceUpdates, size.ToUnknownSize(), sync,
                                mLatestTransactionId, mScrollData, transactionStart);
   }
 
   MakeSnapshotIfRequired(size);
   mNeedsComposite = false;
 
   ClearDisplayItemLayers();
-
-  return true;
 }
 
 void
 WebRenderLayerManager::SetFocusTarget(const FocusTarget& aFocusTarget)
 {
   mFocusTarget = aFocusTarget;
 }
 
--- a/gfx/layers/wr/WebRenderLayerManager.h
+++ b/gfx/layers/wr/WebRenderLayerManager.h
@@ -238,20 +238,16 @@ private:
   /**
    * Take a snapshot of the parent context, and copy
    * it into mTarget.
    */
   void MakeSnapshotIfRequired(LayoutDeviceIntSize aSize);
 
   void ClearLayer(Layer* aLayer);
 
-  bool EndTransactionInternal(EndTransactionFlags aFlags,
-                              nsDisplayList* aDisplayList = nullptr,
-                              nsDisplayListBuilder* aDisplayListBuilder = nullptr);
-
   void RemoveUnusedAndResetWebRenderUserData()
   {
     for (auto iter = mWebRenderUserDatas.Iter(); !iter.Done(); iter.Next()) {
       WebRenderUserData* data = iter.Get()->GetKey();
       if (!data->IsUsed()) {
         nsIFrame* frame = data->GetFrame();
 
         MOZ_ASSERT(frame->HasProperty(nsIFrame::WebRenderUserDataProperty()));