Bug 749678 - 3/5 - stop calling platform-specific getCurrentContext functions - r=jrmuizel

This commit is contained in:
Benoit Jacob 2012-05-08 09:47:34 -04:00
Родитель b97eec9c6c
Коммит f3194c19c8
6 изменённых файлов: 26 добавлений и 49 удалений

Просмотреть файл

@ -656,7 +656,7 @@ public:
virtual GLContextType GetContextType() { return ContextTypeUnknown; }
virtual bool MakeCurrentImpl(bool aForce = false) = 0;
virtual bool MakeCurrentImpl() = 0;
bool MakeCurrent(bool aForce = false) {
if (!aForce &&
@ -665,7 +665,7 @@ public:
return true;
}
bool success = MakeCurrentImpl(aForce);
bool success = MakeCurrentImpl();
if (success) {
SetCurrentGLContext(this);
}

Просмотреть файл

@ -171,12 +171,8 @@ public:
}
}
bool MakeCurrentImpl(bool aForce = false)
bool MakeCurrentImpl()
{
if (!aForce && [NSOpenGLContext currentContext] == mContext) {
return true;
}
if (mContext) {
[mContext makeCurrentContext];
}

Просмотреть файл

@ -420,7 +420,7 @@ public:
return true;
}
bool MakeCurrentImpl(bool aForce = false) {
bool MakeCurrentImpl() {
bool succeeded = true;
// Assume that EGL has the same problem as WGL does,
@ -442,25 +442,24 @@ public:
return succeeded;
}
#endif
if (aForce || sEGLLibrary.fGetCurrentContext() != mContext) {
#ifdef MOZ_WIDGET_QT
// Shared Qt GL context need to be informed about context switch
if (mSharedContext) {
QGLContext* qglCtx = static_cast<QGLContext*>(static_cast<GLContextEGL*>(mSharedContext.get())->mPlatformContext);
if (qglCtx) {
qglCtx->doneCurrent();
}
// Shared Qt GL context need to be informed about context switch
if (mSharedContext) {
QGLContext* qglCtx = static_cast<QGLContext*>(static_cast<GLContextEGL*>(mSharedContext.get())->mPlatformContext);
if (qglCtx) {
qglCtx->doneCurrent();
}
#endif
succeeded = sEGLLibrary.fMakeCurrent(EGL_DISPLAY(),
mSurface, mSurface,
mContext);
if (!succeeded && sEGLLibrary.fGetError() == LOCAL_EGL_CONTEXT_LOST) {
mContextLost = true;
NS_WARNING("EGL context has been lost.");
}
NS_ASSERTION(succeeded, "Failed to make GL context current!");
}
#endif
succeeded = sEGLLibrary.fMakeCurrent(EGL_DISPLAY(),
mSurface, mSurface,
mContext);
if (!succeeded && sEGLLibrary.fGetError() == LOCAL_EGL_CONTEXT_LOST) {
mContextLost = true;
NS_WARNING("EGL context has been lost.");
}
NS_ASSERTION(succeeded, "Failed to make GL context current!");
return succeeded;
}

Просмотреть файл

@ -793,20 +793,10 @@ TRY_AGAIN_NO_SHARING:
return true;
}
bool MakeCurrentImpl(bool aForce = false)
bool MakeCurrentImpl()
{
bool succeeded = true;
// With the ATI FGLRX driver, glxMakeCurrent is very slow even when the context doesn't change.
// (This is not the case with other drivers such as NVIDIA).
// So avoid calling it more than necessary. Since GLX documentation says that:
// "glXGetCurrentContext returns client-side information.
// It does not make a round trip to the server."
// I assume that it's not worth using our own TLS slot here.
if (aForce || sGLXLibrary.xGetCurrentContext() != mContext) {
succeeded = sGLXLibrary.xMakeCurrent(mDisplay, mDrawable, mContext);
NS_ASSERTION(succeeded, "Failed to make GL context current!");
}
bool succeeded = sGLXLibrary.xMakeCurrent(mDisplay, mDrawable, mContext);
NS_ASSERTION(succeeded, "Failed to make GL context current!");
return succeeded;
}

Просмотреть файл

@ -213,7 +213,7 @@ public:
return InitWithPrefix("gl", true);
}
bool MakeCurrentImpl(bool aForce = false)
bool MakeCurrentImpl()
{
bool succeeded
= sOSMesaLibrary.fMakeCurrent(mContext, mThebesSurface->Data(),

Просмотреть файл

@ -333,18 +333,10 @@ public:
return true;
}
bool MakeCurrentImpl(bool aForce = false)
bool MakeCurrentImpl()
{
BOOL succeeded = true;
// wglGetCurrentContext seems to just pull the HGLRC out
// of its TLS slot, so no need to do our own tls slot.
// You would think that wglMakeCurrent would avoid doing
// work if mContext was already current, but not so much..
if (aForce || sWGLLibrary.fGetCurrentContext() != mContext) {
succeeded = sWGLLibrary.fMakeCurrent(mDC, mContext);
NS_ASSERTION(succeeded, "Failed to make GL context current!");
}
bool succeeded = sWGLLibrary.fMakeCurrent(mDC, mContext);
NS_ASSERTION(succeeded, "Failed to make GL context current!");
return succeeded;
}