6
6
#define FLUTTER_IMPELLER_RENDERER_BACKEND_GLES_PROC_TABLE_GLES_H_
7
7
8
8
#include < functional>
9
+ #include < mutex>
9
10
#include < string>
11
+ #include < thread>
10
12
11
13
#include " flutter/fml/logging.h"
12
14
#include " flutter/fml/mapping.h"
@@ -99,6 +101,14 @@ struct GLProc {
99
101
// /
100
102
bool log_calls = false ;
101
103
104
+ // ----------------------------------------------------------------------------
105
+ // / Whether the OpenGL call asserts it is only used from / one thread in
106
+ // / IMPELLER_DEBUG builds.
107
+ // /
108
+ // / This is used to block drawing calls from happening anywhere but the raster
109
+ // / thread.
110
+ bool enforce_one_thread = false ;
111
+
102
112
// ----------------------------------------------------------------------------
103
113
// / @brief Call the GL function with the appropriate parameters. Lookup
104
114
// / the documentation for the GL function being called to
@@ -118,6 +128,16 @@ struct GLProc {
118
128
FML_LOG (IMPORTANT) << name
119
129
<< BuildGLArguments (std::forward<Args>(args)...);
120
130
}
131
+ if (enforce_one_thread) {
132
+ static std::thread::id allowed_thread;
133
+ static std::once_flag flag;
134
+ std::call_once (flag,
135
+ []() { allowed_thread = std::this_thread::get_id (); });
136
+ FML_CHECK (std::this_thread::get_id () == allowed_thread)
137
+ << " This symbol is expected to be called from one thread, the raster "
138
+ " thread. As of this addition, the design of the engine should be "
139
+ " using non-raster threads only for uploading images." ;
140
+ }
121
141
#endif // defined(IMPELLER_DEBUG) && !defined(NDEBUG)
122
142
return function (std::forward<Args>(args)...);
123
143
}
0 commit comments