Bug 1390386 - IsCurrent should understand mImplicitMakeCurrent. - r=jrmuizel
MozReview-Commit-ID: 7vMRUPMc3nN
--- a/gfx/gl/GLContext.h
+++ b/gfx/gl/GLContext.h
@@ -294,17 +294,24 @@ public:
* If this context is double-buffered, returns TRUE.
*/
virtual bool IsDoubleBuffered() const {
return false;
}
virtual GLContextType GetContextType() const = 0;
- virtual bool IsCurrent() const = 0;
+ bool IsCurrent() const {
+ if (mImplicitMakeCurrent)
+ return MakeCurrent();
+
+ return IsCurrentImpl();
+ }
+
+ virtual bool IsCurrentImpl() const = 0;
/**
* Get the default framebuffer for this context.
*/
virtual GLuint GetDefaultFramebuffer() {
return 0;
}
--- a/gfx/gl/GLContextCGL.h
+++ b/gfx/gl/GLContextCGL.h
@@ -42,17 +42,17 @@ public:
bool Init() override;
NSOpenGLContext* GetNSOpenGLContext() const { return mContext; }
CGLContextObj GetCGLContext() const;
virtual bool MakeCurrentImpl(bool aForce) const override;
- virtual bool IsCurrent() const override;
+ virtual bool IsCurrentImpl() const override;
virtual GLenum GetPreferredARGB32Format() const override;
virtual bool SetupLookupFunction() override;
virtual bool IsDoubleBuffered() const override;
virtual bool SwapBuffers() override;
--- a/gfx/gl/GLContextEAGL.h
+++ b/gfx/gl/GLContextEAGL.h
@@ -40,17 +40,17 @@ public:
bool Init() override;
bool AttachToWindow(nsIWidget* aWidget);
EAGLContext* GetEAGLContext() const { return mContext; }
virtual bool MakeCurrentImpl(bool aForce) const override;
- virtual bool IsCurrent() const override;
+ virtual bool IsCurrentImpl() const override;
virtual bool SetupLookupFunction() override;
virtual bool IsDoubleBuffered() const override;
virtual bool SwapBuffers() override;
virtual void GetWSIInfo(nsCString* const out) const override;
--- a/gfx/gl/GLContextEGL.h
+++ b/gfx/gl/GLContextEGL.h
@@ -70,17 +70,17 @@ public:
void SetEGLSurfaceOverride(EGLSurface surf);
EGLSurface GetEGLSurfaceOverride() {
return mSurfaceOverride;
}
virtual bool MakeCurrentImpl(bool aForce) const override;
- virtual bool IsCurrent() const override;
+ virtual bool IsCurrentImpl() const override;
virtual bool RenewSurface(widget::CompositorWidget* aWidget) override;
virtual void ReleaseSurface() override;
virtual bool SetupLookupFunction() override;
virtual bool SwapBuffers() override;
--- a/gfx/gl/GLContextGLX.h
+++ b/gfx/gl/GLContextGLX.h
@@ -43,17 +43,17 @@ public:
MOZ_ASSERT(gl->GetContextType() == GLContextType::GLX);
return static_cast<GLContextGLX*>(gl);
}
bool Init() override;
virtual bool MakeCurrentImpl(bool aForce) const override;
- virtual bool IsCurrent() const override;
+ virtual bool IsCurrentImpl() const override;
virtual bool SetupLookupFunction() override;
virtual bool IsDoubleBuffered() const override;
virtual bool SwapBuffers() override;
virtual void GetWSIInfo(nsCString* const out) const override;
--- a/gfx/gl/GLContextProviderCGL.mm
+++ b/gfx/gl/GLContextProviderCGL.mm
@@ -127,17 +127,17 @@ GLContextCGL::MakeCurrentImpl(bool aForc
// glSwapBuffers, which will happen when swapInt==0.
GLint swapInt = gfxPrefs::LayoutFrameRate() == 0 ? 0 : 1;
[mContext setValues:&swapInt forParameter:NSOpenGLCPSwapInterval];
}
return true;
}
bool
-GLContextCGL::IsCurrent() const
+GLContextCGL::IsCurrentImpl() const
{
return [NSOpenGLContext currentContext] == mContext;
}
GLenum
GLContextCGL::GetPreferredARGB32Format() const
{
return LOCAL_GL_BGRA;
--- a/gfx/gl/GLContextProviderEAGL.mm
+++ b/gfx/gl/GLContextProviderEAGL.mm
@@ -123,17 +123,17 @@ GLContextEAGL::MakeCurrentImpl(bool aFor
if(![EAGLContext setCurrentContext:mContext]) {
return false;
}
}
return true;
}
bool
-GLContextEAGL::IsCurrent() const
+GLContextEAGL::IsCurrentImpl() const
{
return [EAGLContext currentContext] == mContext;
}
bool
GLContextEAGL::SetupLookupFunction()
{
return false;
--- a/gfx/gl/GLContextProviderEGL.cpp
+++ b/gfx/gl/GLContextProviderEGL.cpp
@@ -385,17 +385,17 @@ GLContextEGL::MakeCurrentImpl(bool aForc
} else {
MOZ_ASSERT(sEGLLibrary.CachedCurrentContextMatches());
}
return succeeded;
}
bool
-GLContextEGL::IsCurrent() const
+GLContextEGL::IsCurrentImpl() const
{
return sEGLLibrary.fGetCurrentContext() == mContext;
}
bool
GLContextEGL::RenewSurface(CompositorWidget* aWidget) {
if (!mOwnsContext) {
return false;
--- a/gfx/gl/GLContextProviderGLX.cpp
+++ b/gfx/gl/GLContextProviderGLX.cpp
@@ -634,17 +634,17 @@ GLContextGLX::MakeCurrentImpl(bool aForc
mGLX->fSwapInterval(mDisplay, mDrawable, isASAP ? 0 : 1);
}
}
return succeeded;
}
bool
-GLContextGLX::IsCurrent() const
+GLContextGLX::IsCurrentImpl() const
{
return mGLX->fGetCurrentContext() == mContext;
}
bool
GLContextGLX::SetupLookupFunction()
{
mLookupFunc = (PlatformLookupFunction)sGLXLibrary.GetGetProcAddress();
--- a/gfx/gl/GLContextProviderWGL.cpp
+++ b/gfx/gl/GLContextProviderWGL.cpp
@@ -335,17 +335,17 @@ GLContextWGL::MakeCurrentImpl(bool aForc
succeeded = sWGLLib.mSymbols.fMakeCurrent(mDC, mContext);
NS_ASSERTION(succeeded, "Failed to make GL context current!");
}
return succeeded;
}
bool
-GLContextWGL::IsCurrent() const
+GLContextWGL::IsCurrentImpl() const
{
return sWGLLib.mSymbols.fGetCurrentContext() == mContext;
}
void
GLContextWGL::SetIsDoubleBuffered(bool aIsDB)
{
mIsDoubleBuffered = aIsDB;
--- a/gfx/gl/GLContextWGL.h
+++ b/gfx/gl/GLContextWGL.h
@@ -42,17 +42,17 @@ public:
MOZ_ASSERT(gl->GetContextType() == GLContextType::WGL);
return static_cast<GLContextWGL*>(gl);
}
bool Init() override;
virtual bool MakeCurrentImpl(bool aForce) const override;
- virtual bool IsCurrent() const override;
+ virtual bool IsCurrentImpl() const override;
void SetIsDoubleBuffered(bool aIsDB);
virtual bool IsDoubleBuffered() const override;
virtual bool SwapBuffers() override;
virtual bool SetupLookupFunction() override;