Bug 1390386 - IsCurrent should understand mImplicitMakeCurrent. - r=jrmuizel draft
authorJeff Gilbert <jgilbert@mozilla.com>
Fri, 11 Aug 2017 13:54:40 -0700
changeset 702516 dbc0e03cf34882d45606212bb838def7102622ff
parent 702515 1845f4548f69e6ba9d374bae91f8474651494c4b
child 702517 cb36af392e0439e89270f6ea22ffd014b33055ff
push id90545
push userbmo:jgilbert@mozilla.com
push dateThu, 23 Nov 2017 11:45:26 +0000
reviewersjrmuizel
bugs1390386
milestone59.0a1
Bug 1390386 - IsCurrent should understand mImplicitMakeCurrent. - r=jrmuizel MozReview-Commit-ID: 7vMRUPMc3nN
gfx/gl/GLContext.h
gfx/gl/GLContextCGL.h
gfx/gl/GLContextEAGL.h
gfx/gl/GLContextEGL.h
gfx/gl/GLContextGLX.h
gfx/gl/GLContextProviderCGL.mm
gfx/gl/GLContextProviderEAGL.mm
gfx/gl/GLContextProviderEGL.cpp
gfx/gl/GLContextProviderGLX.cpp
gfx/gl/GLContextProviderWGL.cpp
gfx/gl/GLContextWGL.h
--- a/gfx/gl/GLContext.h
+++ b/gfx/gl/GLContext.h
@@ -293,17 +293,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
@@ -384,17 +384,17 @@ GLContextEGL::MakeCurrentImpl(bool aForc
             }
         }
     }
 
     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;