From e163e03a8ff8401bf91807ca4cee27b28f80267e Mon Sep 17 00:00:00 2001 From: Vladimir Vukicevic Date: Thu, 20 May 2010 17:20:39 -0700 Subject: [PATCH] b=567272; wglMakeCurrent is expensive; r=bas --- gfx/thebes/src/GLContextProviderWGL.cpp | 13 +++++++++++-- 1 file changed, 11 insertions(+), 2 deletions(-) diff --git a/gfx/thebes/src/GLContextProviderWGL.cpp b/gfx/thebes/src/GLContextProviderWGL.cpp index e89a317993f7..0010e679ec8c 100644 --- a/gfx/thebes/src/GLContextProviderWGL.cpp +++ b/gfx/thebes/src/GLContextProviderWGL.cpp @@ -207,8 +207,17 @@ public: PRBool MakeCurrent() { - BOOL succeeded = sWGLLibrary.fMakeCurrent(mDC, mContext); - NS_ASSERTION(succeeded, "Failed to make GL context current!"); + BOOL succeeded = PR_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 (sWGLLibrary.fGetCurrentContext() != mContext) { + succeeded = sWGLLibrary.fMakeCurrent(mDC, mContext); + NS_ASSERTION(succeeded, "Failed to make GL context current!"); + } + return succeeded; }