- Revision
- 188522
- Author
- [email protected]
- Date
- 2015-08-17 08:36:16 -0700 (Mon, 17 Aug 2015)
Log Message
Fix possible EGL and GLX makeCurrent problem of GLPlatformContext and GLPlatformSurface
https://bugs.webkit.org/show_bug.cgi?id=147695
Patch by Jinyoung Hur <[email protected]> on 2015-08-17
Reviewed by Gyuyoung Kim.
GLPLatformContext::makeCurrent is implemented to do no-op when it thinks, comparing with a static
variable declared in GLPlatformContext.cpp, there is no changes. This can lead to not-working
makeCurrent when other part of codes, e.g., Cairo-gl, change EGL or GLX current context by calling
something like eglMakeCurrent. So modify GLPLatformContext::makeCurrent to use the return value of
eglGetCurrentContext or glXGetCurrentContext as a comparing target rather than a static variable.
In addition, GLPlatformSurface::isCurrentDrawable is also modified to use eglGetCurrentSurface or
glXGetCurrentDrawable rather than a static variable.
There are no tests because already existing GL tests will verify this change.
* platform/graphics/opengl/GLPlatformContext.cpp:
(WebCore::GLPlatformContext::makeCurrent):
(WebCore::GLPlatformContext::releaseCurrent):
(WebCore::GLCurrentContextWrapper::GLCurrentContextWrapper): Deleted.
(WebCore::GLPlatformContext::~GLPlatformContext): Deleted.
(WebCore::GLPlatformContext::isCurrentContext): Deleted.
(WebCore::GLPlatformContext::getCurrent): Deleted.
* platform/graphics/opengl/GLPlatformContext.h:
* platform/graphics/opengl/GLPlatformSurface.cpp:
(WebCore::GLPlatformSurface::~GLPlatformSurface): Deleted.
(WebCore::GLPlatformSurface::isCurrentDrawable): Deleted.
(WebCore::GLPlatformSurface::onMakeCurrent): Deleted.
(WebCore::GLPlatformSurface::destroy): Deleted.
* platform/graphics/opengl/GLPlatformSurface.h:
* platform/graphics/surfaces/egl/EGLSurface.cpp:
(WebCore::EGLTransportSurface::isCurrentDrawable):
(WebCore::EGLOffScreenSurface::isCurrentDrawable):
* platform/graphics/surfaces/egl/EGLSurface.h:
* platform/graphics/surfaces/glx/GLXSurface.cpp:
(WebCore::GLXTransportSurface::isCurrentContext):
(WebCore::GLXOffScreenSurface::isCurrentContext):
* platform/graphics/surfaces/glx/GLXSurface.h:
Modified Paths
Diff
Modified: trunk/Source/WebCore/ChangeLog (188521 => 188522)
--- trunk/Source/WebCore/ChangeLog 2015-08-17 00:52:50 UTC (rev 188521)
+++ trunk/Source/WebCore/ChangeLog 2015-08-17 15:36:16 UTC (rev 188522)
@@ -1,3 +1,43 @@
+2015-08-17 Jinyoung Hur <[email protected]>
+
+ Fix possible EGL and GLX makeCurrent problem of GLPlatformContext and GLPlatformSurface
+ https://bugs.webkit.org/show_bug.cgi?id=147695
+
+ Reviewed by Gyuyoung Kim.
+
+ GLPLatformContext::makeCurrent is implemented to do no-op when it thinks, comparing with a static
+ variable declared in GLPlatformContext.cpp, there is no changes. This can lead to not-working
+ makeCurrent when other part of codes, e.g., Cairo-gl, change EGL or GLX current context by calling
+ something like eglMakeCurrent. So modify GLPLatformContext::makeCurrent to use the return value of
+ eglGetCurrentContext or glXGetCurrentContext as a comparing target rather than a static variable.
+ In addition, GLPlatformSurface::isCurrentDrawable is also modified to use eglGetCurrentSurface or
+ glXGetCurrentDrawable rather than a static variable.
+
+ There are no tests because already existing GL tests will verify this change.
+
+ * platform/graphics/opengl/GLPlatformContext.cpp:
+ (WebCore::GLPlatformContext::makeCurrent):
+ (WebCore::GLPlatformContext::releaseCurrent):
+ (WebCore::GLCurrentContextWrapper::GLCurrentContextWrapper): Deleted.
+ (WebCore::GLPlatformContext::~GLPlatformContext): Deleted.
+ (WebCore::GLPlatformContext::isCurrentContext): Deleted.
+ (WebCore::GLPlatformContext::getCurrent): Deleted.
+ * platform/graphics/opengl/GLPlatformContext.h:
+ * platform/graphics/opengl/GLPlatformSurface.cpp:
+ (WebCore::GLPlatformSurface::~GLPlatformSurface): Deleted.
+ (WebCore::GLPlatformSurface::isCurrentDrawable): Deleted.
+ (WebCore::GLPlatformSurface::onMakeCurrent): Deleted.
+ (WebCore::GLPlatformSurface::destroy): Deleted.
+ * platform/graphics/opengl/GLPlatformSurface.h:
+ * platform/graphics/surfaces/egl/EGLSurface.cpp:
+ (WebCore::EGLTransportSurface::isCurrentDrawable):
+ (WebCore::EGLOffScreenSurface::isCurrentDrawable):
+ * platform/graphics/surfaces/egl/EGLSurface.h:
+ * platform/graphics/surfaces/glx/GLXSurface.cpp:
+ (WebCore::GLXTransportSurface::isCurrentContext):
+ (WebCore::GLXOffScreenSurface::isCurrentContext):
+ * platform/graphics/surfaces/glx/GLXSurface.h:
+
2015-08-15 Chris Dumez <[email protected]>
Refactor HTMLCollection to be as fast as CachedLiveNodeList
Modified: trunk/Source/WebCore/platform/graphics/opengl/GLPlatformContext.cpp (188521 => 188522)
--- trunk/Source/WebCore/platform/graphics/opengl/GLPlatformContext.cpp 2015-08-17 00:52:50 UTC (rev 188521)
+++ trunk/Source/WebCore/platform/graphics/opengl/GLPlatformContext.cpp 2015-08-17 15:36:16 UTC (rev 188522)
@@ -43,7 +43,6 @@
#else
static PFNGLGETGRAPHICSRESETSTATUSARBPROC glGetGraphicsResetStatus = 0;
#endif
-static GLPlatformContext* m_currentContext = 0;
class GLCurrentContextWrapper : public GLPlatformContext {
@@ -56,11 +55,14 @@
#elif USE(EGL)
m_contextHandle = eglGetCurrentContext();
#endif
- if (m_contextHandle)
- m_currentContext = this;
}
virtual ~GLCurrentContextWrapper() { }
+
+ bool isCurrentContext() const override
+ {
+ return true;
+ }
};
static std::unique_ptr<GLPlatformContext> createOffScreenContext()
@@ -185,23 +187,21 @@
GLPlatformContext::~GLPlatformContext()
{
- if (this == m_currentContext)
- m_currentContext = 0;
}
bool GLPlatformContext::makeCurrent(GLPlatformSurface* surface)
{
m_contextLost = false;
- if (m_currentContext == this && (!surface || surface->isCurrentDrawable()))
+ if (isCurrentContext() && (!surface || surface->isCurrentDrawable()))
return true;
- m_currentContext = 0;
+ GLPlatformContext* currentContext = 0;
if (!surface || (surface && !surface->drawable()))
platformReleaseCurrent();
else if (platformMakeCurrent(surface)) {
- m_currentContext = this;
+ currentContext = this;
surface->onMakeCurrent();
}
@@ -228,7 +228,7 @@
}
}
- return m_currentContext;
+ return currentContext;
}
bool GLPlatformContext::isValid() const
@@ -238,10 +238,8 @@
void GLPlatformContext::releaseCurrent()
{
- if (this == m_currentContext) {
- m_currentContext = 0;
+ if (isCurrentContext())
platformReleaseCurrent();
- }
}
PlatformContext GLPlatformContext::handle() const
@@ -249,21 +247,11 @@
return m_contextHandle;
}
-bool GLPlatformContext::isCurrentContext() const
-{
- return true;
-}
-
bool GLPlatformContext::initialize(GLPlatformSurface*, PlatformContext)
{
return true;
}
-GLPlatformContext* GLPlatformContext::getCurrent()
-{
- return m_currentContext;
-}
-
bool GLPlatformContext::platformMakeCurrent(GLPlatformSurface*)
{
return true;
Modified: trunk/Source/WebCore/platform/graphics/opengl/GLPlatformContext.h (188521 => 188522)
--- trunk/Source/WebCore/platform/graphics/opengl/GLPlatformContext.h 2015-08-17 00:52:50 UTC (rev 188521)
+++ trunk/Source/WebCore/platform/graphics/opengl/GLPlatformContext.h 2015-08-17 15:36:16 UTC (rev 188522)
@@ -73,15 +73,13 @@
virtual PlatformContext handle() const;
- virtual bool isCurrentContext() const;
+ virtual bool isCurrentContext() const = 0;
bool isValid() const;
// Destroys any GL resources associated with this context.
virtual void destroy();
- static GLPlatformContext* getCurrent();
-
protected:
GLPlatformContext();
virtual bool platformMakeCurrent(GLPlatformSurface*);
Modified: trunk/Source/WebCore/platform/graphics/opengl/GLPlatformSurface.cpp (188521 => 188522)
--- trunk/Source/WebCore/platform/graphics/opengl/GLPlatformSurface.cpp 2015-08-17 00:52:50 UTC (rev 188521)
+++ trunk/Source/WebCore/platform/graphics/opengl/GLPlatformSurface.cpp 2015-08-17 15:36:16 UTC (rev 188522)
@@ -40,8 +40,6 @@
namespace WebCore {
-static GLPlatformSurface* m_currentDrawable = 0;
-
std::unique_ptr<GLPlatformSurface> GLPlatformSurface::createOffScreenSurface(SurfaceAttributes attributes)
{
std::unique_ptr<GLPlatformSurface> surface;
@@ -68,8 +66,6 @@
GLPlatformSurface::~GLPlatformSurface()
{
- if (m_currentDrawable == this)
- m_currentDrawable = 0;
}
PlatformBufferHandle GLPlatformSurface::handle() const
@@ -97,14 +93,8 @@
notImplemented();
}
-bool GLPlatformSurface::isCurrentDrawable() const
-{
- return m_currentDrawable == this;
-}
-
void GLPlatformSurface::onMakeCurrent()
{
- m_currentDrawable = this;
}
void GLPlatformSurface::updateContents(const uint32_t)
@@ -117,8 +107,6 @@
void GLPlatformSurface::destroy()
{
- if (m_currentDrawable == this)
- m_currentDrawable = 0;
}
GLPlatformSurface::SurfaceAttributes GLPlatformSurface::attributes() const
Modified: trunk/Source/WebCore/platform/graphics/opengl/GLPlatformSurface.h (188521 => 188522)
--- trunk/Source/WebCore/platform/graphics/opengl/GLPlatformSurface.h 2015-08-17 00:52:50 UTC (rev 188521)
+++ trunk/Source/WebCore/platform/graphics/opengl/GLPlatformSurface.h 2015-08-17 15:36:16 UTC (rev 188522)
@@ -63,7 +63,8 @@
virtual void swapBuffers();
- virtual bool isCurrentDrawable() const;
+ virtual bool isCurrentDrawable() const = 0;
+
virtual void onMakeCurrent();
// Convenience Function to update surface backbuffer with texture contents.
Modified: trunk/Source/WebCore/platform/graphics/surfaces/egl/EGLSurface.cpp (188521 => 188522)
--- trunk/Source/WebCore/platform/graphics/surfaces/egl/EGLSurface.cpp 2015-08-17 00:52:50 UTC (rev 188521)
+++ trunk/Source/WebCore/platform/graphics/surfaces/egl/EGLSurface.cpp 2015-08-17 15:36:16 UTC (rev 188522)
@@ -86,6 +86,11 @@
return m_configSelector->attributes();
}
+bool EGLTransportSurface::isCurrentDrawable() const
+{
+ return m_drawable == eglGetCurrentSurface(EGL_DRAW);
+}
+
EGLTransportSurface::~EGLTransportSurface()
{
}
@@ -138,6 +143,11 @@
return m_configSelector->attributes();
}
+bool EGLOffScreenSurface::isCurrentDrawable() const
+{
+ return m_drawable == eglGetCurrentSurface(EGL_DRAW);
+}
+
PlatformSurfaceConfig EGLOffScreenSurface::configuration()
{
return m_configSelector->pixmapContextConfig();
Modified: trunk/Source/WebCore/platform/graphics/surfaces/egl/EGLSurface.h (188521 => 188522)
--- trunk/Source/WebCore/platform/graphics/surfaces/egl/EGLSurface.h 2015-08-17 00:52:50 UTC (rev 188521)
+++ trunk/Source/WebCore/platform/graphics/surfaces/egl/EGLSurface.h 2015-08-17 15:36:16 UTC (rev 188522)
@@ -44,6 +44,7 @@
virtual PlatformSurfaceConfig configuration() override;
virtual void destroy() override;
virtual GLPlatformSurface::SurfaceAttributes attributes() const override;
+ virtual bool isCurrentDrawable() const override;
protected:
EGLTransportSurface(const IntSize&, SurfaceAttributes);
@@ -57,6 +58,7 @@
virtual PlatformSurfaceConfig configuration() override;
virtual void destroy() override;
virtual GLPlatformSurface::SurfaceAttributes attributes() const override;
+ virtual bool isCurrentDrawable() const override;
protected:
EGLOffScreenSurface(SurfaceAttributes);
Modified: trunk/Source/WebCore/platform/graphics/surfaces/glx/GLXSurface.cpp (188521 => 188522)
--- trunk/Source/WebCore/platform/graphics/surfaces/glx/GLXSurface.cpp 2015-08-17 00:52:50 UTC (rev 188521)
+++ trunk/Source/WebCore/platform/graphics/surfaces/glx/GLXSurface.cpp 2015-08-17 15:36:16 UTC (rev 188522)
@@ -128,6 +128,11 @@
return m_configSelector->attributes();
}
+bool GLXTransportSurface::isCurrentDrawable() const
+{
+ return m_drawable == glXGetCurrentDrawable();
+}
+
GLXOffScreenSurface::GLXOffScreenSurface(SurfaceAttributes surfaceAttributes)
: GLPlatformSurface(surfaceAttributes)
, m_pixmap(0)
@@ -167,6 +172,11 @@
return m_configSelector->pixmapContextConfig();
}
+bool GLXOffScreenSurface::isCurrentDrawable() const
+{
+ return m_drawable == glXGetCurrentDrawable();
+}
+
void GLXOffScreenSurface::destroy()
{
freeResources();
Modified: trunk/Source/WebCore/platform/graphics/surfaces/glx/GLXSurface.h (188521 => 188522)
--- trunk/Source/WebCore/platform/graphics/surfaces/glx/GLXSurface.h 2015-08-17 00:52:50 UTC (rev 188521)
+++ trunk/Source/WebCore/platform/graphics/surfaces/glx/GLXSurface.h 2015-08-17 15:36:16 UTC (rev 188522)
@@ -43,6 +43,7 @@
virtual void swapBuffers() override;
virtual void setGeometry(const IntRect&) override;
virtual GLPlatformSurface::SurfaceAttributes attributes() const override;
+ virtual bool isCurrentDrawable() const override;
virtual void destroy() override;
private:
@@ -55,6 +56,7 @@
GLXOffScreenSurface(SurfaceAttributes);
virtual ~GLXOffScreenSurface();
virtual PlatformSurfaceConfig configuration() override;
+ virtual bool isCurrentDrawable() const override;
virtual void destroy() override;
private: