Changeset 130525 in webkit
- Timestamp:
- Oct 5, 2012 10:54:57 AM (12 years ago)
- Location:
- trunk
- Files:
-
- 3 added
- 25 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/ChangeLog
r130503 r130525 1 2012-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 1 19 2012-10-04 Rob Buis <rbuis@rim.com> 2 20 -
trunk/GNUmakefile.am
r127872 r130525 238 238 endif 239 239 240 if USE_EGL 241 global_cppflags += \ 242 -DWTF_USE_EGL=1 243 endif 244 245 if USE_GLES2 246 global_cppflags += \ 247 -DWTF_USE_OPENGL_ES_2=1 248 endif 249 240 250 if USE_OPENGL 241 251 global_cppflags += \ -
trunk/Source/WebCore/ChangeLog
r130523 r130525 1 2012-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 1 93 2012-10-04 Jon Lee <jonlee@apple.com> 2 94 -
trunk/Source/WebCore/GNUmakefile.am
r129969 r130525 113 113 -I$(srcdir)/Source/WebCore/platform/graphics/cairo \ 114 114 -I$(srcdir)/Source/WebCore/platform/graphics/glx \ 115 -I$(srcdir)/Source/WebCore/platform/graphics/egl \ 115 116 -I$(srcdir)/Source/WebCore/platform/graphics/gstreamer \ 116 117 -I$(srcdir)/Source/WebCore/platform/graphics/gtk \ -
trunk/Source/WebCore/GNUmakefile.list.am
r130471 r130525 4458 4458 Source/WebCore/platform/graphics/MediaPlayer.h \ 4459 4459 Source/WebCore/platform/graphics/MediaPlayerPrivate.h \ 4460 Source/WebCore/platform/graphics/opengl/Extensions3DOpenGL.cpp \4461 Source/WebCore/platform/graphics/opengl/Extensions3DOpenGL.h \4462 4460 Source/WebCore/platform/graphics/opengl/Extensions3DOpenGLCommon.cpp \ 4463 4461 Source/WebCore/platform/graphics/opengl/Extensions3DOpenGLCommon.h \ 4464 Source/WebCore/platform/graphics/opengl/GraphicsContext3DOpenGL.cpp \4465 4462 Source/WebCore/platform/graphics/opengl/GraphicsContext3DOpenGLCommon.cpp \ 4466 Source/WebCore/platform/graphics/OpenGLShims.cpp \4467 Source/WebCore/platform/graphics/OpenGLShims.h \4468 4463 Source/WebCore/platform/graphics/opentype/OpenTypeVerticalData.h \ 4469 4464 Source/WebCore/platform/graphics/Path.cpp \ … … 5997 5992 if TARGET_X11 5998 5993 webcoregtk_sources += \ 5999 Source/WebCore/platform/graphics/glx/GLContextGLX.cpp \6000 Source/WebCore/platform/graphics/glx/GLContextGLX.h \6001 5994 Source/WebCore/platform/graphics/cairo/GLContext.cpp \ 6002 5995 Source/WebCore/platform/graphics/cairo/GLContext.h \ … … 6009 6002 Source/WebCore/plugins/gtk/PluginViewGtk.cpp \ 6010 6003 Source/WebCore/plugins/gtk/xembed.h 6004 if USE_EGL 6005 webcoregtk_sources += \ 6006 Source/WebCore/platform/graphics/egl/GLContextEGL.cpp \ 6007 Source/WebCore/platform/graphics/egl/GLContextEGL.h 6008 endif # END USE_EGL 6009 if USE_GLX 6010 webcoregtk_sources += \ 6011 Source/WebCore/platform/graphics/glx/GLContextGLX.cpp \ 6012 Source/WebCore/platform/graphics/glx/GLContextGLX.h 6013 endif # END USE_GLX 6011 6014 else 6012 6015 if TARGET_WIN32 … … 6038 6041 endif # END TARGET_WIN32 6039 6042 endif # END TARGET_X11 6043 6044 if USE_GLES2 6045 webcore_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 6050 else 6051 webcore_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 6057 endif # END USE_GLES2 6040 6058 6041 6059 # ---- -
trunk/Source/WebCore/platform/graphics/GraphicsContext3D.h
r130417 r130525 396 396 DEPTH_STENCIL = 0x84F9, 397 397 UNSIGNED_INT_24_8 = 0x84FA, 398 DEPTH24_STENCIL8 = 0x88F0, 398 399 RENDERBUFFER_WIDTH = 0x8D42, 399 400 RENDERBUFFER_HEIGHT = 0x8D43, … … 1022 1023 #endif 1023 1024 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)) 1025 1026 friend class Extensions3DOpenGLES; 1026 1027 OwnPtr<Extensions3DOpenGLES> m_extensions; -
trunk/Source/WebCore/platform/graphics/OpenGLESShims.h
r125039 r130525 27 27 #define OpenGLESShims_h 28 28 29 #if PLATFORM(BLACKBERRY) || PLATFORM(QT) 29 #if PLATFORM(BLACKBERRY) || PLATFORM(QT) || PLATFORM(GTK) 30 30 #define glBindFramebufferEXT glBindFramebuffer 31 31 #define glFramebufferTexture2DEXT glFramebufferTexture2D -
trunk/Source/WebCore/platform/graphics/cairo/GLContext.cpp
r127118 r130525 22 22 #if USE(OPENGL) 23 23 24 #include "GLContextEGL.h" 25 #include "GLContextGLX.h" 24 26 #include <wtf/MainThread.h> 25 27 26 #if USE(GLX)27 #include "GLContextGLX.h"28 #if PLATFORM(X11) 29 #include <X11/Xlib.h> 28 30 #endif 29 31 … … 37 39 } 38 40 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. 45 static Display* gSharedX11Display = 0; 46 Display* GLContext::sharedX11Display() 47 { 48 if (!gSharedX11Display) 49 gSharedX11Display = XOpenDisplay(0); 50 return gSharedX11Display; 51 } 52 53 void 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. 67 typedef Vector<GLContext*> ActiveContextList; 68 static ActiveContextList& activeContextList() 69 { 70 DEFINE_STATIC_LOCAL(ActiveContextList, activeContexts, ()); 71 return activeContexts; 72 } 73 74 void 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 84 static bool gCleaningUpAtExit = false; 85 86 void 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 99 void 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 39 114 PassOwnPtr<GLContext> GLContext::createContextForWindow(uint64_t windowHandle, GLContext* sharingContext) 40 115 { 41 116 #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(); 43 123 #endif 44 124 return nullptr; … … 47 127 GLContext::GLContext() 48 128 { 129 addActiveContext(this); 49 130 } 50 131 51 PassOwnPtr<GLContext> GLContext::createOffscreenContext(GLContext* sharing )132 PassOwnPtr<GLContext> GLContext::createOffscreenContext(GLContext* sharingContext) 52 133 { 53 134 #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(); 55 141 #endif 56 142 return nullptr; … … 65 151 if (this == gCurrentContext) 66 152 gCurrentContext = 0; 153 removeActiveContext(this); 67 154 } 68 155 -
trunk/Source/WebCore/platform/graphics/cairo/GLContext.h
r122175 r130525 26 26 #include <wtf/PassOwnPtr.h> 27 27 28 #if PLATFORM(X11) 29 typedef struct _XDisplay Display; 30 #endif 31 28 32 namespace WebCore { 29 33 … … 40 44 virtual bool makeContextCurrent(); 41 45 virtual void swapBuffers() = 0; 46 virtual void waitNative() = 0; 42 47 virtual bool canRenderToDefaultFramebuffer() = 0; 43 48 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(); 44 58 45 59 #if USE(3D_GRAPHICS) -
trunk/Source/WebCore/platform/graphics/cairo/GraphicsContext3DCairo.cpp
r127044 r130525 31 31 #if USE(3D_GRAPHICS) 32 32 33 #include "Extensions3DOpenGL.h"34 33 #include "GraphicsContext3DPrivate.h" 35 34 #include "Image.h" 36 35 #include "ImageSource.h" 37 36 #include "NotImplemented.h" 38 #include "OpenGLShims.h"39 37 #include "PlatformContextCairo.h" 40 38 #include "RefPtrCairo.h" … … 45 43 #include <wtf/PassOwnPtr.h> 46 44 45 #if USE(OPENGL_ES_2) 46 #include "Extensions3DOpenGLES.h" 47 #else 48 #include "Extensions3DOpenGL.h" 49 #include "OpenGLShims.h" 50 #endif 51 47 52 namespace WebCore { 48 53 … … 56 61 static bool success = true; 57 62 if (!initialized) { 63 #if !USE(OPENGL_ES_2) 58 64 success = initializeOpenGLShims(); 65 #endif 59 66 initialized = true; 60 67 } … … 91 98 ::glTexParameterf(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_LINEAR); 92 99 ::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); 95 102 ::glBindTexture(GL_TEXTURE_2D, 0); 96 103 97 104 // Create an FBO. 98 ::glGenFramebuffers EXT(1, &m_fbo);99 ::glBindFramebuffer EXT(GL_FRAMEBUFFER_EXT, m_fbo);105 ::glGenFramebuffers(1, &m_fbo); 106 ::glBindFramebuffer(GL_FRAMEBUFFER, m_fbo); 100 107 101 108 m_boundFBO = m_fbo; 102 109 if (!m_attrs.antialias && (m_attrs.stencil || m_attrs.depth)) 103 ::glGenRenderbuffers EXT(1, &m_depthStencilBuffer);110 ::glGenRenderbuffers(1, &m_depthStencilBuffer); 104 111 105 112 // Create a multisample FBO. 106 113 if (m_attrs.antialias) { 107 ::glGenFramebuffers EXT(1, &m_multisampleFBO);108 ::glBindFramebuffer EXT(GL_FRAMEBUFFER_EXT, m_multisampleFBO);114 ::glGenFramebuffers(1, &m_multisampleFBO); 115 ::glBindFramebuffer(GL_FRAMEBUFFER, m_multisampleFBO); 109 116 m_boundFBO = m_multisampleFBO; 110 ::glGenRenderbuffers EXT(1, &m_multisampleColorBuffer);117 ::glGenRenderbuffers(1, &m_multisampleColorBuffer); 111 118 if (m_attrs.stencil || m_attrs.depth) 112 ::glGenRenderbuffers EXT(1, &m_multisampleDepthStencilBuffer);119 ::glGenRenderbuffers(1, &m_multisampleDepthStencilBuffer); 113 120 } 114 121 } … … 130 137 m_compiler.setResources(ANGLEResources); 131 138 139 #if !USE(OPENGL_ES_2) 132 140 ::glEnable(GL_VERTEX_PROGRAM_POINT_SIZE); 133 141 ::glEnable(GL_POINT_SPRITE); 142 #endif 143 134 144 ::glClearColor(0, 0, 0, 0); 135 145 } … … 143 153 ::glDeleteTextures(1, &m_texture); 144 154 if (m_attrs.antialias) { 145 ::glDeleteRenderbuffers EXT(1, &m_multisampleColorBuffer);155 ::glDeleteRenderbuffers(1, &m_multisampleColorBuffer); 146 156 if (m_attrs.stencil || m_attrs.depth) 147 ::glDeleteRenderbuffers EXT(1, &m_multisampleDepthStencilBuffer);148 ::glDeleteFramebuffers EXT(1, &m_multisampleFBO);157 ::glDeleteRenderbuffers(1, &m_multisampleDepthStencilBuffer); 158 ::glDeleteFramebuffers(1, &m_multisampleFBO); 149 159 } else { 150 160 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); 159 164 } 160 165 … … 259 264 bool GraphicsContext3D::isGLES2Compliant() const 260 265 { 266 #if USE(OPENGL_ES_2) 267 return true; 268 #else 261 269 return false; 270 #endif 262 271 } 263 272 -
trunk/Source/WebCore/platform/graphics/cairo/GraphicsContext3DPrivate.cpp
r127465 r130525 25 25 #include "HostWindow.h" 26 26 #include "NotImplemented.h" 27 #include "OpenGLShims.h"28 27 #include "PlatformContextCairo.h" 29 28 #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 30 36 31 37 #if USE(ACCELERATED_COMPOSITING) && USE(TEXTURE_MAPPER) && USE(TEXTURE_MAPPER_GL) … … 126 132 127 133 m_context->resolveMultisamplingIfNecessary(); 128 glBindFramebuffer(GraphicsContext3D::FRAMEBUFFER, m_context->m_boundFBO);134 ::glBindFramebuffer(GraphicsContext3D::FRAMEBUFFER, m_context->m_boundFBO); 129 135 130 136 if (previousActiveContext && previousActiveContext != m_glContext) -
trunk/Source/WebCore/platform/graphics/clutter/GraphicsContext3DClutter.cpp
r126635 r130525 57 57 } 58 58 59 void GraphicsContext3D::releaseShaderCompiler()60 {61 notImplemented();62 }63 64 59 bool GraphicsContext3D::getImageData(Image* image, unsigned int format, unsigned int type, bool premultiplyAlpha, bool ignoreGammaAndColorProfile, Vector<uint8_t>& outputVector) 65 60 { -
trunk/Source/WebCore/platform/graphics/efl/GraphicsContext3DEfl.cpp
r126635 r130525 475 475 } 476 476 477 void GraphicsContext3D::releaseShaderCompiler()478 {479 notImplemented();480 }481 482 477 void GraphicsContext3D::renderbufferStorage(GC3Denum target, GC3Denum internalformat, GC3Dsizei width, GC3Dsizei height) 483 478 { -
trunk/Source/WebCore/platform/graphics/glx/GLContextGLX.cpp
r126182 r130525 28 28 namespace WebCore { 29 29 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 display32 // 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 pbuffers42 // 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 reasons44 // that GraphicsContext3Ds will still be alive at exit, including user error (memory45 // 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 context68 // 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 92 30 PassOwnPtr<GLContextGLX> GLContextGLX::createWindowContext(XID window, GLContext* sharingContext) 93 31 { 94 Display* display = shared Display();32 Display* display = sharedX11Display(); 95 33 XWindowAttributes attributes; 96 34 if (!XGetWindowAttributes(display, window, &attributes)) … … 131 69 132 70 int returnedElements; 133 Display* display = shared Display();71 Display* display = sharedX11Display(); 134 72 GLXFBConfig* configs = glXChooseFBConfig(display, 0, fbConfigAttributes, &returnedElements); 135 73 if (!returnedElements) { … … 171 109 }; 172 110 173 Display* display = shared Display();111 Display* display = sharedX11Display(); 174 112 XVisualInfo* visualInfo = glXChooseVisual(display, DefaultScreen(display), visualAttributes); 175 113 if (!visualInfo) … … 201 139 PassOwnPtr<GLContextGLX> GLContextGLX::createContext(XID window, GLContext* sharingContext) 202 140 { 203 if (!shared Display())141 if (!sharedX11Display()) 204 142 return nullptr; 205 143 … … 232 170 , m_glxPixmap(0) 233 171 { 234 addActiveContext(this);235 172 } 236 173 … … 242 179 , m_glxPixmap(glxPixmap) 243 180 { 244 addActiveContext(this);245 181 } 246 182 … … 251 187 // from Mozilla's 3D canvas implementation at: http://bitbucket.org/ilmari/canvas3d/ 252 188 glBindFramebufferEXT(GL_FRAMEBUFFER_EXT, 0); 253 glXMakeCurrent(shared Display(), None, None);254 glXDestroyContext(shared Display(), m_context);189 glXMakeCurrent(sharedX11Display(), None, None); 190 glXDestroyContext(sharedX11Display(), m_context); 255 191 } 256 192 257 193 if (m_pbuffer) { 258 glXDestroyPbuffer(shared Display(), m_pbuffer);194 glXDestroyPbuffer(sharedX11Display(), m_pbuffer); 259 195 m_pbuffer = 0; 260 196 } 261 197 if (m_glxPixmap) { 262 glXDestroyGLXPixmap(shared Display(), m_glxPixmap);198 glXDestroyGLXPixmap(sharedX11Display(), m_glxPixmap); 263 199 m_glxPixmap = 0; 264 200 } 265 201 if (m_pixmap) { 266 XFreePixmap(shared Display(), m_pixmap);202 XFreePixmap(sharedX11Display(), m_pixmap); 267 203 m_pixmap = 0; 268 204 } 269 removeActiveContext(this);270 205 } 271 206 … … 283 218 Window rootWindow; 284 219 unsigned int width, height, borderWidth, depth; 285 if (!XGetGeometry(shared Display(), m_window, &rootWindow, &x, &y, &width, &height, &borderWidth, &depth))220 if (!XGetGeometry(sharedX11Display(), m_window, &rootWindow, &x, &y, &width, &height, &borderWidth, &depth)) 286 221 return IntSize(); 287 222 … … 298 233 299 234 if (m_window) 300 return glXMakeCurrent(shared Display(), m_window, m_context);235 return glXMakeCurrent(sharedX11Display(), m_window, m_context); 301 236 302 237 if (m_pbuffer) 303 return glXMakeCurrent(shared Display(), m_pbuffer, m_context);304 305 return ::glXMakeCurrent(shared Display(), m_glxPixmap, m_context);238 return glXMakeCurrent(sharedX11Display(), m_pbuffer, m_context); 239 240 return ::glXMakeCurrent(sharedX11Display(), m_glxPixmap, m_context); 306 241 } 307 242 … … 309 244 { 310 245 if (m_window) 311 glXSwapBuffers(sharedDisplay(), m_window); 246 glXSwapBuffers(sharedX11Display(), m_window); 247 } 248 249 void GLContextGLX::waitNative() 250 { 251 glXWaitX(); 312 252 } 313 253 -
trunk/Source/WebCore/platform/graphics/glx/GLContextGLX.h
r126182 r130525 26 26 27 27 typedef struct __GLXcontextRec* GLXContext; 28 typedef struct _XDisplay Display;29 28 typedef struct __GLXcontextRec *GLXContext; 30 29 typedef unsigned long GLXPbuffer; … … 46 45 virtual bool makeContextCurrent(); 47 46 virtual void swapBuffers(); 47 virtual void waitNative(); 48 48 virtual bool canRenderToDefaultFramebuffer(); 49 49 virtual IntSize defaultFrameBufferSize(); 50 51 static Display* sharedDisplay();52 50 53 51 #if USE(3D_GRAPHICS) … … 58 56 static PassOwnPtr<GLContextGLX> createPbufferContext(GLXContext sharingContext); 59 57 static PassOwnPtr<GLContextGLX> createPixmapContext(GLXContext sharingContext); 60 static void removeActiveContext(GLContext*);61 62 static void addActiveContext(GLContextGLX*);63 static void cleanupActiveContextsAtExit();64 58 65 59 GLContextGLX(GLXContext); -
trunk/Source/WebCore/platform/graphics/mac/GraphicsContext3DMac.mm
r126635 r130525 278 278 } 279 279 280 void GraphicsContext3D::releaseShaderCompiler()281 {282 makeContextCurrent();283 notImplemented();284 }285 286 280 } 287 281 -
trunk/Source/WebCore/platform/graphics/opengl/GraphicsContext3DOpenGL.cpp
r130235 r130525 49 49 50 50 namespace WebCore { 51 52 void GraphicsContext3D::releaseShaderCompiler() 53 { 54 makeContextCurrent(); 55 notImplemented(); 56 } 51 57 52 58 void GraphicsContext3D::readPixelsAndConvertToBGRAIfNecessary(int x, int y, int width, int height, unsigned char* pixels) -
trunk/Source/WebCore/platform/graphics/opengl/GraphicsContext3DOpenGLES.cpp
r130252 r130525 40 40 #endif 41 41 #include "NotImplemented.h" 42 #include "OpenGLESShims.h"43 42 44 43 namespace WebCore { … … 67 66 if (m_attrs.antialias && m_boundFBO == m_multisampleFBO) { 68 67 resolveMultisamplingIfNecessary(IntRect(x, y, width, height)); 69 ::glBindFramebuffer EXT(GL_FRAMEBUFFER_EXT, m_fbo);68 ::glBindFramebuffer(GL_FRAMEBUFFER, m_fbo); 70 69 ::glFlush(); 71 70 } … … 74 73 75 74 if (m_attrs.antialias && m_boundFBO == m_multisampleFBO) 76 ::glBindFramebuffer EXT(GraphicsContext3D::FRAMEBUFFER, m_multisampleFBO);75 ::glBindFramebuffer(GL_FRAMEBUFFER, m_multisampleFBO); 77 76 #endif 78 77 } … … 123 122 if (m_boundFBO != m_fbo) { 124 123 mustRestoreFBO = true; 125 ::glBindFramebuffer EXT(GraphicsContext3D::FRAMEBUFFER, m_fbo);124 ::glBindFramebuffer(GL_FRAMEBUFFER, m_fbo); 126 125 } 127 126 128 127 ::glBindTexture(GL_TEXTURE_2D, m_texture); 129 128 ::glTexImage2D(GL_TEXTURE_2D, 0, m_internalColorFormat, width, height, 0, colorFormat, pixelDataType, 0); 130 ::glFramebufferTexture2D EXT(GraphicsContext3D::FRAMEBUFFER, GraphicsContext3D::COLOR_ATTACHMENT0, GL_TEXTURE_2D, m_texture, 0);129 ::glFramebufferTexture2D(GL_FRAMEBUFFER, GL_COLOR_ATTACHMENT0, GL_TEXTURE_2D, m_texture, 0); 131 130 132 131 ::glBindTexture(GL_TEXTURE_2D, m_compositorTexture); … … 140 139 // Use a 24 bit depth buffer where we know we have it. 141 140 if (supportPackedDepthStencilBuffer) { 142 ::glBind Texture(GL_TEXTURE_2D, m_depthStencilBuffer);143 ::gl TexImage2D(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); 144 143 if (m_attrs.stencil) 145 ::glFramebuffer Texture2D(GL_FRAMEBUFFER, GL_STENCIL_ATTACHMENT, GL_TEXTURE_2D, m_depthStencilBuffer, 0);144 ::glFramebufferRenderbuffer(GL_FRAMEBUFFER, GL_STENCIL_ATTACHMENT, GL_RENDERBUFFER, m_depthStencilBuffer); 146 145 if (m_attrs.depth) 147 ::glFramebuffer Texture2D(GL_FRAMEBUFFER, GL_DEPTH_ATTACHMENT, GL_TEXTURE_2D, m_depthStencilBuffer, 0);148 ::glBind Texture(GL_TEXTURE_2D, 0);146 ::glFramebufferRenderbuffer(GL_FRAMEBUFFER, GL_DEPTH_ATTACHMENT, GL_RENDERBUFFER, m_depthStencilBuffer); 147 ::glBindRenderbuffer(GL_RENDERBUFFER, 0); 149 148 } else { 150 149 if (m_attrs.stencil) { 151 ::glBindRenderbuffer EXT(GraphicsContext3D::RENDERBUFFER, m_stencilBuffer);152 ::glRenderbufferStorage EXT(GraphicsContext3D::RENDERBUFFER, GL_STENCIL_INDEX8, width, height);153 ::glFramebufferRenderbuffer EXT(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); 154 153 } 155 154 if (m_attrs.depth) { 156 ::glBindRenderbuffer EXT(GraphicsContext3D::RENDERBUFFER, m_depthBuffer);157 ::glRenderbufferStorage EXT(GraphicsContext3D::RENDERBUFFER, GL_DEPTH_COMPONENT16, width, height);158 ::glFramebufferRenderbuffer EXT(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); 159 158 } 160 ::glBindRenderbuffer EXT(GraphicsContext3D::RENDERBUFFER, 0);159 ::glBindRenderbuffer(GL_RENDERBUFFER, 0); 161 160 } 162 161 } 163 if (glCheckFramebufferStatus EXT(GraphicsContext3D::FRAMEBUFFER) != GraphicsContext3D::FRAMEBUFFER_COMPLETE) {162 if (glCheckFramebufferStatus(GL_FRAMEBUFFER) != GL_FRAMEBUFFER_COMPLETE) { 164 163 // FIXME: cleanup 165 164 notImplemented(); … … 179 178 { 180 179 makeContextCurrent(); 181 ::glRenderbufferStorage EXT(target, internalformat, width, height);180 ::glRenderbufferStorage(target, internalformat, width, height); 182 181 } 183 182 -
trunk/Source/WebCore/platform/graphics/qt/GraphicsContext3DQt.cpp
r128315 r130525 100 100 #endif 101 101 } 102 103 #if !USE(OPENGL_ES_2)104 void GraphicsContext3D::releaseShaderCompiler()105 {106 notImplemented();107 }108 #endif109 102 110 103 GraphicsContext3DPrivate::GraphicsContext3DPrivate(GraphicsContext3D* context, HostWindow* hostWindow, GraphicsContext3D::RenderStyle renderStyle) -
trunk/Source/WebCore/platform/graphics/texmap/TextureMapper.h
r129993 r130525 28 28 #define TEXMAP_OPENGL_ES_2 29 29 #endif 30 #endif 31 #if PLATFORM(GTK) && USE(OPENGL_ES_2) 32 #define TEXMAP_OPENGL_ES_2 30 33 #endif 31 34 -
trunk/Source/WebCore/platform/gtk/RedirectedXCompositeWindow.cpp
r129651 r130525 28 28 #include "RedirectedXCompositeWindow.h" 29 29 30 #if USE(GLX) 31 #include "GLContextGLX.h" 32 #include <GL/glx.h> 30 #if PLATFORM(X11) 33 31 #include <X11/extensions/Xcomposite.h> 34 32 #include <X11/extensions/Xdamage.h> … … 106 104 , m_pixmap(0) 107 105 , m_surface(0) 108 , m_pendingResizeSourceId(0)109 106 , m_needsNewPixmapAfterResize(false) 110 107 , m_damage(0) … … 112 109 , m_damageNotifyData(0) 113 110 { 114 Display* display = G DK_DISPLAY_XDISPLAY(gdk_display_get_default());111 Display* display = GLContext::sharedX11Display(); 115 112 116 113 // This is based on code from Chromium: src/content/common/gpu/image_transport_surface_linux.cc … … 166 163 gdk_window_remove_filter(0, reinterpret_cast<GdkFilterFunc>(filterXDamageEvent), 0); 167 164 168 Display* display = G DK_DISPLAY_XDISPLAY(gdk_display_get_default());165 Display* display = GLContext::sharedX11Display(); 169 166 XDamageDestroy(display, m_damage); 170 167 XDestroyWindow(display, m_window); … … 175 172 void RedirectedXCompositeWindow::resize(const IntSize& size) 176 173 { 177 Display* display = G DK_DISPLAY_XDISPLAY(gdk_display_get_default());174 Display* display = GLContext::sharedX11Display(); 178 175 XResizeWindow(display, m_window, size.width(), size.height()); 179 176 180 177 XFlush(display); 181 glXWaitX();178 context()->waitNative(); 182 179 183 180 // This swap is based on code in Chromium. It tries to work-around a bug in the Intel drivers … … 264 261 } // namespace WebCore 265 262 266 #endif // USE(GLX)263 #endif // PLATFORM(X11) -
trunk/Source/WebCore/platform/gtk/RedirectedXCompositeWindow.h
r129651 r130525 28 28 #define RedirectedXCompositeWindow_h 29 29 30 #if USE(GLX)30 #if PLATFORM(X11) 31 31 32 #include "GLContext GLX.h"32 #include "GLContext.h" 33 33 #include "IntSize.h" 34 34 #include "RefPtrCairo.h" … … 79 79 } // namespace WebCore 80 80 81 #endif // USE(GLX)81 #endif // PLATFORM(X11) 82 82 83 83 #endif // RedirectedXCompositeWindow_h -
trunk/Source/WebKit2/ChangeLog
r130523 r130525 1 2012-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 1 18 2012-10-04 Jon Lee <jonlee@apple.com> 2 19 -
trunk/Source/WebKit2/WebProcess/WebPage/gtk/LayerTreeHostGtk.cpp
r130439 r130525 37 37 #include <WebCore/Frame.h> 38 38 #include <WebCore/FrameView.h> 39 #include <WebCore/GLContext GLX.h>39 #include <WebCore/GLContext.h> 40 40 #include <WebCore/Page.h> 41 41 #include <WebCore/Settings.h> -
trunk/configure.ac
r129651 r130525 548 548 AC_MSG_RESULT([$enable_unstable_features]) 549 549 550 found_opengl="no" 551 if test "$with_target" = "x11"; then 550 found_opengl=no 551 AC_ARG_ENABLE(glx, 552 AC_HELP_STRING([--enable-glx], [enable support for GLX [default=auto]]), 553 [], [enable_glx="auto"]) 554 AC_ARG_ENABLE(egl, 555 AC_HELP_STRING([--enable-egl], [enable support for EGL [default=auto]]), 556 [], [enable_egl="auto"]) 557 AC_ARG_ENABLE(gles2, 558 AC_HELP_STRING([--enable-gles2], [enable support for OpenGL ES 2 [default=auto]]), 559 [], [enable_gles2="auto"]) 560 561 have_glx=no 562 AC_CHECK_HEADERS([GL/glx.h], [have_glx="yes"], [have_glx="no"]) 563 AC_MSG_CHECKING([whether to enable GLX support]) 564 if 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 574 fi 575 AC_MSG_RESULT([$enable_glx]) 576 577 have_egl=no 578 AC_CHECK_HEADERS([EGL/egl.h], [have_egl="yes"], [have_egl="no"]) 579 AC_MSG_CHECKING([whether to enable EGL support]) 580 if 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 590 fi 591 AC_MSG_RESULT([$enable_egl]) 592 593 have_gles2=no 594 AC_CHECK_HEADERS([GLES2/gl2.h], [have_gles2="yes"], [have_gles2="no"]) 595 AC_MSG_CHECKING([whether to use OpenGL ES 2 support]) 596 if 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 602 fi 603 if 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 609 fi 610 if 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 621 fi 622 AC_MSG_RESULT([$enable_gles2]) 623 624 if test "$enable_gles2" != "yes"; then 552 625 AC_CHECK_HEADERS([GL/gl.h], [found_opengl="yes"], []) 553 AC_CHECK_HEADERS([GL/glx.h], [], [found_opengl="no"]) 554 fi 626 fi 627 555 628 AC_MSG_CHECKING([which GPU acceleration backend to use]) 556 629 AC_ARG_WITH(acceleration_backend, … … 927 1000 fi 928 1001 929 1002 acceleration_backend_description=$with_acceleration_backend 930 1003 if test "$with_acceleration_backend" = "clutter"; then 931 1004 PKG_CHECK_MODULES(CLUTTER, clutter-1.0 >= $CLUTTER_REQUIRED_VERSION) … … 940 1013 941 1014 if 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+=")" 943 1031 fi 944 1032 AC_SUBST([OPENGL_LIBS]) … … 1049 1137 1050 1138 # These are the same now, but they will soon be separate. 1051 AM_CONDITIONAL([USE_GLX], [test "$with_acceleration_backend" = "opengl"])1052 1139 AM_CONDITIONAL([USE_OPENGL], [test "$with_acceleration_backend" = "opengl"]) 1140 AM_CONDITIONAL([USE_EGL], [test "$enable_egl" = "yes"]) 1141 AM_CONDITIONAL([USE_GLES2], [test "$enable_gles2" = "yes"]) 1142 AM_CONDITIONAL([USE_GLX], [test "$enable_glx" = "yes"]) 1053 1143 1054 1144 # IndexedDB implies LevelDB, but other features may one day require LevelDB. … … 1129 1219 Font backend : $with_font_backend 1130 1220 Optimized memory allocator : $enable_fast_malloc 1131 Accelerated rendering backend : $ with_acceleration_backend1221 Accelerated rendering backend : $acceleration_backend_description 1132 1222 1133 1223 Features:
Note: See TracChangeset
for help on using the changeset viewer.