| Differences between
and this patch
- ChangeLog +13 lines
Lines 1-3 ChangeLog_sec1
1
2012-12-30  Kondapally Kalyan  <kalyan.kondapally@intel.com>
2
3
        [EFL] [WebGL] Rename EGLConfigHelper as EGLConfigSelector.
4
        https://bugs.webkit.org/show_bug.cgi?id=105876
5
6
        Reviewed by Kenneth Rohde Christiansen.
7
8
        This is to sync the naming conventions of our classes in both EGL and GLX implementations. 
9
        In our GLX implementation, class responsible for the same functionality is named as GLXConfigSelector. 
10
        This patch renames EGLConfigHelper as EGLConfigSelector.
11
12
        * Source/cmake/OptionsEfl.cmake:
13
1
2012-12-27  Kondapally Kalyan  <kalyan.kondapally@intel.com>
14
2012-12-27  Kondapally Kalyan  <kalyan.kondapally@intel.com>
2
15
3
        [EFL][WebGL] Implement EGL support with GLX.
16
        [EFL][WebGL] Implement EGL support with GLX.
- Source/WebCore/ChangeLog +39 lines
Lines 1-3 Source/WebCore/ChangeLog_sec1
1
2012-12-30  Kondapally Kalyan  <kalyan.kondapally@intel.com>
2
3
        [EFL] [WebGL] Rename EGLConfigHelper as EGLConfigSelector.
4
        https://bugs.webkit.org/show_bug.cgi?id=105876
5
6
        Reviewed by Kenneth Rohde Christiansen.
7
8
        This is to sync the naming conventions of our classes in both EGL and GLX implementations. 
9
        In our GLX implementation, class responsible for the same functionality is named as GLXConfigSelector. 
10
        This patch renames EGLConfigHelper as EGLConfigSelector.
11
12
        * PlatformEfl.cmake:
13
        * platform/graphics/surfaces/egl/EGLConfigSelector.cpp: Renamed from Source/WebCore/platform/graphics/surfaces/egl/EGLConfigHelper.cpp.
14
        (WebCore):
15
        (WebCore::SharedEGLDisplay::deref):
16
        (WebCore::SharedEGLDisplay::sharedEGLDisplay):
17
        (WebCore::SharedEGLDisplay::SharedEGLDisplay):
18
        (WebCore::SharedEGLDisplay::cleanup):
19
        (WebCore::SharedEGLDisplay::~SharedEGLDisplay):
20
        (WebCore::EGLConfigSelector::EGLConfigSelector):
21
        (WebCore::EGLConfigSelector::~EGLConfigSelector):
22
        (WebCore::EGLConfigSelector::display):
23
        (WebCore::EGLConfigSelector::pBufferContextConfig):
24
        (WebCore::EGLConfigSelector::surfaceContextConfig):
25
        (WebCore::EGLConfigSelector::nativeVisualId):
26
        (WebCore::EGLConfigSelector::reset):
27
        (WebCore::EGLConfigSelector::createConfig):
28
        * platform/graphics/surfaces/egl/EGLConfigSelector.h: Renamed from Source/WebCore/platform/graphics/surfaces/egl/EGLConfigHelper.h.
29
        (WebCore):
30
        (SharedEGLDisplay):
31
        (WebCore::SharedEGLDisplay::create):
32
        (EGLConfigSelector):
33
        * platform/graphics/surfaces/egl/EGLSurface.cpp:
34
        (WebCore::EGLWindowTransportSurface::EGLWindowTransportSurface):
35
        (WebCore::EGLWindowTransportSurface::configuration):
36
        (WebCore::EGLWindowTransportSurface::destroy):
37
        * platform/graphics/surfaces/egl/EGLSurface.h:
38
        (EGLWindowTransportSurface):
39
1
2012-12-30  Philippe Normand  <pnormand@igalia.com>
40
2012-12-30  Philippe Normand  <pnormand@igalia.com>
2
41
3
        [GStreamer] webaudio/decode-audio-data-basic.html fails
42
        [GStreamer] webaudio/decode-audio-data-basic.html fails
- Source/WebCore/PlatformEfl.cmake -1 / +2 lines
Lines 293-300 if (WTF_USE_3D_GRAPHICS) Source/WebCore/PlatformEfl.cmake_sec1
293
293
294
    if (WTF_USE_EGL)
294
    if (WTF_USE_EGL)
295
        list(APPEND WebCore_SOURCES
295
        list(APPEND WebCore_SOURCES
296
            platform/graphics/surfaces/egl/EGLSurface.cpp
296
            platform/graphics/surfaces/egl/EGLConfigSelector.cpp
297
            platform/graphics/surfaces/egl/EGLContext.cpp
297
            platform/graphics/surfaces/egl/EGLContext.cpp
298
            platform/graphics/surfaces/egl/EGLSurface.cpp
298
        )
299
        )
299
    endif ()
300
    endif ()
300
301
- Source/WebCore/platform/graphics/surfaces/egl/EGLConfigHelper.cpp -181 lines
Lines 1-181 Source/WebCore/platform/graphics/surfaces/egl/EGLConfigHelper.cpp_sec1
1
/*
2
 * Copyright (C) 2012 Intel Corporation. All rights reserved.
3
 *
4
 * Redistribution and use in source and binary forms, with or without
5
 * modification, are permitted provided that the following conditions
6
 * are met:
7
 * 1. Redistributions of source code must retain the above copyright
8
 *    notice, this list of conditions and the following disclaimer.
9
 * 2. Redistributions in binary form must reproduce the above copyright
10
 *    notice, this list of conditions and the following disclaimer in the
11
 *    documentation and/or other materials provided with the distribution.
12
 *
13
 * THIS SOFTWARE IS PROVIDED BY APPLE INC. AND ITS CONTRIBUTORS ``AS IS''
14
 * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
15
 * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
16
 * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE INC. OR ITS CONTRIBUTORS
17
 * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
18
 * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
19
 * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
20
 * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
21
 * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
22
 * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF
23
 * THE POSSIBILITY OF SUCH DAMAGE.
24
 */
25
26
#include "config.h"
27
#include "EGLConfigHelper.h"
28
29
#if USE(EGL)
30
31
namespace WebCore {
32
33
SharedEGLDisplay* SharedEGLDisplay::m_staticSharedEGLDisplay = 0;
34
35
static EGLint configAttributeList[] = {
36
#if USE(OPENGL_ES_2)
37
    EGL_RENDERABLE_TYPE, EGL_OPENGL_ES2_BIT,
38
#else
39
    EGL_RENDERABLE_TYPE, EGL_OPENGL_BIT,
40
#endif
41
    EGL_RED_SIZE, 8,
42
    EGL_GREEN_SIZE, 8,
43
    EGL_BLUE_SIZE, 8,
44
    EGL_STENCIL_SIZE, 8,
45
    EGL_ALPHA_SIZE, 8,
46
    EGL_SURFACE_TYPE, EGL_NONE,
47
    EGL_NONE
48
};
49
50
void SharedEGLDisplay::deref()
51
{
52
    if (derefBase()) {
53
        m_staticSharedEGLDisplay = 0;
54
        delete this;
55
    }
56
}
57
58
EGLDisplay SharedEGLDisplay::sharedEGLDisplay()
59
{
60
    return m_eglDisplay;
61
}
62
63
SharedEGLDisplay::SharedEGLDisplay(NativeSharedDisplay* display)
64
    : m_eglDisplay(EGL_NO_DISPLAY)
65
{
66
    if (display)
67
        m_eglDisplay = eglGetDisplay(reinterpret_cast<EGLNativeDisplayType>(display));
68
    else
69
        m_eglDisplay = eglGetDisplay(EGL_DEFAULT_DISPLAY);
70
71
    if (m_eglDisplay == EGL_NO_DISPLAY) {
72
        LOG_ERROR("EGLDisplay Initialization failed.");
73
        return;
74
    }
75
76
    EGLBoolean success;
77
    success = eglInitialize(m_eglDisplay, 0, 0);
78
79
    if (success != EGL_TRUE) {
80
        LOG_ERROR("EGLInitialization failed.");
81
        m_eglDisplay = EGL_NO_DISPLAY;
82
    }
83
84
    success = eglBindAPI(eglAPIVersion);
85
86
    if (success != EGL_TRUE) {
87
        LOG_ERROR("Failed to set EGL API(%d).", eglGetError());
88
        m_eglDisplay = EGL_NO_DISPLAY;
89
    }
90
}
91
92
void SharedEGLDisplay::cleanup()
93
{
94
    if (m_eglDisplay == EGL_NO_DISPLAY)
95
        return;
96
97
    eglMakeCurrent(m_eglDisplay, EGL_NO_SURFACE, EGL_NO_SURFACE, EGL_NO_CONTEXT);
98
    eglTerminate(m_eglDisplay);
99
    m_eglDisplay = EGL_NO_DISPLAY;
100
}
101
102
SharedEGLDisplay::~SharedEGLDisplay()
103
{
104
    cleanup();
105
}
106
107
EGLConfigHelper::EGLConfigHelper(NativeSharedDisplay* display)
108
    : m_pbufferFBConfig(0)
109
    , m_surfaceContextFBConfig(0)
110
{
111
    m_sharedDisplay = SharedEGLDisplay::create(display);
112
}
113
114
EGLConfigHelper::~EGLConfigHelper()
115
{
116
}
117
118
PlatformDisplay EGLConfigHelper::display()
119
{
120
    return m_sharedDisplay->sharedEGLDisplay();
121
}
122
123
EGLConfig EGLConfigHelper::pBufferContextConfig()
124
{
125
    if (!m_pbufferFBConfig) {
126
        configAttributeList[13] = EGL_PIXMAP_BIT;
127
        m_pbufferFBConfig = createConfig(configAttributeList);
128
    }
129
130
    return m_pbufferFBConfig;
131
}
132
133
EGLConfig EGLConfigHelper::surfaceContextConfig()
134
{
135
    if (!m_surfaceContextFBConfig) {
136
        configAttributeList[13] = EGL_WINDOW_BIT;
137
        m_surfaceContextFBConfig = createConfig(configAttributeList);
138
    }
139
140
    return m_surfaceContextFBConfig;
141
}
142
143
EGLint EGLConfigHelper::nativeVisualId(const EGLConfig& config)
144
{
145
    if (display() == EGL_NO_DISPLAY)
146
        return -1;
147
148
    EGLint eglValue = 0;
149
    eglGetConfigAttrib(display(), config, EGL_NATIVE_VISUAL_ID, &eglValue);
150
151
    return eglValue;
152
}
153
154
void EGLConfigHelper::reset()
155
{
156
    m_surfaceContextFBConfig = 0;
157
    m_pbufferFBConfig = 0;
158
}
159
160
EGLConfig EGLConfigHelper::createConfig(const int attributes[])
161
{
162
    if (display() == EGL_NO_DISPLAY)
163
        return 0;
164
165
    int numConfigs;
166
    EGLConfig config = 0;
167
168
    if (!eglChooseConfig(display(), attributes, &config, 1, &numConfigs))
169
        LOG_ERROR("Failed to get supported configirations.");
170
171
    if (numConfigs != 1) {
172
        LOG_ERROR("EGLChooseConfig didn't return exactly one config but (%d).", numConfigs);
173
        config = 0;
174
    }
175
176
    return config;
177
}
178
179
}
180
181
#endif
- Source/WebCore/platform/graphics/surfaces/egl/EGLConfigHelper.h -92 lines
Lines 1-92 Source/WebCore/platform/graphics/surfaces/egl/EGLConfigHelper.h_sec1
1
/*
2
 * Copyright (C) 2012 Intel Corporation. All rights reserved.
3
 *
4
 * Redistribution and use in source and binary forms, with or without
5
 * modification, are permitted provided that the following conditions
6
 * are met:
7
 * 1. Redistributions of source code must retain the above copyright
8
 *    notice, this list of conditions and the following disclaimer.
9
 * 2. Redistributions in binary form must reproduce the above copyright
10
 *    notice, this list of conditions and the following disclaimer in the
11
 *    documentation and/or other materials provided with the distribution.
12
 *
13
 * THIS SOFTWARE IS PROVIDED BY APPLE INC. AND ITS CONTRIBUTORS ``AS IS''
14
 * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
15
 * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
16
 * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE INC. OR ITS CONTRIBUTORS
17
 * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
18
 * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
19
 * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
20
 * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
21
 * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
22
 * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF
23
 * THE POSSIBILITY OF SUCH DAMAGE.
24
 */
25
26
#ifndef EGLConfigHelper_h
27
#define EGLConfigHelper_h
28
29
#if USE(EGL)
30
31
#include <opengl/GLDefs.h>
32
#include <wtf/Noncopyable.h>
33
#include <wtf/PassRefPtr.h>
34
#include <wtf/RefCounted.h>
35
#include <wtf/RefPtr.h>
36
37
namespace WebCore {
38
39
typedef Display NativeSharedDisplay;
40
41
class SharedEGLDisplay : public WTF::RefCountedBase {
42
    WTF_MAKE_NONCOPYABLE(SharedEGLDisplay);
43
44
public:
45
    static PassRefPtr<SharedEGLDisplay> create(NativeSharedDisplay* display)
46
    {
47
        if (!m_staticSharedEGLDisplay)
48
            m_staticSharedEGLDisplay = new SharedEGLDisplay(display);
49
        else
50
            m_staticSharedEGLDisplay->ref();
51
52
        return adoptRef(m_staticSharedEGLDisplay);
53
    }
54
55
    void deref();
56
    EGLDisplay sharedEGLDisplay();
57
58
protected:
59
    SharedEGLDisplay(NativeSharedDisplay*);
60
    void cleanup();
61
    virtual ~SharedEGLDisplay();
62
63
    static SharedEGLDisplay* m_staticSharedEGLDisplay;
64
    EGLDisplay m_eglDisplay;
65
};
66
67
class EGLConfigHelper {
68
    WTF_MAKE_NONCOPYABLE(EGLConfigHelper);
69
70
public:
71
    EGLConfigHelper(NativeSharedDisplay* = 0);
72
    virtual ~EGLConfigHelper();
73
    PlatformDisplay display();
74
    virtual EGLConfig pBufferContextConfig();
75
    virtual EGLConfig surfaceContextConfig();
76
    EGLint nativeVisualId(const EGLConfig&);
77
    void reset();
78
79
private:
80
    EGLConfig createConfig(const int attributes[]);
81
82
protected:
83
    EGLConfig m_pbufferFBConfig;
84
    EGLConfig m_surfaceContextFBConfig;
85
    RefPtr<SharedEGLDisplay> m_sharedDisplay;
86
};
87
88
}
89
90
#endif
91
92
#endif
- Source/WebCore/platform/graphics/surfaces/egl/EGLConfigSelector.cpp +181 lines
Line 0 Source/WebCore/platform/graphics/surfaces/egl/EGLConfigSelector.cpp_sec1
1
/*
2
 * Copyright (C) 2012 Intel Corporation. All rights reserved.
3
 *
4
 * Redistribution and use in source and binary forms, with or without
5
 * modification, are permitted provided that the following conditions
6
 * are met:
7
 * 1. Redistributions of source code must retain the above copyright
8
 *    notice, this list of conditions and the following disclaimer.
9
 * 2. Redistributions in binary form must reproduce the above copyright
10
 *    notice, this list of conditions and the following disclaimer in the
11
 *    documentation and/or other materials provided with the distribution.
12
 *
13
 * THIS SOFTWARE IS PROVIDED BY APPLE INC. AND ITS CONTRIBUTORS ``AS IS''
14
 * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
15
 * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
16
 * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE INC. OR ITS CONTRIBUTORS
17
 * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
18
 * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
19
 * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
20
 * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
21
 * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
22
 * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF
23
 * THE POSSIBILITY OF SUCH DAMAGE.
24
 */
25
26
#include "config.h"
27
#include "EGLConfigSelector.h"
28
29
#if USE(EGL)
30
31
namespace WebCore {
32
33
SharedEGLDisplay* SharedEGLDisplay::m_staticSharedEGLDisplay = 0;
34
35
static EGLint configAttributeList[] = {
36
#if USE(OPENGL_ES_2)
37
    EGL_RENDERABLE_TYPE, EGL_OPENGL_ES2_BIT,
38
#else
39
    EGL_RENDERABLE_TYPE, EGL_OPENGL_BIT,
40
#endif
41
    EGL_RED_SIZE, 8,
42
    EGL_GREEN_SIZE, 8,
43
    EGL_BLUE_SIZE, 8,
44
    EGL_STENCIL_SIZE, 8,
45
    EGL_ALPHA_SIZE, 8,
46
    EGL_SURFACE_TYPE, EGL_NONE,
47
    EGL_NONE
48
};
49
50
void SharedEGLDisplay::deref()
51
{
52
    if (derefBase()) {
53
        m_staticSharedEGLDisplay = 0;
54
        delete this;
55
    }
56
}
57
58
EGLDisplay SharedEGLDisplay::sharedEGLDisplay() const
59
{
60
    return m_eglDisplay;
61
}
62
63
SharedEGLDisplay::SharedEGLDisplay(NativeSharedDisplay* display)
64
    : m_eglDisplay(EGL_NO_DISPLAY)
65
{
66
    if (display)
67
        m_eglDisplay = eglGetDisplay(reinterpret_cast<EGLNativeDisplayType>(display));
68
    else
69
        m_eglDisplay = eglGetDisplay(EGL_DEFAULT_DISPLAY);
70
71
    if (m_eglDisplay == EGL_NO_DISPLAY) {
72
        LOG_ERROR("EGLDisplay Initialization failed.");
73
        return;
74
    }
75
76
    EGLBoolean success;
77
    success = eglInitialize(m_eglDisplay, 0, 0);
78
79
    if (success != EGL_TRUE) {
80
        LOG_ERROR("EGLInitialization failed.");
81
        m_eglDisplay = EGL_NO_DISPLAY;
82
    }
83
84
    success = eglBindAPI(eglAPIVersion);
85
86
    if (success != EGL_TRUE) {
87
        LOG_ERROR("Failed to set EGL API(%d).", eglGetError());
88
        m_eglDisplay = EGL_NO_DISPLAY;
89
    }
90
}
91
92
void SharedEGLDisplay::cleanup()
93
{
94
    if (m_eglDisplay == EGL_NO_DISPLAY)
95
        return;
96
97
    eglMakeCurrent(m_eglDisplay, EGL_NO_SURFACE, EGL_NO_SURFACE, EGL_NO_CONTEXT);
98
    eglTerminate(m_eglDisplay);
99
    m_eglDisplay = EGL_NO_DISPLAY;
100
}
101
102
SharedEGLDisplay::~SharedEGLDisplay()
103
{
104
    cleanup();
105
}
106
107
EGLConfigSelector::EGLConfigSelector(NativeSharedDisplay* display)
108
    : m_pbufferFBConfig(0)
109
    , m_surfaceContextFBConfig(0)
110
{
111
    m_sharedDisplay = SharedEGLDisplay::create(display);
112
}
113
114
EGLConfigSelector::~EGLConfigSelector()
115
{
116
}
117
118
PlatformDisplay EGLConfigSelector::display() const
119
{
120
    return m_sharedDisplay->sharedEGLDisplay();
121
}
122
123
EGLConfig EGLConfigSelector::pBufferContextConfig()
124
{
125
    if (!m_pbufferFBConfig) {
126
        configAttributeList[13] = EGL_PIXMAP_BIT;
127
        m_pbufferFBConfig = createConfig(configAttributeList);
128
    }
129
130
    return m_pbufferFBConfig;
131
}
132
133
EGLConfig EGLConfigSelector::surfaceContextConfig()
134
{
135
    if (!m_surfaceContextFBConfig) {
136
        configAttributeList[13] = EGL_WINDOW_BIT;
137
        m_surfaceContextFBConfig = createConfig(configAttributeList);
138
    }
139
140
    return m_surfaceContextFBConfig;
141
}
142
143
EGLint EGLConfigSelector::nativeVisualId(const EGLConfig& config) const
144
{
145
    if (display() == EGL_NO_DISPLAY)
146
        return -1;
147
148
    EGLint eglValue = 0;
149
    eglGetConfigAttrib(display(), config, EGL_NATIVE_VISUAL_ID, &eglValue);
150
151
    return eglValue;
152
}
153
154
void EGLConfigSelector::reset()
155
{
156
    m_surfaceContextFBConfig = 0;
157
    m_pbufferFBConfig = 0;
158
}
159
160
EGLConfig EGLConfigSelector::createConfig(const int attributes[])
161
{
162
    if (display() == EGL_NO_DISPLAY)
163
        return 0;
164
165
    int numConfigs;
166
    EGLConfig config = 0;
167
168
    if (!eglChooseConfig(display(), attributes, &config, 1, &numConfigs))
169
        LOG_ERROR("Failed to get supported configirations.");
170
171
    if (numConfigs != 1) {
172
        LOG_ERROR("EGLChooseConfig didn't return exactly one config but (%d).", numConfigs);
173
        config = 0;
174
    }
175
176
    return config;
177
}
178
179
}
180
181
#endif
- Source/WebCore/platform/graphics/surfaces/egl/EGLConfigSelector.h +92 lines
Line 0 Source/WebCore/platform/graphics/surfaces/egl/EGLConfigSelector.h_sec1
1
/*
2
 * Copyright (C) 2012 Intel Corporation. All rights reserved.
3
 *
4
 * Redistribution and use in source and binary forms, with or without
5
 * modification, are permitted provided that the following conditions
6
 * are met:
7
 * 1. Redistributions of source code must retain the above copyright
8
 *    notice, this list of conditions and the following disclaimer.
9
 * 2. Redistributions in binary form must reproduce the above copyright
10
 *    notice, this list of conditions and the following disclaimer in the
11
 *    documentation and/or other materials provided with the distribution.
12
 *
13
 * THIS SOFTWARE IS PROVIDED BY APPLE INC. AND ITS CONTRIBUTORS ``AS IS''
14
 * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
15
 * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
16
 * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE INC. OR ITS CONTRIBUTORS
17
 * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
18
 * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
19
 * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
20
 * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
21
 * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
22
 * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF
23
 * THE POSSIBILITY OF SUCH DAMAGE.
24
 */
25
26
#ifndef EGLConfigSelector_h
27
#define EGLConfigSelector_h
28
29
#if USE(EGL)
30
31
#include <opengl/GLDefs.h>
32
#include <wtf/Noncopyable.h>
33
#include <wtf/PassRefPtr.h>
34
#include <wtf/RefCounted.h>
35
#include <wtf/RefPtr.h>
36
37
namespace WebCore {
38
39
typedef Display NativeSharedDisplay;
40
41
class SharedEGLDisplay : public WTF::RefCountedBase {
42
    WTF_MAKE_NONCOPYABLE(SharedEGLDisplay);
43
44
public:
45
    static PassRefPtr<SharedEGLDisplay> create(NativeSharedDisplay* display)
46
    {
47
        if (!m_staticSharedEGLDisplay)
48
            m_staticSharedEGLDisplay = new SharedEGLDisplay(display);
49
        else
50
            m_staticSharedEGLDisplay->ref();
51
52
        return adoptRef(m_staticSharedEGLDisplay);
53
    }
54
55
    void deref();
56
    EGLDisplay sharedEGLDisplay() const;
57
58
protected:
59
    SharedEGLDisplay(NativeSharedDisplay*);
60
    void cleanup();
61
    virtual ~SharedEGLDisplay();
62
63
    static SharedEGLDisplay* m_staticSharedEGLDisplay;
64
    EGLDisplay m_eglDisplay;
65
};
66
67
class EGLConfigSelector {
68
    WTF_MAKE_NONCOPYABLE(EGLConfigSelector);
69
70
public:
71
    EGLConfigSelector(NativeSharedDisplay* = 0);
72
    virtual ~EGLConfigSelector();
73
    PlatformDisplay display() const;
74
    virtual EGLConfig pBufferContextConfig();
75
    virtual EGLConfig surfaceContextConfig();
76
    EGLint nativeVisualId(const EGLConfig&) const;
77
    void reset();
78
79
private:
80
    EGLConfig createConfig(const int attributes[]);
81
82
protected:
83
    EGLConfig m_pbufferFBConfig;
84
    EGLConfig m_surfaceContextFBConfig;
85
    RefPtr<SharedEGLDisplay> m_sharedDisplay;
86
};
87
88
}
89
90
#endif
91
92
#endif
- Source/WebCore/platform/graphics/surfaces/egl/EGLSurface.cpp -8 / +8 lines
Lines 34-56 EGLWindowTransportSurface::EGLWindowTransportSurface() Source/WebCore/platform/graphics/surfaces/egl/EGLSurface.cpp_sec1
34
    : GLPlatformSurface()
34
    : GLPlatformSurface()
35
{
35
{
36
    m_nativeResource = adoptPtr(new NativeOffScreenWindow());
36
    m_nativeResource = adoptPtr(new NativeOffScreenWindow());
37
    m_eglConfigHelper = adoptPtr(new EGLConfigHelper(m_nativeResource->nativeSharedDisplay()));
37
    m_configSelector = adoptPtr(new EGLConfigSelector(m_nativeResource->nativeSharedDisplay()));
38
    m_sharedDisplay = m_eglConfigHelper->display();
38
    m_sharedDisplay = m_configSelector->display();
39
39
40
    if (m_sharedDisplay == EGL_NO_DISPLAY) {
40
    if (m_sharedDisplay == EGL_NO_DISPLAY) {
41
        m_eglConfigHelper = nullptr;
41
        m_configSelector = nullptr;
42
        m_nativeResource = nullptr;
42
        m_nativeResource = nullptr;
43
        return;
43
        return;
44
    }
44
    }
45
45
46
    EGLConfig config = m_eglConfigHelper->surfaceContextConfig();
46
    EGLConfig config = m_configSelector->surfaceContextConfig();
47
47
48
    if (!config) {
48
    if (!config) {
49
        destroy();
49
        destroy();
50
        return;
50
        return;
51
    }
51
    }
52
52
53
    EGLint visualId = m_eglConfigHelper->nativeVisualId(config);
53
    EGLint visualId = m_configSelector->nativeVisualId(config);
54
54
55
    if (visualId == -1) {
55
    if (visualId == -1) {
56
        destroy();
56
        destroy();
Lines 69-75 EGLWindowTransportSurface::EGLWindowTransportSurface() Source/WebCore/platform/graphics/surfaces/egl/EGLSurface.cpp_sec2
69
        return;
69
        return;
70
    }
70
    }
71
71
72
    m_drawable = eglCreateWindowSurface(m_sharedDisplay, m_eglConfigHelper->surfaceContextConfig(), (EGLNativeWindowType)m_bufferHandle, 0);
72
    m_drawable = eglCreateWindowSurface(m_sharedDisplay, m_configSelector->surfaceContextConfig(), (EGLNativeWindowType)m_bufferHandle, 0);
73
73
74
    if (m_drawable == EGL_NO_SURFACE) {
74
    if (m_drawable == EGL_NO_SURFACE) {
75
        LOG_ERROR("Failed to create EGL surface(%d).", eglGetError());
75
        LOG_ERROR("Failed to create EGL surface(%d).", eglGetError());
Lines 83-89 EGLWindowTransportSurface::~EGLWindowTransportSurface() Source/WebCore/platform/graphics/surfaces/egl/EGLSurface.cpp_sec3
83
83
84
PlatformSurfaceConfig EGLWindowTransportSurface::configuration()
84
PlatformSurfaceConfig EGLWindowTransportSurface::configuration()
85
{
85
{
86
    return m_eglConfigHelper->surfaceContextConfig();
86
    return m_configSelector->surfaceContextConfig();
87
}
87
}
88
88
89
void EGLWindowTransportSurface::swapBuffers()
89
void EGLWindowTransportSurface::swapBuffers()
Lines 111-117 void EGLWindowTransportSurface::destroy() Source/WebCore/platform/graphics/surfaces/egl/EGLSurface.cpp_sec4
111
    m_nativeResource->destroyWindow(m_bufferHandle);
111
    m_nativeResource->destroyWindow(m_bufferHandle);
112
    freeEGLResources();
112
    freeEGLResources();
113
    m_nativeResource = nullptr;
113
    m_nativeResource = nullptr;
114
    m_eglConfigHelper = nullptr;
114
    m_configSelector = nullptr;
115
    m_bufferHandle = 0;
115
    m_bufferHandle = 0;
116
}
116
}
117
117
- Source/WebCore/platform/graphics/surfaces/egl/EGLSurface.h -2 / +2 lines
Lines 28-34 Source/WebCore/platform/graphics/surfaces/egl/EGLSurface.h_sec1
28
28
29
#if USE(EGL) && USE(GRAPHICS_SURFACE)
29
#if USE(EGL) && USE(GRAPHICS_SURFACE)
30
30
31
#include "EGLConfigHelper.h"
31
#include "EGLConfigSelector.h"
32
#include "GLPlatformSurface.h"
32
#include "GLPlatformSurface.h"
33
33
34
#include <glx/X11WindowResources.h>
34
#include <glx/X11WindowResources.h>
Lines 53-59 public: Source/WebCore/platform/graphics/surfaces/egl/EGLSurface.h_sec2
53
private:
53
private:
54
    void freeEGLResources();
54
    void freeEGLResources();
55
    OwnPtr<NativeOffScreenWindow> m_nativeResource;
55
    OwnPtr<NativeOffScreenWindow> m_nativeResource;
56
    OwnPtr<EGLConfigHelper> m_eglConfigHelper;
56
    OwnPtr<EGLConfigSelector> m_configSelector;
57
};
57
};
58
58
59
}
59
}

Return to Bug 105876