Modified: trunk/Source/WebCore/ChangeLog (184272 => 184273)
--- trunk/Source/WebCore/ChangeLog 2015-05-13 05:47:03 UTC (rev 184272)
+++ trunk/Source/WebCore/ChangeLog 2015-05-13 06:18:22 UTC (rev 184273)
@@ -1,3 +1,26 @@
+2015-05-12 Carlos Garcia Campos <[email protected]>
+
+ [EGL][X11] XPixmap created in GLContextEGL::createPixmapContext() is leaked
+ https://bugs.webkit.org/show_bug.cgi?id=144909
+
+ Reviewed by Sergio Villar Senin and Žan Doberšek.
+
+ The pixmap is created and passed to eglCreatePixmapSurface(), but
+ never released. eglCreatePixmapSurface() doesn't take the
+ ownership of the pixmap, so we should explicitly free it when the
+ GLContextEGL is destroyed.
+
+ * platform/graphics/egl/GLContextEGL.cpp:
+ (WebCore::GLContextEGL::createPixmapContext): Use XUniquePixmap
+ and transfer the ownership to the context by using the new
+ constructor that receives a XUniquePixmap&&.
+ (WebCore::GLContextEGL::createContext): createPixmapContext() is
+ now only defined for X11.
+ (WebCore::GLContextEGL::GLContextEGL): New constructor that
+ receives a XUniquePixmap&&.
+ * platform/graphics/egl/GLContextEGL.h: Add new constructor and
+ initialize the cairo device when defined to simplify constructors.
+
2015-05-12 Sungmann Cho <[email protected]>
Reindent DIBPixelData.h for consistency.
Modified: trunk/Source/WebCore/platform/graphics/egl/GLContextEGL.cpp (184272 => 184273)
--- trunk/Source/WebCore/platform/graphics/egl/GLContextEGL.cpp 2015-05-13 05:47:03 UTC (rev 184272)
+++ trunk/Source/WebCore/platform/graphics/egl/GLContextEGL.cpp 2015-05-13 06:18:22 UTC (rev 184273)
@@ -143,9 +143,9 @@
return std::make_unique<GLContextEGL>(context, surface, PbufferSurface);
}
+#if PLATFORM(X11)
std::unique_ptr<GLContextEGL> GLContextEGL::createPixmapContext(EGLContext sharingContext)
{
-#if PLATFORM(X11)
EGLDisplay display = sharedEGLDisplay();
if (display == EGL_NO_DISPLAY)
return nullptr;
@@ -165,25 +165,21 @@
}
Display* x11Display = downcast<PlatformDisplayX11>(PlatformDisplay::sharedDisplay()).native();
- Pixmap pixmap = XCreatePixmap(x11Display, DefaultRootWindow(x11Display), 1, 1, depth);
+ XUniquePixmap pixmap = XCreatePixmap(x11Display, DefaultRootWindow(x11Display), 1, 1, depth);
if (!pixmap) {
eglDestroyContext(display, context);
return nullptr;
}
- EGLSurface surface = eglCreatePixmapSurface(display, config, pixmap, 0);
-
+ EGLSurface surface = eglCreatePixmapSurface(display, config, pixmap.get(), 0);
if (surface == EGL_NO_SURFACE) {
- XFreePixmap(x11Display, pixmap);
eglDestroyContext(display, context);
return nullptr;
}
- return std::make_unique<GLContextEGL>(context, surface, PixmapSurface);
-#else
- return nullptr;
-#endif
+ return std::make_unique<GLContextEGL>(context, surface, WTF::move(pixmap));
}
+#endif // PLATFORM(X11)
std::unique_ptr<GLContextEGL> GLContextEGL::createContext(EGLNativeWindowType window, GLContext* sharingContext)
{
@@ -203,12 +199,13 @@
EGLContext eglSharingContext = sharingContext ? static_cast<GLContextEGL*>(sharingContext)->m_context : 0;
auto context = window ? createWindowContext(window, sharingContext) : nullptr;
+#if PLATFORM(X11)
if (!context)
context = createPixmapContext(eglSharingContext);
-
+#endif
if (!context)
context = createPbufferContext(eglSharingContext);
-
+
return WTF::move(context);
}
@@ -216,12 +213,20 @@
: m_context(context)
, m_surface(surface)
, m_type(type)
-#if USE(CAIRO)
- , m_cairoDevice(0)
-#endif
{
+ ASSERT(type != PixmapSurface);
}
+#if PLATFORM(X11)
+GLContextEGL::GLContextEGL(EGLContext context, EGLSurface surface, XUniquePixmap&& pixmap)
+ : m_context(context)
+ , m_surface(surface)
+ , m_type(PixmapSurface)
+ , m_pixmap(WTF::move(pixmap))
+{
+}
+#endif
+
GLContextEGL::~GLContextEGL()
{
#if USE(CAIRO)
Modified: trunk/Source/WebCore/platform/graphics/egl/GLContextEGL.h (184272 => 184273)
--- trunk/Source/WebCore/platform/graphics/egl/GLContextEGL.h 2015-05-13 05:47:03 UTC (rev 184272)
+++ trunk/Source/WebCore/platform/graphics/egl/GLContextEGL.h 2015-05-13 06:18:22 UTC (rev 184273)
@@ -23,9 +23,12 @@
#if USE(EGL)
#include "GLContext.h"
-
#include <EGL/egl.h>
+#if PLATFORM(X11)
+#include "XUniqueResource.h"
+#endif
+
namespace WebCore {
class GLContextEGL : public GLContext {
@@ -36,6 +39,9 @@
static std::unique_ptr<GLContextEGL> createWindowContext(EGLNativeWindowType, GLContext* sharingContext);
GLContextEGL(EGLContext, EGLSurface, EGLSurfaceType);
+#if PLATFORM(X11)
+ GLContextEGL(EGLContext, EGLSurface, XUniquePixmap&&);
+#endif
virtual ~GLContextEGL();
virtual bool makeContextCurrent();
virtual void swapBuffers();
@@ -53,7 +59,9 @@
private:
static std::unique_ptr<GLContextEGL> createPbufferContext(EGLContext sharingContext);
+#if PLATFORM(X11)
static std::unique_ptr<GLContextEGL> createPixmapContext(EGLContext sharingContext);
+#endif
static void addActiveContext(GLContextEGL*);
static void cleanupSharedEGLDisplay(void);
@@ -61,8 +69,11 @@
EGLContext m_context;
EGLSurface m_surface;
EGLSurfaceType m_type;
+#if PLATFORM(X11)
+ XUniquePixmap m_pixmap;
+#endif
#if USE(CAIRO)
- cairo_device_t* m_cairoDevice;
+ cairo_device_t* m_cairoDevice { nullptr };
#endif
};