Source/WebCore/ChangeLog

 12015-05-06 Carlos Garcia Campos <cgarcia@igalia.com>
 2
 3 [EGL] Move EGLDisplay handling to PlatformDisplay
 4 https://bugs.webkit.org/show_bug.cgi?id=144685
 5
 6 Reviewed by NOBODY (OOPS!).
 7
 8 The EGL display is also initialized in multiple places, and could
 9 be unified in PlatformDisplay. Remove the PlatformDisplay
 10 definition from platform/graphics/opengl/GLDefs.h to avoid conflicts.
 11
 12 * platform/graphics/PlatformDisplay.cpp:
 13 (WebCore::PlatformDisplay::PlatformDisplay): Initialize m_eglDisplay.
 14 (WebCore::PlatformDisplay::~PlatformDisplay): Call terminateEGLDisplay().
 15 (WebCore::PlatformDisplay::eglDisplay): Lazy intialize the EGL
 16 display and return it.
 17 (WebCore::PlatformDisplay::initializeEGLDisplay):
 18 (WebCore::PlatformDisplay::terminateEGLDisplay):
 19 * platform/graphics/PlatformDisplay.h:
 20 * platform/graphics/egl/GLContextEGL.cpp:
 21 (WebCore::sharedEGLDisplay): Use PlatformDisplay::eglDisplay().
 22 * platform/graphics/opengl/GLDefs.h: Remove unneeded definitions.
 23 * platform/graphics/opengl/GLPlatformSurface.cpp:
 24 (WebCore::GLPlatformSurface::GLPlatformSurface): Remove
 25 m_sharedDisplay member, PlatformDisplay::sharedDisplay() can be used instead.
 26 (WebCore::GLPlatformSurface::sharedDisplay): Deleted.
 27 * platform/graphics/opengl/GLPlatformSurface.h:
 28 * platform/graphics/surfaces/egl/EGLConfigSelector.h: Use
 29 EGLDisplay instead of PlatformDisplay.
 30 * platform/graphics/surfaces/egl/EGLContext.cpp:
 31 (WebCore::EGLOffScreenContext::initialize): Use PlatformDisplay::eglDisplay().
 32 * platform/graphics/surfaces/egl/EGLHelper.cpp: Remove the
 33 EGLDisplayConnection clas and use PlatformDisplay instead.
 34 (WebCore::EGLHelper::eglDisplay):
 35 (WebCore::EGLHelper::currentDisplay):
 36 (WebCore::EGLDisplayConnection::EGLDisplayConnection): Deleted.
 37 (WebCore::EGLDisplayConnection::~EGLDisplayConnection): Deleted.
 38 (WebCore::EGLDisplayConnection::display): Deleted.
 39 (WebCore::EGLDisplayConnection::terminate): Deleted.
 40 * platform/graphics/surfaces/egl/EGLHelper.h:
 41 * platform/graphics/surfaces/egl/EGLSurface.cpp:
 42 (WebCore::EGLTransportSurface::EGLTransportSurface): Use EGLHelper::eglDisplay().
 43 (WebCore::EGLTransportSurface::destroy): Ditto.
 44 (WebCore::EGLOffScreenSurface::EGLOffScreenSurface): Ditto.
 45 (WebCore::EGLOffScreenSurface::destroy): Ditto.
 46 * platform/graphics/surfaces/egl/EGLXSurface.cpp:
 47 (WebCore::EGLWindowTransportSurface::EGLWindowTransportSurface):
 48 Use PlatformDisplay::eglDisplay().
 49 (WebCore::EGLWindowTransportSurface::swapBuffers): Ditto.
 50 (WebCore::EGLPixmapSurface::EGLPixmapSurface): Ditto.
 51 * platform/graphics/surfaces/glx/GLXSurface.cpp:
 52 (WebCore::GLXTransportSurface::GLXTransportSurface): Do not use m_sharedDisplay.
 53 (WebCore::GLXOffScreenSurface::initialize): Ditto.
 54 * platform/graphics/wayland/PlatformDisplayWayland.cpp:
 55 (WebCore::PlatformDisplayWayland::PlatformDisplayWayland): Call
 56 PlatformDisplay::initializeEGLDisplay() to insialize the EGL display.
 57 * platform/graphics/wayland/PlatformDisplayWayland.h:
 58 * platform/graphics/x11/PlatformDisplayX11.cpp:
 59 (WebCore::PlatformDisplayX11::initializeEGLDisplay): Override
 60 PlatformDisplay::initializeEGLDisplay() to initialize the
 61 m_eglDisplay member.
 62 * platform/graphics/x11/PlatformDisplayX11.h:
 63
1642015-05-05 Carlos Garcia Campos <cgarcia@igalia.com>
265
366 [SOUP] Network Cache: Implement ShareableResource for Soup and enable it for GTK platform

Source/WebCore/platform/graphics/PlatformDisplay.cpp

4545#include <Ecore_X.h>
4646#endif
4747
 48#if USE(EGL)
 49#include <EGL/egl.h>
 50#endif
 51
4852namespace WebCore {
4953
5054std::unique_ptr<PlatformDisplay> PlatformDisplay::createPlatformDisplay()

@@PlatformDisplay& PlatformDisplay::sharedDisplay()
8589 return *display;
8690}
8791
 92PlatformDisplay::PlatformDisplay()
 93#if USE(EGL)
 94 : m_eglDisplay(EGL_NO_DISPLAY)
 95#endif
 96{
 97}
 98
 99PlatformDisplay::~PlatformDisplay()
 100{
 101#if USE(EGL)
 102 terminateEGLDisplay();
 103#endif
 104}
 105
 106#if USE(EGL)
 107EGLDisplay PlatformDisplay::eglDisplay() const
 108{
 109 if (!m_eglDisplayInitialized)
 110 const_cast<PlatformDisplay*>(this)->initializeEGLDisplay();
 111 return m_eglDisplay;
 112}
 113
 114void PlatformDisplay::initializeEGLDisplay()
 115{
 116 m_eglDisplayInitialized = true;
 117
 118 if (m_eglDisplay == EGL_NO_DISPLAY) {
 119 m_eglDisplay = eglGetDisplay(EGL_DEFAULT_DISPLAY);
 120 if (m_eglDisplay == EGL_NO_DISPLAY)
 121 return;
 122 }
 123
 124 if (eglInitialize(m_eglDisplay, 0, 0) == EGL_FALSE) {
 125 LOG_ERROR("EGLDisplay Initialization failed.");
 126 terminateEGLDisplay();
 127 return;
 128 }
 129
 130#if USE(OPENGL_ES_2)
 131 static const EGLenum eglAPIVersion = EGL_OPENGL_ES_API;
 132#else
 133 static const EGLenum eglAPIVersion = EGL_OPENGL_API;
 134#endif
 135 if (eglBindAPI(eglAPIVersion) == EGL_FALSE) {
 136 LOG_ERROR("Failed to set EGL API(%d).", eglGetError());
 137 terminateEGLDisplay();
 138 return;
 139 }
 140}
 141
 142void PlatformDisplay::terminateEGLDisplay()
 143{
 144 if (m_eglDisplay == EGL_NO_DISPLAY)
 145 return;
 146 eglTerminate(m_eglDisplay);
 147 m_eglDisplay = EGL_NO_DISPLAY;
 148}
 149#endif // USE(EGL)
 150
88151} // namespace WebCore

Source/WebCore/platform/graphics/PlatformDisplay.h

2929#include <wtf/Noncopyable.h>
3030#include <wtf/TypeCasts.h>
3131
 32#if USE(EGL)
 33typedef void *EGLDisplay;
 34#endif
 35
3236namespace WebCore {
3337
3438class PlatformDisplay {
3539 WTF_MAKE_NONCOPYABLE(PlatformDisplay); WTF_MAKE_FAST_ALLOCATED;
3640public:
3741 static PlatformDisplay& sharedDisplay();
38  virtual ~PlatformDisplay() = default;
 42 virtual ~PlatformDisplay();
3943
4044 enum class Type {
4145#if PLATFORM(X11)

@@public:
4852
4953 virtual Type type() const = 0;
5054
 55#if USE(EGL)
 56 EGLDisplay eglDisplay() const;
 57#endif
 58
5159protected:
52  PlatformDisplay() = default;
 60 PlatformDisplay();
 61
 62#if USE(EGL)
 63 virtual void initializeEGLDisplay();
 64
 65 EGLDisplay m_eglDisplay;
 66#endif
5367
5468private:
5569 static std::unique_ptr<PlatformDisplay> createPlatformDisplay();
 70
 71#if USE(EGL)
 72 void terminateEGLDisplay();
 73
 74 bool m_eglDisplayInitialized { false };
 75#endif
5676};
5777
5878} // namespace WebCore

Source/WebCore/platform/graphics/egl/GLContextEGL.cpp

2222#if USE(EGL)
2323
2424#include "GraphicsContext3D.h"
 25#include "PlatformDisplay.h"
2526
2627#if USE(CAIRO)
2728#include <cairo.h>

3839#include "PlatformDisplayX11.h"
3940#endif
4041
41 #if PLATFORM(WAYLAND)
42 #include "PlatformDisplayWayland.h"
43 #endif
44 
4542#if ENABLE(ACCELERATED_2D_CANVAS)
4643// cairo-gl.h includes some definitions from GLX that conflict with
4744// the ones provided by us. Since GLContextEGL doesn't use any GLX

5249
5350namespace WebCore {
5451
55 static EGLDisplay gSharedEGLDisplay = EGL_NO_DISPLAY;
56 
57 #if USE(OPENGL_ES_2)
58 static const EGLenum gGLAPI = EGL_OPENGL_ES_API;
59 #else
60 static const EGLenum gGLAPI = EGL_OPENGL_API;
61 #endif
62 
6352static EGLDisplay sharedEGLDisplay()
6453{
65  static bool initialized = false;
66  if (!initialized) {
67  initialized = true;
68 
69 #if PLATFORM(WAYLAND)
70  if (is<PlatformDisplayWayland>(PlatformDisplay::sharedDisplay()))
71  gSharedEGLDisplay = eglGetDisplay(downcast<PlatformDisplayWayland>(PlatformDisplay::sharedDisplay()).native());
72  else // Note that this branch continutes outside this #if-guarded segment.
73 #endif
74 #if PLATFORM(X11)
75  gSharedEGLDisplay = eglGetDisplay(downcast<PlatformDisplayX11>(PlatformDisplay::sharedDisplay()).native());
76 #else
77  gSharedEGLDisplay = eglGetDisplay(EGL_DEFAULT_DISPLAY);
78 #endif
79  if (gSharedEGLDisplay != EGL_NO_DISPLAY && (!eglInitialize(gSharedEGLDisplay, 0, 0) || !eglBindAPI(gGLAPI)))
80  gSharedEGLDisplay = EGL_NO_DISPLAY;
81  }
82  return gSharedEGLDisplay;
 54 return PlatformDisplay::sharedDisplay().eglDisplay();
8355}
8456
8557static const EGLint gContextAttributes[] = {

Source/WebCore/platform/graphics/opengl/GLDefs.h

@@typedef uint32_t PlatformBufferHandle;
5757
5858#if USE(GLX)
5959typedef GLXContext PlatformContext;
60 typedef Display* PlatformDisplay;
6160typedef GLXFBConfig PlatformSurfaceConfig;
6261typedef GLXDrawable PlatformDrawable;
6362#elif USE(EGL)
64 #if USE(OPENGL_ES_2)
65 static const EGLenum eglAPIVersion = EGL_OPENGL_ES_API;
66 #else
67 static const EGLenum eglAPIVersion = EGL_OPENGL_API;
68 #endif
6963typedef EGLContext PlatformContext;
70 typedef EGLDisplay PlatformDisplay;
7164typedef EGLConfig PlatformSurfaceConfig;
7265typedef EGLSurface PlatformDrawable;
7366#else
7467typedef void* PlatformContext;
75 typedef void* PlatformDisplay;
7668typedef void* PlatformSurfaceConfig;
7769typedef void* PlatformDrawable;
7870#endif

Source/WebCore/platform/graphics/opengl/GLPlatformSurface.cpp

@@std::unique_ptr<GLPlatformSurface> GLPlatformSurface::createOffScreenSurface(Sur
6161}
6262
6363GLPlatformSurface::GLPlatformSurface(SurfaceAttributes)
64  : m_sharedDisplay(0)
65  , m_drawable(0)
 64 : m_drawable(0)
6665 , m_bufferHandle(0)
6766{
6867}

@@const IntRect& GLPlatformSurface::geometry() const
8887 return m_rect;
8988}
9089
91 PlatformDisplay GLPlatformSurface::sharedDisplay() const
92 {
93  return m_sharedDisplay;
94 }
95 
9690PlatformSurfaceConfig GLPlatformSurface::configuration()
9791{
9892 return 0;

Source/WebCore/platform/graphics/opengl/GLPlatformSurface.h

@@public:
5959
6060 PlatformDrawable drawable() const;
6161
62  PlatformDisplay sharedDisplay() const;
63 
6462 virtual SurfaceAttributes attributes() const;
6563
6664 virtual void swapBuffers();

@@public:
8482protected:
8583 GLPlatformSurface(SurfaceAttributes);
8684
87  PlatformDisplay m_sharedDisplay;
8885 PlatformDrawable m_drawable;
8986 PlatformBufferHandle m_bufferHandle;
9087 IntRect m_rect;

Source/WebCore/platform/graphics/surfaces/egl/EGLConfigSelector.h

@@protected:
6161 EGLConfig m_pixmapFBConfig;
6262 EGLConfig m_surfaceContextFBConfig;
6363 unsigned m_attributes : 3;
64  PlatformDisplay m_sharedDisplay;
 64 EGLDisplay m_sharedDisplay;
6565};
6666
6767}

Source/WebCore/platform/graphics/surfaces/egl/EGLContext.cpp

2828
2929#if USE(EGL)
3030
 31#include "PlatformDisplay.h"
3132#include <wtf/text/WTFString.h>
3233
3334namespace WebCore {

@@bool EGLOffScreenContext::initialize(GLPlatformSurface* surface, PlatformContext
7273 if (!surface)
7374 return false;
7475
75  if (!eglBindAPI(eglAPIVersion)) {
76  LOG_ERROR("Failed to set EGL API(%d).", eglGetError());
77  return false;
78  }
79 
80  m_display = surface->sharedDisplay();
 76 m_display = PlatformDisplay::sharedDisplay().eglDisplay();
8177 if (!m_display)
8278 return false;
8379

Source/WebCore/platform/graphics/surfaces/egl/EGLHelper.cpp

2828
2929#if USE(EGL)
3030
 31#include "PlatformDisplay.h"
3132#include <opengl/GLPlatformContext.h>
3233
33 #if PLATFORM(X11)
34 #include "X11Helper.h"
35 #endif
3634
3735namespace WebCore {
3836
39 #if PLATFORM(X11)
40 typedef X11Helper NativeWrapper;
41 typedef Display NativeSharedDisplay;
42 #else
43 typedef void NativeSharedDisplay;
44 #endif
45 
4637static PFNEGLCREATEIMAGEKHRPROC eglCreateImageKHR = 0;
4738static PFNEGLDESTROYIMAGEKHRPROC eglDestroyImageKHR = 0;
4839static PFNGLEGLIMAGETARGETTEXTURE2DOESPROC eglImageTargetTexture2DOES = 0;
4940
50 struct EGLDisplayConnection {
51 
52  EGLDisplayConnection(NativeSharedDisplay* display = 0)
53  {
54  if (display)
55  m_eglDisplay = eglGetDisplay(reinterpret_cast<EGLNativeDisplayType>(display));
56  else
57  m_eglDisplay = eglGetDisplay(EGL_DEFAULT_DISPLAY);
58 
59  if (m_eglDisplay == EGL_NO_DISPLAY) {
60  LOG_ERROR("EGLDisplay Initialization failed.");
61  return;
62  }
63 
64  EGLBoolean success;
65  success = eglInitialize(m_eglDisplay, 0, 0);
66 
67  if (success != EGL_TRUE) {
68  LOG_ERROR("EGLInitialization failed.");
69  terminate();
70  return;
71  }
72 
73  success = eglBindAPI(eglAPIVersion);
74 
75  if (success != EGL_TRUE) {
76  LOG_ERROR("Failed to set EGL API(%d).", eglGetError());
77  terminate();
78  return;
79  }
80  }
81 
82  ~EGLDisplayConnection()
83  {
84  terminate();
85  }
86 
87  EGLDisplay display() { return m_eglDisplay; }
88 
89 private:
90  void terminate()
91  {
92  if (m_eglDisplay == EGL_NO_DISPLAY)
93  return;
94 
95  eglTerminate(m_eglDisplay);
96  m_eglDisplay = EGL_NO_DISPLAY;
97  }
98 
99  EGLDisplay m_eglDisplay;
100 };
101 
102 PlatformDisplay EGLHelper::eglDisplay()
 41EGLDisplay EGLHelper::eglDisplay()
10342{
104  // Display connection will only be broken at program shutdown.
105 #if PLATFORM(X11)
106  static EGLDisplayConnection displayConnection(NativeWrapper::nativeDisplay());
107 #else
108  static EGLDisplayConnection displayConnection;
109 #endif
110  return displayConnection.display();
 43 PlatformDisplay::sharedDisplay().eglDisplay();
11144}
11245
113 PlatformDisplay EGLHelper::currentDisplay()
 46EGLDisplay EGLHelper::currentDisplay()
11447{
11548 EGLDisplay display = eglGetCurrentDisplay();
11649

Source/WebCore/platform/graphics/surfaces/egl/EGLHelper.h

@@namespace WebCore {
3434
3535class EGLHelper {
3636public:
37  static PlatformDisplay eglDisplay();
38  static PlatformDisplay currentDisplay();
 37 static EGLDisplay eglDisplay();
 38 static EGLDisplay currentDisplay();
3939 static void resolveEGLBindings();
4040 static void createEGLImage(EGLImageKHR*, GLenum, const EGLClientBuffer, const EGLint* = 0);
4141 static void destroyEGLImage(const EGLImageKHR);

Source/WebCore/platform/graphics/surfaces/egl/EGLSurface.cpp

@@std::unique_ptr<GLTransportSurfaceClient> EGLTransportSurface::createTransportSu
7575EGLTransportSurface::EGLTransportSurface(const IntSize& size, SurfaceAttributes attributes)
7676 : GLTransportSurface(size, attributes)
7777{
78  m_sharedDisplay = EGLHelper::eglDisplay();
79 
80  if (m_sharedDisplay == EGL_NO_DISPLAY)
 78 if (EGLHelper::eglDisplay() == EGL_NO_DISPLAY)
8179 return;
8280
8381 m_configSelector = std::make_unique<EGLConfigSelector>(attributes);

@@EGLTransportSurface::~EGLTransportSurface()
9492
9593void EGLTransportSurface::destroy()
9694{
97  if (m_drawable == EGL_NO_SURFACE || m_sharedDisplay == EGL_NO_DISPLAY)
 95 if (m_drawable == EGL_NO_SURFACE || EGLHelper::eglDisplay() == EGL_NO_DISPLAY)
9896 return;
9997
10098 GLTransportSurface::destroy();
10199
102100 if (m_drawable) {
103  eglDestroySurface(m_sharedDisplay, m_drawable);
 101 eglDestroySurface(EGLHelper::eglDisplay(), m_drawable);
104102 m_drawable = EGL_NO_SURFACE;
105103 }
106104

@@std::unique_ptr<GLPlatformSurface> EGLOffScreenSurface::createOffScreenSurface(S
125123EGLOffScreenSurface::EGLOffScreenSurface(SurfaceAttributes surfaceAttributes)
126124 : GLPlatformSurface(surfaceAttributes)
127125{
128  m_sharedDisplay = EGLHelper::eglDisplay();
129 
130  if (m_sharedDisplay == EGL_NO_DISPLAY)
 126 if (EGLHelper::eglDisplay() == EGL_NO_DISPLAY)
131127 return;
132128
133129 m_configSelector = std::make_unique<EGLConfigSelector>(surfaceAttributes);

@@PlatformSurfaceConfig EGLOffScreenSurface::configuration()
149145
150146void EGLOffScreenSurface::destroy()
151147{
152  if (m_sharedDisplay == EGL_NO_DISPLAY || m_drawable == EGL_NO_SURFACE)
 148 if (EGLHelper::eglDisplay() == EGL_NO_DISPLAY || m_drawable == EGL_NO_SURFACE)
153149 return;
154150
155151 if (m_drawable) {
156  eglDestroySurface(m_sharedDisplay, m_drawable);
 152 eglDestroySurface(EGLHelper::eglDisplay(), m_drawable);
157153 m_drawable = EGL_NO_SURFACE;
158154 }
159155

Source/WebCore/platform/graphics/surfaces/egl/EGLXSurface.cpp

3131#include "EGLConfigSelector.h"
3232#include "EGLHelper.h"
3333#include "GLPlatformContext.h"
 34#include "PlatformDisplay.h"
3435
3536namespace WebCore {
3637

@@EGLWindowTransportSurface::EGLWindowTransportSurface(const IntSize& size, GLPlat
5960 return;
6061 }
6162
62  m_drawable = eglCreateWindowSurface(m_sharedDisplay, m_configSelector->surfaceContextConfig(), static_cast<EGLNativeWindowType>(m_bufferHandle), 0);
 63 m_drawable = eglCreateWindowSurface(PlatformDisplay::sharedDisplay().eglDisplay(), m_configSelector->surfaceContextConfig(), static_cast<EGLNativeWindowType>(m_bufferHandle), 0);
6364
6465 if (m_drawable == EGL_NO_SURFACE) {
6566 LOG_ERROR("Failed to create EGL surface(%d).", eglGetError());

@@EGLWindowTransportSurface::~EGLWindowTransportSurface()
7374
7475void EGLWindowTransportSurface::swapBuffers()
7576{
76  if (!eglSwapBuffers(m_sharedDisplay, m_drawable))
 77 if (!eglSwapBuffers(PlatformDisplay::sharedDisplay().eglDisplay(), m_drawable))
7778 LOG_ERROR("Failed to SwapBuffers(%d).", eglGetError());
7879}
7980

@@EGLPixmapSurface::EGLPixmapSurface(GLPlatformSurface::SurfaceAttributes surfaceA
116117 return;
117118 }
118119
119  m_drawable = eglCreatePixmapSurface(m_sharedDisplay, config, static_cast<EGLNativePixmapType>(m_bufferHandle), 0);
 120 m_drawable = eglCreatePixmapSurface(PlatformDisplay::sharedDisplay().eglDisplay(), config, static_cast<EGLNativePixmapType>(m_bufferHandle), 0);
120121
121122 if (m_drawable == EGL_NO_SURFACE) {
122123 LOG_ERROR("Failed to create EGL surface(%d).", eglGetError());

Source/WebCore/platform/graphics/surfaces/glx/GLXSurface.cpp

@@static bool isMesaGLX()
6464GLXTransportSurface::GLXTransportSurface(const IntSize& size, SurfaceAttributes attributes)
6565 : GLTransportSurface(size, attributes)
6666{
67  m_sharedDisplay = X11Helper::nativeDisplay();
6867 attributes |= GLPlatformSurface::DoubleBuffered;
6968 m_configSelector = std::make_unique<GLXConfigSelector>(attributes);
7069 std::unique_ptr<XVisualInfo, X11Deleter> visInfo(m_configSelector->visualInfo(m_configSelector->surfaceContextConfig()));

@@GLXOffScreenSurface::~GLXOffScreenSurface()
141140
142141void GLXOffScreenSurface::initialize(SurfaceAttributes attributes)
143142{
144  m_sharedDisplay = X11Helper::nativeDisplay();
145 
146143 m_configSelector = std::make_unique<GLXConfigSelector>(attributes);
147144
148145 std::unique_ptr<XVisualInfo, X11Deleter> visualInfo(m_configSelector->visualInfo(m_configSelector->pixmapContextConfig()));

@@void GLXOffScreenSurface::initialize(SurfaceAttributes attributes)
153150 return;
154151 }
155152
156  m_glxPixmap = glXCreateGLXPixmap(m_sharedDisplay, visualInfo.get(), m_pixmap);
 153 m_glxPixmap = glXCreateGLXPixmap(X11Helper::nativeDisplay(), visualInfo.get(), m_pixmap);
157154
158155 if (!m_glxPixmap) {
159156 destroy();

Source/WebCore/platform/graphics/wayland/PlatformDisplayWayland.cpp

@@PlatformDisplayWayland::PlatformDisplayWayland(struct wl_display* wlDisplay)
8787 };
8888
8989 m_eglDisplay = eglGetDisplay(m_display);
90  if (m_eglDisplay == EGL_NO_DISPLAY) {
91  g_warning("PlatformDisplayWayland initialization: failed to acquire EGL display.");
 90 PlatformDisplay::initializeEGLDisplay();
 91 if (m_eglDisplay == EGL_NO_DISPLAY)
9292 return;
93  }
94 
95  if (eglInitialize(m_eglDisplay, 0, 0) == EGL_FALSE) {
96  g_warning("PlatformDisplayWayland initialization: failed to initialize the EGL display.");
97  return;
98  }
99 
100  if (eglBindAPI(EGL_OPENGL_ES_API) == EGL_FALSE) {
101  g_warning("PlatformDisplayWayland initialization: failed to set EGL_OPENGL_ES_API as the rendering API.");
102  return;
103  }
10493
10594 EGLint numberOfConfigs;
10695 if (!eglChooseConfig(m_eglDisplay, configAttributes, &m_eglConfig, 1, &numberOfConfigs) || numberOfConfigs != 1) {

Source/WebCore/platform/graphics/wayland/PlatformDisplayWayland.h

@@public:
4747 virtual ~PlatformDisplayWayland();
4848
4949 struct wl_display* native() const { return m_display; }
50  EGLDisplay eglDisplay() const { return m_eglDisplay; }
5150
5251 std::unique_ptr<WaylandSurface> createSurface(const IntSize&, int widgetID);
5352

@@private:
6867 struct wl_compositor* m_compositor;
6968 struct wl_webkitgtk* m_webkitgtk;
7069
71  EGLDisplay m_eglDisplay;
7270 EGLConfig m_eglConfig;
7371 bool m_eglConfigChosen;
7472};

Source/WebCore/platform/graphics/x11/PlatformDisplayX11.cpp

2929#if PLATFORM(X11)
3030#include <X11/Xlib.h>
3131
 32#if USE(EGL)
 33#include <EGL/egl.h>
 34#endif
 35
3236namespace WebCore {
3337
3438PlatformDisplayX11::PlatformDisplayX11()

@@PlatformDisplayX11::~PlatformDisplayX11()
4953 XCloseDisplay(m_display);
5054}
5155
 56#if USE(EGL)
 57void PlatformDisplayX11::initializeEGLDisplay()
 58{
 59 m_eglDisplay = eglGetDisplay(m_display);
 60 PlatformDisplay::initializeEGLDisplay();
 61}
 62#endif
 63
5264} // namespace WebCore
5365
5466#endif // PLATFORM(X11)

Source/WebCore/platform/graphics/x11/PlatformDisplayX11.h

@@public:
4545private:
4646 virtual Type type() const override { return PlatformDisplay::Type::X11; }
4747
 48#if USE(EGL)
 49 void initializeEGLDisplay() override;
 50#endif
 51
4852 Display* m_display;
4953 bool m_ownedDisplay;
5054};