Title: [183868] trunk/Source/WebCore
Revision
183868
Author
carlo...@webkit.org
Date
2015-05-06 09:06:30 -0700 (Wed, 06 May 2015)

Log Message

[EGL] Move EGLDisplay handling to PlatformDisplay and remove PlatformDisplay definition from GLDefs.h
https://bugs.webkit.org/show_bug.cgi?id=144685

Reviewed by Martin Robinson.

The EGL display is also initialized in multiple places, and could
be unified in PlatformDisplay. Remove the PlatformDisplay
definition from platform/graphics/opengl/GLDefs.h to avoid conflicts.

* platform/graphics/PlatformDisplay.cpp:
(WebCore::PlatformDisplay::PlatformDisplay): Initialize m_eglDisplay.
(WebCore::PlatformDisplay::~PlatformDisplay): Call terminateEGLDisplay().
(WebCore::PlatformDisplay::eglDisplay): Lazy intialize the EGL
display and return it.
(WebCore::PlatformDisplay::initializeEGLDisplay):
(WebCore::PlatformDisplay::terminateEGLDisplay):
* platform/graphics/PlatformDisplay.h:
* platform/graphics/egl/GLContextEGL.cpp:
(WebCore::sharedEGLDisplay): Use PlatformDisplay::eglDisplay().
* platform/graphics/opengl/GLDefs.h: Remove unneeded definitions.
* platform/graphics/opengl/GLPlatformSurface.cpp:
(WebCore::GLPlatformSurface::GLPlatformSurface): Remove
m_sharedDisplay member, PlatformDisplay::sharedDisplay() can be used instead.
(WebCore::GLPlatformSurface::sharedDisplay): Deleted.
* platform/graphics/opengl/GLPlatformSurface.h:
* platform/graphics/surfaces/egl/EGLConfigSelector.h: Use
EGLDisplay instead of PlatformDisplay.
* platform/graphics/surfaces/egl/EGLContext.cpp:
(WebCore::EGLOffScreenContext::initialize): Use PlatformDisplay::eglDisplay().
* platform/graphics/surfaces/egl/EGLHelper.cpp: Remove the
EGLDisplayConnection clas and use PlatformDisplay instead.
(WebCore::EGLHelper::eglDisplay):
(WebCore::EGLHelper::currentDisplay):
(WebCore::EGLDisplayConnection::EGLDisplayConnection): Deleted.
(WebCore::EGLDisplayConnection::~EGLDisplayConnection): Deleted.
(WebCore::EGLDisplayConnection::display): Deleted.
(WebCore::EGLDisplayConnection::terminate): Deleted.
* platform/graphics/surfaces/egl/EGLHelper.h:
* platform/graphics/surfaces/egl/EGLSurface.cpp:
(WebCore::EGLTransportSurface::EGLTransportSurface): Use EGLHelper::eglDisplay().
(WebCore::EGLTransportSurface::destroy): Ditto.
(WebCore::EGLOffScreenSurface::EGLOffScreenSurface): Ditto.
(WebCore::EGLOffScreenSurface::destroy): Ditto.
* platform/graphics/surfaces/egl/EGLXSurface.cpp:
(WebCore::EGLWindowTransportSurface::EGLWindowTransportSurface):
Use PlatformDisplay::eglDisplay().
(WebCore::EGLWindowTransportSurface::swapBuffers): Ditto.
(WebCore::EGLPixmapSurface::EGLPixmapSurface): Ditto.
* platform/graphics/surfaces/glx/GLXContext.cpp:
(WebCore::GLXOffScreenContext::initialize): Use X11Helper::nativeDisplay().
* platform/graphics/surfaces/glx/GLXSurface.cpp:
(WebCore::GLXTransportSurface::GLXTransportSurface): Do not use m_sharedDisplay.
(WebCore::GLXOffScreenSurface::initialize): Ditto.
* platform/graphics/wayland/PlatformDisplayWayland.cpp:
(WebCore::PlatformDisplayWayland::PlatformDisplayWayland): Call
PlatformDisplay::initializeEGLDisplay() to insialize the EGL display.
* platform/graphics/wayland/PlatformDisplayWayland.h:
* platform/graphics/x11/PlatformDisplayX11.cpp:
(WebCore::PlatformDisplayX11::initializeEGLDisplay): Override
PlatformDisplay::initializeEGLDisplay() to initialize the
m_eglDisplay member.
* platform/graphics/x11/PlatformDisplayX11.h:

Modified Paths

Diff

Modified: trunk/Source/WebCore/ChangeLog (183867 => 183868)


--- trunk/Source/WebCore/ChangeLog	2015-05-06 12:55:20 UTC (rev 183867)
+++ trunk/Source/WebCore/ChangeLog	2015-05-06 16:06:30 UTC (rev 183868)
@@ -1,3 +1,68 @@
+2015-05-06  Carlos Garcia Campos  <cgar...@igalia.com>
+
+        [EGL] Move EGLDisplay handling to PlatformDisplay and remove PlatformDisplay definition from GLDefs.h
+        https://bugs.webkit.org/show_bug.cgi?id=144685
+
+        Reviewed by Martin Robinson.
+
+        The EGL display is also initialized in multiple places, and could
+        be unified in PlatformDisplay. Remove the PlatformDisplay
+        definition from platform/graphics/opengl/GLDefs.h to avoid conflicts.
+
+        * platform/graphics/PlatformDisplay.cpp:
+        (WebCore::PlatformDisplay::PlatformDisplay): Initialize m_eglDisplay.
+        (WebCore::PlatformDisplay::~PlatformDisplay): Call terminateEGLDisplay().
+        (WebCore::PlatformDisplay::eglDisplay): Lazy intialize the EGL
+        display and return it.
+        (WebCore::PlatformDisplay::initializeEGLDisplay):
+        (WebCore::PlatformDisplay::terminateEGLDisplay):
+        * platform/graphics/PlatformDisplay.h:
+        * platform/graphics/egl/GLContextEGL.cpp:
+        (WebCore::sharedEGLDisplay): Use PlatformDisplay::eglDisplay().
+        * platform/graphics/opengl/GLDefs.h: Remove unneeded definitions.
+        * platform/graphics/opengl/GLPlatformSurface.cpp:
+        (WebCore::GLPlatformSurface::GLPlatformSurface): Remove
+        m_sharedDisplay member, PlatformDisplay::sharedDisplay() can be used instead.
+        (WebCore::GLPlatformSurface::sharedDisplay): Deleted.
+        * platform/graphics/opengl/GLPlatformSurface.h:
+        * platform/graphics/surfaces/egl/EGLConfigSelector.h: Use
+        EGLDisplay instead of PlatformDisplay.
+        * platform/graphics/surfaces/egl/EGLContext.cpp:
+        (WebCore::EGLOffScreenContext::initialize): Use PlatformDisplay::eglDisplay().
+        * platform/graphics/surfaces/egl/EGLHelper.cpp: Remove the
+        EGLDisplayConnection clas and use PlatformDisplay instead.
+        (WebCore::EGLHelper::eglDisplay):
+        (WebCore::EGLHelper::currentDisplay):
+        (WebCore::EGLDisplayConnection::EGLDisplayConnection): Deleted.
+        (WebCore::EGLDisplayConnection::~EGLDisplayConnection): Deleted.
+        (WebCore::EGLDisplayConnection::display): Deleted.
+        (WebCore::EGLDisplayConnection::terminate): Deleted.
+        * platform/graphics/surfaces/egl/EGLHelper.h:
+        * platform/graphics/surfaces/egl/EGLSurface.cpp:
+        (WebCore::EGLTransportSurface::EGLTransportSurface): Use EGLHelper::eglDisplay().
+        (WebCore::EGLTransportSurface::destroy): Ditto.
+        (WebCore::EGLOffScreenSurface::EGLOffScreenSurface): Ditto.
+        (WebCore::EGLOffScreenSurface::destroy): Ditto.
+        * platform/graphics/surfaces/egl/EGLXSurface.cpp:
+        (WebCore::EGLWindowTransportSurface::EGLWindowTransportSurface):
+        Use PlatformDisplay::eglDisplay().
+        (WebCore::EGLWindowTransportSurface::swapBuffers): Ditto.
+        (WebCore::EGLPixmapSurface::EGLPixmapSurface): Ditto.
+        * platform/graphics/surfaces/glx/GLXContext.cpp:
+        (WebCore::GLXOffScreenContext::initialize): Use X11Helper::nativeDisplay().
+        * platform/graphics/surfaces/glx/GLXSurface.cpp:
+        (WebCore::GLXTransportSurface::GLXTransportSurface): Do not use m_sharedDisplay.
+        (WebCore::GLXOffScreenSurface::initialize): Ditto.
+        * platform/graphics/wayland/PlatformDisplayWayland.cpp:
+        (WebCore::PlatformDisplayWayland::PlatformDisplayWayland): Call
+        PlatformDisplay::initializeEGLDisplay() to insialize the EGL display.
+        * platform/graphics/wayland/PlatformDisplayWayland.h:
+        * platform/graphics/x11/PlatformDisplayX11.cpp:
+        (WebCore::PlatformDisplayX11::initializeEGLDisplay): Override
+        PlatformDisplay::initializeEGLDisplay() to initialize the
+        m_eglDisplay member.
+        * platform/graphics/x11/PlatformDisplayX11.h:
+
 2015-05-06  Joseph Pecoraro  <pecor...@apple.com>
 
         Web Inspector: DOMStorage exception and issue with sessionStorage

Modified: trunk/Source/WebCore/platform/graphics/PlatformDisplay.cpp (183867 => 183868)


--- trunk/Source/WebCore/platform/graphics/PlatformDisplay.cpp	2015-05-06 12:55:20 UTC (rev 183867)
+++ trunk/Source/WebCore/platform/graphics/PlatformDisplay.cpp	2015-05-06 16:06:30 UTC (rev 183868)
@@ -45,6 +45,10 @@
 #include <Ecore_X.h>
 #endif
 
+#if USE(EGL)
+#include <EGL/egl.h>
+#endif
+
 namespace WebCore {
 
 std::unique_ptr<PlatformDisplay> PlatformDisplay::createPlatformDisplay()
@@ -85,4 +89,63 @@
     return *display;
 }
 
+PlatformDisplay::PlatformDisplay()
+#if USE(EGL)
+    : m_eglDisplay(EGL_NO_DISPLAY)
+#endif
+{
+}
+
+PlatformDisplay::~PlatformDisplay()
+{
+#if USE(EGL)
+    terminateEGLDisplay();
+#endif
+}
+
+#if USE(EGL)
+EGLDisplay PlatformDisplay::eglDisplay() const
+{
+    if (!m_eglDisplayInitialized)
+        const_cast<PlatformDisplay*>(this)->initializeEGLDisplay();
+    return m_eglDisplay;
+}
+
+void PlatformDisplay::initializeEGLDisplay()
+{
+    m_eglDisplayInitialized = true;
+
+    if (m_eglDisplay == EGL_NO_DISPLAY) {
+        m_eglDisplay = eglGetDisplay(EGL_DEFAULT_DISPLAY);
+        if (m_eglDisplay == EGL_NO_DISPLAY)
+            return;
+    }
+
+    if (eglInitialize(m_eglDisplay, 0, 0) == EGL_FALSE) {
+        LOG_ERROR("EGLDisplay Initialization failed.");
+        terminateEGLDisplay();
+        return;
+    }
+
+#if USE(OPENGL_ES_2)
+    static const EGLenum eglAPIVersion = EGL_OPENGL_ES_API;
+#else
+    static const EGLenum eglAPIVersion = EGL_OPENGL_API;
+#endif
+    if (eglBindAPI(eglAPIVersion) == EGL_FALSE) {
+        LOG_ERROR("Failed to set EGL API(%d).", eglGetError());
+        terminateEGLDisplay();
+        return;
+    }
+}
+
+void PlatformDisplay::terminateEGLDisplay()
+{
+    if (m_eglDisplay == EGL_NO_DISPLAY)
+        return;
+    eglTerminate(m_eglDisplay);
+    m_eglDisplay = EGL_NO_DISPLAY;
+}
+#endif // USE(EGL)
+
 } // namespace WebCore

Modified: trunk/Source/WebCore/platform/graphics/PlatformDisplay.h (183867 => 183868)


--- trunk/Source/WebCore/platform/graphics/PlatformDisplay.h	2015-05-06 12:55:20 UTC (rev 183867)
+++ trunk/Source/WebCore/platform/graphics/PlatformDisplay.h	2015-05-06 16:06:30 UTC (rev 183868)
@@ -29,13 +29,17 @@
 #include <wtf/Noncopyable.h>
 #include <wtf/TypeCasts.h>
 
+#if USE(EGL)
+typedef void *EGLDisplay;
+#endif
+
 namespace WebCore {
 
 class PlatformDisplay {
     WTF_MAKE_NONCOPYABLE(PlatformDisplay); WTF_MAKE_FAST_ALLOCATED;
 public:
     static PlatformDisplay& sharedDisplay();
-    virtual ~PlatformDisplay() = default;
+    virtual ~PlatformDisplay();
 
     enum class Type {
 #if PLATFORM(X11)
@@ -48,11 +52,27 @@
 
     virtual Type type() const = 0;
 
+#if USE(EGL)
+    EGLDisplay eglDisplay() const;
+#endif
+
 protected:
-    PlatformDisplay() = default;
+    PlatformDisplay();
 
+#if USE(EGL)
+    virtual void initializeEGLDisplay();
+
+    EGLDisplay m_eglDisplay;
+#endif
+
 private:
     static std::unique_ptr<PlatformDisplay> createPlatformDisplay();
+
+#if USE(EGL)
+    void terminateEGLDisplay();
+
+    bool m_eglDisplayInitialized { false };
+#endif
 };
 
 } // namespace WebCore

Modified: trunk/Source/WebCore/platform/graphics/egl/GLContextEGL.cpp (183867 => 183868)


--- trunk/Source/WebCore/platform/graphics/egl/GLContextEGL.cpp	2015-05-06 12:55:20 UTC (rev 183867)
+++ trunk/Source/WebCore/platform/graphics/egl/GLContextEGL.cpp	2015-05-06 16:06:30 UTC (rev 183868)
@@ -22,6 +22,7 @@
 #if USE(EGL)
 
 #include "GraphicsContext3D.h"
+#include "PlatformDisplay.h"
 
 #if USE(CAIRO)
 #include <cairo.h>
@@ -38,10 +39,6 @@
 #include "PlatformDisplayX11.h"
 #endif
 
-#if PLATFORM(WAYLAND)
-#include "PlatformDisplayWayland.h"
-#endif
-
 #if ENABLE(ACCELERATED_2D_CANVAS)
 // cairo-gl.h includes some definitions from GLX that conflict with
 // the ones provided by us. Since GLContextEGL doesn't use any GLX
@@ -52,34 +49,9 @@
 
 namespace WebCore {
 
-static EGLDisplay gSharedEGLDisplay = EGL_NO_DISPLAY;
-
-#if USE(OPENGL_ES_2)
-static const EGLenum gGLAPI = EGL_OPENGL_ES_API;
-#else
-static const EGLenum gGLAPI = EGL_OPENGL_API;
-#endif
-
 static EGLDisplay sharedEGLDisplay()
 {
-    static bool initialized = false;
-    if (!initialized) {
-        initialized = true;
-
-#if PLATFORM(WAYLAND)
-        if (is<PlatformDisplayWayland>(PlatformDisplay::sharedDisplay()))
-            gSharedEGLDisplay = eglGetDisplay(downcast<PlatformDisplayWayland>(PlatformDisplay::sharedDisplay()).native());
-        else // Note that this branch continutes outside this #if-guarded segment.
-#endif
-#if PLATFORM(X11)
-            gSharedEGLDisplay = eglGetDisplay(downcast<PlatformDisplayX11>(PlatformDisplay::sharedDisplay()).native());
-#else
-            gSharedEGLDisplay = eglGetDisplay(EGL_DEFAULT_DISPLAY);
-#endif
-        if (gSharedEGLDisplay != EGL_NO_DISPLAY && (!eglInitialize(gSharedEGLDisplay, 0, 0) || !eglBindAPI(gGLAPI)))
-            gSharedEGLDisplay = EGL_NO_DISPLAY;
-    }
-    return gSharedEGLDisplay;
+    return PlatformDisplay::sharedDisplay().eglDisplay();
 }
 
 static const EGLint gContextAttributes[] = {

Modified: trunk/Source/WebCore/platform/graphics/opengl/GLDefs.h (183867 => 183868)


--- trunk/Source/WebCore/platform/graphics/opengl/GLDefs.h	2015-05-06 12:55:20 UTC (rev 183867)
+++ trunk/Source/WebCore/platform/graphics/opengl/GLDefs.h	2015-05-06 16:06:30 UTC (rev 183868)
@@ -57,22 +57,14 @@
 
 #if USE(GLX)
 typedef GLXContext PlatformContext;
-typedef Display* PlatformDisplay;
 typedef GLXFBConfig PlatformSurfaceConfig;
 typedef GLXDrawable PlatformDrawable;
 #elif USE(EGL)
-#if USE(OPENGL_ES_2)
-static const EGLenum eglAPIVersion = EGL_OPENGL_ES_API;
-#else
-static const EGLenum eglAPIVersion = EGL_OPENGL_API;
-#endif
 typedef EGLContext PlatformContext;
-typedef EGLDisplay PlatformDisplay;
 typedef EGLConfig PlatformSurfaceConfig;
 typedef EGLSurface PlatformDrawable;
 #else
 typedef void* PlatformContext;
-typedef void* PlatformDisplay;
 typedef void* PlatformSurfaceConfig;
 typedef void* PlatformDrawable;
 #endif

Modified: trunk/Source/WebCore/platform/graphics/opengl/GLPlatformSurface.cpp (183867 => 183868)


--- trunk/Source/WebCore/platform/graphics/opengl/GLPlatformSurface.cpp	2015-05-06 12:55:20 UTC (rev 183867)
+++ trunk/Source/WebCore/platform/graphics/opengl/GLPlatformSurface.cpp	2015-05-06 16:06:30 UTC (rev 183868)
@@ -61,8 +61,7 @@
 }
 
 GLPlatformSurface::GLPlatformSurface(SurfaceAttributes)
-    : m_sharedDisplay(0)
-    , m_drawable(0)
+    : m_drawable(0)
     , m_bufferHandle(0)
 {
 }
@@ -88,11 +87,6 @@
     return m_rect;
 }
 
-PlatformDisplay GLPlatformSurface::sharedDisplay() const
-{
-    return m_sharedDisplay;
-}
-
 PlatformSurfaceConfig GLPlatformSurface::configuration()
 {
     return 0;

Modified: trunk/Source/WebCore/platform/graphics/opengl/GLPlatformSurface.h (183867 => 183868)


--- trunk/Source/WebCore/platform/graphics/opengl/GLPlatformSurface.h	2015-05-06 12:55:20 UTC (rev 183867)
+++ trunk/Source/WebCore/platform/graphics/opengl/GLPlatformSurface.h	2015-05-06 16:06:30 UTC (rev 183868)
@@ -59,8 +59,6 @@
 
     PlatformDrawable drawable() const;
 
-    PlatformDisplay sharedDisplay() const;
-
     virtual SurfaceAttributes attributes() const;
 
     virtual void swapBuffers();
@@ -84,7 +82,6 @@
 protected:
     GLPlatformSurface(SurfaceAttributes);
 
-    PlatformDisplay m_sharedDisplay;
     PlatformDrawable m_drawable;
     PlatformBufferHandle m_bufferHandle;
     IntRect m_rect;

Modified: trunk/Source/WebCore/platform/graphics/surfaces/egl/EGLConfigSelector.h (183867 => 183868)


--- trunk/Source/WebCore/platform/graphics/surfaces/egl/EGLConfigSelector.h	2015-05-06 12:55:20 UTC (rev 183867)
+++ trunk/Source/WebCore/platform/graphics/surfaces/egl/EGLConfigSelector.h	2015-05-06 16:06:30 UTC (rev 183868)
@@ -61,7 +61,7 @@
     EGLConfig m_pixmapFBConfig;
     EGLConfig m_surfaceContextFBConfig;
     unsigned m_attributes : 3;
-    PlatformDisplay m_sharedDisplay;
+    EGLDisplay m_sharedDisplay;
 };
 
 }

Modified: trunk/Source/WebCore/platform/graphics/surfaces/egl/EGLContext.cpp (183867 => 183868)


--- trunk/Source/WebCore/platform/graphics/surfaces/egl/EGLContext.cpp	2015-05-06 12:55:20 UTC (rev 183867)
+++ trunk/Source/WebCore/platform/graphics/surfaces/egl/EGLContext.cpp	2015-05-06 16:06:30 UTC (rev 183868)
@@ -28,6 +28,7 @@
 
 #if USE(EGL)
 
+#include "PlatformDisplay.h"
 #include <wtf/text/WTFString.h>
 
 namespace WebCore {
@@ -72,12 +73,7 @@
     if (!surface)
         return false;
 
-    if (!eglBindAPI(eglAPIVersion)) {
-        LOG_ERROR("Failed to set EGL API(%d).", eglGetError());
-        return false;
-    }
-
-    m_display = surface->sharedDisplay();
+    m_display = PlatformDisplay::sharedDisplay().eglDisplay();
     if (!m_display)
         return false;
 

Modified: trunk/Source/WebCore/platform/graphics/surfaces/egl/EGLHelper.cpp (183867 => 183868)


--- trunk/Source/WebCore/platform/graphics/surfaces/egl/EGLHelper.cpp	2015-05-06 12:55:20 UTC (rev 183867)
+++ trunk/Source/WebCore/platform/graphics/surfaces/egl/EGLHelper.cpp	2015-05-06 16:06:30 UTC (rev 183868)
@@ -28,89 +28,22 @@
 
 #if USE(EGL)
 
+#include "PlatformDisplay.h"
 #include <opengl/GLPlatformContext.h>
 
-#if PLATFORM(X11)
-#include "X11Helper.h"
-#endif
 
 namespace WebCore {
 
-#if PLATFORM(X11)
-typedef X11Helper NativeWrapper;
-typedef Display NativeSharedDisplay;
-#else
-typedef void NativeSharedDisplay;
-#endif
-
 static PFNEGLCREATEIMAGEKHRPROC eglCreateImageKHR = 0;
 static PFNEGLDESTROYIMAGEKHRPROC eglDestroyImageKHR = 0;
 static PFNGLEGLIMAGETARGETTEXTURE2DOESPROC eglImageTargetTexture2DOES = 0;
 
-struct EGLDisplayConnection {
-
-    EGLDisplayConnection(NativeSharedDisplay* display = 0)
-    {
-        if (display)
-            m_eglDisplay = eglGetDisplay(reinterpret_cast<EGLNativeDisplayType>(display));
-        else
-            m_eglDisplay = eglGetDisplay(EGL_DEFAULT_DISPLAY);
-
-        if (m_eglDisplay == EGL_NO_DISPLAY) {
-            LOG_ERROR("EGLDisplay Initialization failed.");
-            return;
-        }
-
-        EGLBoolean success;
-        success = eglInitialize(m_eglDisplay, 0, 0);
-
-        if (success != EGL_TRUE) {
-            LOG_ERROR("EGLInitialization failed.");
-            terminate();
-            return;
-        }
-
-        success = eglBindAPI(eglAPIVersion);
-
-        if (success != EGL_TRUE) {
-            LOG_ERROR("Failed to set EGL API(%d).", eglGetError());
-            terminate();
-            return;
-        }
-    }
-
-    ~EGLDisplayConnection()
-    {
-        terminate();
-    }
-
-    EGLDisplay display() { return m_eglDisplay; }
-
-private:
-    void terminate()
-    {
-        if (m_eglDisplay == EGL_NO_DISPLAY)
-            return;
-
-        eglTerminate(m_eglDisplay);
-        m_eglDisplay = EGL_NO_DISPLAY;
-    }
-
-    EGLDisplay m_eglDisplay;
-};
-
-PlatformDisplay EGLHelper::eglDisplay()
+EGLDisplay EGLHelper::eglDisplay()
 {
-    // Display connection will only be broken at program shutdown.
-#if PLATFORM(X11)
-    static EGLDisplayConnection displayConnection(NativeWrapper::nativeDisplay());
-#else
-    static EGLDisplayConnection displayConnection;
-#endif
-    return displayConnection.display();
+    PlatformDisplay::sharedDisplay().eglDisplay();
 }
 
-PlatformDisplay EGLHelper::currentDisplay()
+EGLDisplay EGLHelper::currentDisplay()
 {
     EGLDisplay display = eglGetCurrentDisplay();
 

Modified: trunk/Source/WebCore/platform/graphics/surfaces/egl/EGLHelper.h (183867 => 183868)


--- trunk/Source/WebCore/platform/graphics/surfaces/egl/EGLHelper.h	2015-05-06 12:55:20 UTC (rev 183867)
+++ trunk/Source/WebCore/platform/graphics/surfaces/egl/EGLHelper.h	2015-05-06 16:06:30 UTC (rev 183868)
@@ -34,8 +34,8 @@
 
 class EGLHelper {
 public:
-    static PlatformDisplay eglDisplay();
-    static PlatformDisplay currentDisplay();
+    static EGLDisplay eglDisplay();
+    static EGLDisplay currentDisplay();
     static void resolveEGLBindings();
     static void createEGLImage(EGLImageKHR*, GLenum, const EGLClientBuffer, const EGLint* = 0);
     static void destroyEGLImage(const EGLImageKHR);

Modified: trunk/Source/WebCore/platform/graphics/surfaces/egl/EGLSurface.cpp (183867 => 183868)


--- trunk/Source/WebCore/platform/graphics/surfaces/egl/EGLSurface.cpp	2015-05-06 12:55:20 UTC (rev 183867)
+++ trunk/Source/WebCore/platform/graphics/surfaces/egl/EGLSurface.cpp	2015-05-06 16:06:30 UTC (rev 183868)
@@ -75,9 +75,7 @@
 EGLTransportSurface::EGLTransportSurface(const IntSize& size, SurfaceAttributes attributes)
     : GLTransportSurface(size, attributes)
 {
-    m_sharedDisplay = EGLHelper::eglDisplay();
-
-    if (m_sharedDisplay == EGL_NO_DISPLAY)
+    if (EGLHelper::eglDisplay() == EGL_NO_DISPLAY)
         return;
 
     m_configSelector = std::make_unique<EGLConfigSelector>(attributes);
@@ -94,13 +92,13 @@
 
 void EGLTransportSurface::destroy()
 {
-    if (m_drawable == EGL_NO_SURFACE || m_sharedDisplay == EGL_NO_DISPLAY)
+    if (m_drawable == EGL_NO_SURFACE || EGLHelper::eglDisplay() == EGL_NO_DISPLAY)
         return;
 
     GLTransportSurface::destroy();
 
     if (m_drawable) {
-        eglDestroySurface(m_sharedDisplay, m_drawable);
+        eglDestroySurface(EGLHelper::eglDisplay(), m_drawable);
         m_drawable = EGL_NO_SURFACE;
     }
 
@@ -125,9 +123,7 @@
 EGLOffScreenSurface::EGLOffScreenSurface(SurfaceAttributes surfaceAttributes)
     : GLPlatformSurface(surfaceAttributes)
 {
-    m_sharedDisplay = EGLHelper::eglDisplay();
-
-    if (m_sharedDisplay == EGL_NO_DISPLAY)
+    if (EGLHelper::eglDisplay() == EGL_NO_DISPLAY)
         return;
 
     m_configSelector = std::make_unique<EGLConfigSelector>(surfaceAttributes);
@@ -149,11 +145,11 @@
 
 void EGLOffScreenSurface::destroy()
 {
-    if (m_sharedDisplay == EGL_NO_DISPLAY || m_drawable == EGL_NO_SURFACE)
+    if (EGLHelper::eglDisplay() == EGL_NO_DISPLAY || m_drawable == EGL_NO_SURFACE)
         return;
 
     if (m_drawable) {
-        eglDestroySurface(m_sharedDisplay, m_drawable);
+        eglDestroySurface(EGLHelper::eglDisplay(), m_drawable);
         m_drawable = EGL_NO_SURFACE;
     }
 

Modified: trunk/Source/WebCore/platform/graphics/surfaces/egl/EGLXSurface.cpp (183867 => 183868)


--- trunk/Source/WebCore/platform/graphics/surfaces/egl/EGLXSurface.cpp	2015-05-06 12:55:20 UTC (rev 183867)
+++ trunk/Source/WebCore/platform/graphics/surfaces/egl/EGLXSurface.cpp	2015-05-06 16:06:30 UTC (rev 183868)
@@ -31,6 +31,7 @@
 #include "EGLConfigSelector.h"
 #include "EGLHelper.h"
 #include "GLPlatformContext.h"
+#include "PlatformDisplay.h"
 
 namespace WebCore {
 
@@ -59,7 +60,7 @@
         return;
     }
 
-    m_drawable = eglCreateWindowSurface(m_sharedDisplay, m_configSelector->surfaceContextConfig(), static_cast<EGLNativeWindowType>(m_bufferHandle), 0);
+    m_drawable = eglCreateWindowSurface(PlatformDisplay::sharedDisplay().eglDisplay(), m_configSelector->surfaceContextConfig(), static_cast<EGLNativeWindowType>(m_bufferHandle), 0);
 
     if (m_drawable == EGL_NO_SURFACE) {
         LOG_ERROR("Failed to create EGL surface(%d).", eglGetError());
@@ -73,7 +74,7 @@
 
 void EGLWindowTransportSurface::swapBuffers()
 {
-    if (!eglSwapBuffers(m_sharedDisplay, m_drawable))
+    if (!eglSwapBuffers(PlatformDisplay::sharedDisplay().eglDisplay(), m_drawable))
         LOG_ERROR("Failed to SwapBuffers(%d).", eglGetError());
 }
 
@@ -116,7 +117,7 @@
         return;
     }
 
-    m_drawable = eglCreatePixmapSurface(m_sharedDisplay, config, static_cast<EGLNativePixmapType>(m_bufferHandle), 0);
+    m_drawable = eglCreatePixmapSurface(PlatformDisplay::sharedDisplay().eglDisplay(), config, static_cast<EGLNativePixmapType>(m_bufferHandle), 0);
 
     if (m_drawable == EGL_NO_SURFACE) {
         LOG_ERROR("Failed to create EGL surface(%d).", eglGetError());

Modified: trunk/Source/WebCore/platform/graphics/surfaces/glx/GLXContext.cpp (183867 => 183868)


--- trunk/Source/WebCore/platform/graphics/surfaces/glx/GLXContext.cpp	2015-05-06 12:55:20 UTC (rev 183867)
+++ trunk/Source/WebCore/platform/graphics/surfaces/glx/GLXContext.cpp	2015-05-06 16:06:30 UTC (rev 183868)
@@ -61,7 +61,7 @@
     if (!surface)
         return false;
 
-    Display* x11Display = surface->sharedDisplay();
+    Display* x11Display = X11Helper::nativeDisplay();
     if (!x11Display)
         return false;
 
@@ -106,7 +106,7 @@
 
 bool GLXOffScreenContext::platformMakeCurrent(GLPlatformSurface* surface)
 {
-    return glXMakeCurrent(surface->sharedDisplay(), surface->drawable(), m_contextHandle);
+    return glXMakeCurrent(X11Helper::nativeDisplay(), surface->drawable(), m_contextHandle);
 }
 
 void GLXOffScreenContext::platformReleaseCurrent()

Modified: trunk/Source/WebCore/platform/graphics/surfaces/glx/GLXSurface.cpp (183867 => 183868)


--- trunk/Source/WebCore/platform/graphics/surfaces/glx/GLXSurface.cpp	2015-05-06 12:55:20 UTC (rev 183867)
+++ trunk/Source/WebCore/platform/graphics/surfaces/glx/GLXSurface.cpp	2015-05-06 16:06:30 UTC (rev 183868)
@@ -64,7 +64,6 @@
 GLXTransportSurface::GLXTransportSurface(const IntSize& size, SurfaceAttributes attributes)
     : GLTransportSurface(size, attributes)
 {
-    m_sharedDisplay = X11Helper::nativeDisplay();
     attributes |= GLPlatformSurface::DoubleBuffered;
     m_configSelector = std::make_unique<GLXConfigSelector>(attributes);
     std::unique_ptr<XVisualInfo, X11Deleter> visInfo(m_configSelector->visualInfo(m_configSelector->surfaceContextConfig()));
@@ -98,7 +97,7 @@
     GLTransportSurface::setGeometry(newRect);
     X11Helper::resizeWindow(newRect, m_drawable);
     // Force resize of GL surface after window resize.
-    glXSwapBuffers(sharedDisplay(), m_drawable);
+    glXSwapBuffers(X11Helper::nativeDisplay(), m_drawable);
 }
 
 void GLXTransportSurface::swapBuffers()
@@ -106,7 +105,7 @@
     if (!m_drawable)
         return;
 
-    glXSwapBuffers(sharedDisplay(), m_drawable);
+    glXSwapBuffers(X11Helper::nativeDisplay(), m_drawable);
 }
 
 void GLXTransportSurface::destroy()
@@ -141,8 +140,6 @@
 
 void GLXOffScreenSurface::initialize(SurfaceAttributes attributes)
 {
-    m_sharedDisplay = X11Helper::nativeDisplay();
-
     m_configSelector = std::make_unique<GLXConfigSelector>(attributes);
 
     std::unique_ptr<XVisualInfo, X11Deleter> visualInfo(m_configSelector->visualInfo(m_configSelector->pixmapContextConfig()));
@@ -153,7 +150,7 @@
         return;
     }
 
-    m_glxPixmap = glXCreateGLXPixmap(m_sharedDisplay, visualInfo.get(), m_pixmap);
+    m_glxPixmap = glXCreateGLXPixmap(X11Helper::nativeDisplay(), visualInfo.get(), m_pixmap);
 
     if (!m_glxPixmap) {
         destroy();
@@ -175,7 +172,7 @@
 
 void GLXOffScreenSurface::freeResources()
 {
-    Display* display = sharedDisplay();
+    Display* display = X11Helper::nativeDisplay();
 
     if (!display)
         return;

Modified: trunk/Source/WebCore/platform/graphics/wayland/PlatformDisplayWayland.cpp (183867 => 183868)


--- trunk/Source/WebCore/platform/graphics/wayland/PlatformDisplayWayland.cpp	2015-05-06 12:55:20 UTC (rev 183867)
+++ trunk/Source/WebCore/platform/graphics/wayland/PlatformDisplayWayland.cpp	2015-05-06 16:06:30 UTC (rev 183868)
@@ -87,21 +87,10 @@
     };
 
     m_eglDisplay = eglGetDisplay(m_display);
-    if (m_eglDisplay == EGL_NO_DISPLAY) {
-        g_warning("PlatformDisplayWayland initialization: failed to acquire EGL display.");
+    PlatformDisplay::initializeEGLDisplay();
+    if (m_eglDisplay == EGL_NO_DISPLAY)
         return;
-    }
 
-    if (eglInitialize(m_eglDisplay, 0, 0) == EGL_FALSE) {
-        g_warning("PlatformDisplayWayland initialization: failed to initialize the EGL display.");
-        return;
-    }
-
-    if (eglBindAPI(EGL_OPENGL_ES_API) == EGL_FALSE) {
-        g_warning("PlatformDisplayWayland initialization: failed to set EGL_OPENGL_ES_API as the rendering API.");
-        return;
-    }
-
     EGLint numberOfConfigs;
     if (!eglChooseConfig(m_eglDisplay, configAttributes, &m_eglConfig, 1, &numberOfConfigs) || numberOfConfigs != 1) {
         g_warning("PlatformDisplayWayland initialization: failed to find the desired EGL configuration.");

Modified: trunk/Source/WebCore/platform/graphics/wayland/PlatformDisplayWayland.h (183867 => 183868)


--- trunk/Source/WebCore/platform/graphics/wayland/PlatformDisplayWayland.h	2015-05-06 12:55:20 UTC (rev 183867)
+++ trunk/Source/WebCore/platform/graphics/wayland/PlatformDisplayWayland.h	2015-05-06 16:06:30 UTC (rev 183868)
@@ -47,7 +47,6 @@
     virtual ~PlatformDisplayWayland();
 
     struct wl_display* native() const { return m_display; }
-    EGLDisplay eglDisplay() const { return m_eglDisplay; }
 
     std::unique_ptr<WaylandSurface> createSurface(const IntSize&, int widgetID);
 
@@ -68,7 +67,6 @@
     struct wl_compositor* m_compositor;
     struct wl_webkitgtk* m_webkitgtk;
 
-    EGLDisplay m_eglDisplay;
     EGLConfig m_eglConfig;
     bool m_eglConfigChosen;
 };

Modified: trunk/Source/WebCore/platform/graphics/x11/PlatformDisplayX11.cpp (183867 => 183868)


--- trunk/Source/WebCore/platform/graphics/x11/PlatformDisplayX11.cpp	2015-05-06 12:55:20 UTC (rev 183867)
+++ trunk/Source/WebCore/platform/graphics/x11/PlatformDisplayX11.cpp	2015-05-06 16:06:30 UTC (rev 183868)
@@ -29,6 +29,10 @@
 #if PLATFORM(X11)
 #include <X11/Xlib.h>
 
+#if USE(EGL)
+#include <EGL/egl.h>
+#endif
+
 namespace WebCore {
 
 PlatformDisplayX11::PlatformDisplayX11()
@@ -49,6 +53,14 @@
         XCloseDisplay(m_display);
 }
 
+#if USE(EGL)
+void PlatformDisplayX11::initializeEGLDisplay()
+{
+    m_eglDisplay = eglGetDisplay(m_display);
+    PlatformDisplay::initializeEGLDisplay();
+}
+#endif
+
 } // namespace WebCore
 
 #endif // PLATFORM(X11)

Modified: trunk/Source/WebCore/platform/graphics/x11/PlatformDisplayX11.h (183867 => 183868)


--- trunk/Source/WebCore/platform/graphics/x11/PlatformDisplayX11.h	2015-05-06 12:55:20 UTC (rev 183867)
+++ trunk/Source/WebCore/platform/graphics/x11/PlatformDisplayX11.h	2015-05-06 16:06:30 UTC (rev 183868)
@@ -45,6 +45,10 @@
 private:
     virtual Type type() const override { return PlatformDisplay::Type::X11; }
 
+#if USE(EGL)
+    void initializeEGLDisplay() override;
+#endif
+
     Display* m_display;
     bool m_ownedDisplay;
 };
_______________________________________________
webkit-changes mailing list
webkit-changes@lists.webkit.org
https://lists.webkit.org/mailman/listinfo/webkit-changes

Reply via email to