summaryrefslogtreecommitdiffstats
path: root/src/angle/patches/0008-ANGLE-DX11-Prevent-assert-when-view-is-minimized-or-.patch
blob: 10b36c2096e06a392bc6c3edbc1a516ff2e016b2 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
From 6f4600a842bbc7438c8d330305de82b960598ad3 Mon Sep 17 00:00:00 2001
From: Andrew Knight <andrew.knight@digia.com>
Date: Sun, 15 Sep 2013 00:18:44 +0300
Subject: [PATCH] ANGLE DX11: Prevent assert when view is minimized or size
 goes to 0x0

This allows the Direct3D 11 version of ANGLE to gracefully allow
surfaces with dimensions of 0. This is important because Qt may resize
the surface to 0x0 because of window minimization or other user
action (window resize). As EGL specifies that empty (0x0) surfaces are
valid, this makes sure an assert doesn't occur in the case that a valid
surface is resized to an empty one.

Change-Id: Ia60c4c694090d03c1da7f43c56e90b925c8eab6d
---
 src/3rdparty/angle/src/libEGL/Surface.cpp                 | 9 ++++++++-
 src/3rdparty/angle/src/libGLESv2/renderer/SwapChain11.cpp | 3 +++
 2 files changed, 11 insertions(+), 1 deletion(-)

diff --git a/src/3rdparty/angle/src/libEGL/Surface.cpp b/src/3rdparty/angle/src/libEGL/Surface.cpp
index 311790c..b47a7bc 100644
--- a/src/3rdparty/angle/src/libEGL/Surface.cpp
+++ b/src/3rdparty/angle/src/libEGL/Surface.cpp
@@ -135,9 +135,16 @@ bool Surface::resetSwapChain()
 
 bool Surface::resizeSwapChain(int backbufferWidth, int backbufferHeight)
 {
-    ASSERT(backbufferWidth >= 0 && backbufferHeight >= 0);
     ASSERT(mSwapChain);
 
+    // Prevent bad swap chain resize by calling reset if size is invalid
+    if (backbufferWidth < 1 || backbufferHeight < 1)
+    {
+        mWidth = backbufferWidth;
+        mHeight = backbufferHeight;
+        return mSwapChain->reset(0, 0, mSwapInterval) == EGL_SUCCESS;
+    }
+
     EGLint status = mSwapChain->resize(backbufferWidth, backbufferHeight);
 
     if (status == EGL_CONTEXT_LOST)
diff --git a/src/3rdparty/angle/src/libGLESv2/renderer/SwapChain11.cpp b/src/3rdparty/angle/src/libGLESv2/renderer/SwapChain11.cpp
index a50db3b..0da58cb 100644
--- a/src/3rdparty/angle/src/libGLESv2/renderer/SwapChain11.cpp
+++ b/src/3rdparty/angle/src/libGLESv2/renderer/SwapChain11.cpp
@@ -369,6 +369,9 @@ EGLint SwapChain11::resize(EGLint backbufferWidth, EGLint backbufferHeight)
         return EGL_BAD_ACCESS;
     }
 
+    if (!mSwapChain)
+        reset(backbufferWidth, backbufferHeight, mSwapInterval);
+
     // Can only call resize if we have already created our swap buffer and resources
     ASSERT(mSwapChain && mBackBufferTexture && mBackBufferRTView);
 
-- 
1.8.1.msysgit.1