| Differences between
and this patch
- ChangeLog +12 lines
Lines 1-3 ChangeLog_sec1
1
2012-12-21  Kondapally Kalyan  <kalyan.kondapally@intel.com>
2
3
        [EFL][WebGL] Implement EGL support with GLX.
4
        https://bugs.webkit.org/show_bug.cgi?id=105602
5
6
        Reviewed by NOBODY (OOPS!).
7
8
        Adds support for EGL with GLX backend. EGL support can be enabled during compile time
9
        by passing -DENABLE_EGL=ON as cmake config parameter.
10
11
        * Source/cmake/OptionsEfl.cmake:
12
1
2012-12-21  Sheriff Bot  <webkit.review.bot@gmail.com>
13
2012-12-21  Sheriff Bot  <webkit.review.bot@gmail.com>
2
14
3
        Unreviewed, rolling out r138338.
15
        Unreviewed, rolling out r138338.
- Source/WebCore/ChangeLog +76 lines
Lines 1-3 Source/WebCore/ChangeLog_sec1
1
2012-12-21  Kondapally Kalyan  <kalyan.kondapally@intel.com>
2
3
        [EFL][WebGL] Implement EGL support with GLX.
4
        https://bugs.webkit.org/show_bug.cgi?id=105602
5
6
        Reviewed by NOBODY (OOPS!).
7
8
        This is in preparation for adding GLES2 support.
9
        This patch adds support for EGL with GLX backend. EGL support can be enabled during compile time
10
        by passing -DENABLE_EGL=ON as cmake config parameter. This is disabled by default.
11
12
        * PlatformEfl.cmake:
13
        * platform/graphics/opengl/GLDefs.h:
14
        (WebCore):
15
        * platform/graphics/opengl/GLPlatformContext.cpp:
16
        (WebCore):
17
        (WebCore::GLPlatformContext::createContext): Added GLX checks.
18
        (WebCore::GLPlatformContext::createOffScreenContext): Added support for creating EGLOffscreen Context.
19
        (WebCore::GLPlatformContext::createCurrentContextWrapper): Added support for creating EGLCurrentContextWrapper.
20
        * platform/graphics/opengl/GLPlatformContext.h:
21
        * platform/graphics/opengl/GLPlatformSurface.cpp:
22
        (WebCore::GLPlatformSurface::createTransportSurface): Added support for creating EGLSurface.
23
24
        * platform/graphics/surfaces/egl/EGLContext.cpp: Added.
25
        (WebCore):
26
        (WebCore::isRobustnessExtSupported):
27
        (WebCore::EGLCurrentContextWrapper::EGLCurrentContextWrapper):
28
        (WebCore::EGLCurrentContextWrapper::handle):
29
        (WebCore::EGLOffScreenContext::EGLOffScreenContext):
30
        (WebCore::EGLOffScreenContext::initialize):
31
        (WebCore::EGLOffScreenContext::~EGLOffScreenContext):
32
        (WebCore::EGLOffScreenContext::isCurrentContext):
33
        (WebCore::EGLOffScreenContext::platformMakeCurrent):
34
        (WebCore::EGLOffScreenContext::platformReleaseCurrent):
35
        (WebCore::EGLOffScreenContext::freeResources):
36
        (WebCore::EGLOffScreenContext::destroy):
37
        * platform/graphics/surfaces/egl/EGLContext.h:
38
        (WebCore):
39
        (EGLCurrentContextWrapper):
40
        (WebCore::EGLCurrentContextWrapper::~EGLCurrentContextWrapper):
41
        (EGLOffScreenContext):
42
43
        EGL implementation for Context Management.
44
45
        * platform/graphics/surfaces/egl/EGLSurface.cpp: Added.
46
        (WebCore):
47
        (WebCore::EGLWindowTransportSurface::EGLWindowTransportSurface):
48
        (WebCore::EGLWindowTransportSurface::~EGLWindowTransportSurface):
49
        (WebCore::EGLWindowTransportSurface::configuration):
50
        (WebCore::EGLWindowTransportSurface::swapBuffers):
51
        (WebCore::EGLWindowTransportSurface::destroy):
52
        (WebCore::EGLWindowTransportSurface::freeEGLResources):
53
        * platform/graphics/surfaces/egl/EGLSurface.h:
54
        (WebCore):
55
        (EGLWindowTransportSurface):
56
57
        EGL implementation for Offscreen Surface. The surface is backed by native window.
58
59
        * platform/graphics/surfaces/egl/EGLConfigHelper.cpp: Added.
60
        (WebCore):
61
        (WebCore::SharedEGLDisplay::deref):
62
        (WebCore::SharedEGLDisplay::sharedEGLDisplay):
63
        (WebCore::SharedEGLDisplay::SharedEGLDisplay):
64
        (WebCore::SharedEGLDisplay::cleanup):
65
        (WebCore::SharedEGLDisplay::~SharedEGLDisplay):
66
        (WebCore::EGLConfigHelper::EGLConfigHelper):
67
        (WebCore::EGLConfigHelper::~EGLConfigHelper):
68
        (WebCore::EGLConfigHelper::display):
69
        (WebCore::EGLConfigHelper::pBufferContextConfig):
70
        (WebCore::EGLConfigHelper::surfaceContextConfig):
71
        (WebCore::EGLConfigHelper::nativeVisualId):
72
        (WebCore::EGLConfigHelper::reset):
73
        (WebCore::EGLConfigHelper::createConfig):
74
75
        Helper class to initialize EGL resources and choose right EGL configuration.
76
1
2012-12-21  Brady Eidson  <beidson@apple.com>
77
2012-12-21  Brady Eidson  <beidson@apple.com>
2
78
3
        Update localizable strings as a followup to http://trac.webkit.org/changeset/138387
79
        Update localizable strings as a followup to http://trac.webkit.org/changeset/138387
- Source/WebCore/PlatformEfl.cmake -2 / +28 lines
Lines 265-270 if (WTF_USE_3D_GRAPHICS) Source/WebCore/PlatformEfl.cmake_sec1
265
        "${WEBCORE_DIR}/platform/graphics/surfaces/glx"
265
        "${WEBCORE_DIR}/platform/graphics/surfaces/glx"
266
        "${WEBCORE_DIR}/platform/graphics/texmap"
266
        "${WEBCORE_DIR}/platform/graphics/texmap"
267
    )
267
    )
268
269
    if (WTF_USE_EGL)
270
        list(APPEND WebCore_INCLUDE_DIRECTORIES
271
            ${EGL_INCLUDE_DIR}
272
            "${WEBCORE_DIR}/platform/graphics/surfaces/egl"
273
    )
274
    endif ()
275
268
    list(APPEND WebCore_SOURCES
276
    list(APPEND WebCore_SOURCES
269
        platform/graphics/OpenGLShims.cpp
277
        platform/graphics/OpenGLShims.cpp
270
        platform/graphics/cairo/DrawingBufferCairo.cpp
278
        platform/graphics/cairo/DrawingBufferCairo.cpp
Lines 277-294 if (WTF_USE_3D_GRAPHICS) Source/WebCore/PlatformEfl.cmake_sec2
277
        platform/graphics/opengl/GraphicsContext3DOpenGL.cpp
285
        platform/graphics/opengl/GraphicsContext3DOpenGL.cpp
278
        platform/graphics/opengl/GraphicsContext3DOpenGLCommon.cpp
286
        platform/graphics/opengl/GraphicsContext3DOpenGLCommon.cpp
279
        platform/graphics/surfaces/GraphicsSurface.cpp
287
        platform/graphics/surfaces/GraphicsSurface.cpp
280
        platform/graphics/surfaces/glx/GLXSurface.cpp
281
        platform/graphics/surfaces/glx/GLXContext.cpp
282
        platform/graphics/surfaces/glx/GraphicsSurfaceGLX.cpp
288
        platform/graphics/surfaces/glx/GraphicsSurfaceGLX.cpp
283
        platform/graphics/surfaces/glx/X11WindowResources.cpp
289
        platform/graphics/surfaces/glx/X11WindowResources.cpp
284
        platform/graphics/texmap/TextureMapperGL.cpp
290
        platform/graphics/texmap/TextureMapperGL.cpp
285
        platform/graphics/texmap/TextureMapperShaderManager.cpp
291
        platform/graphics/texmap/TextureMapperShaderManager.cpp
286
    )
292
    )
293
294
    if (WTF_USE_EGL)
295
        list(APPEND WebCore_SOURCES
296
            platform/graphics/surfaces/egl/EGLSurface.cpp
297
            platform/graphics/surfaces/egl/EGLContext.cpp
298
        )
299
    endif ()
300
301
    if (WTF_USE_GLX)
302
        list(APPEND WebCore_SOURCES
303
            platform/graphics/surfaces/glx/GLXSurface.cpp
304
            platform/graphics/surfaces/glx/GLXContext.cpp
305
        )
306
    endif ()
307
287
    list(APPEND WebCore_LIBRARIES
308
    list(APPEND WebCore_LIBRARIES
288
        ${X11_X11_LIB}
309
        ${X11_X11_LIB}
289
        ${X11_Xcomposite_LIB}
310
        ${X11_Xcomposite_LIB}
290
        ${X11_Xrender_LIB}
311
        ${X11_Xrender_LIB}
291
    )
312
    )
313
    if (WTF_USE_EGL)
314
        list(APPEND WebCore_LIBRARIES
315
            ${EGL_LIBRARY}
316
        )
317
    endif ()
292
endif ()
318
endif ()
293
319
294
add_definitions(-DDATA_DIR="${CMAKE_INSTALL_PREFIX}/${DATA_INSTALL_DIR}")
320
add_definitions(-DDATA_DIR="${CMAKE_INSTALL_PREFIX}/${DATA_INSTALL_DIR}")
- Source/WebCore/platform/graphics/opengl/GLDefs.h -2 / +18 lines
Lines 28-39 Source/WebCore/platform/graphics/opengl/GLDefs.h_sec1
28
28
29
#if USE(ACCELERATED_COMPOSITING)
29
#if USE(ACCELERATED_COMPOSITING)
30
30
31
#include "OpenGLShims.h"
32
33
#if USE(OPENGL_ES_2)
31
#if USE(OPENGL_ES_2)
32
#include "OpenGLESShims.h"
34
#include <GLES2/gl2.h>
33
#include <GLES2/gl2.h>
35
#include <GLES2/gl2ext.h>
34
#include <GLES2/gl2ext.h>
36
#else
35
#else
36
#include "OpenGLShims.h"
37
#include <GL/gl.h>
37
#include <GL/gl.h>
38
#include <GL/glext.h>
38
#include <GL/glext.h>
39
#endif
39
#endif
Lines 42-47 Source/WebCore/platform/graphics/opengl/GLDefs.h_sec2
42
#include <GL/glx.h>
42
#include <GL/glx.h>
43
#endif
43
#endif
44
44
45
#if USE(EGL)
46
#define EGL_EGLEXT_PROTOTYPES 1
47
#include <EGL/egl.h>
48
#include <EGL/eglext.h>
49
#endif
50
45
namespace WebCore {
51
namespace WebCore {
46
52
47
typedef uint32_t PlatformBufferHandle;
53
typedef uint32_t PlatformBufferHandle;
Lines 51-56 typedef GLXContext PlatformContext; Source/WebCore/platform/graphics/opengl/GLDefs.h_sec3
51
typedef Display* PlatformDisplay;
57
typedef Display* PlatformDisplay;
52
typedef GLXFBConfig PlatformSurfaceConfig;
58
typedef GLXFBConfig PlatformSurfaceConfig;
53
typedef GLXDrawable PlatformDrawable;
59
typedef GLXDrawable PlatformDrawable;
60
#elif USE(EGL)
61
#if USE(OPENGL_ES_2)
62
static const EGLenum eglAPIVersion = EGL_OPENGL_ES_API;
63
#else
64
static const EGLenum eglAPIVersion = EGL_OPENGL_API;
65
#endif
66
typedef EGLContext PlatformContext;
67
typedef EGLDisplay PlatformDisplay;
68
typedef EGLConfig PlatformSurfaceConfig;
69
typedef EGLSurface PlatformDrawable;
54
#else
70
#else
55
typedef void* PlatformContext;
71
typedef void* PlatformContext;
56
typedef void* PlatformDisplay;
72
typedef void* PlatformDisplay;
- Source/WebCore/platform/graphics/opengl/GLPlatformContext.cpp -6 / +10 lines
Lines 30-35 Source/WebCore/platform/graphics/opengl/GLPlatformContext.cpp_sec1
30
30
31
#if USE(GLX)
31
#if USE(GLX)
32
#include "GLXContext.h"
32
#include "GLXContext.h"
33
#elif USE(EGL)
34
#include "EGLContext.h"
33
#endif
35
#endif
34
36
35
#include "NotImplemented.h"
37
#include "NotImplemented.h"
Lines 44-54 PassOwnPtr<GLPlatformContext> GLPlatformContext::createContext(GraphicsContext3D Source/WebCore/platform/graphics/opengl/GLPlatformContext.cpp_sec2
44
    if (!initializeOpenGLShims())
46
    if (!initializeOpenGLShims())
45
        return nullptr;
47
        return nullptr;
46
48
47
    if (!glGetGraphicsResetStatusARB) {
48
#if USE(GLX)
49
#if USE(GLX)
50
    if (!glGetGraphicsResetStatusARB) {
49
        glGetGraphicsResetStatusARB = reinterpret_cast<PFNGLGETGRAPHICSRESETSTATUSARBPROC>(glXGetProcAddressARB(reinterpret_cast<const GLubyte*>("glGetGraphicsResetStatusARB")));
51
        glGetGraphicsResetStatusARB = reinterpret_cast<PFNGLGETGRAPHICSRESETSTATUSARBPROC>(glXGetProcAddressARB(reinterpret_cast<const GLubyte*>("glGetGraphicsResetStatusARB")));
50
#endif
51
    }
52
    }
53
#endif
52
54
53
    switch (renderStyle) {
55
    switch (renderStyle) {
54
    case GraphicsContext3D::RenderOffscreen:
56
    case GraphicsContext3D::RenderOffscreen:
Lines 70-77 PassOwnPtr<GLPlatformContext> GLPlatformContext::createContext(GraphicsContext3D Source/WebCore/platform/graphics/opengl/GLPlatformContext.cpp_sec3
70
PassOwnPtr<GLPlatformContext> GLPlatformContext::createOffScreenContext()
72
PassOwnPtr<GLPlatformContext> GLPlatformContext::createOffScreenContext()
71
{
73
{
72
#if USE(GLX)
74
#if USE(GLX)
73
    OwnPtr<GLPlatformContext> glxContext = adoptPtr(new GLXOffScreenContext());
75
    return adoptPtr(new GLXOffScreenContext());
74
    return glxContext.release();
76
#elif USE(EGL)
77
    return adoptPtr(new EGLOffScreenContext());
75
#endif
78
#endif
76
79
77
    return nullptr;
80
    return nullptr;
Lines 80-87 PassOwnPtr<GLPlatformContext> GLPlatformContext::createOffScreenContext() Source/WebCore/platform/graphics/opengl/GLPlatformContext.cpp_sec4
80
PassOwnPtr<GLPlatformContext> GLPlatformContext::createCurrentContextWrapper()
83
PassOwnPtr<GLPlatformContext> GLPlatformContext::createCurrentContextWrapper()
81
{
84
{
82
#if USE(GLX)
85
#if USE(GLX)
83
    OwnPtr<GLPlatformContext> glxContext = adoptPtr(new GLXCurrentContextWrapper());
86
    return adoptPtr(new GLXCurrentContextWrapper());
84
    return glxContext.release();
87
#elif USE(EGL)
88
    return adoptPtr(new EGLCurrentContextWrapper());
85
#endif
89
#endif
86
90
87
    return nullptr;
91
    return nullptr;
- Source/WebCore/platform/graphics/opengl/GLPlatformContext.h -1 / +1 lines
Lines 64-70 public: Source/WebCore/platform/graphics/opengl/GLPlatformContext.h_sec1
64
    // Doesn't have any effect if this is not the current Context.
64
    // Doesn't have any effect if this is not the current Context.
65
    void releaseCurrent();
65
    void releaseCurrent();
66
66
67
    PlatformContext handle() const;
67
    virtual PlatformContext handle() const;
68
68
69
    virtual bool isCurrentContext() const;
69
    virtual bool isCurrentContext() const;
70
70
- Source/WebCore/platform/graphics/opengl/GLPlatformSurface.cpp -2 / +10 lines
Lines 32-37 Source/WebCore/platform/graphics/opengl/GLPlatformSurface.cpp_sec1
32
#include "GLXSurface.h"
32
#include "GLXSurface.h"
33
#endif
33
#endif
34
34
35
#if USE(EGL)
36
#include "EGLSurface.h"
37
#endif
38
35
#include "NotImplemented.h"
39
#include "NotImplemented.h"
36
40
37
namespace WebCore {
41
namespace WebCore {
Lines 50-59 PassOwnPtr<GLPlatformSurface> GLPlatformSurface::createOffscreenSurface() Source/WebCore/platform/graphics/opengl/GLPlatformSurface.cpp_sec2
50
54
51
PassOwnPtr<GLPlatformSurface> GLPlatformSurface::createTransportSurface()
55
PassOwnPtr<GLPlatformSurface> GLPlatformSurface::createTransportSurface()
52
{
56
{
53
#if USE(GLX) && USE(GRAPHICS_SURFACE)
57
#if USE(GRAPHICS_SURFACE)
58
#if USE(GLX)
54
    OwnPtr<GLPlatformSurface> surface = adoptPtr(new GLXTransportSurface());
59
    OwnPtr<GLPlatformSurface> surface = adoptPtr(new GLXTransportSurface());
60
#elif USE(EGL)
61
    OwnPtr<GLPlatformSurface> surface = adoptPtr(new EGLWindowTransportSurface());
62
#endif
55
63
56
    if (surface->handle())
64
    if (surface && surface->handle() && surface->drawable())
57
        return surface.release();
65
        return surface.release();
58
#endif
66
#endif
59
67
- Source/WebCore/platform/graphics/surfaces/egl/EGLConfigHelper.cpp +181 lines
Line 0 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.\n");
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.\n");
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).\n", 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 rightConfig = 0;
167
168
    if (!eglChooseConfig(display(), attributes, &rightConfig, 1, &numConfigs))
169
        LOG_ERROR("Failed to get supported configirations.\n");
170
171
    if (numConfigs != 1) {
172
        LOG_ERROR("EGLChooseConfig didn't return exactly one config but (%d).\n", numConfigs);
173
        rightConfig = 0;
174
    }
175
176
    return rightConfig;
177
}
178
179
}
180
181
#endif
- Source/WebCore/platform/graphics/surfaces/egl/EGLConfigHelper.h +92 lines
Line 0 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/EGLContext.cpp +172 lines
Line 0 Source/WebCore/platform/graphics/surfaces/egl/EGLContext.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 "EGLContext.h"
28
29
#if USE(EGL)
30
31
#include <wtf/text/WTFString.h>
32
33
#if HAVE(GLX)
34
#include <GL/glx.h>
35
#endif
36
37
namespace WebCore {
38
39
static const EGLint contextAttributes[] = {
40
#if USE(OPENGL_ES_2)
41
    EGL_CONTEXT_CLIENT_VERSION, 2,
42
#endif
43
    EGL_NONE
44
};
45
46
static const EGLint contextRobustnessAttributes[] = {
47
#if USE(OPENGL_ES_2)
48
    EGL_CONTEXT_CLIENT_VERSION, 2,
49
#endif
50
    EGL_CONTEXT_OPENGL_RESET_NOTIFICATION_STRATEGY_EXT,
51
    EGL_LOSE_CONTEXT_ON_RESET_EXT,
52
    EGL_NONE
53
};
54
55
static bool isRobustnessExtSupported(EGLDisplay display)
56
{
57
    static bool didQueryForRobustnessExtension = false;
58
    static bool isRobustnessExtensionSupported = false;
59
60
    if (!didQueryForRobustnessExtension) {
61
        didQueryForRobustnessExtension = true;
62
        String supportedExtensions = reinterpret_cast<const char*>(eglQueryString(display, EGL_EXTENSIONS));
63
64
        if (!supportedExtensions.isEmpty()) {
65
            supportedExtensions.append(" ");
66
            isRobustnessExtensionSupported = supportedExtensions.contains("EGL_EXT_create_context_robustness");
67
        }
68
    }
69
70
    return isRobustnessExtensionSupported;
71
}
72
73
EGLCurrentContextWrapper::EGLCurrentContextWrapper()
74
    : GLPlatformContext()
75
{
76
}
77
78
// FIXME: This is a temporary workaround until we are able to build evas with EGL support.
79
PlatformContext EGLCurrentContextWrapper::handle() const
80
{
81
    return glXGetCurrentContext();
82
}
83
84
EGLOffScreenContext::EGLOffScreenContext()
85
    : GLPlatformContext()
86
    , m_display(0)
87
{
88
}
89
90
bool EGLOffScreenContext::initialize(GLPlatformSurface* surface)
91
{
92
    if (!surface)
93
        return false;
94
95
    if (!eglBindAPI(eglAPIVersion)) {
96
        LOG_ERROR("Failed to set EGL API(%d).\n", eglGetError());
97
        return false;
98
    }
99
100
    m_display = surface->sharedDisplay();
101
    if (!m_display)
102
        return false;
103
104
    EGLConfig config = surface->configuration();
105
    if (!config)
106
        return false;
107
108
    if (config) {
109
        if (isRobustnessExtSupported(m_display))
110
            m_contextHandle = eglCreateContext(m_display, config, EGL_NO_CONTEXT, contextRobustnessAttributes);
111
112
        if (m_contextHandle != EGL_NO_CONTEXT)
113
            m_resetLostContext = true;
114
        else
115
            m_contextHandle = eglCreateContext(m_display, config, EGL_NO_CONTEXT, contextAttributes);
116
117
        if (m_contextHandle != EGL_NO_CONTEXT)
118
            return true;
119
    }
120
121
    return false;
122
}
123
124
EGLOffScreenContext::~EGLOffScreenContext()
125
{
126
}
127
128
bool EGLOffScreenContext::isCurrentContext() const
129
{
130
    return m_contextHandle == eglGetCurrentContext();
131
}
132
133
bool EGLOffScreenContext::platformMakeCurrent(GLPlatformSurface* surface)
134
{
135
    if (!eglMakeCurrent(m_display, surface->drawable(), surface->drawable(), m_contextHandle)) {
136
        LOG_ERROR("Failed to make context current.(%d).\n", eglGetError());
137
138
        if (m_resetLostContext && eglGetError() == EGL_CONTEXT_LOST) {
139
            LOG_ERROR("Lost current context.\n");
140
            m_contextLost = true;
141
        }
142
143
        return false;
144
    }
145
146
    return true;
147
}
148
149
void EGLOffScreenContext::platformReleaseCurrent()
150
{
151
    eglMakeCurrent(m_display, EGL_NO_SURFACE, EGL_NO_SURFACE, EGL_NO_CONTEXT);
152
}
153
154
void EGLOffScreenContext::freeResources()
155
{
156
    if (m_contextHandle == EGL_NO_CONTEXT)
157
        return;
158
159
    eglDestroyContext(m_display, m_contextHandle);
160
    m_contextHandle = EGL_NO_CONTEXT;
161
    m_display = 0;
162
}
163
164
void EGLOffScreenContext::destroy()
165
{
166
    GLPlatformContext::destroy();
167
    freeResources();
168
}
169
170
}
171
172
#endif
- Source/WebCore/platform/graphics/surfaces/egl/EGLContext.h +63 lines
Line 0 Source/WebCore/platform/graphics/surfaces/egl/EGLContext.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 EGLContext_h
27
#define EGLContext_h
28
29
#if USE(EGL)
30
31
#include "GLPlatformContext.h"
32
33
namespace WebCore {
34
35
class EGLCurrentContextWrapper : public GLPlatformContext {
36
37
public:
38
    EGLCurrentContextWrapper();
39
    virtual PlatformContext handle() const OVERRIDE;
40
    virtual ~EGLCurrentContextWrapper() { }
41
};
42
43
class EGLOffScreenContext : public GLPlatformContext {
44
45
public:
46
    EGLOffScreenContext();
47
    virtual ~EGLOffScreenContext();
48
    virtual bool initialize(GLPlatformSurface*) OVERRIDE;
49
    virtual bool platformMakeCurrent(GLPlatformSurface*) OVERRIDE;
50
    virtual void platformReleaseCurrent() OVERRIDE;
51
    virtual void destroy() OVERRIDE;
52
    virtual bool isCurrentContext() const OVERRIDE;
53
54
private:
55
    void freeResources();
56
    EGLDisplay m_display;
57
};
58
59
}
60
61
#endif
62
63
#endif
- Source/WebCore/platform/graphics/surfaces/egl/EGLSurface.cpp +142 lines
Line 0 Source/WebCore/platform/graphics/surfaces/egl/EGLSurface.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 "EGLSurface.h"
28
29
#if USE(EGL) && USE(GRAPHICS_SURFACE)
30
31
namespace WebCore {
32
33
EGLWindowTransportSurface::EGLWindowTransportSurface()
34
    : GLPlatformSurface()
35
{
36
    m_nativeResource = adoptPtr(new NativeOffScreenWindow());
37
    m_eglConfigHelper = adoptPtr(new EGLConfigHelper(m_nativeResource->nativeSharedDisplay()));
38
    m_sharedDisplay = m_eglConfigHelper->display();
39
40
    if (m_sharedDisplay == EGL_NO_DISPLAY) {
41
        m_eglConfigHelper = nullptr;
42
        m_nativeResource = nullptr;
43
        return;
44
    }
45
46
    EGLConfig config = m_eglConfigHelper->surfaceContextConfig();
47
48
    if (!config) {
49
        destroy();
50
        return;
51
    }
52
53
    EGLint visualId = m_eglConfigHelper->nativeVisualId(config);
54
55
    if (visualId == -1) {
56
        destroy();
57
        return;
58
    }
59
60
    if (!m_nativeResource->setVisualId(visualId)) {
61
        destroy();
62
        return;
63
    }
64
65
    m_nativeResource->createOffscreenWindow(&m_bufferHandle);
66
67
    if (!m_bufferHandle) {
68
        destroy();
69
        return;
70
    }
71
72
    m_drawable = eglCreateWindowSurface(m_sharedDisplay, m_eglConfigHelper->surfaceContextConfig(), (EGLNativeWindowType)m_bufferHandle, 0);
73
74
    if (m_drawable == EGL_NO_SURFACE) {
75
        LOG_ERROR("Failed to create EGL surface(%d).\n", eglGetError());
76
        destroy();
77
    }
78
}
79
80
EGLWindowTransportSurface::~EGLWindowTransportSurface()
81
{
82
}
83
84
PlatformSurfaceConfig EGLWindowTransportSurface::configuration()
85
{
86
    return m_eglConfigHelper->surfaceContextConfig();
87
}
88
89
void EGLWindowTransportSurface::swapBuffers()
90
{
91
    if (!m_drawable)
92
        return;
93
94
    EGLBoolean success = eglBindAPI(eglAPIVersion);
95
96
    if (success != EGL_TRUE) {
97
        LOG_ERROR("Failed to set EGL API(%d).\n", eglGetError());
98
        destroy();
99
    }
100
101
    success = eglSwapBuffers(m_sharedDisplay, m_drawable);
102
103
    if (success != EGL_TRUE) {
104
        LOG_ERROR("Failed to SwapBuffers(%d).\n", eglGetError());
105
        destroy();
106
    }
107
}
108
109
void EGLWindowTransportSurface::destroy()
110
{
111
    m_nativeResource->destroyWindow(m_bufferHandle);
112
    freeEGLResources();
113
    m_nativeResource = nullptr;
114
    m_eglConfigHelper = nullptr;
115
    m_bufferHandle = 0;
116
}
117
118
void EGLWindowTransportSurface::freeEGLResources()
119
{
120
    if (m_drawable == EGL_NO_SURFACE || m_sharedDisplay == EGL_NO_DISPLAY)
121
        return;
122
123
    EGLBoolean eglResult = eglBindAPI(eglAPIVersion);
124
125
    if (eglResult != EGL_TRUE) {
126
        LOG_ERROR("Failed to set EGL API(%d).\n", eglGetError());
127
        return;
128
    }
129
130
    eglDestroySurface(m_sharedDisplay, m_drawable);
131
    m_drawable = EGL_NO_SURFACE;
132
}
133
134
void EGLWindowTransportSurface::setGeometry(const IntRect& newRect)
135
{
136
    GLPlatformSurface::setGeometry(newRect);
137
    m_nativeResource->reSizeWindow(newRect, m_bufferHandle);
138
}
139
140
}
141
142
#endif
- Source/WebCore/platform/graphics/surfaces/egl/EGLSurface.h +63 lines
Line 0 Source/WebCore/platform/graphics/surfaces/egl/EGLSurface.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 EGLSurface_h
27
#define EGLSurface_h
28
29
#if USE(EGL) && USE(GRAPHICS_SURFACE)
30
31
#include "EGLConfigHelper.h"
32
#include "GLPlatformSurface.h"
33
34
#include <glx/X11WindowResources.h>
35
#include <wtf/Noncopyable.h>
36
#include <wtf/PassOwnPtr.h>
37
38
namespace WebCore {
39
40
typedef X11OffScreenWindow NativeOffScreenWindow;
41
42
// Contents of the surface are backed by native window.
43
class EGLWindowTransportSurface : public GLPlatformSurface {
44
45
public:
46
    EGLWindowTransportSurface();
47
    virtual ~EGLWindowTransportSurface();
48
    virtual PlatformSurfaceConfig configuration() OVERRIDE;
49
    virtual void setGeometry(const IntRect& newRect) OVERRIDE;
50
    virtual void swapBuffers() OVERRIDE;
51
    virtual void destroy() OVERRIDE;
52
53
private:
54
    void freeEGLResources();
55
    OwnPtr<NativeOffScreenWindow> m_nativeResource;
56
    OwnPtr<EGLConfigHelper> m_eglConfigHelper;
57
};
58
59
}
60
61
#endif
62
63
#endif
- Source/WebCore/platform/graphics/surfaces/glx/GLXSurface.cpp -2 / +8 lines
Lines 36-42 static const int pbufferAttributes[] = { GLX_PBUFFER_WIDTH, 1, GLX_PBUFFER_HEIGH Source/WebCore/platform/graphics/surfaces/glx/GLXSurface.cpp_sec1
36
GLXTransportSurface::GLXTransportSurface()
36
GLXTransportSurface::GLXTransportSurface()
37
    : X11OffScreenWindow()
37
    : X11OffScreenWindow()
38
{
38
{
39
    createOffscreenWindow();
39
    createOffscreenWindow(&m_bufferHandle);
40
    m_drawable = m_bufferHandle;
40
    m_drawable = m_bufferHandle;
41
}
41
}
42
42
Lines 49-54 PlatformSurfaceConfig GLXTransportSurface::configuration() Source/WebCore/platform/graphics/surfaces/glx/GLXSurface.cpp_sec2
49
    return m_sharedResources->surfaceContextConfig();
49
    return m_sharedResources->surfaceContextConfig();
50
}
50
}
51
51
52
void GLXTransportSurface::setGeometry(const IntRect& newRect)
53
{
54
    GLPlatformSurface::setGeometry(newRect);
55
    reSizeWindow(newRect, m_drawable);
56
}
57
52
void GLXTransportSurface::swapBuffers()
58
void GLXTransportSurface::swapBuffers()
53
{
59
{
54
    if (!m_drawable)
60
    if (!m_drawable)
Lines 66-72 void GLXTransportSurface::swapBuffers() Source/WebCore/platform/graphics/surfaces/glx/GLXSurface.cpp_sec3
66
72
67
void GLXTransportSurface::destroy()
73
void GLXTransportSurface::destroy()
68
{
74
{
69
    destroyWindow();
75
    destroyWindow(m_bufferHandle);
70
    m_bufferHandle = 0;
76
    m_bufferHandle = 0;
71
}
77
}
72
78
- Source/WebCore/platform/graphics/surfaces/glx/GLXSurface.h +1 lines
Lines 43-48 public: Source/WebCore/platform/graphics/surfaces/glx/GLXSurface.h_sec1
43
    virtual ~GLXTransportSurface();
43
    virtual ~GLXTransportSurface();
44
    PlatformSurfaceConfig configuration();
44
    PlatformSurfaceConfig configuration();
45
    void swapBuffers();
45
    void swapBuffers();
46
    void setGeometry(const IntRect&);
46
    void destroy();
47
    void destroy();
47
48
48
private:
49
private:
- Source/WebCore/platform/graphics/surfaces/glx/GLXWindowResources.h -1 / +16 lines
Lines 51-56 public: Source/WebCore/platform/graphics/surfaces/glx/GLXWindowResources.h_sec1
51
        return SharedX11Resources::x11Display();
51
        return SharedX11Resources::x11Display();
52
    }
52
    }
53
53
54
    XVisualInfo* visualInfo()
55
    {
56
        if (!m_VisualInfo)
57
            surfaceContextConfig();
58
59
        return m_VisualInfo;
60
    }
61
54
    virtual GLXFBConfig pBufferContextConfig()
62
    virtual GLXFBConfig pBufferContextConfig()
55
    {
63
    {
56
        if (!m_pbufferfbConfig) {
64
        if (!m_pbufferfbConfig) {
Lines 98-108 public: Source/WebCore/platform/graphics/surfaces/glx/GLXWindowResources.h_sec2
98
        return m_surfaceContextfbConfig;
106
        return m_surfaceContextfbConfig;
99
    }
107
    }
100
108
101
private:
109
protected:
102
    SharedGLXResources()
110
    SharedGLXResources()
103
        : SharedX11Resources()
111
        : SharedX11Resources()
104
        , m_pbufferfbConfig(0)
112
        , m_pbufferfbConfig(0)
105
        , m_surfaceContextfbConfig(0)
113
        , m_surfaceContextfbConfig(0)
114
        , m_VisualInfo(0)
106
    {
115
    {
107
    }
116
    }
108
117
Lines 160-169 private: Source/WebCore/platform/graphics/surfaces/glx/GLXWindowResources.h_sec3
160
169
161
        if (m_surfaceContextfbConfig)
170
        if (m_surfaceContextfbConfig)
162
            m_surfaceContextfbConfig = 0;
171
            m_surfaceContextfbConfig = 0;
172
173
        if (m_VisualInfo) {
174
            XFree(m_VisualInfo);
175
            m_VisualInfo = 0;
176
        }
163
    }
177
    }
164
178
165
    GLXFBConfig m_pbufferfbConfig;
179
    GLXFBConfig m_pbufferfbConfig;
166
    GLXFBConfig m_surfaceContextfbConfig;
180
    GLXFBConfig m_surfaceContextfbConfig;
181
    XVisualInfo* m_VisualInfo;
167
};
182
};
168
183
169
}
184
}
- Source/WebCore/platform/graphics/surfaces/glx/X11WindowResources.cpp -21 / +85 lines
Lines 28-34 Source/WebCore/platform/graphics/surfaces/glx/X11WindowResources.cpp_sec1
28
28
29
#if USE(ACCELERATED_COMPOSITING)
29
#if USE(ACCELERATED_COMPOSITING)
30
30
31
#if USE(GLX)
31
#include "GLXWindowResources.h"
32
#include "GLXWindowResources.h"
33
#endif
32
34
33
namespace WebCore {
35
namespace WebCore {
34
36
Lines 37-62 PlatformSharedResources* SharedX11Resources::m_staticSharedResource = 0; Source/WebCore/platform/graphics/surfaces/glx/X11WindowResources.cpp_sec2
37
X11OffScreenWindow::X11OffScreenWindow()
39
X11OffScreenWindow::X11OffScreenWindow()
38
    : GLPlatformSurface()
40
    : GLPlatformSurface()
39
    , m_sharedResources(0)
41
    , m_sharedResources(0)
42
    , m_configVisualInfo(0)
40
{
43
{
41
    m_sharedResources = PlatformSharedResources::create();
44
    m_sharedResources = PlatformSharedResources::create();
42
45
43
    if (!m_sharedResources)
46
    if (!m_sharedResources)
44
        return;
47
        return;
45
48
46
    m_sharedDisplay = m_sharedResources->nativeDisplay();
49
    m_sharedDisplay = m_sharedResources->x11Display();
47
}
50
}
48
51
49
X11OffScreenWindow::~X11OffScreenWindow()
52
X11OffScreenWindow::~X11OffScreenWindow()
50
{
53
{
54
    if (m_configVisualInfo) {
55
        XFree(m_configVisualInfo);
56
        m_configVisualInfo = 0;
57
    }
51
}
58
}
52
59
53
void X11OffScreenWindow::setGeometry(const IntRect& newRect)
60
void X11OffScreenWindow::reSizeWindow(const IntRect& newRect, PlatformBufferHandle windowId)
54
{
61
{
55
    GLPlatformSurface::setGeometry(newRect);
62
    XResizeWindow(m_sharedResources->x11Display(), windowId, newRect.width(), newRect.height());
56
    XResizeWindow(m_sharedResources->x11Display(), m_bufferHandle, newRect.width(), newRect.height());
57
}
63
}
58
64
59
void X11OffScreenWindow::createOffscreenWindow()
65
void X11OffScreenWindow::createOffscreenWindow(PlatformBufferHandle* handleId)
60
{
66
{
61
    if (!m_sharedResources)
67
    if (!m_sharedResources)
62
        return;
68
        return;
Lines 65-78 void X11OffScreenWindow::createOffscreenWindow() Source/WebCore/platform/graphics/surfaces/glx/X11WindowResources.cpp_sec3
65
    if (!display)
71
    if (!display)
66
        return;
72
        return;
67
73
68
    PlatformSurfaceConfig config = m_sharedResources->surfaceContextConfig();
74
#if USE(GLX)
69
70
    if (!config) {
71
        LOG_ERROR("Failed to retrieve a valid configiration.");
72
        return;
73
    }
74
75
    XVisualInfo* visInfo = m_sharedResources->visualInfo();
75
    XVisualInfo* visInfo = m_sharedResources->visualInfo();
76
#else
77
    XVisualInfo* visInfo = m_configVisualInfo;
78
#endif
76
79
77
    if (!visInfo) {
80
    if (!visInfo) {
78
        LOG_ERROR("Failed to find valid XVisual");
81
        LOG_ERROR("Failed to find valid XVisual");
Lines 88-111 void X11OffScreenWindow::createOffscreenWindow() Source/WebCore/platform/graphics/surfaces/glx/X11WindowResources.cpp_sec4
88
    attribute.background_pixel = WhitePixel(display, 0);
91
    attribute.background_pixel = WhitePixel(display, 0);
89
    attribute.border_pixel = BlackPixel(display, 0);
92
    attribute.border_pixel = BlackPixel(display, 0);
90
    attribute.colormap = cmap;
93
    attribute.colormap = cmap;
91
    m_bufferHandle = XCreateWindow(display, xWindow, 0, 0, 1, 1, 0, visInfo->depth, InputOutput, visInfo->visual, CWBackPixel | CWBorderPixel | CWColormap, &attribute);
94
    PlatformBufferHandle tempHandleId;
95
    tempHandleId = XCreateWindow(display, xWindow, 0, 0, 1, 1, 0, visInfo->depth, InputOutput, visInfo->visual, CWBackPixel | CWBorderPixel | CWColormap, &attribute);
92
96
93
    if (!m_bufferHandle) {
97
    if (!tempHandleId) {
94
        LOG_ERROR("Failed to create offscreen window");
98
        LOG_ERROR("Failed to create offscreen window");
95
        return;
99
        return;
96
    }
100
    }
97
101
98
    XSetWindowBackgroundPixmap(display, m_bufferHandle, 0);
102
    XSetWindowBackgroundPixmap(display, tempHandleId, 0);
99
    XCompositeRedirectWindow(display, m_bufferHandle, CompositeRedirectManual);
103
    XCompositeRedirectWindow(display, tempHandleId, CompositeRedirectManual);
104
    *handleId = tempHandleId;
105
    m_bufferHandle = tempHandleId;
100
106
101
    if (m_sharedResources->isXRenderExtensionSupported())
107
    if (m_sharedResources->isXRenderExtensionSupported())
102
        XMapWindow(display, m_bufferHandle);
108
        XMapWindow(display, tempHandleId);
103
109
104
}
110
}
105
111
106
void X11OffScreenWindow::destroyWindow()
112
void X11OffScreenWindow::destroyWindow(PlatformBufferHandle windowId)
107
{
113
{
108
    if (!m_bufferHandle)
114
    if (!windowId)
109
        return;
115
        return;
110
116
111
    GLPlatformSurface::destroy();
117
    GLPlatformSurface::destroy();
Lines 113-121 void X11OffScreenWindow::destroyWindow() Source/WebCore/platform/graphics/surfaces/glx/X11WindowResources.cpp_sec5
113
    if (!display)
119
    if (!display)
114
        return;
120
        return;
115
121
116
    XDestroyWindow(display, m_bufferHandle);
122
    XDestroyWindow(display, windowId);
117
    m_bufferHandle = 0;
123
}
124
125
Display* X11OffScreenWindow::nativeSharedDisplay()
126
{
127
    return m_sharedResources->x11Display();
128
}
129
130
#if USE(EGL)
131
bool X11OffScreenWindow::setVisualId(const EGLint id)
132
{
133
    VisualID visualId = static_cast<VisualID>(id);
134
135
    if (!visualId)
136
        return false;
137
138
    // EGL has suggested a visual id, so get the rest of the visual info for that id.
139
    XVisualInfo visualInfoTemplate;
140
    memset(&visualInfoTemplate, 0, sizeof(XVisualInfo));
141
    visualInfoTemplate.visualid = visualId;
142
143
    XVisualInfo* chosenVisualInfo;
144
    int matchingCount = 0;
145
    chosenVisualInfo = XGetVisualInfo(m_sharedResources->x11Display(), VisualIDMask, &visualInfoTemplate, &matchingCount);
146
    if (chosenVisualInfo) {
147
#if USE(GRAPHICS_SURFACE)
148
        if (m_sharedResources->isXRenderExtensionSupported()) {
149
            XRenderPictFormat* format = XRenderFindVisualFormat(m_sharedResources->x11Display(), chosenVisualInfo->visual);
150
            if (format && format->direct.alphaMask > 0) {
151
                m_configVisualInfo = chosenVisualInfo;
152
                return true;
153
            }
154
        }
155
#endif
156
        if (chosenVisualInfo->depth == 32) {
157
            m_configVisualInfo = chosenVisualInfo;
158
            return true;
159
        }
160
    }
161
162
    if (!m_configVisualInfo) {
163
        memset(&visualInfoTemplate, 0, sizeof(XVisualInfo));
164
        XVisualInfo* matchingVisuals;
165
        int matchingCount = 0;
166
167
        visualInfoTemplate.depth = chosenVisualInfo->depth;
168
        matchingVisuals = XGetVisualInfo(m_sharedResources->x11Display(), VisualDepthMask, &visualInfoTemplate, &matchingCount);
169
170
        if (matchingVisuals) {
171
            m_configVisualInfo = &matchingVisuals[0];
172
            XFree(matchingVisuals);
173
            return true;
174
        }
175
    }
176
177
    if (!m_configVisualInfo)
178
        LOG_ERROR("Failed to retrieve XVisual Info.\n");
179
180
    return false;
118
}
181
}
182
#endif
119
183
120
}
184
}
121
185
- Source/WebCore/platform/graphics/surfaces/glx/X11WindowResources.h -22 / +25 lines
Lines 40-52 Source/WebCore/platform/graphics/surfaces/glx/X11WindowResources.h_sec1
40
40
41
namespace WebCore {
41
namespace WebCore {
42
42
43
#if USE(GLX)
43
class SharedGLXResources;
44
class SharedGLXResources;
44
typedef SharedGLXResources PlatformSharedResources;
45
typedef SharedGLXResources PlatformSharedResources;
46
#elif USE(EGL)
47
class SharedX11Resources;
48
typedef SharedX11Resources PlatformSharedResources;
49
#endif
45
50
46
class SharedX11Resources : public WTF::RefCountedBase {
51
class SharedX11Resources : public WTF::RefCountedBase {
47
    WTF_MAKE_NONCOPYABLE(SharedX11Resources);
52
    WTF_MAKE_NONCOPYABLE(SharedX11Resources);
48
53
49
public:
54
public:
55
#if USE(EGL)
56
    static PassRefPtr<PlatformSharedResources> create()
57
    {
58
        if (!m_staticSharedResource)
59
            m_staticSharedResource = new PlatformSharedResources();
60
        else
61
            m_staticSharedResource->ref();
62
63
        return adoptRef(m_staticSharedResource);
64
    }
65
#endif
66
50
    void deref()
67
    void deref()
51
    {
68
    {
52
        if (derefBase()) {
69
        if (derefBase()) {
Lines 94-122 public: Source/WebCore/platform/graphics/surfaces/glx/X11WindowResources.h_sec2
94
        return m_window;
111
        return m_window;
95
    }
112
    }
96
113
97
    XVisualInfo* visualInfo()
98
    {
99
        if (!m_VisualInfo)
100
            surfaceContextConfig();
101
102
        return m_VisualInfo;
103
    }
104
105
    bool isXRenderExtensionSupported()
114
    bool isXRenderExtensionSupported()
106
    {
115
    {
107
        return m_supportsXRenderExtension;
116
        return m_supportsXRenderExtension;
108
    }
117
    }
109
118
110
    virtual PlatformSurfaceConfig pBufferContextConfig() = 0;
111
    virtual PlatformSurfaceConfig surfaceContextConfig() = 0;
112
    virtual PlatformDisplay nativeDisplay() = 0;
113
114
protected:
119
protected:
115
    SharedX11Resources()
120
    SharedX11Resources()
116
        : m_supportsXRenderExtension(false)
121
        : m_supportsXRenderExtension(false)
117
        , m_window(0)
122
        , m_window(0)
118
        , m_display(0)
123
        , m_display(0)
119
        , m_VisualInfo(0)
120
    {
124
    {
121
    }
125
    }
122
126
Lines 131-141 protected: Source/WebCore/platform/graphics/surfaces/glx/X11WindowResources.h_sec3
131
            m_window = 0;
135
            m_window = 0;
132
        }
136
        }
133
137
134
        if (m_VisualInfo) {
135
            XFree(m_VisualInfo);
136
            m_VisualInfo = 0;
137
        }
138
139
        XCloseDisplay(m_display);
138
        XCloseDisplay(m_display);
140
        m_display = 0;
139
        m_display = 0;
141
    }
140
    }
Lines 144-150 protected: Source/WebCore/platform/graphics/surfaces/glx/X11WindowResources.h_sec4
144
    bool m_supportsXRenderExtension;
143
    bool m_supportsXRenderExtension;
145
    Window m_window;
144
    Window m_window;
146
    Display* m_display;
145
    Display* m_display;
147
    XVisualInfo* m_VisualInfo;
148
};
146
};
149
147
150
class X11OffScreenWindow : public GLPlatformSurface {
148
class X11OffScreenWindow : public GLPlatformSurface {
Lines 153-164 class X11OffScreenWindow : public GLPlatformSurface { Source/WebCore/platform/graphics/surfaces/glx/X11WindowResources.h_sec5
153
public:
151
public:
154
    X11OffScreenWindow();
152
    X11OffScreenWindow();
155
    virtual ~X11OffScreenWindow();
153
    virtual ~X11OffScreenWindow();
156
    void setGeometry(const IntRect&);
154
    void createOffscreenWindow(PlatformBufferHandle*);
157
    void createOffscreenWindow();
155
    void destroyWindow(PlatformBufferHandle);
158
    void destroyWindow();
156
    void reSizeWindow(const IntRect&, PlatformBufferHandle);
157
    Display* nativeSharedDisplay();
158
#if USE(EGL)
159
    bool setVisualId(const EGLint);
160
#endif
159
161
160
protected:
162
protected:
161
    RefPtr<PlatformSharedResources> m_sharedResources;
163
    RefPtr<PlatformSharedResources> m_sharedResources;
164
    XVisualInfo* m_configVisualInfo;
162
};
165
};
163
166
164
}
167
}
- Source/cmake/OptionsEfl.cmake -4 / +17 lines
Lines 175-186 if (ENABLE_WEBGL OR WTF_USE_TILED_BACKING_STORE) Source/cmake/OptionsEfl.cmake_sec1
175
175
176
    if (OPENGLX_FOUND)
176
    if (OPENGLX_FOUND)
177
        add_definitions(-DHAVE_GLX)
177
        add_definitions(-DHAVE_GLX)
178
        add_definitions(-DWTF_USE_GLX=1)
178
    endif ()
179
180
    option(ENABLE_EGL ON)
179
181
180
        if (X11_Xcomposite_FOUND AND X11_Xrender_FOUND)
182
    if (ENABLE_EGL)
181
           set(USE_GRAPHICS_SURFACE 1)
183
        find_package(EGL REQUIRED)
182
        endif ()
183
    endif ()
184
    endif ()
185
186
    if (EGL_FOUND)
187
        set(WTF_USE_EGL 1)
188
        add_definitions(-DWTF_USE_EGL=1)
189
     elseif (OPENGLX_FOUND)
190
         set(WTF_USE_GLX 1)
191
         add_definitions(-DWTF_USE_GLX=1)
192
    endif ()
193
194
     if ((OPENGLX_FOUND OR EGL_FOUND) AND X11_Xcomposite_FOUND AND X11_Xrender_FOUND)
195
         set(USE_GRAPHICS_SURFACE 1)
196
     endif ()
184
endif ()
197
endif ()
185
198
186
if (ENABLE_INSPECTOR)
199
if (ENABLE_INSPECTOR)

Return to Bug 105602