.: [EFL][WebGL][Wk2] Replace HAVE(GLX) checks with USE(GLX).
authorcommit-queue@webkit.org <commit-queue@webkit.org@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Thu, 20 Dec 2012 23:57:01 +0000 (23:57 +0000)
committercommit-queue@webkit.org <commit-queue@webkit.org@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Thu, 20 Dec 2012 23:57:01 +0000 (23:57 +0000)
https://bugs.webkit.org/show_bug.cgi?id=105431

Patch by Kondapally Kalyan <kalyan.kondapally@intel.com> on 2012-12-20
Reviewed by Kenneth Rohde Christiansen.

This patch changes the check HAVE(GLX) to USE(GLX).
This would enable us to choose our preferred GL backend during build time.

* Source/cmake/OptionsEfl.cmake:

Source/WebCore: [EFL][WebGL][Wk2] Replace HAVE(GLX) checks with USE(GLX)
https://bugs.webkit.org/show_bug.cgi?id=105431

Patch by Kondapally Kalyan <kalyan.kondapally@intel.com> on 2012-12-20
Reviewed by Kenneth Rohde Christiansen.

This patch changes the check HAVE(GLX) to USE(GLX).
This would enable us to choose our preferred GL backend during build time.
This patch also adds an additional api to query the shared buffer handle.
Buffer handle is not same as gl surface and would depend on how the content is
backed up.

* platform/graphics/opengl/GLDefs.h:
(WebCore):
* platform/graphics/opengl/GLPlatformContext.cpp:
(WebCore::GLPlatformContext::createContext):
(WebCore::GLPlatformContext::createOffScreenContext):
(WebCore::GLPlatformContext::createCurrentContextWrapper):
* platform/graphics/opengl/GLPlatformSurface.cpp:
(WebCore::GLPlatformSurface::createOffscreenSurface):
(WebCore::GLPlatformSurface::createTransportSurface):
(WebCore::GLPlatformSurface::GLPlatformSurface):
(WebCore::GLPlatformSurface::handle):
(WebCore):
(WebCore::GLPlatformSurface::drawable):
* platform/graphics/opengl/GLPlatformSurface.h:
(GLPlatformSurface):
* platform/graphics/surfaces/glx/GLXContext.cpp:
* platform/graphics/surfaces/glx/GLXContext.h:
* platform/graphics/surfaces/glx/GLXSurface.cpp:
(WebCore::GLXTransportSurface::GLXTransportSurface):
(WebCore::GLXTransportSurface::destroy):
(WebCore::GLXPBuffer::initialize):
(WebCore::GLXPBuffer::freeResources):
* platform/graphics/surfaces/glx/GLXSurface.h:
* platform/graphics/surfaces/glx/GLXWindowResources.h:
* platform/graphics/surfaces/glx/X11WindowResources.cpp:
(WebCore::X11OffScreenWindow::X11OffScreenWindow):
(WebCore::X11OffScreenWindow::setGeometry):
(WebCore::X11OffScreenWindow::createOffscreenWindow):
(WebCore::X11OffScreenWindow::destroyWindow):
* platform/graphics/surfaces/glx/X11WindowResources.h:
(WebCore):
(DummySharedResources):
(WebCore::DummySharedResources::create):
(WebCore::DummySharedResources::nativeDisplay):
(WebCore::DummySharedResources::pBufferContextConfig):
(WebCore::DummySharedResources::surfaceContextConfig):
(WebCore::DummySharedResources::DummySharedResources):
(WebCore::DummySharedResources::~DummySharedResources):

git-svn-id: https://svn.webkit.org/repository/webkit/trunk@138313 268f45cc-cd09-0410-ab3c-d52691b4dbfc

13 files changed:
ChangeLog
Source/WebCore/ChangeLog
Source/WebCore/platform/graphics/opengl/GLDefs.h
Source/WebCore/platform/graphics/opengl/GLPlatformContext.cpp
Source/WebCore/platform/graphics/opengl/GLPlatformSurface.cpp
Source/WebCore/platform/graphics/opengl/GLPlatformSurface.h
Source/WebCore/platform/graphics/surfaces/glx/GLXContext.cpp
Source/WebCore/platform/graphics/surfaces/glx/GLXContext.h
Source/WebCore/platform/graphics/surfaces/glx/GLXSurface.cpp
Source/WebCore/platform/graphics/surfaces/glx/GLXSurface.h
Source/WebCore/platform/graphics/surfaces/glx/GLXWindowResources.h
Source/WebCore/platform/graphics/surfaces/glx/X11WindowResources.cpp
Source/cmake/OptionsEfl.cmake

index 30076d1..9a4bacb 100644 (file)
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,15 @@
+2012-12-20  Kondapally Kalyan  <kalyan.kondapally@intel.com>
+
+        [EFL][WebGL][Wk2] Replace HAVE(GLX) checks with USE(GLX).
+        https://bugs.webkit.org/show_bug.cgi?id=105431
+
+        Reviewed by Kenneth Rohde Christiansen.
+
+        This patch changes the check HAVE(GLX) to USE(GLX).
+        This would enable us to choose our preferred GL backend during build time.
+
+        * Source/cmake/OptionsEfl.cmake:
+
 2012-12-20  Zan Dobersek  <zandobersek@gmail.com>
 
         [GTK] Remove the --enable-unstable-features configuration option
index be71b1d..f6b1f41 100644 (file)
@@ -1,3 +1,55 @@
+2012-12-20  Kondapally Kalyan  <kalyan.kondapally@intel.com>
+
+        [EFL][WebGL][Wk2] Replace HAVE(GLX) checks with USE(GLX)
+        https://bugs.webkit.org/show_bug.cgi?id=105431
+
+        Reviewed by Kenneth Rohde Christiansen.
+
+        This patch changes the check HAVE(GLX) to USE(GLX).
+        This would enable us to choose our preferred GL backend during build time.
+        This patch also adds an additional api to query the shared buffer handle.
+        Buffer handle is not same as gl surface and would depend on how the content is
+        backed up.
+
+        * platform/graphics/opengl/GLDefs.h:
+        (WebCore):
+        * platform/graphics/opengl/GLPlatformContext.cpp:
+        (WebCore::GLPlatformContext::createContext):
+        (WebCore::GLPlatformContext::createOffScreenContext):
+        (WebCore::GLPlatformContext::createCurrentContextWrapper):
+        * platform/graphics/opengl/GLPlatformSurface.cpp:
+        (WebCore::GLPlatformSurface::createOffscreenSurface):
+        (WebCore::GLPlatformSurface::createTransportSurface):
+        (WebCore::GLPlatformSurface::GLPlatformSurface):
+        (WebCore::GLPlatformSurface::handle):
+        (WebCore):
+        (WebCore::GLPlatformSurface::drawable):
+        * platform/graphics/opengl/GLPlatformSurface.h:
+        (GLPlatformSurface):
+        * platform/graphics/surfaces/glx/GLXContext.cpp:
+        * platform/graphics/surfaces/glx/GLXContext.h:
+        * platform/graphics/surfaces/glx/GLXSurface.cpp:
+        (WebCore::GLXTransportSurface::GLXTransportSurface):
+        (WebCore::GLXTransportSurface::destroy):
+        (WebCore::GLXPBuffer::initialize):
+        (WebCore::GLXPBuffer::freeResources):
+        * platform/graphics/surfaces/glx/GLXSurface.h:
+        * platform/graphics/surfaces/glx/GLXWindowResources.h:
+        * platform/graphics/surfaces/glx/X11WindowResources.cpp:
+        (WebCore::X11OffScreenWindow::X11OffScreenWindow):
+        (WebCore::X11OffScreenWindow::setGeometry):
+        (WebCore::X11OffScreenWindow::createOffscreenWindow):
+        (WebCore::X11OffScreenWindow::destroyWindow):
+        * platform/graphics/surfaces/glx/X11WindowResources.h:
+        (WebCore):
+        (DummySharedResources):
+        (WebCore::DummySharedResources::create):
+        (WebCore::DummySharedResources::nativeDisplay):
+        (WebCore::DummySharedResources::pBufferContextConfig):
+        (WebCore::DummySharedResources::surfaceContextConfig):
+        (WebCore::DummySharedResources::DummySharedResources):
+        (WebCore::DummySharedResources::~DummySharedResources):
+
 2012-12-20  Emil A Eklund  <eae@chromium.org>
 
         [flexbox] Fix handling of very large flex grow/shrink values
index df5bcdd..2dfb4c9 100644 (file)
 #include <GL/glext.h>
 #endif
 
-#if HAVE(GLX)
+#if USE(GLX)
 #include <GL/glx.h>
 #endif
 
 namespace WebCore {
 
-#if HAVE(GLX)
+typedef uint32_t PlatformBufferHandle;
+
+#if USE(GLX)
 typedef GLXContext PlatformContext;
 typedef Display* PlatformDisplay;
 typedef GLXFBConfig PlatformSurfaceConfig;
-typedef GLXDrawable PlatformSurface;
+typedef GLXDrawable PlatformDrawable;
 #else
 typedef void* PlatformContext;
 typedef void* PlatformDisplay;
 typedef void* PlatformSurfaceConfig;
-typedef void* PlatformSurface;
+typedef void* PlatformDrawable;
 #endif
 
 }
index 24c8444..7621e2e 100644 (file)
@@ -28,7 +28,7 @@
 
 #if USE(ACCELERATED_COMPOSITING)
 
-#if HAVE(GLX)
+#if USE(GLX)
 #include "GLXContext.h"
 #endif
 
@@ -45,7 +45,7 @@ PassOwnPtr<GLPlatformContext> GLPlatformContext::createContext(GraphicsContext3D
         return nullptr;
 
     if (!glGetGraphicsResetStatusARB) {
-#if HAVE(GLX)
+#if USE(GLX)
         glGetGraphicsResetStatusARB = reinterpret_cast<PFNGLGETGRAPHICSRESETSTATUSARBPROC>(glXGetProcAddressARB(reinterpret_cast<const GLubyte*>("glGetGraphicsResetStatusARB")));
 #endif
     }
@@ -69,7 +69,7 @@ PassOwnPtr<GLPlatformContext> GLPlatformContext::createContext(GraphicsContext3D
 
 PassOwnPtr<GLPlatformContext> GLPlatformContext::createOffScreenContext()
 {
-#if HAVE(GLX)
+#if USE(GLX)
     OwnPtr<GLPlatformContext> glxContext = adoptPtr(new GLXOffScreenContext());
     return glxContext.release();
 #endif
@@ -79,7 +79,7 @@ PassOwnPtr<GLPlatformContext> GLPlatformContext::createOffScreenContext()
 
 PassOwnPtr<GLPlatformContext> GLPlatformContext::createCurrentContextWrapper()
 {
-#if HAVE(GLX)
+#if USE(GLX)
     OwnPtr<GLPlatformContext> glxContext = adoptPtr(new GLXCurrentContextWrapper());
     return glxContext.release();
 #endif
index 160ca3f..8391e47 100644 (file)
@@ -38,10 +38,10 @@ namespace WebCore {
 
 PassOwnPtr<GLPlatformSurface> GLPlatformSurface::createOffscreenSurface()
 {
-#if HAVE(GLX)
+#if USE(GLX)
     OwnPtr<GLPlatformSurface> surface = adoptPtr(new GLXPBuffer());
 
-    if (surface->handle())
+    if (surface->handle() && surface->drawable())
         return surface.release();
 #endif
 
@@ -50,7 +50,7 @@ PassOwnPtr<GLPlatformSurface> GLPlatformSurface::createOffscreenSurface()
 
 PassOwnPtr<GLPlatformSurface> GLPlatformSurface::createTransportSurface()
 {
-#if HAVE(GLX) && USE(GRAPHICS_SURFACE)
+#if USE(GLX) && USE(GRAPHICS_SURFACE)
     OwnPtr<GLPlatformSurface> surface = adoptPtr(new GLXTransportSurface());
 
     if (surface->handle())
@@ -65,6 +65,7 @@ GLPlatformSurface::GLPlatformSurface()
     , m_fboId(0)
     , m_sharedDisplay(0)
     , m_drawable(0)
+    , m_bufferHandle(0)
 {
 }
 
@@ -72,7 +73,12 @@ GLPlatformSurface::~GLPlatformSurface()
 {
 }
 
-PlatformSurface GLPlatformSurface::handle() const
+PlatformBufferHandle GLPlatformSurface::handle() const
+{
+    return m_bufferHandle;
+}
+
+PlatformDrawable GLPlatformSurface::drawable() const
 {
     return m_drawable;
 }
index 463a6b2..e8db425 100644 (file)
@@ -52,8 +52,10 @@ public:
 
     const IntRect& geometry() const;
 
-    // Get the underlying platform specific surface handle.
-    PlatformSurface handle() const;
+    // Get the underlying platform specific buffer handle.
+    PlatformBufferHandle handle() const;
+
+    PlatformDrawable drawable() const;
 
     PlatformDisplay sharedDisplay() const;
 
@@ -78,7 +80,8 @@ protected:
     IntRect m_rect;
     GLuint m_fboId;
     PlatformDisplay m_sharedDisplay;
-    PlatformSurface m_drawable;
+    PlatformDrawable m_drawable;
+    PlatformBufferHandle m_bufferHandle;
 };
 
 }
index 295f06c..9956cb1 100644 (file)
@@ -26,7 +26,7 @@
 #include "config.h"
 #include "GLXContext.h"
 
-#if USE(ACCELERATED_COMPOSITING) && HAVE(GLX)
+#if USE(ACCELERATED_COMPOSITING) && USE(GLX)
 
 namespace WebCore {
 
index 7cff8d5..43a52dc 100644 (file)
@@ -26,7 +26,7 @@
 #ifndef GLXContext_h
 #define GLXContext_h
 
-#if USE(ACCELERATED_COMPOSITING) && HAVE(GLX)
+#if USE(ACCELERATED_COMPOSITING) && USE(GLX)
 
 #include "GLPlatformContext.h"
 
index 3bc3206..96a0ab9 100644 (file)
@@ -26,7 +26,7 @@
 #include "config.h"
 #include "GLXSurface.h"
 
-#if USE(ACCELERATED_COMPOSITING) && HAVE(GLX)
+#if USE(ACCELERATED_COMPOSITING) && USE(GLX)
 
 namespace WebCore {
 
@@ -37,6 +37,7 @@ GLXTransportSurface::GLXTransportSurface()
     : X11OffScreenWindow()
 {
     createOffscreenWindow();
+    m_drawable = m_bufferHandle;
 }
 
 GLXTransportSurface::~GLXTransportSurface()
@@ -66,6 +67,7 @@ void GLXTransportSurface::swapBuffers()
 void GLXTransportSurface::destroy()
 {
     destroyWindow();
+    m_bufferHandle = 0;
 }
 
 #endif
@@ -88,6 +90,7 @@ void GLXPBuffer::initialize()
         return;
 
     m_drawable = glXCreatePbuffer(display, config, pbufferAttributes);
+    m_bufferHandle = m_drawable;
 }
 
 PlatformSurfaceConfig GLXPBuffer::configuration()
@@ -112,6 +115,7 @@ void GLXPBuffer::freeResources()
 
     glXDestroyPbuffer(display, m_drawable);
     m_drawable = 0;
+    m_bufferHandle = 0;
 }
 
 void GLXPBuffer::setGeometry(const IntRect& newRect)
index cf01a45..4e87685 100644 (file)
@@ -26,7 +26,7 @@
 #ifndef GLXSurface_h
 #define GLXSurface_h
 
-#if USE(ACCELERATED_COMPOSITING) && HAVE(GLX)
+#if USE(ACCELERATED_COMPOSITING) && USE(GLX)
 
 #include "GLXWindowResources.h"
 
index b8054f2..c173557 100644 (file)
@@ -28,7 +28,7 @@
 
 #include "X11WindowResources.h"
 
-#if USE(ACCELERATED_COMPOSITING) && HAVE(GLX)
+#if USE(ACCELERATED_COMPOSITING) && USE(GLX)
 
 namespace WebCore {
 
index 755a488..60293e7 100644 (file)
@@ -36,8 +36,13 @@ PlatformSharedResources* SharedX11Resources::m_staticSharedResource = 0;
 
 X11OffScreenWindow::X11OffScreenWindow()
     : GLPlatformSurface()
+    , m_sharedResources(0)
 {
     m_sharedResources = PlatformSharedResources::create();
+
+    if (!m_sharedResources)
+        return;
+
     m_sharedDisplay = m_sharedResources->nativeDisplay();
 }
 
@@ -48,16 +53,19 @@ X11OffScreenWindow::~X11OffScreenWindow()
 void X11OffScreenWindow::setGeometry(const IntRect& newRect)
 {
     GLPlatformSurface::setGeometry(newRect);
-    XResizeWindow(m_sharedResources->x11Display(), m_drawable, newRect.width(), newRect.height());
+    XResizeWindow(m_sharedResources->x11Display(), m_bufferHandle, newRect.width(), newRect.height());
 }
 
 void X11OffScreenWindow::createOffscreenWindow()
 {
+    if (!m_sharedResources)
+        return;
+
     Display* display = m_sharedResources->x11Display();
     if (!display)
         return;
 
-    GLXFBConfig config = m_sharedResources->surfaceContextConfig();
+    PlatformSurfaceConfig config = m_sharedResources->surfaceContextConfig();
 
     if (!config) {
         LOG_ERROR("Failed to retrieve a valid configiration.");
@@ -80,33 +88,33 @@ void X11OffScreenWindow::createOffscreenWindow()
     attribute.background_pixel = WhitePixel(display, 0);
     attribute.border_pixel = BlackPixel(display, 0);
     attribute.colormap = cmap;
-    m_drawable = XCreateWindow(display, xWindow, 0, 0, 1, 1, 0, visInfo->depth, InputOutput, visInfo->visual, CWBackPixel | CWBorderPixel | CWColormap, &attribute);
+    m_bufferHandle = XCreateWindow(display, xWindow, 0, 0, 1, 1, 0, visInfo->depth, InputOutput, visInfo->visual, CWBackPixel | CWBorderPixel | CWColormap, &attribute);
 
-    if (!m_drawable) {
+    if (!m_bufferHandle) {
         LOG_ERROR("Failed to create offscreen window");
         return;
     }
 
-    XSetWindowBackgroundPixmap(display, m_drawable, 0);
-    XCompositeRedirectWindow(display, m_drawable, CompositeRedirectManual);
+    XSetWindowBackgroundPixmap(display, m_bufferHandle, 0);
+    XCompositeRedirectWindow(display, m_bufferHandle, CompositeRedirectManual);
 
     if (m_sharedResources->isXRenderExtensionSupported())
-        XMapWindow(display, m_drawable);
+        XMapWindow(display, m_bufferHandle);
 
 }
 
 void X11OffScreenWindow::destroyWindow()
 {
-    if (!m_drawable)
+    if (!m_bufferHandle)
         return;
 
     GLPlatformSurface::destroy();
-    Display* display = sharedDisplay();
+    Display* display = m_sharedResources->x11Display();
     if (!display)
         return;
 
-    XDestroyWindow(display, m_drawable);
-    m_drawable = 0;
+    XDestroyWindow(display, m_bufferHandle);
+    m_bufferHandle = 0;
 }
 
 }
index 6e5610a..a5133e9 100644 (file)
@@ -169,6 +169,8 @@ if (ENABLE_WEBGL OR WTF_USE_TILED_BACKING_STORE)
 
     if (OPENGLX_FOUND)
         add_definitions(-DHAVE_GLX)
+        add_definitions(-DWTF_USE_GLX=1)
+
         if (X11_Xcomposite_FOUND AND X11_Xrender_FOUND)
            set(USE_GRAPHICS_SURFACE 1)
         endif ()