Bug 899435. Part 4 - smooth resizing with OMTC. r=roc
authorNicholas Cameron <ncameron@mozilla.com>
Fri, 09 Aug 2013 11:32:26 +1200
changeset 141839 3d4fa3ab3108b285c50145f20940892a6d3535bb
parent 141838 d232d5d67b92bf9908b73e545ad867c85ea0100e
child 141840 b0b4166c8807c76d521aadc980c8d3a9fd56a9ef
push id32245
push userncameron@mozilla.com
push dateThu, 08 Aug 2013 23:32:29 +0000
treeherdermozilla-inbound@3d4fa3ab3108 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersroc
bugs899435
milestone26.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 899435. Part 4 - smooth resizing with OMTC. r=roc
gfx/layers/d3d11/CompositorD3D11.cpp
gfx/layers/d3d9/CompositorD3D9.cpp
widget/windows/nsWindow.cpp
widget/windows/nsWindow.h
widget/xpwidgets/nsBaseWidget.cpp
widget/xpwidgets/nsBaseWidget.h
--- a/gfx/layers/d3d11/CompositorD3D11.cpp
+++ b/gfx/layers/d3d11/CompositorD3D11.cpp
@@ -657,21 +657,27 @@ CompositorD3D11::BeginFrame(const Rect* 
 
   SetRenderTarget(mDefaultRT);
 }
 
 void
 CompositorD3D11::EndFrame()
 {
   mContext->Flush();
-  mSwapChain->Present(0, 0);
+
+  nsIntSize oldSize = mSize;
+  EnsureSize();
+  if (oldSize == mSize) {
+    mSwapChain->Present(0, 0);
 
-  if (mTarget) {
-    PaintToTarget();
+    if (mTarget) {
+      PaintToTarget();
+    }
   }
+
   mCurrentRT = nullptr;
 }
 
 void
 CompositorD3D11::PrepareViewport(const gfx::IntSize& aSize,
                                  const gfxMatrix& aWorldTransform)
 {
   D3D11_VIEWPORT viewport;
--- a/gfx/layers/d3d9/CompositorD3D9.cpp
+++ b/gfx/layers/d3d9/CompositorD3D9.cpp
@@ -479,20 +479,24 @@ CompositorD3D9::BeginFrame(const Rect *a
   SetRenderTarget(mDefaultRT);
 }
 
 void
 CompositorD3D9::EndFrame()
 {
   device()->EndScene();
 
-  if (!!mTarget) {
-    PaintToTarget();
-  } else {
-    mSwapChain->Present();
+  nsIntSize oldSize = mSize;
+  EnsureSize();
+  if (oldSize == mSize) {
+    if (mTarget) {
+      PaintToTarget();
+    } else {
+      mSwapChain->Present();
+    }
   }
 
   mCurrentRT = nullptr;
 }
 
 void
 CompositorD3D9::PrepareViewport(const gfx::IntSize& aSize,
                                 const gfxMatrix &aWorldTransform)
--- a/widget/windows/nsWindow.cpp
+++ b/widget/windows/nsWindow.cpp
@@ -6560,16 +6560,29 @@ nsWindow::GetPreferredCompositorBackend(
     return mozilla::layers::LAYERS_BASIC;
   }
   if (prefs.mPreferD3D9) {
     return mozilla::layers::LAYERS_D3D9;
   }
   return mozilla::layers::LAYERS_D3D11;
 }
 
+void
+nsWindow::WindowUsesOMTC()
+{
+  ULONG_PTR style = ::GetClassLongPtr(mWnd, GCL_STYLE);
+  if (!style) {
+    NS_WARNING("Could not get window class style");
+    return;
+  }
+  style |= CS_HREDRAW | CS_VREDRAW;
+  DebugOnly<ULONG_PTR> result = ::SetClassLongPtr(mWnd, GCL_STYLE, style);
+  NS_WARN_IF_FALSE(result, "Could not reset window class style");
+}
+
 bool
 nsWindow::HasBogusPopupsDropShadowOnMultiMonitor() {
   if (sHasBogusPopupsDropShadowOnMultiMonitor == TRI_UNKNOWN) {
     // Since any change in the preferences requires a restart, this can be
     // done just once.
     // Check for Direct2D first.
     sHasBogusPopupsDropShadowOnMultiMonitor =
       gfxWindowsPlatform::GetPlatform()->GetRenderMode() ==
--- a/widget/windows/nsWindow.h
+++ b/widget/windows/nsWindow.h
@@ -272,16 +272,18 @@ public:
   void                    PickerClosed();
 
   bool                    const DestroyCalled() { return mDestroyCalled; }
 
   virtual mozilla::layers::LayersBackend GetPreferredCompositorBackend();
 
 protected:
 
+  virtual void WindowUsesOMTC() MOZ_OVERRIDE;
+
   // A magic number to identify the FAKETRACKPOINTSCROLLABLE window created
   // when the trackpoint hack is enabled.
   enum { eFakeTrackPointScrollableID = 0x46545053 };
 
   /**
    * Callbacks
    */
   static LRESULT CALLBACK WindowProc(HWND hWnd, UINT msg, WPARAM wParam, LPARAM lParam);
--- a/widget/xpwidgets/nsBaseWidget.cpp
+++ b/widget/xpwidgets/nsBaseWidget.cpp
@@ -965,16 +965,17 @@ void nsBaseWidget::CreateCompositor(int 
     if (!lf) {
       delete lm;
       mCompositorChild = nullptr;
       return;
     }
     lf->SetShadowManager(shadowManager);
     lf->IdentifyTextureHost(textureFactoryIdentifier);
     ImageBridgeChild::IdentifyCompositorTextureHost(textureFactoryIdentifier);
+    WindowUsesOMTC();
 
     mLayerManager = lm;
     return;
   }
 
   NS_WARNING("Failed to create an OMT compositor.");
   DestroyCompositor();
   // Compositor child had the only reference to LayerManager and will have
--- a/widget/xpwidgets/nsBaseWidget.h
+++ b/widget/xpwidgets/nsBaseWidget.h
@@ -358,16 +358,21 @@ protected:
     *aHeight = std::max(mSizeConstraints.mMinSize.height,
                       std::min(mSizeConstraints.mMaxSize.height, *aHeight));
   }
 
   virtual CompositorChild* GetRemoteRenderer() MOZ_OVERRIDE;
 
   virtual mozilla::layers::LayersBackend GetPreferredCompositorBackend();
 
+  /**
+   * Notify the widget that this window is being used with OMTC.
+   */
+  virtual void WindowUsesOMTC() {}
+
 protected:
   /**
    * Starts the OMTC compositor destruction sequence.
    *
    * When this function returns, the compositor should not be 
    * able to access the opengl context anymore.
    * It is safe to call it several times if platform implementations
    * require the compositor to be destroyed before ~nsBaseWidget is