| 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 +71 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):
18
        (WebCore::GLPlatformContext::createOffScreenContext):
19
        (WebCore::GLPlatformContext::createCurrentContextWrapper):
20
        * platform/graphics/opengl/GLPlatformContext.h:
21
        * platform/graphics/opengl/GLPlatformSurface.cpp:
22
        (WebCore::GLPlatformSurface::createTransportSurface):
23
24
        EGL implementation for Context Management.
25
        * platform/graphics/surfaces/egl/EGLContext.cpp: Added.
26
        (WebCore):
27
        (WebCore::isRobustnessExtSupported):
28
        (WebCore::EGLCurrentContextWrapper::EGLCurrentContextWrapper):
29
        (WebCore::EGLCurrentContextWrapper::handle):
30
        (WebCore::EGLOffScreenContext::EGLOffScreenContext):
31
        (WebCore::EGLOffScreenContext::initialize):
32
        (WebCore::EGLOffScreenContext::~EGLOffScreenContext):
33
        (WebCore::EGLOffScreenContext::isCurrentContext):
34
        (WebCore::EGLOffScreenContext::platformMakeCurrent):
35
        (WebCore::EGLOffScreenContext::platformReleaseCurrent):
36
        (WebCore::EGLOffScreenContext::freeResources):
37
        (WebCore::EGLOffScreenContext::destroy):
38
        * platform/graphics/surfaces/egl/EGLContext.h:
39
        (WebCore):
40
        (EGLCurrentContextWrapper):
41
        (WebCore::EGLCurrentContextWrapper::~EGLCurrentContextWrapper):
42
        (EGLOffScreenContext):
43
44
        EGL implementation for Offscreen Surface.
45
        * platform/graphics/surfaces/egl/EGLSurface.cpp: Added.
46
        (WebCore):
47
        (WebCore::EGLTransportSurface::EGLTransportSurface):
48
        (WebCore::EGLTransportSurface::~EGLTransportSurface):
49
        (WebCore::EGLTransportSurface::configuration):
50
        (WebCore::EGLTransportSurface::swapBuffers):
51
        (WebCore::EGLTransportSurface::destroy):
52
        (WebCore::EGLTransportSurface::freeEGLResources):
53
        * platform/graphics/surfaces/egl/EGLSurface.h:
54
        (WebCore):
55
        (EGLTransportSurface):
56
57
        X integration.
58
        * platform/graphics/surfaces/glx/EGLXWindowResources.h: Added.
59
        (WebCore):
60
        (SharedEGLResources):
61
        (WebCore::SharedEGLResources::create):
62
        (WebCore::SharedEGLResources::nativeDisplay):
63
        (WebCore::SharedEGLResources::pBufferContextConfig):
64
        (WebCore::SharedEGLResources::surfaceContextConfig):
65
        (WebCore::SharedEGLResources::SharedEGLResources):
66
        (WebCore::SharedEGLResources::cleanup):
67
        (WebCore::SharedEGLResources::createConfig):
68
        (WebCore::SharedEGLResources::~SharedEGLResources):
69
        * platform/graphics/surfaces/glx/X11WindowResources.cpp:
70
        * platform/graphics/surfaces/glx/X11WindowResources.h:
71
1
2012-12-21  Brady Eidson  <beidson@apple.com>
72
2012-12-21  Brady Eidson  <beidson@apple.com>
2
73
3
        Update localizable strings as a followup to http://trac.webkit.org/changeset/138387
74
        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 +16 lines
Lines 42-47 Source/WebCore/platform/graphics/opengl/GLDefs.h_sec1
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_sec2
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 / +14 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
    OwnPtr<GLPlatformContext> context = adoptPtr(new GLXOffScreenContext());
74
    return glxContext.release();
76
    return context.release();
77
#elif USE(EGL)
78
    OwnPtr<GLPlatformContext> context = adoptPtr(new EGLOffScreenContext());
79
    return context.release();
75
#endif
80
#endif
76
81
77
    return nullptr;
82
    return nullptr;
Lines 80-87 PassOwnPtr<GLPlatformContext> GLPlatformContext::createOffScreenContext() Source/WebCore/platform/graphics/opengl/GLPlatformContext.cpp_sec4
80
PassOwnPtr<GLPlatformContext> GLPlatformContext::createCurrentContextWrapper()
85
PassOwnPtr<GLPlatformContext> GLPlatformContext::createCurrentContextWrapper()
81
{
86
{
82
#if USE(GLX)
87
#if USE(GLX)
83
    OwnPtr<GLPlatformContext> glxContext = adoptPtr(new GLXCurrentContextWrapper());
88
    OwnPtr<GLPlatformContext> context = adoptPtr(new GLXCurrentContextWrapper());
84
    return glxContext.release();
89
    return context.release();
90
#elif USE(EGL)
91
    OwnPtr<GLPlatformContext> context = adoptPtr(new EGLCurrentContextWrapper());
92
    return context.release();
85
#endif
93
#endif
86
94
87
    return nullptr;
95
    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 EGLTransportSurface());
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/EGLContext.cpp +176 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(ACCELERATED_COMPOSITING) && 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 queryDone = false;
58
    static bool isEGLEXTsupported = false;
59
60
    if (!queryDone) {
61
        queryDone = true;
62
        String supportedExtensions = reinterpret_cast<const char*>(eglQueryString(display, EGL_EXTENSIONS));
63
        if (!supportedExtensions.isEmpty()) {
64
            supportedExtensions.append(" ");
65
            isEGLEXTsupported = supportedExtensions.contains("EGL_EXT_create_context_robustness ");
66
        }
67
    }
68
69
    return isEGLEXTsupported;
70
}
71
72
EGLCurrentContextWrapper::EGLCurrentContextWrapper()
73
    : GLPlatformContext()
74
{
75
}
76
77
// FIXME: This is a temporary workaround till we are able to build evas with EGL support
78
PlatformContext EGLCurrentContextWrapper::handle() const
79
{
80
    return glXGetCurrentContext();
81
}
82
83
EGLOffScreenContext::EGLOffScreenContext()
84
    : GLPlatformContext()
85
    , m_display(0)
86
{
87
}
88
89
bool EGLOffScreenContext::initialize(GLPlatformSurface* surface)
90
{
91
    if (!surface)
92
        return false;
93
94
    if (!eglBindAPI(eglAPIVersion)) {
95
        LOG_ERROR("Failed to set EGL API(%d).\n", eglGetError());
96
        return false;
97
    }
98
99
    m_display = surface->sharedDisplay();
100
    if (!m_display)
101
        return false;
102
103
    EGLConfig config = surface->configuration();
104
    if (!config)
105
        return false;
106
107
    if (config) {
108
        if (isRobustnessExtSupported(m_display))
109
            m_contextHandle = eglCreateContext(m_display, config, EGL_NO_CONTEXT, contextRobustnessAttributes);
110
111
        if (!m_contextHandle && m_contextHandle != EGL_NO_CONTEXT)
112
            m_resetLostContext = true;
113
        else
114
            m_contextHandle = eglCreateContext(m_display, config, EGL_NO_CONTEXT, contextAttributes);
115
116
        if (m_contextHandle && m_contextHandle != EGL_NO_CONTEXT)
117
            return true;
118
    }
119
120
    return false;
121
}
122
123
EGLOffScreenContext::~EGLOffScreenContext()
124
{
125
}
126
127
bool EGLOffScreenContext::isCurrentContext() const
128
{
129
    return m_contextHandle == eglGetCurrentContext();
130
}
131
132
bool EGLOffScreenContext::platformMakeCurrent(GLPlatformSurface* surface)
133
{
134
    if (!eglBindAPI(eglAPIVersion)) {
135
        LOG_ERROR("Failed to set EGL API(%d).\n", eglGetError());
136
        return false;
137
    }
138
139
    if (!eglMakeCurrent(m_display, surface->drawable(), surface->drawable(), m_contextHandle)) {
140
        LOG_ERROR("Failed to make context current.(%d).\n", eglGetError());
141
142
        if (m_resetLostContext && eglGetError() == EGL_CONTEXT_LOST) {
143
            LOG_ERROR("Lost current context.\n");
144
            m_contextLost = true;
145
        }
146
147
        return false;
148
    }
149
150
    return true;
151
}
152
153
void EGLOffScreenContext::platformReleaseCurrent()
154
{
155
    eglMakeCurrent(m_display, EGL_NO_SURFACE, EGL_NO_SURFACE, EGL_NO_CONTEXT);
156
}
157
158
void EGLOffScreenContext::freeResources()
159
{
160
    if (m_contextHandle)
161
        eglDestroyContext(m_display, m_contextHandle);
162
163
    m_contextHandle = 0;
164
    m_display = 0;
165
}
166
167
void EGLOffScreenContext::destroy()
168
{
169
    GLPlatformContext::destroy();
170
    freeResources();
171
}
172
173
}
174
175
#endif
176
- Source/WebCore/platform/graphics/surfaces/egl/EGLContext.h +65 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(ACCELERATED_COMPOSITING) && USE(EGL)
30
31
#include "GLPlatformContext.h"
32
33
namespace WebCore {
34
35
class EGLCurrentContextWrapper : public GLPlatformContext {
36
    WTF_MAKE_NONCOPYABLE(EGLCurrentContextWrapper);
37
38
public:
39
    EGLCurrentContextWrapper();
40
    PlatformContext handle() const;
41
    virtual ~EGLCurrentContextWrapper() { }
42
};
43
44
class EGLOffScreenContext : public GLPlatformContext {
45
    WTF_MAKE_NONCOPYABLE(EGLOffScreenContext);
46
47
public:
48
    EGLOffScreenContext();
49
    virtual ~EGLOffScreenContext();
50
    bool initialize(GLPlatformSurface*);
51
    bool platformMakeCurrent(GLPlatformSurface*);
52
    void platformReleaseCurrent();
53
    void destroy();
54
    bool isCurrentContext() const;
55
56
private:
57
    void freeResources();
58
    EGLDisplay m_display;
59
};
60
61
}
62
63
#endif
64
65
#endif
- Source/WebCore/platform/graphics/surfaces/egl/EGLSurface.cpp +115 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(ACCELERATED_COMPOSITING) && USE(EGL) && USE(GRAPHICS_SURFACE)
30
31
namespace WebCore {
32
33
EGLTransportSurface::EGLTransportSurface()
34
    : X11OffScreenWindow()
35
{
36
    if (m_sharedDisplay == EGL_NO_DISPLAY) {
37
        LOG_ERROR("No valid hardware display found.\n");
38
        return;
39
    }
40
41
    if (!configuration()) {
42
        destroy();
43
        return;
44
    }
45
46
    createOffscreenWindow();
47
48
    if (!m_bufferHandle) {
49
        LOG_ERROR("Failed to create XWindow.\n");
50
        destroy();
51
        return;
52
    }
53
54
    m_drawable = eglCreateWindowSurface(m_sharedResources->nativeDisplay(), configuration(), (EGLNativeWindowType)m_bufferHandle, 0);
55
56
    if (m_drawable == EGL_NO_SURFACE) {
57
        LOG_ERROR("Failed to create EGL surface(%d).\n", eglGetError());
58
        destroy();
59
    }
60
}
61
62
EGLTransportSurface::~EGLTransportSurface()
63
{
64
}
65
66
PlatformSurfaceConfig EGLTransportSurface::configuration()
67
{
68
    return m_sharedResources->surfaceContextConfig();
69
}
70
71
void EGLTransportSurface::swapBuffers()
72
{
73
    if (!m_drawable)
74
        return;
75
76
    EGLBoolean success = eglBindAPI(eglAPIVersion);
77
78
    if (success != EGL_TRUE) {
79
        LOG_ERROR("Failed to set EGL API(%d).\n", eglGetError());
80
        destroy();
81
    }
82
83
    success = eglSwapBuffers(sharedDisplay(), m_drawable);
84
85
    if (success != EGL_TRUE) {
86
        LOG_ERROR("Failed to SwapBuffers(%d).\n", eglGetError());
87
        destroy();
88
    }
89
}
90
91
void EGLTransportSurface::destroy()
92
{
93
    destroyWindow();
94
    freeEGLResources();
95
}
96
97
void EGLTransportSurface::freeEGLResources()
98
{
99
    if (m_drawable == EGL_NO_SURFACE)
100
        return;
101
102
    EGLBoolean eglResult = eglBindAPI(eglAPIVersion);
103
104
    if (eglResult != EGL_TRUE) {
105
        LOG_ERROR("Failed to set EGL API(%d).\n", eglGetError());
106
        return;
107
    }
108
109
    eglDestroySurface(sharedDisplay(), m_drawable);
110
    m_drawable = EGL_NO_SURFACE;
111
}
112
113
}
114
115
#endif
- Source/WebCore/platform/graphics/surfaces/egl/EGLSurface.h +55 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(ACCELERATED_COMPOSITING) && USE(EGL) && USE(GRAPHICS_SURFACE)
30
31
#include <glx/EGLXWindowResources.h>
32
#include <wtf/Noncopyable.h>
33
#include <wtf/RefCounted.h>
34
35
namespace WebCore {
36
37
class EGLTransportSurface : public X11OffScreenWindow {
38
    WTF_MAKE_NONCOPYABLE(EGLTransportSurface);
39
40
public:
41
    EGLTransportSurface();
42
    virtual ~EGLTransportSurface();
43
    PlatformSurfaceConfig configuration();
44
    void swapBuffers();
45
    void destroy();
46
47
private:
48
    void freeEGLResources();
49
};
50
51
}
52
53
#endif
54
55
#endif
- Source/WebCore/platform/graphics/surfaces/glx/EGLXWindowResources.h +240 lines
Line 0 Source/WebCore/platform/graphics/surfaces/glx/EGLXWindowResources.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 EGLXWindowResources_h
27
#define EGLXWindowResources_h
28
29
#include "X11WindowResources.h"
30
31
#if USE(ACCELERATED_COMPOSITING) && USE(EGL)
32
33
#include <opengl/GLDefs.h>
34
35
namespace WebCore {
36
37
class SharedEGLResources : public SharedX11Resources {
38
39
public:
40
    static PassRefPtr<SharedEGLResources> create()
41
    {
42
        if (!m_staticSharedResource)
43
            m_staticSharedResource = new SharedEGLResources();
44
        else
45
            m_staticSharedResource->ref();
46
47
        return adoptRef(m_staticSharedResource);
48
    }
49
50
    PlatformDisplay nativeDisplay()
51
    {
52
        if (m_eglDisplay == EGL_NO_DISPLAY) {
53
            EGLBoolean success;
54
55
            m_eglDisplay = eglGetDisplay(reinterpret_cast<EGLNativeDisplayType>(SharedX11Resources::x11Display()));
56
57
            if (m_eglDisplay == EGL_NO_DISPLAY) {
58
                LOG_ERROR("EGLDisplay Initialization failed.\n");
59
                return m_eglDisplay;
60
            }
61
62
            success = eglInitialize(m_eglDisplay, 0, 0);
63
64
            if (success != EGL_TRUE) {
65
                LOG_ERROR("EGLInitialization failed.\n");
66
                cleanup();
67
                return m_eglDisplay;
68
            }
69
70
            success = eglBindAPI(eglAPIVersion);
71
72
            if (success != EGL_TRUE) {
73
                LOG_ERROR("failed to set EGL API(%d).\n", eglGetError());
74
                cleanup();
75
            }
76
        }
77
78
        return m_eglDisplay;
79
    }
80
81
    virtual EGLConfig pBufferContextConfig()
82
    {
83
        if (!m_pbufferfbConfig) {
84
            EGLint attributeList[] = {
85
#if USE(OPENGL_ES_2)
86
                EGL_RENDERABLE_TYPE, EGL_OPENGL_ES2_BIT,
87
#else
88
                EGL_RENDERABLE_TYPE, EGL_OPENGL_BIT,
89
#endif
90
                EGL_RED_SIZE, 8,
91
                EGL_GREEN_SIZE, 8,
92
                EGL_BLUE_SIZE, 8,
93
                EGL_STENCIL_SIZE, 8,
94
                EGL_ALPHA_SIZE, 8,
95
                EGL_SURFACE_TYPE, EGL_PIXMAP_BIT,
96
                EGL_NONE
97
            };
98
            m_pbufferfbConfig = createConfig(attributeList);
99
        }
100
        return m_pbufferfbConfig;
101
    }
102
103
    virtual EGLConfig surfaceContextConfig()
104
    {
105
        if (!m_surfaceContextfbConfig) {
106
            EGLint attributeList[] = {
107
                EGL_LEVEL, 0,
108
#if USE(OPENGL_ES_2)
109
                EGL_RENDERABLE_TYPE, EGL_OPENGL_ES2_BIT,
110
#else
111
                EGL_RENDERABLE_TYPE, EGL_OPENGL_BIT,
112
#endif
113
                EGL_RED_SIZE, 8,
114
                EGL_GREEN_SIZE, 8,
115
                EGL_BLUE_SIZE, 8,
116
                EGL_STENCIL_SIZE, 8,
117
                EGL_ALPHA_SIZE, 8,
118
                EGL_DEPTH_SIZE, 8,
119
                EGL_SURFACE_TYPE, EGL_WINDOW_BIT,
120
                EGL_NONE
121
            };
122
            m_surfaceContextfbConfig = createConfig(attributeList);
123
        }
124
125
        return m_surfaceContextfbConfig;
126
    }
127
128
private:
129
    SharedEGLResources()
130
        : SharedX11Resources()
131
    {
132
        m_eglDisplay = EGL_NO_DISPLAY;
133
        m_surfaceContextfbConfig = 0;
134
        m_pbufferfbConfig = 0;
135
    }
136
137
    void cleanup()
138
    {
139
        eglMakeCurrent(m_eglDisplay, EGL_NO_SURFACE, EGL_NO_SURFACE, EGL_NO_CONTEXT);
140
        eglTerminate(m_eglDisplay);
141
        m_eglDisplay = EGL_NO_DISPLAY;
142
    }
143
144
    EGLConfig createConfig(const int attributes[])
145
    {
146
        if (m_eglDisplay == EGL_NO_DISPLAY) {
147
            // Try to initialize Display if already not done.
148
            nativeDisplay();
149
150
            if (m_eglDisplay == EGL_NO_DISPLAY)
151
                return 0;
152
        }
153
154
        int numConfigs;
155
        EGLConfig rightConfig = 0;
156
157
        if (!eglChooseConfig(m_eglDisplay, attributes, &rightConfig, 1, &numConfigs)) {
158
            LOG_ERROR("Failed to get supported configirations.\n");
159
            cleanup();
160
        }
161
162
        if (numConfigs != 1) {
163
            LOG_ERROR("EGLChooseConfig didn't return exactly one config but (%d).\n", numConfigs);
164
            cleanup();
165
        }
166
167
        VisualID visualId = 0;
168
        EGLint eglValue = 0;
169
170
        // Check if EGL provides us with a valid visual id.
171
        eglGetConfigAttrib(m_eglDisplay, rightConfig, EGL_NATIVE_VISUAL_ID, &eglValue);
172
        visualId = static_cast<VisualID>(eglValue);
173
        if (visualId) {
174
            // EGL has suggested a visual id, so get the rest of the visual info for that id.
175
            XVisualInfo visualInfoTemplate;
176
            memset(&visualInfoTemplate, 0, sizeof(XVisualInfo));
177
            visualInfoTemplate.visualid = visualId;
178
179
            XVisualInfo *chosenVisualInfo;
180
            int matchingCount = 0;
181
            chosenVisualInfo = XGetVisualInfo(x11Display(), VisualIDMask, &visualInfoTemplate, &matchingCount);
182
            if (chosenVisualInfo) {
183
#if USE(GRAPHICS_SURFACE)
184
                if (m_supportsXRenderExtension) {
185
                    XRenderPictFormat* format = XRenderFindVisualFormat(x11Display(), chosenVisualInfo->visual);
186
                    if (format && format->direct.alphaMask > 0)
187
                        m_VisualInfo = chosenVisualInfo;
188
                }
189
#endif
190
                if (!m_VisualInfo && chosenVisualInfo->depth == 32)
191
                    m_VisualInfo = chosenVisualInfo;
192
            }
193
194
            if (!m_VisualInfo) {
195
                XVisualInfo visualInfoTemplate;
196
                memset(&visualInfoTemplate, 0, sizeof(XVisualInfo));
197
                XVisualInfo *matchingVisuals;
198
                int matchingCount = 0;
199
200
                visualInfoTemplate.depth = chosenVisualInfo->depth;
201
                matchingVisuals = XGetVisualInfo(x11Display(), VisualDepthMask, &visualInfoTemplate, &matchingCount);
202
203
                if (matchingVisuals) {
204
                    m_VisualInfo = &matchingVisuals[0];
205
                    XFree(matchingVisuals);
206
                }
207
            }
208
        }
209
210
        if (!m_VisualInfo) {
211
            LOG_ERROR("Failed to get Visual Info.\n");
212
            cleanup();
213
        }
214
215
        return rightConfig;
216
    }
217
218
    virtual ~SharedEGLResources()
219
    {
220
        if (m_eglDisplay == EGL_NO_DISPLAY)
221
            return;
222
223
        if (m_surfaceContextfbConfig)
224
            m_surfaceContextfbConfig = 0;
225
226
        eglTerminate(m_eglDisplay);
227
        m_eglDisplay = EGL_NO_DISPLAY;
228
    }
229
230
protected:
231
    EGLDisplay m_eglDisplay;
232
    EGLConfig m_pbufferfbConfig;
233
    EGLConfig m_surfaceContextfbConfig;
234
};
235
236
}
237
238
#endif
239
240
#endif
- Source/WebCore/platform/graphics/surfaces/glx/X11WindowResources.cpp +6 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
34
35
#if USE(EGL)
36
#include "EGLXWindowResources.h"
37
#endif
32
38
33
namespace WebCore {
39
namespace WebCore {
34
40
- Source/WebCore/platform/graphics/surfaces/glx/X11WindowResources.h +5 lines
Lines 40-47 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 SharedEGLResources;
48
typedef SharedEGLResources 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);
- 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