| Differences between
and this patch
- a/Source/WebCore/ChangeLog +63 lines
Lines 1-3 a/Source/WebCore/ChangeLog_sec1
1
2015-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
1
2015-05-05  Carlos Garcia Campos  <cgarcia@igalia.com>
64
2015-05-05  Carlos Garcia Campos  <cgarcia@igalia.com>
2
65
3
        [SOUP] Network Cache: Implement ShareableResource for Soup and enable it for GTK platform
66
        [SOUP] Network Cache: Implement ShareableResource for Soup and enable it for GTK platform
- a/Source/WebCore/platform/graphics/PlatformDisplay.cpp +63 lines
Lines 45-50 a/Source/WebCore/platform/graphics/PlatformDisplay.cpp_sec1
45
#include <Ecore_X.h>
45
#include <Ecore_X.h>
46
#endif
46
#endif
47
47
48
#if USE(EGL)
49
#include <EGL/egl.h>
50
#endif
51
48
namespace WebCore {
52
namespace WebCore {
49
53
50
std::unique_ptr<PlatformDisplay> PlatformDisplay::createPlatformDisplay()
54
std::unique_ptr<PlatformDisplay> PlatformDisplay::createPlatformDisplay()
Lines 85-88 PlatformDisplay& PlatformDisplay::sharedDisplay() a/Source/WebCore/platform/graphics/PlatformDisplay.cpp_sec2
85
    return *display;
89
    return *display;
86
}
90
}
87
91
92
PlatformDisplay::PlatformDisplay()
93
#if USE(EGL)
94
    : m_eglDisplay(EGL_NO_DISPLAY)
95
#endif
96
{
97
}
98
99
PlatformDisplay::~PlatformDisplay()
100
{
101
#if USE(EGL)
102
    terminateEGLDisplay();
103
#endif
104
}
105
106
#if USE(EGL)
107
EGLDisplay PlatformDisplay::eglDisplay() const
108
{
109
    if (!m_eglDisplayInitialized)
110
        const_cast<PlatformDisplay*>(this)->initializeEGLDisplay();
111
    return m_eglDisplay;
112
}
113
114
void 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
142
void 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
88
} // namespace WebCore
151
} // namespace WebCore
- a/Source/WebCore/platform/graphics/PlatformDisplay.h -2 / +22 lines
Lines 29-41 a/Source/WebCore/platform/graphics/PlatformDisplay.h_sec1
29
#include <wtf/Noncopyable.h>
29
#include <wtf/Noncopyable.h>
30
#include <wtf/TypeCasts.h>
30
#include <wtf/TypeCasts.h>
31
31
32
#if USE(EGL)
33
typedef void *EGLDisplay;
34
#endif
35
32
namespace WebCore {
36
namespace WebCore {
33
37
34
class PlatformDisplay {
38
class PlatformDisplay {
35
    WTF_MAKE_NONCOPYABLE(PlatformDisplay); WTF_MAKE_FAST_ALLOCATED;
39
    WTF_MAKE_NONCOPYABLE(PlatformDisplay); WTF_MAKE_FAST_ALLOCATED;
36
public:
40
public:
37
    static PlatformDisplay& sharedDisplay();
41
    static PlatformDisplay& sharedDisplay();
38
    virtual ~PlatformDisplay() = default;
42
    virtual ~PlatformDisplay();
39
43
40
    enum class Type {
44
    enum class Type {
41
#if PLATFORM(X11)
45
#if PLATFORM(X11)
Lines 48-58 public: a/Source/WebCore/platform/graphics/PlatformDisplay.h_sec2
48
52
49
    virtual Type type() const = 0;
53
    virtual Type type() const = 0;
50
54
55
#if USE(EGL)
56
    EGLDisplay eglDisplay() const;
57
#endif
58
51
protected:
59
protected:
52
    PlatformDisplay() = default;
60
    PlatformDisplay();
61
62
#if USE(EGL)
63
    virtual void initializeEGLDisplay();
64
65
    EGLDisplay m_eglDisplay;
66
#endif
53
67
54
private:
68
private:
55
    static std::unique_ptr<PlatformDisplay> createPlatformDisplay();
69
    static std::unique_ptr<PlatformDisplay> createPlatformDisplay();
70
71
#if USE(EGL)
72
    void terminateEGLDisplay();
73
74
    bool m_eglDisplayInitialized { false };
75
#endif
56
};
76
};
57
77
58
} // namespace WebCore
78
} // namespace WebCore
- a/Source/WebCore/platform/graphics/egl/GLContextEGL.cpp -30 / +2 lines
Lines 22-27 a/Source/WebCore/platform/graphics/egl/GLContextEGL.cpp_sec1
22
#if USE(EGL)
22
#if USE(EGL)
23
23
24
#include "GraphicsContext3D.h"
24
#include "GraphicsContext3D.h"
25
#include "PlatformDisplay.h"
25
26
26
#if USE(CAIRO)
27
#if USE(CAIRO)
27
#include <cairo.h>
28
#include <cairo.h>
Lines 38-47 a/Source/WebCore/platform/graphics/egl/GLContextEGL.cpp_sec2
38
#include "PlatformDisplayX11.h"
39
#include "PlatformDisplayX11.h"
39
#endif
40
#endif
40
41
41
#if PLATFORM(WAYLAND)
42
#include "PlatformDisplayWayland.h"
43
#endif
44
45
#if ENABLE(ACCELERATED_2D_CANVAS)
42
#if ENABLE(ACCELERATED_2D_CANVAS)
46
// cairo-gl.h includes some definitions from GLX that conflict with
43
// cairo-gl.h includes some definitions from GLX that conflict with
47
// the ones provided by us. Since GLContextEGL doesn't use any GLX
44
// the ones provided by us. Since GLContextEGL doesn't use any GLX
Lines 52-85 a/Source/WebCore/platform/graphics/egl/GLContextEGL.cpp_sec3
52
49
53
namespace WebCore {
50
namespace WebCore {
54
51
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
63
static EGLDisplay sharedEGLDisplay()
52
static EGLDisplay sharedEGLDisplay()
64
{
53
{
65
    static bool initialized = false;
54
    return PlatformDisplay::sharedDisplay().eglDisplay();
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;
83
}
55
}
84
56
85
static const EGLint gContextAttributes[] = {
57
static const EGLint gContextAttributes[] = {
- a/Source/WebCore/platform/graphics/opengl/GLDefs.h -8 lines
Lines 57-78 typedef uint32_t PlatformBufferHandle; a/Source/WebCore/platform/graphics/opengl/GLDefs.h_sec1
57
57
58
#if USE(GLX)
58
#if USE(GLX)
59
typedef GLXContext PlatformContext;
59
typedef GLXContext PlatformContext;
60
typedef Display* PlatformDisplay;
61
typedef GLXFBConfig PlatformSurfaceConfig;
60
typedef GLXFBConfig PlatformSurfaceConfig;
62
typedef GLXDrawable PlatformDrawable;
61
typedef GLXDrawable PlatformDrawable;
63
#elif USE(EGL)
62
#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
69
typedef EGLContext PlatformContext;
63
typedef EGLContext PlatformContext;
70
typedef EGLDisplay PlatformDisplay;
71
typedef EGLConfig PlatformSurfaceConfig;
64
typedef EGLConfig PlatformSurfaceConfig;
72
typedef EGLSurface PlatformDrawable;
65
typedef EGLSurface PlatformDrawable;
73
#else
66
#else
74
typedef void* PlatformContext;
67
typedef void* PlatformContext;
75
typedef void* PlatformDisplay;
76
typedef void* PlatformSurfaceConfig;
68
typedef void* PlatformSurfaceConfig;
77
typedef void* PlatformDrawable;
69
typedef void* PlatformDrawable;
78
#endif
70
#endif
- a/Source/WebCore/platform/graphics/opengl/GLPlatformSurface.cpp -7 / +1 lines
Lines 61-68 std::unique_ptr<GLPlatformSurface> GLPlatformSurface::createOffScreenSurface(Sur a/Source/WebCore/platform/graphics/opengl/GLPlatformSurface.cpp_sec1
61
}
61
}
62
62
63
GLPlatformSurface::GLPlatformSurface(SurfaceAttributes)
63
GLPlatformSurface::GLPlatformSurface(SurfaceAttributes)
64
    : m_sharedDisplay(0)
64
    : m_drawable(0)
65
    , m_drawable(0)
66
    , m_bufferHandle(0)
65
    , m_bufferHandle(0)
67
{
66
{
68
}
67
}
Lines 88-98 const IntRect& GLPlatformSurface::geometry() const a/Source/WebCore/platform/graphics/opengl/GLPlatformSurface.cpp_sec2
88
    return m_rect;
87
    return m_rect;
89
}
88
}
90
89
91
PlatformDisplay GLPlatformSurface::sharedDisplay() const
92
{
93
    return m_sharedDisplay;
94
}
95
96
PlatformSurfaceConfig GLPlatformSurface::configuration()
90
PlatformSurfaceConfig GLPlatformSurface::configuration()
97
{
91
{
98
    return 0;
92
    return 0;
- a/Source/WebCore/platform/graphics/opengl/GLPlatformSurface.h -3 lines
Lines 59-66 public: a/Source/WebCore/platform/graphics/opengl/GLPlatformSurface.h_sec1
59
59
60
    PlatformDrawable drawable() const;
60
    PlatformDrawable drawable() const;
61
61
62
    PlatformDisplay sharedDisplay() const;
63
64
    virtual SurfaceAttributes attributes() const;
62
    virtual SurfaceAttributes attributes() const;
65
63
66
    virtual void swapBuffers();
64
    virtual void swapBuffers();
Lines 84-90 public: a/Source/WebCore/platform/graphics/opengl/GLPlatformSurface.h_sec2
84
protected:
82
protected:
85
    GLPlatformSurface(SurfaceAttributes);
83
    GLPlatformSurface(SurfaceAttributes);
86
84
87
    PlatformDisplay m_sharedDisplay;
88
    PlatformDrawable m_drawable;
85
    PlatformDrawable m_drawable;
89
    PlatformBufferHandle m_bufferHandle;
86
    PlatformBufferHandle m_bufferHandle;
90
    IntRect m_rect;
87
    IntRect m_rect;
- a/Source/WebCore/platform/graphics/surfaces/egl/EGLConfigSelector.h -1 / +1 lines
Lines 61-67 protected: a/Source/WebCore/platform/graphics/surfaces/egl/EGLConfigSelector.h_sec1
61
    EGLConfig m_pixmapFBConfig;
61
    EGLConfig m_pixmapFBConfig;
62
    EGLConfig m_surfaceContextFBConfig;
62
    EGLConfig m_surfaceContextFBConfig;
63
    unsigned m_attributes : 3;
63
    unsigned m_attributes : 3;
64
    PlatformDisplay m_sharedDisplay;
64
    EGLDisplay m_sharedDisplay;
65
};
65
};
66
66
67
}
67
}
- a/Source/WebCore/platform/graphics/surfaces/egl/EGLContext.cpp -6 / +2 lines
Lines 28-33 a/Source/WebCore/platform/graphics/surfaces/egl/EGLContext.cpp_sec1
28
28
29
#if USE(EGL)
29
#if USE(EGL)
30
30
31
#include "PlatformDisplay.h"
31
#include <wtf/text/WTFString.h>
32
#include <wtf/text/WTFString.h>
32
33
33
namespace WebCore {
34
namespace WebCore {
Lines 72-83 bool EGLOffScreenContext::initialize(GLPlatformSurface* surface, PlatformContext a/Source/WebCore/platform/graphics/surfaces/egl/EGLContext.cpp_sec2
72
    if (!surface)
73
    if (!surface)
73
        return false;
74
        return false;
74
75
75
    if (!eglBindAPI(eglAPIVersion)) {
76
    m_display = PlatformDisplay::sharedDisplay().eglDisplay();
76
        LOG_ERROR("Failed to set EGL API(%d).", eglGetError());
77
        return false;
78
    }
79
80
    m_display = surface->sharedDisplay();
81
    if (!m_display)
77
    if (!m_display)
82
        return false;
78
        return false;
83
79
- a/Source/WebCore/platform/graphics/surfaces/egl/EGLHelper.cpp -71 / +4 lines
Lines 28-116 a/Source/WebCore/platform/graphics/surfaces/egl/EGLHelper.cpp_sec1
28
28
29
#if USE(EGL)
29
#if USE(EGL)
30
30
31
#include "PlatformDisplay.h"
31
#include <opengl/GLPlatformContext.h>
32
#include <opengl/GLPlatformContext.h>
32
33
33
#if PLATFORM(X11)
34
#include "X11Helper.h"
35
#endif
36
34
37
namespace WebCore {
35
namespace WebCore {
38
36
39
#if PLATFORM(X11)
40
typedef X11Helper NativeWrapper;
41
typedef Display NativeSharedDisplay;
42
#else
43
typedef void NativeSharedDisplay;
44
#endif
45
46
static PFNEGLCREATEIMAGEKHRPROC eglCreateImageKHR = 0;
37
static PFNEGLCREATEIMAGEKHRPROC eglCreateImageKHR = 0;
47
static PFNEGLDESTROYIMAGEKHRPROC eglDestroyImageKHR = 0;
38
static PFNEGLDESTROYIMAGEKHRPROC eglDestroyImageKHR = 0;
48
static PFNGLEGLIMAGETARGETTEXTURE2DOESPROC eglImageTargetTexture2DOES = 0;
39
static PFNGLEGLIMAGETARGETTEXTURE2DOESPROC eglImageTargetTexture2DOES = 0;
49
40
50
struct EGLDisplayConnection {
41
EGLDisplay EGLHelper::eglDisplay()
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()
103
{
42
{
104
    // Display connection will only be broken at program shutdown.
43
    PlatformDisplay::sharedDisplay().eglDisplay();
105
#if PLATFORM(X11)
106
    static EGLDisplayConnection displayConnection(NativeWrapper::nativeDisplay());
107
#else
108
    static EGLDisplayConnection displayConnection;
109
#endif
110
    return displayConnection.display();
111
}
44
}
112
45
113
PlatformDisplay EGLHelper::currentDisplay()
46
EGLDisplay EGLHelper::currentDisplay()
114
{
47
{
115
    EGLDisplay display = eglGetCurrentDisplay();
48
    EGLDisplay display = eglGetCurrentDisplay();
116
49
- a/Source/WebCore/platform/graphics/surfaces/egl/EGLHelper.h -2 / +2 lines
Lines 34-41 namespace WebCore { a/Source/WebCore/platform/graphics/surfaces/egl/EGLHelper.h_sec1
34
34
35
class EGLHelper {
35
class EGLHelper {
36
public:
36
public:
37
    static PlatformDisplay eglDisplay();
37
    static EGLDisplay eglDisplay();
38
    static PlatformDisplay currentDisplay();
38
    static EGLDisplay currentDisplay();
39
    static void resolveEGLBindings();
39
    static void resolveEGLBindings();
40
    static void createEGLImage(EGLImageKHR*, GLenum, const EGLClientBuffer, const EGLint* = 0);
40
    static void createEGLImage(EGLImageKHR*, GLenum, const EGLClientBuffer, const EGLint* = 0);
41
    static void destroyEGLImage(const EGLImageKHR);
41
    static void destroyEGLImage(const EGLImageKHR);
- a/Source/WebCore/platform/graphics/surfaces/egl/EGLSurface.cpp -10 / +6 lines
Lines 75-83 std::unique_ptr<GLTransportSurfaceClient> EGLTransportSurface::createTransportSu a/Source/WebCore/platform/graphics/surfaces/egl/EGLSurface.cpp_sec1
75
EGLTransportSurface::EGLTransportSurface(const IntSize& size, SurfaceAttributes attributes)
75
EGLTransportSurface::EGLTransportSurface(const IntSize& size, SurfaceAttributes attributes)
76
    : GLTransportSurface(size, attributes)
76
    : GLTransportSurface(size, attributes)
77
{
77
{
78
    m_sharedDisplay = EGLHelper::eglDisplay();
78
    if (EGLHelper::eglDisplay() == EGL_NO_DISPLAY)
79
80
    if (m_sharedDisplay == EGL_NO_DISPLAY)
81
        return;
79
        return;
82
80
83
    m_configSelector = std::make_unique<EGLConfigSelector>(attributes);
81
    m_configSelector = std::make_unique<EGLConfigSelector>(attributes);
Lines 94-106 EGLTransportSurface::~EGLTransportSurface() a/Source/WebCore/platform/graphics/surfaces/egl/EGLSurface.cpp_sec2
94
92
95
void EGLTransportSurface::destroy()
93
void EGLTransportSurface::destroy()
96
{
94
{
97
    if (m_drawable == EGL_NO_SURFACE || m_sharedDisplay == EGL_NO_DISPLAY)
95
    if (m_drawable == EGL_NO_SURFACE || EGLHelper::eglDisplay() == EGL_NO_DISPLAY)
98
        return;
96
        return;
99
97
100
    GLTransportSurface::destroy();
98
    GLTransportSurface::destroy();
101
99
102
    if (m_drawable) {
100
    if (m_drawable) {
103
        eglDestroySurface(m_sharedDisplay, m_drawable);
101
        eglDestroySurface(EGLHelper::eglDisplay(), m_drawable);
104
        m_drawable = EGL_NO_SURFACE;
102
        m_drawable = EGL_NO_SURFACE;
105
    }
103
    }
106
104
Lines 125-133 std::unique_ptr<GLPlatformSurface> EGLOffScreenSurface::createOffScreenSurface(S a/Source/WebCore/platform/graphics/surfaces/egl/EGLSurface.cpp_sec3
125
EGLOffScreenSurface::EGLOffScreenSurface(SurfaceAttributes surfaceAttributes)
123
EGLOffScreenSurface::EGLOffScreenSurface(SurfaceAttributes surfaceAttributes)
126
    : GLPlatformSurface(surfaceAttributes)
124
    : GLPlatformSurface(surfaceAttributes)
127
{
125
{
128
    m_sharedDisplay = EGLHelper::eglDisplay();
126
    if (EGLHelper::eglDisplay() == EGL_NO_DISPLAY)
129
130
    if (m_sharedDisplay == EGL_NO_DISPLAY)
131
        return;
127
        return;
132
128
133
    m_configSelector = std::make_unique<EGLConfigSelector>(surfaceAttributes);
129
    m_configSelector = std::make_unique<EGLConfigSelector>(surfaceAttributes);
Lines 149-159 PlatformSurfaceConfig EGLOffScreenSurface::configuration() a/Source/WebCore/platform/graphics/surfaces/egl/EGLSurface.cpp_sec4
149
145
150
void EGLOffScreenSurface::destroy()
146
void EGLOffScreenSurface::destroy()
151
{
147
{
152
    if (m_sharedDisplay == EGL_NO_DISPLAY || m_drawable == EGL_NO_SURFACE)
148
    if (EGLHelper::eglDisplay() == EGL_NO_DISPLAY || m_drawable == EGL_NO_SURFACE)
153
        return;
149
        return;
154
150
155
    if (m_drawable) {
151
    if (m_drawable) {
156
        eglDestroySurface(m_sharedDisplay, m_drawable);
152
        eglDestroySurface(EGLHelper::eglDisplay(), m_drawable);
157
        m_drawable = EGL_NO_SURFACE;
153
        m_drawable = EGL_NO_SURFACE;
158
    }
154
    }
159
155
- a/Source/WebCore/platform/graphics/surfaces/egl/EGLXSurface.cpp -3 / +4 lines
Lines 31-36 a/Source/WebCore/platform/graphics/surfaces/egl/EGLXSurface.cpp_sec1
31
#include "EGLConfigSelector.h"
31
#include "EGLConfigSelector.h"
32
#include "EGLHelper.h"
32
#include "EGLHelper.h"
33
#include "GLPlatformContext.h"
33
#include "GLPlatformContext.h"
34
#include "PlatformDisplay.h"
34
35
35
namespace WebCore {
36
namespace WebCore {
36
37
Lines 59-65 EGLWindowTransportSurface::EGLWindowTransportSurface(const IntSize& size, GLPlat a/Source/WebCore/platform/graphics/surfaces/egl/EGLXSurface.cpp_sec2
59
        return;
60
        return;
60
    }
61
    }
61
62
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);
63
64
64
    if (m_drawable == EGL_NO_SURFACE) {
65
    if (m_drawable == EGL_NO_SURFACE) {
65
        LOG_ERROR("Failed to create EGL surface(%d).", eglGetError());
66
        LOG_ERROR("Failed to create EGL surface(%d).", eglGetError());
Lines 73-79 EGLWindowTransportSurface::~EGLWindowTransportSurface() a/Source/WebCore/platform/graphics/surfaces/egl/EGLXSurface.cpp_sec3
73
74
74
void EGLWindowTransportSurface::swapBuffers()
75
void EGLWindowTransportSurface::swapBuffers()
75
{
76
{
76
    if (!eglSwapBuffers(m_sharedDisplay, m_drawable))
77
    if (!eglSwapBuffers(PlatformDisplay::sharedDisplay().eglDisplay(), m_drawable))
77
        LOG_ERROR("Failed to SwapBuffers(%d).", eglGetError());
78
        LOG_ERROR("Failed to SwapBuffers(%d).", eglGetError());
78
}
79
}
79
80
Lines 116-122 EGLPixmapSurface::EGLPixmapSurface(GLPlatformSurface::SurfaceAttributes surfaceA a/Source/WebCore/platform/graphics/surfaces/egl/EGLXSurface.cpp_sec4
116
        return;
117
        return;
117
    }
118
    }
118
119
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);
120
121
121
    if (m_drawable == EGL_NO_SURFACE) {
122
    if (m_drawable == EGL_NO_SURFACE) {
122
        LOG_ERROR("Failed to create EGL surface(%d).", eglGetError());
123
        LOG_ERROR("Failed to create EGL surface(%d).", eglGetError());
- a/Source/WebCore/platform/graphics/surfaces/glx/GLXSurface.cpp -4 / +1 lines
Lines 64-70 static bool isMesaGLX() a/Source/WebCore/platform/graphics/surfaces/glx/GLXSurface.cpp_sec1
64
GLXTransportSurface::GLXTransportSurface(const IntSize& size, SurfaceAttributes attributes)
64
GLXTransportSurface::GLXTransportSurface(const IntSize& size, SurfaceAttributes attributes)
65
    : GLTransportSurface(size, attributes)
65
    : GLTransportSurface(size, attributes)
66
{
66
{
67
    m_sharedDisplay = X11Helper::nativeDisplay();
68
    attributes |= GLPlatformSurface::DoubleBuffered;
67
    attributes |= GLPlatformSurface::DoubleBuffered;
69
    m_configSelector = std::make_unique<GLXConfigSelector>(attributes);
68
    m_configSelector = std::make_unique<GLXConfigSelector>(attributes);
70
    std::unique_ptr<XVisualInfo, X11Deleter> visInfo(m_configSelector->visualInfo(m_configSelector->surfaceContextConfig()));
69
    std::unique_ptr<XVisualInfo, X11Deleter> visInfo(m_configSelector->visualInfo(m_configSelector->surfaceContextConfig()));
Lines 141-148 GLXOffScreenSurface::~GLXOffScreenSurface() a/Source/WebCore/platform/graphics/surfaces/glx/GLXSurface.cpp_sec2
141
140
142
void GLXOffScreenSurface::initialize(SurfaceAttributes attributes)
141
void GLXOffScreenSurface::initialize(SurfaceAttributes attributes)
143
{
142
{
144
    m_sharedDisplay = X11Helper::nativeDisplay();
145
146
    m_configSelector = std::make_unique<GLXConfigSelector>(attributes);
143
    m_configSelector = std::make_unique<GLXConfigSelector>(attributes);
147
144
148
    std::unique_ptr<XVisualInfo, X11Deleter> visualInfo(m_configSelector->visualInfo(m_configSelector->pixmapContextConfig()));
145
    std::unique_ptr<XVisualInfo, X11Deleter> visualInfo(m_configSelector->visualInfo(m_configSelector->pixmapContextConfig()));
Lines 153-159 void GLXOffScreenSurface::initialize(SurfaceAttributes attributes) a/Source/WebCore/platform/graphics/surfaces/glx/GLXSurface.cpp_sec3
153
        return;
150
        return;
154
    }
151
    }
155
152
156
    m_glxPixmap = glXCreateGLXPixmap(m_sharedDisplay, visualInfo.get(), m_pixmap);
153
    m_glxPixmap = glXCreateGLXPixmap(X11Helper::nativeDisplay(), visualInfo.get(), m_pixmap);
157
154
158
    if (!m_glxPixmap) {
155
    if (!m_glxPixmap) {
159
        destroy();
156
        destroy();
- a/Source/WebCore/platform/graphics/wayland/PlatformDisplayWayland.cpp -13 / +2 lines
Lines 87-106 PlatformDisplayWayland::PlatformDisplayWayland(struct wl_display* wlDisplay) a/Source/WebCore/platform/graphics/wayland/PlatformDisplayWayland.cpp_sec1
87
    };
87
    };
88
88
89
    m_eglDisplay = eglGetDisplay(m_display);
89
    m_eglDisplay = eglGetDisplay(m_display);
90
    if (m_eglDisplay == EGL_NO_DISPLAY) {
90
    PlatformDisplay::initializeEGLDisplay();
91
        g_warning("PlatformDisplayWayland initialization: failed to acquire EGL display.");
91
    if (m_eglDisplay == EGL_NO_DISPLAY)
92
        return;
92
        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
    }
104
93
105
    EGLint numberOfConfigs;
94
    EGLint numberOfConfigs;
106
    if (!eglChooseConfig(m_eglDisplay, configAttributes, &m_eglConfig, 1, &numberOfConfigs) || numberOfConfigs != 1) {
95
    if (!eglChooseConfig(m_eglDisplay, configAttributes, &m_eglConfig, 1, &numberOfConfigs) || numberOfConfigs != 1) {
- a/Source/WebCore/platform/graphics/wayland/PlatformDisplayWayland.h -2 lines
Lines 47-53 public: a/Source/WebCore/platform/graphics/wayland/PlatformDisplayWayland.h_sec1
47
    virtual ~PlatformDisplayWayland();
47
    virtual ~PlatformDisplayWayland();
48
48
49
    struct wl_display* native() const { return m_display; }
49
    struct wl_display* native() const { return m_display; }
50
    EGLDisplay eglDisplay() const { return m_eglDisplay; }
51
50
52
    std::unique_ptr<WaylandSurface> createSurface(const IntSize&, int widgetID);
51
    std::unique_ptr<WaylandSurface> createSurface(const IntSize&, int widgetID);
53
52
Lines 68-74 private: a/Source/WebCore/platform/graphics/wayland/PlatformDisplayWayland.h_sec2
68
    struct wl_compositor* m_compositor;
67
    struct wl_compositor* m_compositor;
69
    struct wl_webkitgtk* m_webkitgtk;
68
    struct wl_webkitgtk* m_webkitgtk;
70
69
71
    EGLDisplay m_eglDisplay;
72
    EGLConfig m_eglConfig;
70
    EGLConfig m_eglConfig;
73
    bool m_eglConfigChosen;
71
    bool m_eglConfigChosen;
74
};
72
};
- a/Source/WebCore/platform/graphics/x11/PlatformDisplayX11.cpp +12 lines
Lines 29-34 a/Source/WebCore/platform/graphics/x11/PlatformDisplayX11.cpp_sec1
29
#if PLATFORM(X11)
29
#if PLATFORM(X11)
30
#include <X11/Xlib.h>
30
#include <X11/Xlib.h>
31
31
32
#if USE(EGL)
33
#include <EGL/egl.h>
34
#endif
35
32
namespace WebCore {
36
namespace WebCore {
33
37
34
PlatformDisplayX11::PlatformDisplayX11()
38
PlatformDisplayX11::PlatformDisplayX11()
Lines 49-54 PlatformDisplayX11::~PlatformDisplayX11() a/Source/WebCore/platform/graphics/x11/PlatformDisplayX11.cpp_sec2
49
        XCloseDisplay(m_display);
53
        XCloseDisplay(m_display);
50
}
54
}
51
55
56
#if USE(EGL)
57
void PlatformDisplayX11::initializeEGLDisplay()
58
{
59
    m_eglDisplay = eglGetDisplay(m_display);
60
    PlatformDisplay::initializeEGLDisplay();
61
}
62
#endif
63
52
} // namespace WebCore
64
} // namespace WebCore
53
65
54
#endif // PLATFORM(X11)
66
#endif // PLATFORM(X11)
- a/Source/WebCore/platform/graphics/x11/PlatformDisplayX11.h +4 lines
Lines 45-50 public: a/Source/WebCore/platform/graphics/x11/PlatformDisplayX11.h_sec1
45
private:
45
private:
46
    virtual Type type() const override { return PlatformDisplay::Type::X11; }
46
    virtual Type type() const override { return PlatformDisplay::Type::X11; }
47
47
48
#if USE(EGL)
49
    void initializeEGLDisplay() override;
50
#endif
51
48
    Display* m_display;
52
    Display* m_display;
49
    bool m_ownedDisplay;
53
    bool m_ownedDisplay;
50
};
54
};

Return to Bug 144685