Bug 877225 - Transition from snapped view shows stretched page for a moment. r=bas
authorBrian R. Bondy <netzen@gmail.com>
Sun, 15 Sep 2013 15:30:11 -0700
changeset 160181 41104c4a62ee0da726f0be3d895f16a17fc6a4bb
parent 160180 72f8d310a7235e48d1a6656295cd1a72b5a30240
child 160182 4e553e8da44ee2936e9b4586749c484aadd74004
push id2961
push userlsblakk@mozilla.com
push dateMon, 28 Oct 2013 21:59:28 +0000
treeherdermozilla-beta@73ef4f13486f [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersbas
bugs877225
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 877225 - Transition from snapped view shows stretched page for a moment. r=bas
gfx/layers/d3d10/LayerManagerD3D10.cpp
gfx/layers/d3d10/LayerManagerD3D10.h
gfx/layers/d3d11/CompositorD3D11.cpp
gfx/layers/d3d11/CompositorD3D11.h
--- a/gfx/layers/d3d10/LayerManagerD3D10.cpp
+++ b/gfx/layers/d3d10/LayerManagerD3D10.cpp
@@ -57,16 +57,17 @@ static const GUID sDeviceAttachments =
 // {716AEDB1-C9C3-4B4D-8332-6F65D44AF6A8}
 static const GUID sLayerManagerCount = 
 { 0x716aedb1, 0xc9c3, 0x4b4d, { 0x83, 0x32, 0x6f, 0x65, 0xd4, 0x4a, 0xf6, 0xa8 } };
 
 cairo_user_data_key_t gKeyD3D10Texture;
 
 LayerManagerD3D10::LayerManagerD3D10(nsIWidget *aWidget)
   : mWidget(aWidget)
+  , mDisableSequenceForNextFrame(false)
 {
 }
 
 struct DeviceAttachments
 {
   nsRefPtr<ID3D10Effect> mEffect;
   nsRefPtr<ID3D10InputLayout> mInputLayout;
   nsRefPtr<ID3D10Buffer> mVertexBuffer;
@@ -240,17 +241,17 @@ LayerManagerD3D10::Initialize(bool force
     swapDesc.Format = DXGI_FORMAT_B8G8R8A8_UNORM;
     swapDesc.Stereo = false; 
     // Don't use multi-sampling
     swapDesc.SampleDesc.Count = 1;
     swapDesc.SampleDesc.Quality = 0;
     swapDesc.BufferUsage = DXGI_USAGE_RENDER_TARGET_OUTPUT;
     // Use double buffering to enable flip
     swapDesc.BufferCount = 2;
-    swapDesc.Scaling = DXGI_SCALING_STRETCH;
+    swapDesc.Scaling = DXGI_SCALING_NONE;
     // All Metro style apps must use this SwapEffect
     swapDesc.SwapEffect = DXGI_SWAP_EFFECT_FLIP_SEQUENTIAL;
     swapDesc.Flags = 0;
 
     /**
      * Create a swap chain, this swap chain will contain the backbuffer for
      * the window we draw to. The front buffer is the full screen front
      * buffer.
@@ -643,16 +644,17 @@ LayerManagerD3D10::VerifyBufferSize()
       mSwapChain->ResizeBuffers(1, rect.width, rect.height,
                                 DXGI_FORMAT_B8G8R8A8_UNORM,
                                 0);
 #ifdef MOZ_METRO
     } else if (IsRunningInWindowsMetro()) {
       mSwapChain->ResizeBuffers(2, rect.width, rect.height,
                                 DXGI_FORMAT_B8G8R8A8_UNORM,
                                 0);
+      mDisableSequenceForNextFrame = true;
 #endif
     } else {
       mSwapChain->ResizeBuffers(1, rect.width, rect.height,
                                 DXGI_FORMAT_B8G8R8A8_UNORM,
                                 DXGI_SWAP_CHAIN_FLAG_GDI_COMPATIBLE);
     }
   }
 }
@@ -725,17 +727,18 @@ LayerManagerD3D10::Render(EndTransaction
   // whether our thoughts of the causes of the issues are correct.
   if (FAILED(mDevice->GetDeviceRemovedReason())) {
     return;
   }
 
   if (mTarget) {
     PaintToTarget();
   } else {
-    mSwapChain->Present(0, 0);
+    mSwapChain->Present(0, mDisableSequenceForNextFrame ? DXGI_PRESENT_DO_NOT_SEQUENCE : 0);
+    mDisableSequenceForNextFrame = false;
   }
   LayerManager::PostPresent();
 }
 
 void
 LayerManagerD3D10::PaintToTarget()
 {
   nsRefPtr<ID3D10Texture2D> backBuf;
--- a/gfx/layers/d3d10/LayerManagerD3D10.h
+++ b/gfx/layers/d3d10/LayerManagerD3D10.h
@@ -165,16 +165,18 @@ private:
   nsRefPtr<ReadbackManagerD3D10> mReadbackManager;
 
   nsRefPtr<ID3D10RenderTargetView> mRTView;
 
   nsRefPtr<IDXGISwapChain> mSwapChain;
 
   nsIWidget *mWidget;
 
+  bool mDisableSequenceForNextFrame;
+
   CallbackInfo mCurrentCallbackInfo;
 
   nsIntSize mViewport;
 
   /* Nv3DVUtils instance */ 
   nsAutoPtr<Nv3DVUtils> mNv3DVUtils; 
 
   /*
--- a/gfx/layers/d3d11/CompositorD3D11.cpp
+++ b/gfx/layers/d3d11/CompositorD3D11.cpp
@@ -58,16 +58,17 @@ struct DeviceAttachmentsD3D11
   RefPtr<ID3D11BlendState> mNonPremulBlendState;
   RefPtr<ID3D11BlendState> mComponentBlendState;
 };
 
 CompositorD3D11::CompositorD3D11(nsIWidget* aWidget)
   : mAttachments(nullptr)
   , mWidget(aWidget)
   , mHwnd(nullptr)
+  , mDisableSequenceForNextFrame(false)
 {
   sBackend = LAYERS_D3D11;
 }
 
 CompositorD3D11::~CompositorD3D11()
 {
   if (mDevice) {
     int referenceCount = 0;
@@ -265,17 +266,17 @@ CompositorD3D11::Initialize()
     swapDesc.Format = DXGI_FORMAT_B8G8R8A8_UNORM;
     swapDesc.Stereo = false;
     // Don't use multi-sampling
     swapDesc.SampleDesc.Count = 1;
     swapDesc.SampleDesc.Quality = 0;
     swapDesc.BufferUsage = DXGI_USAGE_RENDER_TARGET_OUTPUT;
     // Use double buffering to enable flip
     swapDesc.BufferCount = 2;
-    swapDesc.Scaling = DXGI_SCALING_STRETCH;
+    swapDesc.Scaling = DXGI_SCALING_NONE;
     // All Metro style apps must use this SwapEffect
     swapDesc.SwapEffect = DXGI_SWAP_EFFECT_FLIP_SEQUENTIAL;
     swapDesc.Flags = 0;
 
     /**
      * Create a swap chain, this swap chain will contain the backbuffer for
      * the window we draw to. The front buffer is the full screen front
      * buffer.
@@ -684,23 +685,23 @@ CompositorD3D11::BeginFrame(const Rect* 
 void
 CompositorD3D11::EndFrame()
 {
   mContext->Flush();
 
   nsIntSize oldSize = mSize;
   EnsureSize();
   if (oldSize == mSize) {
-    mSwapChain->Present(0, 0);
-
+    mSwapChain->Present(0, mDisableSequenceForNextFrame ? DXGI_PRESENT_DO_NOT_SEQUENCE : 0);
+    mDisableSequenceForNextFrame = false;
     if (mTarget) {
       PaintToTarget();
     }
   }
-
+  
   mCurrentRT = nullptr;
 }
 
 void
 CompositorD3D11::PrepareViewport(const gfx::IntSize& aSize,
                                  const gfxMatrix& aWorldTransform)
 {
   D3D11_VIEWPORT viewport;
@@ -753,16 +754,17 @@ CompositorD3D11::VerifyBufferSize()
     mSwapChain->ResizeBuffers(1, mSize.width, mSize.height,
                               DXGI_FORMAT_B8G8R8A8_UNORM,
                               0);
 #ifdef MOZ_METRO
   } else if (IsRunningInWindowsMetro()) {
     mSwapChain->ResizeBuffers(2, mSize.width, mSize.height,
                               DXGI_FORMAT_B8G8R8A8_UNORM,
                               0);
+    mDisableSequenceForNextFrame = true;
 #endif
   } else {
     mSwapChain->ResizeBuffers(1, mSize.width, mSize.height,
                               DXGI_FORMAT_B8G8R8A8_UNORM,
                               DXGI_SWAP_CHAIN_FLAG_GDI_COMPATIBLE);
   }
 }
 
--- a/gfx/layers/d3d11/CompositorD3D11.h
+++ b/gfx/layers/d3d11/CompositorD3D11.h
@@ -174,14 +174,15 @@ private:
   nsIntSize mSize;
 
   HWND mHwnd;
 
   D3D_FEATURE_LEVEL mFeatureLevel;
 
   VertexShaderConstants mVSConstants;
   PixelShaderConstants mPSConstants;
+  bool mDisableSequenceForNextFrame;
 };
 
 }
 }
 
 #endif