Changeset 130525 in webkit


Ignore:
Timestamp:
Oct 5, 2012 10:54:57 AM (12 years ago)
Author:
Martin Robinson
Message:

[GTK] Add support for creating EGL contexts
https://bugs.webkit.org/show_bug.cgi?id=77921

Patch by José Dapena Paz <jdapena@igalia.com> on 2012-10-05
Reviewed by Martin Robinson.

This patch adds support for EGL, using OpenGL and OpenGL ES 2. Both
options are set up on compile time, with the configure options
--enable-egl and --enable-gles2.

The implementation only adds support for EGL on top of X11, to
isolate the changes to the minimum. More changes should come
later to enable EGL for other targets (as Wayland).

.:

  • GNUmakefile.am:
  • configure.ac: new configure options --enable-egl and --enable-gles2.

Source/WebCore:

No new tests required, as existing WebGL and AC tests should cover
the cases.

  • GNUmakefile.am:
  • GNUmakefile.list.am:
  • platform/graphics/GraphicsContext3D.h:

(GraphicsContext3D):

  • platform/graphics/OpenGLESShims.h:
  • platform/graphics/cairo/GLContext.cpp:

(WebCore):
(WebCore::GLContext::sharedX11Display):
(WebCore::GLContext::cleanupSharedX11Display):
(WebCore::activeContextList):
(WebCore::GLContext::addActiveContext):
(WebCore::GLContext::removeActiveContext):
(WebCore::GLContext::cleanupActiveContextsAtExit):
(WebCore::GLContext::createContextForWindow):
(WebCore::GLContext::createOffscreenContext):

  • platform/graphics/cairo/GLContext.h:

(GLContext):

  • platform/graphics/cairo/GraphicsContext3DCairo.cpp:

(WebCore::GraphicsContext3D::create):
(WebCore::GraphicsContext3D::GraphicsContext3D):
(WebCore::GraphicsContext3D::~GraphicsContext3D):
(WebCore::GraphicsContext3D::isGLES2Compliant):

  • platform/graphics/cairo/GraphicsContext3DPrivate.cpp:

(WebCore::GraphicsContext3DPrivate::paintToTextureMapper):

  • platform/graphics/clutter/GraphicsContext3DClutter.cpp:
  • platform/graphics/efl/GraphicsContext3DEfl.cpp:
  • platform/graphics/egl/GLContextEGL.cpp: Added.

(WebCore):
(WebCore::sharedEGLDisplay):
(WebCore::getEGLConfig):
(WebCore::GLContextEGL::createWindowContext):
(WebCore::GLContextEGL::createPbufferContext):
(WebCore::GLContextEGL::createPixmapContext):
(WebCore::GLContextEGL::createContext):
(WebCore::GLContextEGL::GLContextEGL):
(WebCore::GLContextEGL::~GLContextEGL):
(WebCore::GLContextEGL::canRenderToDefaultFramebuffer):
(WebCore::GLContextEGL::defaultFrameBufferSize):
(WebCore::GLContextEGL::makeContextCurrent):
(WebCore::GLContextEGL::swapBuffers):
(WebCore::GLContextEGL::waitNative):
(WebCore::GLContextEGL::platformContext):

  • platform/graphics/egl/GLContextEGL.h: Added.

(WebCore):
(GLContextEGL):

  • platform/graphics/glx/GLContextGLX.cpp:

(WebCore::GLContextGLX::createWindowContext):
(WebCore::GLContextGLX::createPbufferContext):
(WebCore::GLContextGLX::createPixmapContext):
(WebCore::GLContextGLX::createContext):
(WebCore::GLContextGLX::~GLContextGLX):
(WebCore::GLContextGLX::defaultFrameBufferSize):
(WebCore::GLContextGLX::makeContextCurrent):
(WebCore::GLContextGLX::swapBuffers):
(WebCore):
(WebCore::GLContextGLX::waitNative):

  • platform/graphics/glx/GLContextGLX.h:

(GLContextGLX):

  • platform/graphics/mac/GraphicsContext3DMac.mm:
  • platform/graphics/opengl/GraphicsContext3DOpenGL.cpp:

(WebCore::GraphicsContext3D::releaseShaderCompiler):
(WebCore):

  • platform/graphics/opengl/GraphicsContext3DOpenGLES.cpp:

(WebCore::GraphicsContext3D::readPixels):
(WebCore::GraphicsContext3D::reshapeFBOs):
(WebCore::GraphicsContext3D::renderbufferStorage):

  • platform/graphics/qt/GraphicsContext3DQt.cpp:
  • platform/graphics/texmap/TextureMapper.h:
  • platform/gtk/RedirectedXCompositeWindow.cpp:

(WebCore::RedirectedXCompositeWindow::RedirectedXCompositeWindow):
(WebCore::RedirectedXCompositeWindow::~RedirectedXCompositeWindow):
(WebCore::RedirectedXCompositeWindow::resize):

  • platform/gtk/RedirectedXCompositeWindow.h:

Source/WebKit2:

  • WebProcess/WebPage/gtk/LayerTreeHostGtk.cpp:
Location:
trunk
Files:
3 added
25 edited

Legend:

Unmodified
Added
Removed
  • trunk/ChangeLog

    r130503 r130525  
     12012-10-05  José Dapena Paz  <jdapena@igalia.com>
     2
     3        [GTK] Add support for creating EGL contexts
     4        https://bugs.webkit.org/show_bug.cgi?id=77921
     5
     6        Reviewed by Martin Robinson.
     7
     8        This patch adds support for EGL, using OpenGL and OpenGL ES 2. Both
     9        options are set up on compile time, with the configure options
     10        --enable-egl and --enable-gles2.
     11
     12        The implementation only adds support for EGL on top of X11, to
     13        isolate the changes to the minimum. More changes should come
     14        later to enable EGL for other targets (as Wayland).
     15
     16        * GNUmakefile.am:
     17        * configure.ac: new configure options --enable-egl and --enable-gles2.
     18
    1192012-10-04  Rob Buis  <rbuis@rim.com>
    220
  • trunk/GNUmakefile.am

    r127872 r130525  
    238238endif
    239239
     240if USE_EGL
     241global_cppflags += \
     242        -DWTF_USE_EGL=1
     243endif
     244
     245if USE_GLES2
     246global_cppflags += \
     247        -DWTF_USE_OPENGL_ES_2=1
     248endif
     249
    240250if USE_OPENGL
    241251global_cppflags += \
  • trunk/Source/WebCore/ChangeLog

    r130523 r130525  
     12012-10-05  José Dapena Paz  <jdapena@igalia.com>
     2
     3        [GTK] Add support for creating EGL contexts
     4        https://bugs.webkit.org/show_bug.cgi?id=77921
     5
     6        Reviewed by Martin Robinson.
     7
     8        This patch adds support for EGL, using OpenGL and OpenGL ES 2. Both
     9        options are set up on compile time, with the configure options
     10        --enable-egl and --enable-gles2.
     11
     12        The implementation only adds support for EGL on top of X11, to
     13        isolate the changes to the minimum. More changes should come
     14        later to enable EGL for other targets (as Wayland).
     15
     16        No new tests required, as existing WebGL and AC tests should cover
     17        the cases.
     18
     19        * GNUmakefile.am:
     20        * GNUmakefile.list.am:
     21        * platform/graphics/GraphicsContext3D.h:
     22        (GraphicsContext3D):
     23        * platform/graphics/OpenGLESShims.h:
     24        * platform/graphics/cairo/GLContext.cpp:
     25        (WebCore):
     26        (WebCore::GLContext::sharedX11Display):
     27        (WebCore::GLContext::cleanupSharedX11Display):
     28        (WebCore::activeContextList):
     29        (WebCore::GLContext::addActiveContext):
     30        (WebCore::GLContext::removeActiveContext):
     31        (WebCore::GLContext::cleanupActiveContextsAtExit):
     32        (WebCore::GLContext::createContextForWindow):
     33        (WebCore::GLContext::createOffscreenContext):
     34        * platform/graphics/cairo/GLContext.h:
     35        (GLContext):
     36        * platform/graphics/cairo/GraphicsContext3DCairo.cpp:
     37        (WebCore::GraphicsContext3D::create):
     38        (WebCore::GraphicsContext3D::GraphicsContext3D):
     39        (WebCore::GraphicsContext3D::~GraphicsContext3D):
     40        (WebCore::GraphicsContext3D::isGLES2Compliant):
     41        * platform/graphics/cairo/GraphicsContext3DPrivate.cpp:
     42        (WebCore::GraphicsContext3DPrivate::paintToTextureMapper):
     43        * platform/graphics/clutter/GraphicsContext3DClutter.cpp:
     44        * platform/graphics/efl/GraphicsContext3DEfl.cpp:
     45        * platform/graphics/egl/GLContextEGL.cpp: Added.
     46        (WebCore):
     47        (WebCore::sharedEGLDisplay):
     48        (WebCore::getEGLConfig):
     49        (WebCore::GLContextEGL::createWindowContext):
     50        (WebCore::GLContextEGL::createPbufferContext):
     51        (WebCore::GLContextEGL::createPixmapContext):
     52        (WebCore::GLContextEGL::createContext):
     53        (WebCore::GLContextEGL::GLContextEGL):
     54        (WebCore::GLContextEGL::~GLContextEGL):
     55        (WebCore::GLContextEGL::canRenderToDefaultFramebuffer):
     56        (WebCore::GLContextEGL::defaultFrameBufferSize):
     57        (WebCore::GLContextEGL::makeContextCurrent):
     58        (WebCore::GLContextEGL::swapBuffers):
     59        (WebCore::GLContextEGL::waitNative):
     60        (WebCore::GLContextEGL::platformContext):
     61        * platform/graphics/egl/GLContextEGL.h: Added.
     62        (WebCore):
     63        (GLContextEGL):
     64        * platform/graphics/glx/GLContextGLX.cpp:
     65        (WebCore::GLContextGLX::createWindowContext):
     66        (WebCore::GLContextGLX::createPbufferContext):
     67        (WebCore::GLContextGLX::createPixmapContext):
     68        (WebCore::GLContextGLX::createContext):
     69        (WebCore::GLContextGLX::~GLContextGLX):
     70        (WebCore::GLContextGLX::defaultFrameBufferSize):
     71        (WebCore::GLContextGLX::makeContextCurrent):
     72        (WebCore::GLContextGLX::swapBuffers):
     73        (WebCore):
     74        (WebCore::GLContextGLX::waitNative):
     75        * platform/graphics/glx/GLContextGLX.h:
     76        (GLContextGLX):
     77        * platform/graphics/mac/GraphicsContext3DMac.mm:
     78        * platform/graphics/opengl/GraphicsContext3DOpenGL.cpp:
     79        (WebCore::GraphicsContext3D::releaseShaderCompiler):
     80        (WebCore):
     81        * platform/graphics/opengl/GraphicsContext3DOpenGLES.cpp:
     82        (WebCore::GraphicsContext3D::readPixels):
     83        (WebCore::GraphicsContext3D::reshapeFBOs):
     84        (WebCore::GraphicsContext3D::renderbufferStorage):
     85        * platform/graphics/qt/GraphicsContext3DQt.cpp:
     86        * platform/graphics/texmap/TextureMapper.h:
     87        * platform/gtk/RedirectedXCompositeWindow.cpp:
     88        (WebCore::RedirectedXCompositeWindow::RedirectedXCompositeWindow):
     89        (WebCore::RedirectedXCompositeWindow::~RedirectedXCompositeWindow):
     90        (WebCore::RedirectedXCompositeWindow::resize):
     91        * platform/gtk/RedirectedXCompositeWindow.h:
     92
    1932012-10-04  Jon Lee  <jonlee@apple.com>
    294
  • trunk/Source/WebCore/GNUmakefile.am

    r129969 r130525  
    113113        -I$(srcdir)/Source/WebCore/platform/graphics/cairo \
    114114        -I$(srcdir)/Source/WebCore/platform/graphics/glx \
     115        -I$(srcdir)/Source/WebCore/platform/graphics/egl \
    115116        -I$(srcdir)/Source/WebCore/platform/graphics/gstreamer \
    116117        -I$(srcdir)/Source/WebCore/platform/graphics/gtk \
  • trunk/Source/WebCore/GNUmakefile.list.am

    r130471 r130525  
    44584458        Source/WebCore/platform/graphics/MediaPlayer.h \
    44594459        Source/WebCore/platform/graphics/MediaPlayerPrivate.h \
    4460         Source/WebCore/platform/graphics/opengl/Extensions3DOpenGL.cpp \
    4461         Source/WebCore/platform/graphics/opengl/Extensions3DOpenGL.h \
    44624460        Source/WebCore/platform/graphics/opengl/Extensions3DOpenGLCommon.cpp \
    44634461        Source/WebCore/platform/graphics/opengl/Extensions3DOpenGLCommon.h \
    4464         Source/WebCore/platform/graphics/opengl/GraphicsContext3DOpenGL.cpp \
    44654462        Source/WebCore/platform/graphics/opengl/GraphicsContext3DOpenGLCommon.cpp \
    4466         Source/WebCore/platform/graphics/OpenGLShims.cpp \
    4467         Source/WebCore/platform/graphics/OpenGLShims.h \
    44684463        Source/WebCore/platform/graphics/opentype/OpenTypeVerticalData.h \
    44694464        Source/WebCore/platform/graphics/Path.cpp \
     
    59975992if TARGET_X11
    59985993webcoregtk_sources += \
    5999         Source/WebCore/platform/graphics/glx/GLContextGLX.cpp \
    6000         Source/WebCore/platform/graphics/glx/GLContextGLX.h \
    60015994        Source/WebCore/platform/graphics/cairo/GLContext.cpp \
    60025995        Source/WebCore/platform/graphics/cairo/GLContext.h \
     
    60096002        Source/WebCore/plugins/gtk/PluginViewGtk.cpp \
    60106003        Source/WebCore/plugins/gtk/xembed.h
     6004if USE_EGL
     6005webcoregtk_sources += \
     6006        Source/WebCore/platform/graphics/egl/GLContextEGL.cpp \
     6007        Source/WebCore/platform/graphics/egl/GLContextEGL.h
     6008endif # END USE_EGL
     6009if USE_GLX
     6010webcoregtk_sources += \
     6011        Source/WebCore/platform/graphics/glx/GLContextGLX.cpp \
     6012        Source/WebCore/platform/graphics/glx/GLContextGLX.h
     6013endif # END USE_GLX
    60116014else
    60126015if TARGET_WIN32
     
    60386041endif # END TARGET_WIN32
    60396042endif # END TARGET_X11
     6043
     6044if USE_GLES2
     6045webcore_sources += \
     6046        Source/WebCore/platform/graphics/opengl/Extensions3DOpenGLES.cpp \
     6047        Source/WebCore/platform/graphics/opengl/Extensions3DOpenGLES.h \
     6048        Source/WebCore/platform/graphics/opengl/GraphicsContext3DOpenGLES.cpp \
     6049        Source/WebCore/platform/graphics/OpenGLESShims.h
     6050else
     6051webcore_sources += \
     6052        Source/WebCore/platform/graphics/opengl/Extensions3DOpenGL.cpp \
     6053        Source/WebCore/platform/graphics/opengl/Extensions3DOpenGL.h \
     6054        Source/WebCore/platform/graphics/opengl/GraphicsContext3DOpenGL.cpp \
     6055        Source/WebCore/platform/graphics/OpenGLShims.cpp \
     6056        Source/WebCore/platform/graphics/OpenGLShims.h
     6057endif # END USE_GLES2
    60406058
    60416059# ----
  • trunk/Source/WebCore/platform/graphics/GraphicsContext3D.h

    r130417 r130525  
    396396        DEPTH_STENCIL = 0x84F9,
    397397        UNSIGNED_INT_24_8 = 0x84FA,
     398        DEPTH24_STENCIL8 = 0x88F0,
    398399        RENDERBUFFER_WIDTH = 0x8D42,
    399400        RENDERBUFFER_HEIGHT = 0x8D43,
     
    10221023#endif
    10231024
    1024 #if PLATFORM(BLACKBERRY) || (PLATFORM(QT) && defined(QT_OPENGL_ES_2))
     1025#if PLATFORM(BLACKBERRY) || (PLATFORM(QT) && defined(QT_OPENGL_ES_2)) || (PLATFORM(GTK) && USE(OPENGL_ES_2))
    10251026    friend class Extensions3DOpenGLES;
    10261027    OwnPtr<Extensions3DOpenGLES> m_extensions;
  • trunk/Source/WebCore/platform/graphics/OpenGLESShims.h

    r125039 r130525  
    2727#define OpenGLESShims_h
    2828
    29 #if PLATFORM(BLACKBERRY) || PLATFORM(QT)
     29#if PLATFORM(BLACKBERRY) || PLATFORM(QT) || PLATFORM(GTK)
    3030#define glBindFramebufferEXT glBindFramebuffer
    3131#define glFramebufferTexture2DEXT glFramebufferTexture2D
  • trunk/Source/WebCore/platform/graphics/cairo/GLContext.cpp

    r127118 r130525  
    2222#if USE(OPENGL)
    2323
     24#include "GLContextEGL.h"
     25#include "GLContextGLX.h"
    2426#include <wtf/MainThread.h>
    2527
    26 #if USE(GLX)
    27 #include "GLContextGLX.h"
     28#if PLATFORM(X11)
     29#include <X11/Xlib.h>
    2830#endif
    2931
     
    3739}
    3840
     41#if PLATFORM(X11)
     42// We do not want to call glXMakeContextCurrent using different Display pointers,
     43// because it might lead to crashes in some drivers (fglrx). We use a shared display
     44// pointer here.
     45static Display* gSharedX11Display = 0;
     46Display* GLContext::sharedX11Display()
     47{
     48    if (!gSharedX11Display)
     49        gSharedX11Display = XOpenDisplay(0);
     50    return gSharedX11Display;
     51}
     52
     53void GLContext::cleanupSharedX11Display()
     54{
     55    if (!gSharedX11Display)
     56        return;
     57    XCloseDisplay(gSharedX11Display);
     58    gSharedX11Display = 0;
     59}
     60#endif // PLATFORM(X11)
     61
     62// Because of driver bugs, exiting the program when there are active pbuffers
     63// can crash the X server (this has been observed with the official Nvidia drivers).
     64// We need to ensure that we clean everything up on exit. There are several reasons
     65// that GraphicsContext3Ds will still be alive at exit, including user error (memory
     66// leaks) and the page cache. In any case, we don't want the X server to crash.
     67typedef Vector<GLContext*> ActiveContextList;
     68static ActiveContextList& activeContextList()
     69{
     70    DEFINE_STATIC_LOCAL(ActiveContextList, activeContexts, ());
     71    return activeContexts;
     72}
     73
     74void GLContext::addActiveContext(GLContext* context)
     75{
     76    static bool addedAtExitHandler = false;
     77    if (!addedAtExitHandler) {
     78        atexit(&GLContext::cleanupActiveContextsAtExit);
     79        addedAtExitHandler = true;
     80    }
     81    activeContextList().append(context);
     82}
     83
     84static bool gCleaningUpAtExit = false;
     85
     86void GLContext::removeActiveContext(GLContext* context)
     87{
     88    // If we are cleaning up the context list at exit, don't bother removing the context
     89    // from the list, since we don't want to modify the list while it's being iterated.
     90    if (gCleaningUpAtExit)
     91        return;
     92
     93    ActiveContextList& contextList = activeContextList();
     94    size_t i = contextList.find(context);
     95    if (i != notFound)
     96        contextList.remove(i);
     97}
     98
     99void GLContext::cleanupActiveContextsAtExit()
     100{
     101    gCleaningUpAtExit = true;
     102
     103    ActiveContextList& contextList = activeContextList();
     104    for (size_t i = 0; i < contextList.size(); ++i)
     105        delete contextList[i];
     106
     107#if PLATFORM(X11)
     108    cleanupSharedX11Display();
     109#endif
     110}
     111
     112
     113
    39114PassOwnPtr<GLContext> GLContext::createContextForWindow(uint64_t windowHandle, GLContext* sharingContext)
    40115{
    41116#if USE(GLX)
    42     return GLContextGLX::createContext(windowHandle, sharingContext);
     117    if (OwnPtr<GLContext> glxContext = GLContextGLX::createContext(windowHandle, sharingContext))
     118        return glxContext.release();
     119#endif
     120#if USE(EGL)
     121    if (OwnPtr<GLContext> eglContext = GLContextEGL::createContext(windowHandle, sharingContext))
     122        return eglContext.release();
    43123#endif
    44124    return nullptr;
     
    47127GLContext::GLContext()
    48128{
     129    addActiveContext(this);
    49130}
    50131
    51 PassOwnPtr<GLContext> GLContext::createOffscreenContext(GLContext* sharing)
     132PassOwnPtr<GLContext> GLContext::createOffscreenContext(GLContext* sharingContext)
    52133{
    53134#if USE(GLX)
    54     return GLContextGLX::createContext(0, sharing);
     135    if (OwnPtr<GLContext> glxContext = GLContextGLX::createContext(0, sharingContext))
     136        return glxContext.release();
     137#endif
     138#if USE(EGL)
     139    if (OwnPtr<GLContext> eglContext = GLContextEGL::createContext(0, sharingContext))
     140        return eglContext.release();
    55141#endif
    56142    return nullptr;
     
    65151    if (this == gCurrentContext)
    66152        gCurrentContext = 0;
     153    removeActiveContext(this);
    67154}
    68155
  • trunk/Source/WebCore/platform/graphics/cairo/GLContext.h

    r122175 r130525  
    2626#include <wtf/PassOwnPtr.h>
    2727
     28#if PLATFORM(X11)
     29typedef struct _XDisplay Display;
     30#endif
     31
    2832namespace WebCore {
    2933
     
    4044    virtual bool makeContextCurrent();
    4145    virtual void swapBuffers() = 0;
     46    virtual void waitNative() = 0;
    4247    virtual bool canRenderToDefaultFramebuffer() = 0;
    4348    virtual IntSize defaultFrameBufferSize() = 0;
     49
     50#if PLATFORM(X11)
     51    static Display* sharedX11Display();
     52    static void cleanupSharedX11Display();
     53#endif
     54
     55    static void addActiveContext(GLContext*);
     56    static void removeActiveContext(GLContext*);
     57    static void cleanupActiveContextsAtExit();
    4458
    4559#if USE(3D_GRAPHICS)
  • trunk/Source/WebCore/platform/graphics/cairo/GraphicsContext3DCairo.cpp

    r127044 r130525  
    3131#if USE(3D_GRAPHICS)
    3232
    33 #include "Extensions3DOpenGL.h"
    3433#include "GraphicsContext3DPrivate.h"
    3534#include "Image.h"
    3635#include "ImageSource.h"
    3736#include "NotImplemented.h"
    38 #include "OpenGLShims.h"
    3937#include "PlatformContextCairo.h"
    4038#include "RefPtrCairo.h"
     
    4543#include <wtf/PassOwnPtr.h>
    4644
     45#if USE(OPENGL_ES_2)
     46#include "Extensions3DOpenGLES.h"
     47#else
     48#include "Extensions3DOpenGL.h"
     49#include "OpenGLShims.h"
     50#endif
     51
    4752namespace WebCore {
    4853
     
    5661    static bool success = true;
    5762    if (!initialized) {
     63#if !USE(OPENGL_ES_2)
    5864        success = initializeOpenGLShims();
     65#endif
    5966        initialized = true;
    6067    }
     
    9198        ::glTexParameterf(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_LINEAR);
    9299        ::glTexParameterf(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_LINEAR);
    93         ::glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_CLAMP);
    94         ::glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_CLAMP);
     100        ::glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_CLAMP_TO_EDGE);
     101        ::glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_CLAMP_TO_EDGE);
    95102        ::glBindTexture(GL_TEXTURE_2D, 0);
    96103
    97104        // Create an FBO.
    98         ::glGenFramebuffersEXT(1, &m_fbo);
    99         ::glBindFramebufferEXT(GL_FRAMEBUFFER_EXT, m_fbo);
     105        ::glGenFramebuffers(1, &m_fbo);
     106        ::glBindFramebuffer(GL_FRAMEBUFFER, m_fbo);
    100107
    101108        m_boundFBO = m_fbo;
    102109        if (!m_attrs.antialias && (m_attrs.stencil || m_attrs.depth))
    103             ::glGenRenderbuffersEXT(1, &m_depthStencilBuffer);
     110            ::glGenRenderbuffers(1, &m_depthStencilBuffer);
    104111
    105112        // Create a multisample FBO.
    106113        if (m_attrs.antialias) {
    107             ::glGenFramebuffersEXT(1, &m_multisampleFBO);
    108             ::glBindFramebufferEXT(GL_FRAMEBUFFER_EXT, m_multisampleFBO);
     114            ::glGenFramebuffers(1, &m_multisampleFBO);
     115            ::glBindFramebuffer(GL_FRAMEBUFFER, m_multisampleFBO);
    109116            m_boundFBO = m_multisampleFBO;
    110             ::glGenRenderbuffersEXT(1, &m_multisampleColorBuffer);
     117            ::glGenRenderbuffers(1, &m_multisampleColorBuffer);
    111118            if (m_attrs.stencil || m_attrs.depth)
    112                 ::glGenRenderbuffersEXT(1, &m_multisampleDepthStencilBuffer);
     119                ::glGenRenderbuffers(1, &m_multisampleDepthStencilBuffer);
    113120        }
    114121    }
     
    130137    m_compiler.setResources(ANGLEResources);
    131138
     139#if !USE(OPENGL_ES_2)
    132140    ::glEnable(GL_VERTEX_PROGRAM_POINT_SIZE);
    133141    ::glEnable(GL_POINT_SPRITE);
     142#endif
     143
    134144    ::glClearColor(0, 0, 0, 0);
    135145}
     
    143153    ::glDeleteTextures(1, &m_texture);
    144154    if (m_attrs.antialias) {
    145         ::glDeleteRenderbuffersEXT(1, &m_multisampleColorBuffer);
     155        ::glDeleteRenderbuffers(1, &m_multisampleColorBuffer);
    146156        if (m_attrs.stencil || m_attrs.depth)
    147             ::glDeleteRenderbuffersEXT(1, &m_multisampleDepthStencilBuffer);
    148         ::glDeleteFramebuffersEXT(1, &m_multisampleFBO);
     157            ::glDeleteRenderbuffers(1, &m_multisampleDepthStencilBuffer);
     158        ::glDeleteFramebuffers(1, &m_multisampleFBO);
    149159    } else {
    150160        if (m_attrs.stencil || m_attrs.depth)
    151             ::glDeleteRenderbuffersEXT(1, &m_depthStencilBuffer);
    152     }
    153     ::glDeleteFramebuffersEXT(1, &m_fbo);
    154 }
    155 
    156 void GraphicsContext3D::releaseShaderCompiler()
    157 {
    158     notImplemented();
     161            ::glDeleteRenderbuffers(1, &m_depthStencilBuffer);
     162    }
     163    ::glDeleteFramebuffers(1, &m_fbo);
    159164}
    160165
     
    259264bool GraphicsContext3D::isGLES2Compliant() const
    260265{
     266#if USE(OPENGL_ES_2)
     267    return true;
     268#else
    261269    return false;
     270#endif
    262271}
    263272
  • trunk/Source/WebCore/platform/graphics/cairo/GraphicsContext3DPrivate.cpp

    r127465 r130525  
    2525#include "HostWindow.h"
    2626#include "NotImplemented.h"
    27 #include "OpenGLShims.h"
    2827#include "PlatformContextCairo.h"
    2928#include <wtf/OwnArrayPtr.h>
     29
     30#if USE(OPENGL_ES_2)
     31#include <GLES2/gl2.h>
     32#include <GLES2/gl2ext.h>
     33#else
     34#include "OpenGLShims.h"
     35#endif
    3036
    3137#if USE(ACCELERATED_COMPOSITING) && USE(TEXTURE_MAPPER) && USE(TEXTURE_MAPPER_GL)
     
    126132
    127133        m_context->resolveMultisamplingIfNecessary();
    128         glBindFramebuffer(GraphicsContext3D::FRAMEBUFFER, m_context->m_boundFBO);
     134        ::glBindFramebuffer(GraphicsContext3D::FRAMEBUFFER, m_context->m_boundFBO);
    129135
    130136        if (previousActiveContext && previousActiveContext != m_glContext)
  • trunk/Source/WebCore/platform/graphics/clutter/GraphicsContext3DClutter.cpp

    r126635 r130525  
    5757}
    5858
    59 void GraphicsContext3D::releaseShaderCompiler()
    60 {
    61     notImplemented();
    62 }
    63 
    6459bool GraphicsContext3D::getImageData(Image* image, unsigned int format, unsigned int type, bool premultiplyAlpha, bool ignoreGammaAndColorProfile, Vector<uint8_t>& outputVector)
    6560{
  • trunk/Source/WebCore/platform/graphics/efl/GraphicsContext3DEfl.cpp

    r126635 r130525  
    475475}
    476476
    477 void GraphicsContext3D::releaseShaderCompiler()
    478 {
    479     notImplemented();
    480 }
    481 
    482477void GraphicsContext3D::renderbufferStorage(GC3Denum target, GC3Denum internalformat, GC3Dsizei width, GC3Dsizei height)
    483478{
  • trunk/Source/WebCore/platform/graphics/glx/GLContextGLX.cpp

    r126182 r130525  
    2828namespace WebCore {
    2929
    30 // We do not want to call glXMakeContextCurrent using different Display pointers,
    31 // because it might lead to crashes in some drivers (fglrx). We use a shared display
    32 // pointer here.
    33 static Display* gSharedDisplay = 0;
    34 Display* GLContextGLX::sharedDisplay()
    35 {
    36     if (!gSharedDisplay)
    37         gSharedDisplay = XOpenDisplay(0);
    38     return gSharedDisplay;
    39 }
    40 
    41 // Because of driver bugs, exiting the program when there are active pbuffers
    42 // can crash the X server (this has been observed with the official Nvidia drivers).
    43 // We need to ensure that we clean everything up on exit. There are several reasons
    44 // that GraphicsContext3Ds will still be alive at exit, including user error (memory
    45 // leaks) and the page cache. In any case, we don't want the X server to crash.
    46 typedef Vector<GLContext*> ActiveContextList;
    47 static ActiveContextList& activeContextList()
    48 {
    49     DEFINE_STATIC_LOCAL(ActiveContextList, activeContexts, ());
    50     return activeContexts;
    51 }
    52 
    53 void GLContextGLX::addActiveContext(GLContextGLX* context)
    54 {
    55     static bool addedAtExitHandler = false;
    56     if (!addedAtExitHandler) {
    57         atexit(&GLContextGLX::cleanupActiveContextsAtExit);
    58         addedAtExitHandler = true;
    59     }
    60     activeContextList().append(context);
    61 }
    62 
    63 static bool gCleaningUpAtExit = false;
    64 
    65 void GLContextGLX::removeActiveContext(GLContext* context)
    66 {
    67     // If we are cleaning up the context list at exit, don't bother removing the context
    68     // from the list, since we don't want to modify the list while it's being iterated.
    69     if (gCleaningUpAtExit)
    70         return;
    71 
    72     ActiveContextList& contextList = activeContextList();
    73     size_t i = contextList.find(context);
    74     if (i != notFound)
    75         contextList.remove(i);
    76 }
    77 
    78 void GLContextGLX::cleanupActiveContextsAtExit()
    79 {
    80     gCleaningUpAtExit = true;
    81 
    82     ActiveContextList& contextList = activeContextList();
    83     for (size_t i = 0; i < contextList.size(); ++i)
    84         delete contextList[i];
    85 
    86     if (!gSharedDisplay)
    87         return;
    88     XCloseDisplay(gSharedDisplay);
    89     gSharedDisplay = 0;
    90 }
    91 
    9230PassOwnPtr<GLContextGLX> GLContextGLX::createWindowContext(XID window, GLContext* sharingContext)
    9331{
    94     Display* display = sharedDisplay();
     32    Display* display = sharedX11Display();
    9533    XWindowAttributes attributes;
    9634    if (!XGetWindowAttributes(display, window, &attributes))
     
    13169
    13270    int returnedElements;
    133     Display* display = sharedDisplay();
     71    Display* display = sharedX11Display();
    13472    GLXFBConfig* configs = glXChooseFBConfig(display, 0, fbConfigAttributes, &returnedElements);
    13573    if (!returnedElements) {
     
    171109    };
    172110
    173     Display* display = sharedDisplay();
     111    Display* display = sharedX11Display();
    174112    XVisualInfo* visualInfo = glXChooseVisual(display, DefaultScreen(display), visualAttributes);
    175113    if (!visualInfo)
     
    201139PassOwnPtr<GLContextGLX> GLContextGLX::createContext(XID window, GLContext* sharingContext)
    202140{
    203     if (!sharedDisplay())
     141    if (!sharedX11Display())
    204142        return nullptr;
    205143
     
    232170    , m_glxPixmap(0)
    233171{
    234     addActiveContext(this);
    235172}
    236173
     
    242179    , m_glxPixmap(glxPixmap)
    243180{
    244     addActiveContext(this);
    245181}
    246182
     
    251187        // from Mozilla's 3D canvas implementation at: http://bitbucket.org/ilmari/canvas3d/
    252188        glBindFramebufferEXT(GL_FRAMEBUFFER_EXT, 0);
    253         glXMakeCurrent(sharedDisplay(), None, None);
    254         glXDestroyContext(sharedDisplay(), m_context);
     189        glXMakeCurrent(sharedX11Display(), None, None);
     190        glXDestroyContext(sharedX11Display(), m_context);
    255191    }
    256192
    257193    if (m_pbuffer) {
    258         glXDestroyPbuffer(sharedDisplay(), m_pbuffer);
     194        glXDestroyPbuffer(sharedX11Display(), m_pbuffer);
    259195        m_pbuffer = 0;
    260196    }
    261197    if (m_glxPixmap) {
    262         glXDestroyGLXPixmap(sharedDisplay(), m_glxPixmap);
     198        glXDestroyGLXPixmap(sharedX11Display(), m_glxPixmap);
    263199        m_glxPixmap = 0;
    264200    }
    265201    if (m_pixmap) {
    266         XFreePixmap(sharedDisplay(), m_pixmap);
     202        XFreePixmap(sharedX11Display(), m_pixmap);
    267203        m_pixmap = 0;
    268204    }
    269     removeActiveContext(this);
    270205}
    271206
     
    283218    Window rootWindow;
    284219    unsigned int width, height, borderWidth, depth;
    285     if (!XGetGeometry(sharedDisplay(), m_window, &rootWindow, &x, &y, &width, &height, &borderWidth, &depth))
     220    if (!XGetGeometry(sharedX11Display(), m_window, &rootWindow, &x, &y, &width, &height, &borderWidth, &depth))
    286221        return IntSize();
    287222
     
    298233
    299234    if (m_window)
    300         return glXMakeCurrent(sharedDisplay(), m_window, m_context);
     235        return glXMakeCurrent(sharedX11Display(), m_window, m_context);
    301236
    302237    if (m_pbuffer)
    303         return glXMakeCurrent(sharedDisplay(), m_pbuffer, m_context);
    304 
    305     return ::glXMakeCurrent(sharedDisplay(), m_glxPixmap, m_context);
     238        return glXMakeCurrent(sharedX11Display(), m_pbuffer, m_context);
     239
     240    return ::glXMakeCurrent(sharedX11Display(), m_glxPixmap, m_context);
    306241}
    307242
     
    309244{
    310245    if (m_window)
    311         glXSwapBuffers(sharedDisplay(), m_window);
     246        glXSwapBuffers(sharedX11Display(), m_window);
     247}
     248
     249void GLContextGLX::waitNative()
     250{
     251    glXWaitX();
    312252}
    313253
  • trunk/Source/WebCore/platform/graphics/glx/GLContextGLX.h

    r126182 r130525  
    2626
    2727typedef struct __GLXcontextRec* GLXContext;
    28 typedef struct _XDisplay Display;
    2928typedef struct __GLXcontextRec *GLXContext;
    3029typedef unsigned long GLXPbuffer;
     
    4645    virtual bool makeContextCurrent();
    4746    virtual void swapBuffers();
     47    virtual void waitNative();
    4848    virtual bool canRenderToDefaultFramebuffer();
    4949    virtual IntSize defaultFrameBufferSize();
    50 
    51     static Display* sharedDisplay();
    5250
    5351#if USE(3D_GRAPHICS)
     
    5856    static PassOwnPtr<GLContextGLX> createPbufferContext(GLXContext sharingContext);
    5957    static PassOwnPtr<GLContextGLX> createPixmapContext(GLXContext sharingContext);
    60     static void removeActiveContext(GLContext*);
    61 
    62     static void addActiveContext(GLContextGLX*);
    63     static void cleanupActiveContextsAtExit();
    6458
    6559    GLContextGLX(GLXContext);
  • trunk/Source/WebCore/platform/graphics/mac/GraphicsContext3DMac.mm

    r126635 r130525  
    278278}
    279279
    280 void GraphicsContext3D::releaseShaderCompiler()
    281 {
    282     makeContextCurrent();
    283     notImplemented();
    284 }
    285 
    286280}
    287281
  • trunk/Source/WebCore/platform/graphics/opengl/GraphicsContext3DOpenGL.cpp

    r130235 r130525  
    4949
    5050namespace WebCore {
     51
     52void GraphicsContext3D::releaseShaderCompiler()
     53{
     54    makeContextCurrent();
     55    notImplemented();
     56}
    5157
    5258void GraphicsContext3D::readPixelsAndConvertToBGRAIfNecessary(int x, int y, int width, int height, unsigned char* pixels)
  • trunk/Source/WebCore/platform/graphics/opengl/GraphicsContext3DOpenGLES.cpp

    r130252 r130525  
    4040#endif
    4141#include "NotImplemented.h"
    42 #include "OpenGLESShims.h"
    4342
    4443namespace WebCore {
     
    6766    if (m_attrs.antialias && m_boundFBO == m_multisampleFBO) {
    6867         resolveMultisamplingIfNecessary(IntRect(x, y, width, height));
    69         ::glBindFramebufferEXT(GL_FRAMEBUFFER_EXT, m_fbo);
     68        ::glBindFramebuffer(GL_FRAMEBUFFER, m_fbo);
    7069        ::glFlush();
    7170    }
     
    7473
    7574    if (m_attrs.antialias && m_boundFBO == m_multisampleFBO)
    76         ::glBindFramebufferEXT(GraphicsContext3D::FRAMEBUFFER, m_multisampleFBO);
     75        ::glBindFramebuffer(GL_FRAMEBUFFER, m_multisampleFBO);
    7776#endif
    7877}
     
    123122    if (m_boundFBO != m_fbo) {
    124123        mustRestoreFBO = true;
    125         ::glBindFramebufferEXT(GraphicsContext3D::FRAMEBUFFER, m_fbo);
     124        ::glBindFramebuffer(GL_FRAMEBUFFER, m_fbo);
    126125    }
    127126
    128127    ::glBindTexture(GL_TEXTURE_2D, m_texture);
    129128    ::glTexImage2D(GL_TEXTURE_2D, 0, m_internalColorFormat, width, height, 0, colorFormat, pixelDataType, 0);
    130     ::glFramebufferTexture2DEXT(GraphicsContext3D::FRAMEBUFFER, GraphicsContext3D::COLOR_ATTACHMENT0, GL_TEXTURE_2D, m_texture, 0);
     129    ::glFramebufferTexture2D(GL_FRAMEBUFFER, GL_COLOR_ATTACHMENT0, GL_TEXTURE_2D, m_texture, 0);
    131130
    132131    ::glBindTexture(GL_TEXTURE_2D, m_compositorTexture);
     
    140139        // Use a 24 bit depth buffer where we know we have it.
    141140        if (supportPackedDepthStencilBuffer) {
    142             ::glBindTexture(GL_TEXTURE_2D, m_depthStencilBuffer);
    143             ::glTexImage2D(GL_TEXTURE_2D, 0, GraphicsContext3D::DEPTH_STENCIL, width, height, 0, GraphicsContext3D::DEPTH_STENCIL, GraphicsContext3D::UNSIGNED_INT_24_8, 0);
     141            ::glBindRenderbuffer(GL_RENDERBUFFER, m_depthStencilBuffer);
     142            ::glRenderbufferStorage(GL_RENDERBUFFER, GL_DEPTH24_STENCIL8_OES, width, height);
    144143            if (m_attrs.stencil)
    145                 ::glFramebufferTexture2D(GL_FRAMEBUFFER, GL_STENCIL_ATTACHMENT, GL_TEXTURE_2D, m_depthStencilBuffer, 0);
     144                ::glFramebufferRenderbuffer(GL_FRAMEBUFFER, GL_STENCIL_ATTACHMENT, GL_RENDERBUFFER, m_depthStencilBuffer);
    146145            if (m_attrs.depth)
    147                 ::glFramebufferTexture2D(GL_FRAMEBUFFER, GL_DEPTH_ATTACHMENT, GL_TEXTURE_2D, m_depthStencilBuffer, 0);
    148             ::glBindTexture(GL_TEXTURE_2D, 0);
     146                ::glFramebufferRenderbuffer(GL_FRAMEBUFFER, GL_DEPTH_ATTACHMENT, GL_RENDERBUFFER, m_depthStencilBuffer);
     147            ::glBindRenderbuffer(GL_RENDERBUFFER, 0);
    149148        } else {
    150149            if (m_attrs.stencil) {
    151                 ::glBindRenderbufferEXT(GraphicsContext3D::RENDERBUFFER, m_stencilBuffer);
    152                 ::glRenderbufferStorageEXT(GraphicsContext3D::RENDERBUFFER, GL_STENCIL_INDEX8, width, height);
    153                 ::glFramebufferRenderbufferEXT(GraphicsContext3D::FRAMEBUFFER, GraphicsContext3D::STENCIL_ATTACHMENT, GraphicsContext3D::RENDERBUFFER, m_stencilBuffer);
     150                ::glBindRenderbuffer(GL_RENDERBUFFER, m_stencilBuffer);
     151                ::glRenderbufferStorage(GL_RENDERBUFFER, GL_STENCIL_INDEX8, width, height);
     152                ::glFramebufferRenderbuffer(GL_FRAMEBUFFER, GL_STENCIL_ATTACHMENT, GL_RENDERBUFFER, m_stencilBuffer);
    154153            }
    155154            if (m_attrs.depth) {
    156                 ::glBindRenderbufferEXT(GraphicsContext3D::RENDERBUFFER, m_depthBuffer);
    157                 ::glRenderbufferStorageEXT(GraphicsContext3D::RENDERBUFFER, GL_DEPTH_COMPONENT16, width, height);
    158                 ::glFramebufferRenderbufferEXT(GraphicsContext3D::FRAMEBUFFER, GraphicsContext3D::DEPTH_ATTACHMENT, GraphicsContext3D::RENDERBUFFER, m_depthBuffer);
     155                ::glBindRenderbuffer(GL_RENDERBUFFER, m_depthBuffer);
     156                ::glRenderbufferStorage(GL_RENDERBUFFER, GL_DEPTH_COMPONENT16, width, height);
     157                ::glFramebufferRenderbuffer(GL_FRAMEBUFFER, GL_DEPTH_ATTACHMENT, GL_RENDERBUFFER, m_depthBuffer);
    159158            }
    160             ::glBindRenderbufferEXT(GraphicsContext3D::RENDERBUFFER, 0);
     159            ::glBindRenderbuffer(GL_RENDERBUFFER, 0);
    161160        }
    162161    }
    163     if (glCheckFramebufferStatusEXT(GraphicsContext3D::FRAMEBUFFER) != GraphicsContext3D::FRAMEBUFFER_COMPLETE) {
     162    if (glCheckFramebufferStatus(GL_FRAMEBUFFER) != GL_FRAMEBUFFER_COMPLETE) {
    164163        // FIXME: cleanup
    165164        notImplemented();
     
    179178{
    180179    makeContextCurrent();
    181     ::glRenderbufferStorageEXT(target, internalformat, width, height);
     180    ::glRenderbufferStorage(target, internalformat, width, height);
    182181}
    183182
  • trunk/Source/WebCore/platform/graphics/qt/GraphicsContext3DQt.cpp

    r128315 r130525  
    100100#endif
    101101}
    102 
    103 #if !USE(OPENGL_ES_2)
    104 void GraphicsContext3D::releaseShaderCompiler()
    105 {
    106     notImplemented();
    107 }
    108 #endif
    109102
    110103GraphicsContext3DPrivate::GraphicsContext3DPrivate(GraphicsContext3D* context, HostWindow* hostWindow, GraphicsContext3D::RenderStyle renderStyle)
  • trunk/Source/WebCore/platform/graphics/texmap/TextureMapper.h

    r129993 r130525  
    2828    #define TEXMAP_OPENGL_ES_2
    2929#endif
     30#endif
     31#if PLATFORM(GTK) && USE(OPENGL_ES_2)
     32#define TEXMAP_OPENGL_ES_2
    3033#endif
    3134
  • trunk/Source/WebCore/platform/gtk/RedirectedXCompositeWindow.cpp

    r129651 r130525  
    2828#include "RedirectedXCompositeWindow.h"
    2929
    30 #if USE(GLX)
    31 #include "GLContextGLX.h"
    32 #include <GL/glx.h>
     30#if PLATFORM(X11)
    3331#include <X11/extensions/Xcomposite.h>
    3432#include <X11/extensions/Xdamage.h>
     
    106104    , m_pixmap(0)
    107105    , m_surface(0)
    108     , m_pendingResizeSourceId(0)
    109106    , m_needsNewPixmapAfterResize(false)
    110107    , m_damage(0)
     
    112109    , m_damageNotifyData(0)
    113110{
    114     Display* display = GDK_DISPLAY_XDISPLAY(gdk_display_get_default());
     111    Display* display = GLContext::sharedX11Display();
    115112
    116113    // This is based on code from Chromium: src/content/common/gpu/image_transport_surface_linux.cc
     
    166163        gdk_window_remove_filter(0, reinterpret_cast<GdkFilterFunc>(filterXDamageEvent), 0);
    167164
    168     Display* display = GDK_DISPLAY_XDISPLAY(gdk_display_get_default());
     165    Display* display = GLContext::sharedX11Display();
    169166    XDamageDestroy(display, m_damage);
    170167    XDestroyWindow(display, m_window);
     
    175172void RedirectedXCompositeWindow::resize(const IntSize& size)
    176173{
    177     Display* display = GDK_DISPLAY_XDISPLAY(gdk_display_get_default());
     174    Display* display = GLContext::sharedX11Display();
    178175    XResizeWindow(display, m_window, size.width(), size.height());
    179176
    180177    XFlush(display);
    181     glXWaitX();
     178    context()->waitNative();
    182179
    183180    // This swap is based on code in Chromium. It tries to work-around a bug in the Intel drivers
     
    264261} // namespace WebCore
    265262
    266 #endif // USE(GLX)
     263#endif // PLATFORM(X11)
  • trunk/Source/WebCore/platform/gtk/RedirectedXCompositeWindow.h

    r129651 r130525  
    2828#define  RedirectedXCompositeWindow_h
    2929
    30 #if USE(GLX)
     30#if PLATFORM(X11)
    3131
    32 #include "GLContextGLX.h"
     32#include "GLContext.h"
    3333#include "IntSize.h"
    3434#include "RefPtrCairo.h"
     
    7979} // namespace WebCore
    8080
    81 #endif // USE(GLX)
     81#endif // PLATFORM(X11)
    8282
    8383#endif // RedirectedXCompositeWindow_h
  • trunk/Source/WebKit2/ChangeLog

    r130523 r130525  
     12012-10-05  José Dapena Paz  <jdapena@igalia.com>
     2
     3        [GTK] Add support for creating EGL contexts
     4        https://bugs.webkit.org/show_bug.cgi?id=77921
     5
     6        Reviewed by Martin Robinson.
     7
     8        This patch adds support for EGL, using OpenGL and OpenGL ES 2. Both
     9        options are set up on compile time, with the configure options
     10        --enable-egl and --enable-gles2.
     11
     12        The implementation only adds support for EGL on top of X11, to
     13        isolate the changes to the minimum. More changes should come
     14        later to enable EGL for other targets (as Wayland).
     15
     16        * WebProcess/WebPage/gtk/LayerTreeHostGtk.cpp:
     17
    1182012-10-04  Jon Lee  <jonlee@apple.com>
    219
  • trunk/Source/WebKit2/WebProcess/WebPage/gtk/LayerTreeHostGtk.cpp

    r130439 r130525  
    3737#include <WebCore/Frame.h>
    3838#include <WebCore/FrameView.h>
    39 #include <WebCore/GLContextGLX.h>
     39#include <WebCore/GLContext.h>
    4040#include <WebCore/Page.h>
    4141#include <WebCore/Settings.h>
  • trunk/configure.ac

    r129651 r130525  
    548548AC_MSG_RESULT([$enable_unstable_features])
    549549
    550 found_opengl="no"
    551 if test "$with_target" = "x11"; then
     550found_opengl=no
     551AC_ARG_ENABLE(glx,
     552              AC_HELP_STRING([--enable-glx], [enable support for GLX [default=auto]]),
     553              [], [enable_glx="auto"])
     554AC_ARG_ENABLE(egl,
     555              AC_HELP_STRING([--enable-egl], [enable support for EGL [default=auto]]),
     556              [], [enable_egl="auto"])
     557AC_ARG_ENABLE(gles2,
     558              AC_HELP_STRING([--enable-gles2], [enable support for OpenGL ES 2 [default=auto]]),
     559              [], [enable_gles2="auto"])
     560
     561have_glx=no
     562AC_CHECK_HEADERS([GL/glx.h], [have_glx="yes"], [have_glx="no"])
     563AC_MSG_CHECKING([whether to enable GLX support])
     564if test "$enable_glx" != "no"; then
     565   if test "$have_glx" = "no"; then
     566      if test "$enable_glx" = "yes"; then
     567         AC_MSG_ERROR([--enable-glx specified, but not available])
     568      else
     569         enable_glx=no
     570      fi
     571   elif test "$enable_gles2" != "yes"; then
     572      enable_glx=yes
     573   fi
     574fi
     575AC_MSG_RESULT([$enable_glx])
     576
     577have_egl=no
     578AC_CHECK_HEADERS([EGL/egl.h], [have_egl="yes"], [have_egl="no"])
     579AC_MSG_CHECKING([whether to enable EGL support])
     580if test "$enable_egl" != "no"; then
     581   if test "$have_egl" = "no"; then
     582      if test "$enable_egl" = "yes"; then
     583         AC_MSG_ERROR([--enable-egl specified, but not available])
     584      else
     585         enable_egl=no
     586      fi
     587   else
     588      enable_egl=yes
     589   fi
     590fi
     591AC_MSG_RESULT([$enable_egl])
     592
     593have_gles2=no
     594AC_CHECK_HEADERS([GLES2/gl2.h], [have_gles2="yes"], [have_gles2="no"])
     595AC_MSG_CHECKING([whether to use OpenGL ES 2 support])
     596if test "$enable_glx" = "yes"; then
     597   if test "$enable_gles2" = "yes"; then
     598      AC_MSG_ERROR([Cannot enable OpenGL ES 2 support with GLX])
     599   else
     600      enable_gles2=no
     601   fi
     602fi
     603if test "$enable_egl" = "no"; then
     604   if test "$enable_gles2" = "yes"; then
     605      AC_MSG_ERROR([Cannot enable OpenGL ES 2 support without EGL])
     606   else
     607      enable_gles2=no
     608   fi
     609fi
     610if test "$enable_gles2" != "no"; then
     611   if test "$have_gles2" = "no"; then
     612      if test "$enable_gles2" = "yes"; then
     613         AC_MSG_ERROR([--enable-gles2 specified, but not available])
     614      else
     615         enable_gles2=no
     616      fi
     617   else
     618      enable_gles2=yes
     619      found_opengl=yes
     620   fi
     621fi
     622AC_MSG_RESULT([$enable_gles2])
     623
     624if test "$enable_gles2" != "yes"; then
    552625    AC_CHECK_HEADERS([GL/gl.h], [found_opengl="yes"], [])
    553     AC_CHECK_HEADERS([GL/glx.h], [], [found_opengl="no"])
    554 fi
     626fi
     627
    555628AC_MSG_CHECKING([which GPU acceleration backend to use])
    556629AC_ARG_WITH(acceleration_backend,
     
    9271000fi
    9281001
    929 
     1002acceleration_backend_description=$with_acceleration_backend
    9301003if test "$with_acceleration_backend" = "clutter"; then
    9311004   PKG_CHECK_MODULES(CLUTTER, clutter-1.0 >= $CLUTTER_REQUIRED_VERSION)
     
    9401013
    9411014if test "$with_acceleration_backend" = "opengl"; then
    942     OPENGL_LIBS="-lGL -ldl"
     1015   if test "$enable_gles2" = "yes"; then
     1016    acceleration_backend_description+= "(gles2"
     1017    OPENGL_LIBS="-lGLESv2"
     1018   else
     1019    acceleration_backend_description+="(gl"
     1020    OPENGL_LIBS="-lGL"
     1021   fi
     1022   if test "$enable_egl" = "yes"; then
     1023    acceleration_backend_description+=", egl"
     1024    OPENGL_LIBS+=" -lEGL"
     1025   fi
     1026   if test "$enable_glx" = "yes"; then
     1027    acceleration_backend_description+=", glx"
     1028   fi
     1029   OPENGL_LIBS+=" -ldl"
     1030   acceleration_backend_description+=")"
    9431031fi
    9441032AC_SUBST([OPENGL_LIBS])
     
    10491137
    10501138# These are the same now, but they will soon be separate.
    1051 AM_CONDITIONAL([USE_GLX], [test "$with_acceleration_backend" = "opengl"])
    10521139AM_CONDITIONAL([USE_OPENGL], [test "$with_acceleration_backend" = "opengl"])
     1140AM_CONDITIONAL([USE_EGL], [test "$enable_egl" = "yes"])
     1141AM_CONDITIONAL([USE_GLES2], [test "$enable_gles2" = "yes"])
     1142AM_CONDITIONAL([USE_GLX], [test "$enable_glx" = "yes"])
    10531143
    10541144# IndexedDB implies LevelDB, but other features may one day require LevelDB.
     
    11291219 Font backend                                             : $with_font_backend
    11301220 Optimized memory allocator                               : $enable_fast_malloc
    1131  Accelerated rendering backend                            : $with_acceleration_backend
     1221 Accelerated rendering backend                            : $acceleration_backend_description
    11321222
    11331223Features:
Note: See TracChangeset for help on using the changeset viewer.