summaryrefslogtreecommitdiffstats
path: root/src/angle/patches/0004-Make-it-possible-to-link-ANGLE-statically-for-single.patch
blob: 1dfe6154e7f2de47d890ce03afb8ff4d7409db75 (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
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
From cb00356bad800ca2397301cb8b79ad0b097bddd8 Mon Sep 17 00:00:00 2001
From: Friedemann Kleint <Friedemann.Kleint@digia.com>
Date: Tue, 16 Sep 2014 23:43:00 +0300
Subject: [PATCH 04/16] Make it possible to link ANGLE statically for
 single-thread use.

Fix exports and provide static instances of thread-local
data depending on QT_OPENGL_ES_2_ANGLE_STATIC.

Change-Id: Ifab25a820adf5953bb3b09036de53dbf7f1a7fd5
---
 src/3rdparty/angle/include/KHR/khrplatform.h |  2 +-
 src/3rdparty/angle/src/libEGL/main.cpp       | 10 ++++++++++
 src/3rdparty/angle/src/libGLESv2/main.cpp    | 10 ++++++++++
 3 files changed, 21 insertions(+), 1 deletion(-)

diff --git a/src/3rdparty/angle/include/KHR/khrplatform.h b/src/3rdparty/angle/include/KHR/khrplatform.h
index c9e6f17..1ac2d3f 100644
--- a/src/3rdparty/angle/include/KHR/khrplatform.h
+++ b/src/3rdparty/angle/include/KHR/khrplatform.h
@@ -97,7 +97,7 @@
  *-------------------------------------------------------------------------
  * This precedes the return type of the function in the function prototype.
  */
-#if defined(_WIN32) && !defined(__SCITECH_SNAP__)
+#if defined(_WIN32) && !defined(__SCITECH_SNAP__) && !defined(QT_OPENGL_ES_2_ANGLE_STATIC)
 #   define KHRONOS_APICALL __declspec(dllimport)
 #elif defined (__SYMBIAN32__)
 #   define KHRONOS_APICALL IMPORT_C
diff --git a/src/3rdparty/angle/src/libEGL/main.cpp b/src/3rdparty/angle/src/libEGL/main.cpp
index 0f8439c..8a1baef 100644
--- a/src/3rdparty/angle/src/libEGL/main.cpp
+++ b/src/3rdparty/angle/src/libEGL/main.cpp
@@ -49,6 +49,8 @@ void DeallocateCurrent()
 
 }
 
+#ifndef QT_OPENGL_ES_2_ANGLE_STATIC
+
 extern "C" BOOL WINAPI DllMain(HINSTANCE instance, DWORD reason, LPVOID reserved)
 {
     switch (reason)
@@ -100,16 +102,24 @@ extern "C" BOOL WINAPI DllMain(HINSTANCE instance, DWORD reason, LPVOID reserved
     return TRUE;
 }
 
+#endif // !QT_OPENGL_ES_2_ANGLE_STATIC
+
 namespace egl
 {
 
 Current *GetCurrentData()
 {
+#ifndef QT_OPENGL_ES_2_ANGLE_STATIC
     Current *current = reinterpret_cast<Current*>(GetTLSValue(currentTLS));
 
     // ANGLE issue 488: when the dll is loaded after thread initialization,
     // thread local storage (current) might not exist yet.
     return (current ? current : AllocateCurrent());
+#else
+    // No precautions for thread safety taken as ANGLE is used single-threaded in Qt.
+    static Current current = { EGL_SUCCESS, EGL_OPENGL_ES_API, EGL_NO_DISPLAY, EGL_NO_SURFACE, EGL_NO_SURFACE };
+    return &current;
+#endif
 }
 
 void setCurrentError(EGLint error)
diff --git a/src/3rdparty/angle/src/libGLESv2/main.cpp b/src/3rdparty/angle/src/libGLESv2/main.cpp
index 4444d1a..1c577bc 100644
--- a/src/3rdparty/angle/src/libGLESv2/main.cpp
+++ b/src/3rdparty/angle/src/libGLESv2/main.cpp
@@ -46,6 +46,8 @@ void DeallocateCurrent()
 
 }
 
+#ifndef QT_OPENGL_ES_2_ANGLE_STATIC
+
 extern "C" BOOL WINAPI DllMain(HINSTANCE instance, DWORD reason, LPVOID reserved)
 {
     switch (reason)
@@ -82,16 +84,24 @@ extern "C" BOOL WINAPI DllMain(HINSTANCE instance, DWORD reason, LPVOID reserved
     return TRUE;
 }
 
+#endif // !QT_OPENGL_ES_2_ANGLE_STATIC
+
 namespace gl
 {
 
 Current *GetCurrentData()
 {
+#ifndef QT_OPENGL_ES_2_ANGLE_STATIC
     Current *current = reinterpret_cast<Current*>(GetTLSValue(currentTLS));
 
     // ANGLE issue 488: when the dll is loaded after thread initialization,
     // thread local storage (current) might not exist yet.
     return (current ? current : AllocateCurrent());
+#else
+    // No precautions for thread safety taken as ANGLE is used single-threaded in Qt.
+    static Current current = { 0, 0 };
+    return &current;
+#endif
 }
 
 void makeCurrent(Context *context, egl::Display *display, egl::Surface *surface)
-- 
1.9.0.msysgit.0