Bug 1486958 - Sync FlushRendering() only during resizing on windows r=mattwoodrow
authorsotaro <sotaro.ikeda.g@gmail.com>
Fri, 14 Sep 2018 17:13:55 +0900
changeset 492077 ca89cc5c6a17a86ac36c59260b5870f6bd62b4f3
parent 492076 a9fdec3eed75112ddf060a383cfadded04d1d29a
child 492078 b3aeeb0a0a8b05174a123eb732066a5bb966e2fa
push id9984
push userffxbld-merge
push dateMon, 15 Oct 2018 21:07:35 +0000
treeherdermozilla-beta@183d27ea8570 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersmattwoodrow
bugs1486958
milestone64.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 1486958 - Sync FlushRendering() only during resizing on windows r=mattwoodrow
gfx/layers/wr/WebRenderLayerManager.cpp
widget/nsIWidget.h
widget/windows/nsWindow.cpp
widget/windows/nsWindow.h
--- a/gfx/layers/wr/WebRenderLayerManager.cpp
+++ b/gfx/layers/wr/WebRenderLayerManager.cpp
@@ -632,18 +632,22 @@ void
 WebRenderLayerManager::FlushRendering()
 {
   CompositorBridgeChild* cBridge = GetCompositorBridgeChild();
   if (!cBridge) {
     return;
   }
   MOZ_ASSERT(mWidget);
 
-  // When DirectComposition and compositor window are used, we do not need to do sync FlushRendering.
-  if (WrBridge()->GetCompositorUseDComp()) {
+  // If value of IsResizingNativeWidget() is nothing, we assume that resizing might happen.
+  bool resizing = mWidget && mWidget->IsResizingNativeWidget().valueOr(true);
+
+  // Limit async FlushRendering to !resizing and Win DComp.
+  // XXX relax the limitation
+  if (WrBridge()->GetCompositorUseDComp() && !resizing) {
     cBridge->SendFlushRenderingAsync();
   } else if (mWidget->SynchronouslyRepaintOnResize() || gfxPrefs::LayersForceSynchronousResize()) {
     cBridge->SendFlushRendering();
   } else {
     cBridge->SendFlushRenderingAsync();
   }
 }
 
--- a/widget/nsIWidget.h
+++ b/widget/nsIWidget.h
@@ -773,16 +773,21 @@ class nsIWidget : public nsISupports
      *
      */
     virtual void Resize(double aX,
                         double aY,
                         double aWidth,
                         double aHeight,
                         bool   aRepaint) = 0;
 
+    virtual mozilla::Maybe<bool> IsResizingNativeWidget()
+    {
+        return mozilla::Nothing();
+    }
+
     /**
      * Resize the widget so that the inner client area has the given size.
      *
      * @param aWidth   the new width of the client area.
      * @param aHeight  the new height of the client area.
      * @param aRepaint whether the widget should be repainted
      */
     virtual void ResizeClient(double aWidth,
--- a/widget/windows/nsWindow.cpp
+++ b/widget/windows/nsWindow.cpp
@@ -1983,16 +1983,25 @@ nsWindow::Resize(double aX, double aY, d
   }
 
   if (aRepaint)
     Invalidate();
 
   NotifyRollupGeometryChange();
 }
 
+mozilla::Maybe<bool>
+nsWindow::IsResizingNativeWidget()
+{
+  if (mResizeState == RESIZING) {
+    return Some(true);
+  }
+  return Some(false);
+}
+
 nsresult
 nsWindow::BeginResizeDrag(WidgetGUIEvent* aEvent,
                           int32_t aHorizontal,
                           int32_t aVertical)
 {
   NS_ENSURE_ARG_POINTER(aEvent);
 
   if (aEvent->mClass != eMouseEventClass) {
--- a/widget/windows/nsWindow.h
+++ b/widget/windows/nsWindow.h
@@ -126,16 +126,17 @@ public:
   virtual void            Show(bool aState) override;
   virtual bool            IsVisible() const override;
   virtual void            ConstrainPosition(bool aAllowSlop, int32_t *aX, int32_t *aY) override;
   virtual void            SetSizeConstraints(const SizeConstraints& aConstraints) override;
   virtual const SizeConstraints GetSizeConstraints() override;
   virtual void            Move(double aX, double aY) override;
   virtual void            Resize(double aWidth, double aHeight, bool aRepaint) override;
   virtual void            Resize(double aX, double aY, double aWidth, double aHeight, bool aRepaint) override;
+  virtual mozilla::Maybe<bool> IsResizingNativeWidget() override;
   virtual MOZ_MUST_USE nsresult
                           BeginResizeDrag(mozilla::WidgetGUIEvent* aEvent,
                                           int32_t aHorizontal,
                                           int32_t aVertical) override;
   virtual void            PlaceBehind(nsTopLevelWidgetZPlacement aPlacement, nsIWidget *aWidget, bool aActivate) override;
   virtual void            SetSizeMode(nsSizeMode aMode) override;
   virtual void            SuppressAnimation(bool aSuppress) override;
   virtual void            Enable(bool aState) override;