Bug 1289236. Remove ResizeTransparentWindow. r=dvander
authorJeff Muizelaar <jmuizelaar@mozilla.com>
Mon, 25 Jul 2016 18:04:33 -0400
changeset 349388 59db65b2b2c2ddb4f99a62d5903668308c94067c
parent 349387 4afd920b80d2c94b2afd811c3c388a8757f1adae
child 349389 18af1ad335a52bc3852d195627757ceb0dad6836
push id1230
push userjlund@mozilla.com
push dateMon, 31 Oct 2016 18:13:35 +0000
treeherdermozilla-release@5e06e3766db2 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersdvander
bugs1289236
milestone50.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 1289236. Remove ResizeTransparentWindow. r=dvander We can just recreate the surface when needed.
widget/windows/CompositorWidgetChild.cpp
widget/windows/CompositorWidgetChild.h
widget/windows/CompositorWidgetParent.cpp
widget/windows/CompositorWidgetParent.h
widget/windows/PCompositorWidget.ipdl
widget/windows/WinCompositorWidget.cpp
widget/windows/WinCompositorWidget.h
widget/windows/nsWindow.cpp
--- a/widget/windows/CompositorWidgetChild.cpp
+++ b/widget/windows/CompositorWidgetChild.cpp
@@ -48,22 +48,16 @@ CompositorWidgetChild::UpdateTransparenc
 }
 
 void
 CompositorWidgetChild::ClearTransparentWindow()
 {
   Unused << SendClearTransparentWindow();
 }
 
-void
-CompositorWidgetChild::ResizeTransparentWindow(const gfx::IntSize& aSize)
-{
-  Unused << SendResizeTransparentWindow(aSize);
-}
-
 HDC
 CompositorWidgetChild::GetTransparentDC() const
 {
   // Not supported in out-of-process mode.
   return nullptr;
 }
 
 bool
--- a/widget/windows/CompositorWidgetChild.h
+++ b/widget/windows/CompositorWidgetChild.h
@@ -24,17 +24,16 @@ public:
                         RefPtr<CompositorWidgetVsyncObserver> aVsyncObserver);
   ~CompositorWidgetChild() override;
 
   void EnterPresentLock() override;
   void LeavePresentLock() override;
   void OnDestroyWindow() override;
   void UpdateTransparency(nsTransparencyMode aMode) override;
   void ClearTransparentWindow() override;
-  void ResizeTransparentWindow(const gfx::IntSize& aSize) override;
   HDC GetTransparentDC() const override;
 
   bool RecvObserveVsync() override;
   bool RecvUnobserveVsync() override;
 
 private:
   RefPtr<CompositorVsyncDispatcher> mVsyncDispatcher;
   RefPtr<CompositorWidgetVsyncObserver> mVsyncObserver;
--- a/widget/windows/CompositorWidgetParent.cpp
+++ b/widget/windows/CompositorWidgetParent.cpp
@@ -41,23 +41,16 @@ CompositorWidgetParent::RecvUpdateTransp
 
 bool
 CompositorWidgetParent::RecvClearTransparentWindow()
 {
   ClearTransparentWindow();
   return true;
 }
 
-bool
-CompositorWidgetParent::RecvResizeTransparentWindow(const IntSize& aSize)
-{
-  ResizeTransparentWindow(aSize);
-  return true;
-}
-
 nsIWidget*
 CompositorWidgetParent::RealWidget()
 {
   return nullptr;
 }
 
 void
 CompositorWidgetParent::ObserveVsync(VsyncObserver* aObserver)
--- a/widget/windows/CompositorWidgetParent.h
+++ b/widget/windows/CompositorWidgetParent.h
@@ -19,17 +19,16 @@ class CompositorWidgetParent final
 public:
   CompositorWidgetParent(const CompositorWidgetInitData& aInitData);
   ~CompositorWidgetParent() override;
 
   bool RecvEnterPresentLock() override;
   bool RecvLeavePresentLock() override;
   bool RecvUpdateTransparency(const int32_t& aMode) override;
   bool RecvClearTransparentWindow() override;
-  bool RecvResizeTransparentWindow(const IntSize& aSize) override;
   void ActorDestroy(ActorDestroyReason aWhy) override;
 
   nsIWidget* RealWidget() override;
   void ObserveVsync(VsyncObserver* aObserver) override;
   RefPtr<VsyncObserver> GetVsyncObserver() const override;
 
 private:
   RefPtr<VsyncObserver> mVsyncObserver;
--- a/widget/windows/PCompositorWidget.ipdl
+++ b/widget/windows/PCompositorWidget.ipdl
@@ -15,17 +15,16 @@ sync protocol PCompositorWidget
 {
   manager PCompositorBridge;
 
 parent:
   sync EnterPresentLock();
   sync LeavePresentLock();
   async UpdateTransparency(int32_t aMode);
   sync ClearTransparentWindow();
-  sync ResizeTransparentWindow(IntSize aSize);
   async __delete__();
 
 child:
   async ObserveVsync();
   async UnobserveVsync();
 };
 
 } // namespace widget
--- a/widget/windows/WinCompositorWidget.cpp
+++ b/widget/windows/WinCompositorWidget.cpp
@@ -176,19 +176,21 @@ WinCompositorWidget::LeavePresentLock()
   mPresentLock.Leave();
 }
 
 RefPtr<gfxASurface>
 WinCompositorWidget::EnsureTransparentSurface()
 {
   MOZ_ASSERT(mTransparencyMode == eTransparencyTransparent);
 
-  if (!mTransparentSurface) {
-    LayoutDeviceIntSize size = GetClientSize();
-    CreateTransparentSurface(IntSize(size.width, size.height));
+  IntSize size = GetClientSize().ToUnknownSize();
+  if (!mTransparentSurface || mTransparentSurface->GetSize() != size) {
+    mTransparentSurface = nullptr;
+    mMemoryDC = nullptr;
+    CreateTransparentSurface(size);
   }
 
   RefPtr<gfxASurface> surface = mTransparentSurface;
   return surface.forget();
 }
 
 void
 WinCompositorWidget::CreateTransparentSurface(const gfx::IntSize& aSize)
@@ -217,37 +219,25 @@ WinCompositorWidget::UpdateTransparency(
 
 void
 WinCompositorWidget::ClearTransparentWindow()
 {
   if (!mTransparentSurface) {
     return;
   }
 
-  IntSize size = mTransparentSurface->GetSize();
-  RefPtr<DrawTarget> drawTarget = gfxPlatform::GetPlatform()->
-    CreateDrawTargetForSurface(mTransparentSurface, size);
-  drawTarget->ClearRect(Rect(0, 0, size.width, size.height));
-  RedrawTransparentWindow();
-}
+  EnsureTransparentSurface();
 
-void
-WinCompositorWidget::ResizeTransparentWindow(const gfx::IntSize& aSize)
-{
-  MOZ_ASSERT(mTransparencyMode == eTransparencyTransparent);
-
-  if (mTransparentSurface && mTransparentSurface->GetSize() == aSize) {
-    return;
+  IntSize size = mTransparentSurface->GetSize();
+  if (!size.IsEmpty()) {
+    RefPtr<DrawTarget> drawTarget = gfxPlatform::GetPlatform()->
+      CreateDrawTargetForSurface(mTransparentSurface, size);
+    drawTarget->ClearRect(Rect(0, 0, size.width, size.height));
+    RedrawTransparentWindow();
   }
-
-  // Destroy the old surface.
-  mTransparentSurface = nullptr;
-  mMemoryDC = nullptr;
-
-  CreateTransparentSurface(aSize);
 }
 
 bool
 WinCompositorWidget::RedrawTransparentWindow()
 {
   MOZ_ASSERT(mTransparencyMode == eTransparencyTransparent);
 
   LayoutDeviceIntSize size = GetClientSize();
--- a/widget/windows/WinCompositorWidget.h
+++ b/widget/windows/WinCompositorWidget.h
@@ -24,19 +24,16 @@ public:
   virtual void EnterPresentLock() = 0;
   virtual void LeavePresentLock() = 0;
   virtual void OnDestroyWindow() = 0;
 
   // Transparency handling.
   virtual void UpdateTransparency(nsTransparencyMode aMode) = 0;
   virtual void ClearTransparentWindow() = 0;
 
-  // Update the bounds of the transparent surface.
-  virtual void ResizeTransparentWindow(const gfx::IntSize& aSize) = 0;
-
   // If in-process and using software rendering, return the backing transparent
   // DC.
   virtual HDC GetTransparentDC() const = 0;
 };
  
 // This is the Windows-specific implementation of CompositorWidget. For
 // the most part it only requires an HWND, however it maintains extra state
 // for transparent windows, as well as for synchronizing WM_SETTEXT messages
@@ -66,17 +63,16 @@ public:
   }
 
   // CompositorWidgetDelegate overrides.
   void EnterPresentLock() override;
   void LeavePresentLock() override;
   void OnDestroyWindow() override;
   void UpdateTransparency(nsTransparencyMode aMode) override;
   void ClearTransparentWindow() override;
-  void ResizeTransparentWindow(const gfx::IntSize& aSize) override;
 
   bool RedrawTransparentWindow();
 
   // Ensure that a transparent surface exists, then return it.
   RefPtr<gfxASurface> EnsureTransparentSurface();
 
   HDC GetTransparentDC() const override {
     return mMemoryDC;
--- a/widget/windows/nsWindow.cpp
+++ b/widget/windows/nsWindow.cpp
@@ -1652,22 +1652,16 @@ NS_METHOD nsWindow::Resize(double aWidth
   // Avoid unnecessary resizing calls
   if (mBounds.width == width && mBounds.height == height) {
     if (aRepaint) {
       Invalidate();
     }
     return NS_OK;
   }
 
-  if (mTransparencyMode == eTransparencyTransparent) {
-    if (mCompositorWidgetDelegate) {
-      mCompositorWidgetDelegate->ResizeTransparentWindow(gfx::IntSize(width, height));
-    }
-  }
-
   // Set cached value for lightweight and printing
   mBounds.width  = width;
   mBounds.height = height;
 
   if (mWnd) {
     UINT  flags = SWP_NOZORDER | SWP_NOACTIVATE | SWP_NOMOVE;
 
     if (!aRepaint) {
@@ -1711,22 +1705,16 @@ NS_METHOD nsWindow::Resize(double aX, do
   if (mBounds.x == x && mBounds.y == y &&
       mBounds.width == width && mBounds.height == height) {
     if (aRepaint) {
       Invalidate();
     }
     return NS_OK;
   }
 
-  if (eTransparencyTransparent == mTransparencyMode) {
-    if (mCompositorWidgetDelegate) {
-      mCompositorWidgetDelegate->ResizeTransparentWindow(gfx::IntSize(width, height));
-    }
-  }
-
   // Set cached value for lightweight and printing
   mBounds.x      = x;
   mBounds.y      = y;
   mBounds.width  = width;
   mBounds.height = height;
 
   if (mWnd) {
     UINT  flags = SWP_NOZORDER | SWP_NOACTIVATE;
@@ -6309,22 +6297,16 @@ void nsWindow::OnWindowPosChanged(WINDOW
     int32_t newWidth, newHeight;
 
     ::GetWindowRect(mWnd, &r);
 
     newWidth  = r.right - r.left;
     newHeight = r.bottom - r.top;
     nsIntRect rect(wp->x, wp->y, newWidth, newHeight);
 
-    if (eTransparencyTransparent == mTransparencyMode) {
-      if (mCompositorWidgetDelegate) {
-        mCompositorWidgetDelegate->ResizeTransparentWindow(gfx::IntSize(newWidth, newHeight));
-      }
-    }
-
     if (newWidth > mLastSize.width)
     {
       RECT drect;
 
       // getting wider
       drect.left   = wp->x + mLastSize.width;
       drect.top    = wp->y;
       drect.right  = drect.left + (newWidth - mLastSize.width);