mirror of
https://gitlab.winehq.org/wine/wine-gecko.git
synced 2024-09-13 09:24:08 -07:00
backout 6ae546e8bc55
This commit is contained in:
parent
e8a9b6ac25
commit
70ec83200b
@ -63,8 +63,8 @@ namespace mozilla {
|
||||
namespace gl {
|
||||
|
||||
#ifdef DEBUG
|
||||
Monitor GLContext::sCurrentGLContextMonitor("sCurrentGLContext_monitor");
|
||||
PRUintn GLContext::sCurrentGLContextTLS = -1;
|
||||
// see comment near declaration in GLContext.h. Should be thread-local.
|
||||
GLContext* GLContext::sCurrentGLContext = nsnull;
|
||||
#endif
|
||||
|
||||
PRUint32 GLContext::sDebugMode = 0;
|
||||
|
@ -52,10 +52,6 @@
|
||||
#include <windows.h>
|
||||
#endif
|
||||
|
||||
#ifdef DEBUG
|
||||
#include "mozilla/Monitor.h"
|
||||
#endif
|
||||
|
||||
#include "GLDefs.h"
|
||||
#include "gfxASurface.h"
|
||||
#include "gfxImageSurface.h"
|
||||
@ -608,13 +604,7 @@ public:
|
||||
|
||||
bool MakeCurrent(bool aForce = false) {
|
||||
#ifdef DEBUG
|
||||
MonitorAutoLock lock(sCurrentGLContextMonitor);
|
||||
GLContext *currentGLContext = NULL;
|
||||
|
||||
if (sCurrentGLContextTLS == -1)
|
||||
PR_NewThreadPrivateIndex(&sCurrentGLContextTLS, NULL);
|
||||
|
||||
PR_SetThreadPrivate(sCurrentGLContextTLS, this);
|
||||
sCurrentGLContext = this;
|
||||
#endif
|
||||
return MakeCurrentImpl(aForce);
|
||||
}
|
||||
@ -1519,13 +1509,10 @@ protected:
|
||||
GLContextSymbols mSymbols;
|
||||
|
||||
#ifdef DEBUG
|
||||
// GLDebugMode will check that we don't send call
|
||||
// to a GLContext that isn't current on the current
|
||||
// thread.
|
||||
// Store the current context when binding to thread local
|
||||
// storage to support DebugMode on an arbitrary thread.
|
||||
static Monitor sCurrentGLContextMonitor;
|
||||
static PRUintn sCurrentGLContextTLS;
|
||||
// this should be thread-local, but that is slightly annoying to implement because on Mac
|
||||
// we don't have any __thread-like keyword. So for now, MOZ_GL_DEBUG assumes (and asserts)
|
||||
// that only the main thread is doing OpenGL calls.
|
||||
static THEBES_API GLContext* sCurrentGLContext;
|
||||
#endif
|
||||
|
||||
void UpdateActualFormat();
|
||||
@ -1649,18 +1636,21 @@ public:
|
||||
|
||||
void BeforeGLCall(const char* glFunction) {
|
||||
if (DebugMode()) {
|
||||
MonitorAutoLock lock(sCurrentGLContextMonitor);
|
||||
GLContext *currentGLContext = NULL;
|
||||
|
||||
if (sCurrentGLContextTLS != -1)
|
||||
currentGLContext = (GLContext*)PR_GetThreadPrivate(sCurrentGLContextTLS);
|
||||
|
||||
// since the static member variable sCurrentGLContext is not thread-local as it should,
|
||||
// we have to assert that we're in the main thread. Note that sCurrentGLContext is only used
|
||||
// for the OpenGL debug mode.
|
||||
if (!NS_IsMainThread()) {
|
||||
NS_ERROR("OpenGL call from non-main thread. While this is fine in itself, "
|
||||
"the OpenGL debug mode, which is currently enabled, doesn't support this. "
|
||||
"It needs to be patched by making GLContext::sCurrentGLContext be thread-local.\n");
|
||||
NS_ABORT();
|
||||
}
|
||||
if (DebugMode() & DebugTrace)
|
||||
printf_stderr("[gl:%p] > %s\n", this, glFunction);
|
||||
if (this != currentGLContext) {
|
||||
if (this != sCurrentGLContext) {
|
||||
printf_stderr("Fatal: %s called on non-current context %p. "
|
||||
"The current context for this thread is %p.\n",
|
||||
glFunction, this, currentGLContext);
|
||||
glFunction, this, sCurrentGLContext);
|
||||
NS_ABORT();
|
||||
}
|
||||
}
|
||||
|
@ -267,6 +267,15 @@ is_power_of_two(int v)
|
||||
static void BeforeGLCall(const char* glFunction)
|
||||
{
|
||||
if (GLContext::DebugMode()) {
|
||||
// since the static member variable sCurrentGLContext is not thread-local as it should,
|
||||
// we have to assert that we're in the main thread. Note that sCurrentGLContext is only used
|
||||
// for the OpenGL debug mode.
|
||||
if (!NS_IsMainThread()) {
|
||||
NS_ERROR("OpenGL call from non-main thread. While this is fine in itself, "
|
||||
"the OpenGL debug mode, which is currently enabled, doesn't support this. "
|
||||
"It needs to be patched by making GLContext::sCurrentGLContext be thread-local.\n");
|
||||
NS_ABORT();
|
||||
}
|
||||
if (GLContext::DebugMode() & GLContext::DebugTrace)
|
||||
printf_stderr("[egl] > %s\n", glFunction);
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user