From 79d2bac44cb2a0793c00886f0499422ab6ffa09c Mon Sep 17 00:00:00 2001
From: Maurice Kalinowski <maurice.kalinowski@qt.io>
Date: Fri, 12 Aug 2016 08:11:16 +0200
Subject: [PATCH] ANGLE: Fix initialization of zero-sized window

The clientRect might be empty when creating a window of zero size. The
side effect of a division by zero is that matrix transformation fails
and hence the swapchain gets into an invalid state.

Change-Id: Idbaed72deadb7b87052ac27e194a40d1810e6f7a
---
 .../libANGLE/renderer/d3d/d3d11/winrt/SwapChainPanelNativeWindow.cpp  | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/src/3rdparty/angle/src/libANGLE/renderer/d3d/d3d11/winrt/SwapChainPanelNativeWindow.cpp b/src/3rdparty/angle/src/libANGLE/renderer/d3d/d3d11/winrt/SwapChainPanelNativeWindow.cpp
index d3ed35b..548b460 100644
--- a/src/3rdparty/angle/src/libANGLE/renderer/d3d/d3d11/winrt/SwapChainPanelNativeWindow.cpp
+++ b/src/3rdparty/angle/src/libANGLE/renderer/d3d/d3d11/winrt/SwapChainPanelNativeWindow.cpp
@@ -322,8 +322,8 @@ HRESULT SwapChainPanelNativeWindow::createSwapChain(ID3D11Device *device,
 
 HRESULT SwapChainPanelNativeWindow::scaleSwapChain(const Size &windowSize, const RECT &clientRect)
 {
-    Size renderScale = {windowSize.Width / clientRect.right,
-                        windowSize.Height / clientRect.bottom};
+    Size renderScale = {windowSize.Width / std::max(LONG(1), clientRect.right),
+                        windowSize.Height / std::max(LONG(1), clientRect.bottom)};
     // Setup a scale matrix for the swap chain
     DXGI_MATRIX_3X2_F scaleMatrix = {};
     scaleMatrix._11 = renderScale.Width;
-- 
2.9.2.windows.1

