Title: [138567] trunk/Source/WebCore
Revision
138567
Author
[email protected]
Date
2012-12-29 10:11:57 -0800 (Sat, 29 Dec 2012)

Log Message

[EFL][WebGL] Refactor GLXImplementation.
https://bugs.webkit.org/show_bug.cgi?id=105825

Patch by Kondapally Kalyan <[email protected]> on 2012-12-29
Reviewed by Kenneth Rohde Christiansen.

This patch decouples native window management and logic to find surface configuration in GLX implementation.

* platform/graphics/opengl/GLDefs.h:
* platform/graphics/surfaces/glx/GLXConfigSelector.h: Renamed from Source/WebCore/platform/graphics/surfaces/glx/GLXWindowResources.h.
(WebCore):
(GLXConfigSelector):
(WebCore::GLXConfigSelector::GLXConfigSelector):
(WebCore::GLXConfigSelector::~GLXConfigSelector):
(WebCore::GLXConfigSelector::visualInfo):
(WebCore::GLXConfigSelector::pBufferContextConfig):
(WebCore::GLXConfigSelector::surfaceContextConfig):
(WebCore::GLXConfigSelector::reset):
(WebCore::GLXConfigSelector::createConfig):

Helper class to find surface configuration.

* platform/graphics/surfaces/glx/GLXContext.h:
(GLXOffScreenContext):
* platform/graphics/surfaces/glx/GLXSurface.cpp:
(WebCore::GLXTransportSurface::GLXTransportSurface):
(WebCore::GLXTransportSurface::configuration):
(WebCore::GLXTransportSurface::setGeometry):
(WebCore::GLXTransportSurface::destroy):
(WebCore::GLXPBuffer::GLXPBuffer):
(WebCore::GLXPBuffer::initialize):
(WebCore::GLXPBuffer::configuration):
* platform/graphics/surfaces/glx/GLXSurface.h:
(GLXTransportSurface):
(GLXPBuffer):

Inheritance changed from X11OffScreenWindow to GLPlatformSurface.

* platform/graphics/surfaces/glx/X11WindowResources.cpp:
(WebCore):
(WebCore::X11OffScreenWindow::X11OffScreenWindow):
(WebCore::X11OffScreenWindow::reSizeWindow):
(WebCore::X11OffScreenWindow::createOffscreenWindow):
(WebCore::X11OffScreenWindow::destroyWindow):
(WebCore::X11OffScreenWindow::nativeSharedDisplay):
(WebCore::X11OffScreenWindow::setVisualInfo):
(WebCore::X11OffScreenWindow::isXRenderExtensionSupported):
* platform/graphics/surfaces/glx/X11WindowResources.h:
(WebCore::SharedX11Resources::create):
(SharedX11Resources):
(X11OffScreenWindow):

 Removed code related to surface configiration.

Modified Paths

Added Paths

Removed Paths

Diff

Modified: trunk/Source/WebCore/ChangeLog (138566 => 138567)


--- trunk/Source/WebCore/ChangeLog	2012-12-29 17:02:21 UTC (rev 138566)
+++ trunk/Source/WebCore/ChangeLog	2012-12-29 18:11:57 UTC (rev 138567)
@@ -1,3 +1,58 @@
+2012-12-29  Kondapally Kalyan  <[email protected]>
+
+        [EFL][WebGL] Refactor GLXImplementation.
+        https://bugs.webkit.org/show_bug.cgi?id=105825
+
+        Reviewed by Kenneth Rohde Christiansen.
+
+        This patch decouples native window management and logic to find surface configuration in GLX implementation.
+
+        * platform/graphics/opengl/GLDefs.h:
+        * platform/graphics/surfaces/glx/GLXConfigSelector.h: Renamed from Source/WebCore/platform/graphics/surfaces/glx/GLXWindowResources.h.
+        (WebCore):
+        (GLXConfigSelector):
+        (WebCore::GLXConfigSelector::GLXConfigSelector):
+        (WebCore::GLXConfigSelector::~GLXConfigSelector):
+        (WebCore::GLXConfigSelector::visualInfo):
+        (WebCore::GLXConfigSelector::pBufferContextConfig):
+        (WebCore::GLXConfigSelector::surfaceContextConfig):
+        (WebCore::GLXConfigSelector::reset):
+        (WebCore::GLXConfigSelector::createConfig):
+
+        Helper class to find surface configuration.
+
+        * platform/graphics/surfaces/glx/GLXContext.h:
+        (GLXOffScreenContext):
+        * platform/graphics/surfaces/glx/GLXSurface.cpp:
+        (WebCore::GLXTransportSurface::GLXTransportSurface):
+        (WebCore::GLXTransportSurface::configuration):
+        (WebCore::GLXTransportSurface::setGeometry):
+        (WebCore::GLXTransportSurface::destroy):
+        (WebCore::GLXPBuffer::GLXPBuffer):
+        (WebCore::GLXPBuffer::initialize):
+        (WebCore::GLXPBuffer::configuration):
+        * platform/graphics/surfaces/glx/GLXSurface.h:
+        (GLXTransportSurface):
+        (GLXPBuffer):
+
+        Inheritance changed from X11OffScreenWindow to GLPlatformSurface.
+
+        * platform/graphics/surfaces/glx/X11WindowResources.cpp:
+        (WebCore):
+        (WebCore::X11OffScreenWindow::X11OffScreenWindow):
+        (WebCore::X11OffScreenWindow::reSizeWindow):
+        (WebCore::X11OffScreenWindow::createOffscreenWindow):
+        (WebCore::X11OffScreenWindow::destroyWindow):
+        (WebCore::X11OffScreenWindow::nativeSharedDisplay):
+        (WebCore::X11OffScreenWindow::setVisualInfo):
+        (WebCore::X11OffScreenWindow::isXRenderExtensionSupported):
+        * platform/graphics/surfaces/glx/X11WindowResources.h:
+        (WebCore::SharedX11Resources::create):
+        (SharedX11Resources):
+        (X11OffScreenWindow):
+
+         Removed code related to surface configiration.
+
 2012-12-29  Eugene Klyuchnikov  <[email protected]>
 
         Web Inspector: [Timeline] cpu bar popover shows wrong duration / cpu time.

Modified: trunk/Source/WebCore/platform/graphics/opengl/GLDefs.h (138566 => 138567)


--- trunk/Source/WebCore/platform/graphics/opengl/GLDefs.h	2012-12-29 17:02:21 UTC (rev 138566)
+++ trunk/Source/WebCore/platform/graphics/opengl/GLDefs.h	2012-12-29 18:11:57 UTC (rev 138567)
@@ -41,7 +41,9 @@
 #include <GL/gl.h>
 #include <GL/glext.h>
 #if USE(GLX)
+#define GLX_GLXEXT_PROTOTYPES 1
 #include <GL/glx.h>
+#include <GL/glxext.h>
 #endif
 #endif
 

Copied: trunk/Source/WebCore/platform/graphics/surfaces/glx/GLXConfigSelector.h (from rev 138566, trunk/Source/WebCore/platform/graphics/surfaces/glx/GLXWindowResources.h) (0 => 138567)


--- trunk/Source/WebCore/platform/graphics/surfaces/glx/GLXConfigSelector.h	                        (rev 0)
+++ trunk/Source/WebCore/platform/graphics/surfaces/glx/GLXConfigSelector.h	2012-12-29 18:11:57 UTC (rev 138567)
@@ -0,0 +1,166 @@
+/*
+ * Copyright (C) 2012 Intel Corporation. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ *    notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ *    notice, this list of conditions and the following disclaimer in the
+ *    documentation and/or other materials provided with the distribution.
+ *
+ * THIS SOFTWARE IS PROVIDED BY APPLE INC. AND ITS CONTRIBUTORS ``AS IS''
+ * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
+ * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE INC. OR ITS CONTRIBUTORS
+ * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
+ * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
+ * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
+ * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
+ * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
+ * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF
+ * THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#ifndef GLXConfigSelector_h
+#define GLXConfigSelector_h
+
+#include "X11WindowResources.h"
+
+#if USE(ACCELERATED_COMPOSITING) && USE(GLX)
+
+namespace WebCore {
+
+class GLXConfigSelector {
+    WTF_MAKE_NONCOPYABLE(GLXConfigSelector);
+
+public:
+    GLXConfigSelector(Display* xDisplay, bool supportsXRenderExtension)
+        : m_pbufferFBConfig(0)
+        , m_surfaceContextFBConfig(0)
+        , m_visualInfo(0)
+        , m_sharedDisplay(xDisplay)
+        , m_supportsXRenderExtension(supportsXRenderExtension)
+    {
+    }
+
+    virtual ~GLXConfigSelector()
+    {
+    }
+
+    XVisualInfo* visualInfo() const
+    {
+        return m_visualInfo;
+    }
+
+    GLXFBConfig pBufferContextConfig()
+    {
+        if (!m_pbufferFBConfig) {
+            static const int attributes[] = {
+                GLX_LEVEL, 0,
+                GLX_DRAWABLE_TYPE, GLX_PBUFFER_BIT,
+                GLX_RENDER_TYPE,   GLX_RGBA_BIT,
+                GLX_RED_SIZE,      1,
+                GLX_GREEN_SIZE,    1,
+                GLX_BLUE_SIZE,     1,
+                GLX_DOUBLEBUFFER,  GL_FALSE,
+                None
+            };
+
+            int numAvailableConfigs;
+            GLXFBConfig* temp = glXChooseFBConfig(m_sharedDisplay, DefaultScreen(m_sharedDisplay), attributes, &numAvailableConfigs);
+            if (numAvailableConfigs)
+                m_pbufferFBConfig = temp[0];
+            XFree(temp);
+        }
+
+        return m_pbufferFBConfig;
+    }
+
+    GLXFBConfig surfaceContextConfig()
+    {
+        if (!m_surfaceContextFBConfig) {
+            static int attributes[] = {
+                GLX_LEVEL, 0,
+                GLX_DRAWABLE_TYPE, GLX_WINDOW_BIT,
+                GLX_RENDER_TYPE,   GLX_RGBA_BIT,
+                GLX_RED_SIZE,      1,
+                GLX_GREEN_SIZE,    1,
+                GLX_BLUE_SIZE,     1,
+                GLX_ALPHA_SIZE,    1,
+                GLX_DEPTH_SIZE,    1,
+                GLX_X_VISUAL_TYPE, GLX_TRUE_COLOR,
+                GLX_DOUBLEBUFFER,  True,
+                None
+            };
+
+            m_surfaceContextFBConfig = createConfig(attributes);
+        }
+
+        return m_surfaceContextFBConfig;
+    }
+
+    void reset()
+    {
+        m_pbufferFBConfig = 0;
+        m_surfaceContextFBConfig = 0;
+    }
+
+private:
+    GLXFBConfig createConfig(const int attributes[])
+    {
+        int numAvailableConfigs;
+        m_visualInfo = 0;
+        GLXFBConfig* temp = glXChooseFBConfig(m_sharedDisplay, DefaultScreen(m_sharedDisplay), attributes, &numAvailableConfigs);
+
+        if (!numAvailableConfigs)
+            return 0;
+
+        GLXFBConfig selectedConfig = 0;
+        bool found = false;
+
+        for (int i = 0; i < numAvailableConfigs; ++i) {
+            m_visualInfo = glXGetVisualFromFBConfig(m_sharedDisplay, temp[i]);
+            if (!m_visualInfo)
+                continue;
+#if USE(GRAPHICS_SURFACE)
+            if (m_supportsXRenderExtension) {
+                XRenderPictFormat* format = XRenderFindVisualFormat(m_sharedDisplay, m_visualInfo->visual);
+                if (format && format->direct.alphaMask > 0) {
+                    selectedConfig = temp[i];
+                    found = true;
+                    break;
+                }
+            } else if (m_visualInfo->depth == 32) {
+#else
+            if (m_visualInfo->depth == 32) {
+#endif
+                selectedConfig = temp[i];
+                found = true;
+            }
+        }
+
+        // Did not find any visual supporting alpha, select the first available config.
+        if (!found) {
+            selectedConfig = temp[0];
+            m_visualInfo = glXGetVisualFromFBConfig(m_sharedDisplay, temp[0]);
+        }
+
+        XFree(temp);
+
+        return selectedConfig;
+    }
+
+    GLXFBConfig m_pbufferFBConfig;
+    GLXFBConfig m_surfaceContextFBConfig;
+    XVisualInfo* m_visualInfo;
+    Display* m_sharedDisplay;
+    bool m_supportsXRenderExtension;
+};
+
+}
+
+#endif
+
+#endif

Modified: trunk/Source/WebCore/platform/graphics/surfaces/glx/GLXContext.h (138566 => 138567)


--- trunk/Source/WebCore/platform/graphics/surfaces/glx/GLXContext.h	2012-12-29 17:02:21 UTC (rev 138566)
+++ trunk/Source/WebCore/platform/graphics/surfaces/glx/GLXContext.h	2012-12-29 18:11:57 UTC (rev 138567)
@@ -33,7 +33,6 @@
 namespace WebCore {
 
 class GLXCurrentContextWrapper : public GLPlatformContext {
-    WTF_MAKE_NONCOPYABLE(GLXCurrentContextWrapper);
 
 public:
     GLXCurrentContextWrapper()
@@ -46,16 +45,15 @@
 };
 
 class GLXOffScreenContext : public GLPlatformContext {
-    WTF_MAKE_NONCOPYABLE(GLXOffScreenContext);
 
 public:
     GLXOffScreenContext();
     virtual ~GLXOffScreenContext();
-    bool initialize(GLPlatformSurface*);
-    bool platformMakeCurrent(GLPlatformSurface*);
-    void platformReleaseCurrent();
-    void destroy();
-    bool isCurrentContext() const;
+    virtual bool initialize(GLPlatformSurface*) OVERRIDE;
+    virtual bool platformMakeCurrent(GLPlatformSurface*) OVERRIDE;
+    virtual void platformReleaseCurrent() OVERRIDE;
+    virtual void destroy() OVERRIDE;
+    virtual bool isCurrentContext() const OVERRIDE;
 
 private:
     void freeResources();

Modified: trunk/Source/WebCore/platform/graphics/surfaces/glx/GLXSurface.cpp (138566 => 138567)


--- trunk/Source/WebCore/platform/graphics/surfaces/glx/GLXSurface.cpp	2012-12-29 17:02:21 UTC (rev 138566)
+++ trunk/Source/WebCore/platform/graphics/surfaces/glx/GLXSurface.cpp	2012-12-29 18:11:57 UTC (rev 138567)
@@ -34,9 +34,31 @@
 
 #if USE(GRAPHICS_SURFACE)
 GLXTransportSurface::GLXTransportSurface()
-    : X11OffScreenWindow()
+    : GLPlatformSurface()
 {
-    createOffscreenWindow(&m_bufferHandle);
+    m_nativeResource = adoptPtr(new X11OffScreenWindow());
+    m_sharedDisplay = m_nativeResource->nativeSharedDisplay();
+
+    if (!m_sharedDisplay) {
+        m_nativeResource = nullptr;
+        return;
+    }
+
+    m_configSelector = adoptPtr(new GLXConfigSelector(m_sharedDisplay, m_nativeResource->isXRenderExtensionSupported()));
+
+    if (!configuration()) {
+        destroy();
+        return;
+    }
+
+    m_nativeResource->setVisualInfo(m_configSelector->visualInfo());
+    m_nativeResource->createOffscreenWindow(&m_bufferHandle);
+
+    if (!m_bufferHandle) {
+        destroy();
+        return;
+    }
+
     m_drawable = m_bufferHandle;
 }
 
@@ -46,13 +68,13 @@
 
 PlatformSurfaceConfig GLXTransportSurface::configuration()
 {
-    return m_sharedResources->surfaceContextConfig();
+    return m_configSelector->surfaceContextConfig();
 }
 
 void GLXTransportSurface::setGeometry(const IntRect& newRect)
 {
     GLPlatformSurface::setGeometry(newRect);
-    reSizeWindow(newRect, m_drawable);
+    m_nativeResource->reSizeWindow(newRect, m_drawable);
 }
 
 void GLXTransportSurface::swapBuffers()
@@ -72,14 +94,20 @@
 
 void GLXTransportSurface::destroy()
 {
-    destroyWindow(m_bufferHandle);
-    m_bufferHandle = 0;
+    if (m_bufferHandle) {
+        m_nativeResource->destroyWindow(m_bufferHandle);
+        m_bufferHandle = 0;
+        m_drawable = 0;
+    }
+
+    m_nativeResource = nullptr;
+    m_configSelector = nullptr;
 }
 
 #endif
 
 GLXPBuffer::GLXPBuffer()
-    : X11OffScreenWindow()
+    : GLPlatformSurface()
 {
     initialize();
 }
@@ -90,18 +118,35 @@
 
 void GLXPBuffer::initialize()
 {
-    Display* display = sharedDisplay();
-    GLXFBConfig config = m_sharedResources->pBufferContextConfig();
-    if (!config)
+    m_nativeResource = adoptPtr(new X11OffScreenWindow());
+    m_sharedDisplay = m_nativeResource->nativeSharedDisplay();
+
+    if (!m_sharedDisplay) {
+        m_nativeResource = nullptr;
         return;
+    }
 
-    m_drawable = glXCreatePbuffer(display, config, pbufferAttributes);
+    m_configSelector = adoptPtr(new GLXConfigSelector(m_sharedDisplay, m_nativeResource->isXRenderExtensionSupported()));
+    GLXFBConfig config = m_configSelector->pBufferContextConfig();
+
+    if (!config) {
+        destroy();
+        return;
+    }
+
+    m_drawable = glXCreatePbuffer(m_sharedDisplay, config, pbufferAttributes);
+
+    if (!m_drawable) {
+        destroy();
+        return;
+    }
+
     m_bufferHandle = m_drawable;
 }
 
 PlatformSurfaceConfig GLXPBuffer::configuration()
 {
-    return m_sharedResources->pBufferContextConfig();
+    return m_configSelector->pBufferContextConfig();
 }
 
 void GLXPBuffer::destroy()
@@ -111,17 +156,17 @@
 
 void GLXPBuffer::freeResources()
 {
-    if (!m_drawable)
-        return;
-
     GLPlatformSurface::destroy();
     Display* display = sharedDisplay();
-    if (!display)
-        return;
 
-    glXDestroyPbuffer(display, m_drawable);
-    m_drawable = 0;
-    m_bufferHandle = 0;
+    if (m_drawable && display) {
+        glXDestroyPbuffer(display, m_drawable);
+        m_drawable = 0;
+        m_bufferHandle = 0;
+    }
+
+    m_configSelector = nullptr;
+    m_nativeResource = nullptr;
 }
 
 void GLXPBuffer::setGeometry(const IntRect& newRect)

Modified: trunk/Source/WebCore/platform/graphics/surfaces/glx/GLXSurface.h (138566 => 138567)


--- trunk/Source/WebCore/platform/graphics/surfaces/glx/GLXSurface.h	2012-12-29 17:02:21 UTC (rev 138566)
+++ trunk/Source/WebCore/platform/graphics/surfaces/glx/GLXSurface.h	2012-12-29 18:11:57 UTC (rev 138567)
@@ -28,42 +28,44 @@
 
 #if USE(ACCELERATED_COMPOSITING) && USE(GLX)
 
-#include "GLXWindowResources.h"
+#include "GLPlatformSurface.h"
+#include "GLXConfigSelector.h"
+#include "X11WindowResources.h"
 
-#include <wtf/Noncopyable.h>
-
 namespace WebCore {
 
 #if USE(GRAPHICS_SURFACE)
-class GLXTransportSurface : public X11OffScreenWindow {
-    WTF_MAKE_NONCOPYABLE(GLXTransportSurface);
+class GLXTransportSurface : public GLPlatformSurface {
 
 public:
     GLXTransportSurface();
     virtual ~GLXTransportSurface();
-    PlatformSurfaceConfig configuration();
-    void swapBuffers();
-    void setGeometry(const IntRect&);
-    void destroy();
+    virtual PlatformSurfaceConfig configuration() OVERRIDE;
+    virtual void swapBuffers() OVERRIDE;
+    virtual void setGeometry(const IntRect&) OVERRIDE;
+    virtual void destroy() OVERRIDE;
 
 private:
     void initialize();
+    OwnPtr<X11OffScreenWindow> m_nativeResource;
+    OwnPtr<GLXConfigSelector> m_configSelector;
 };
 #endif
 
-class GLXPBuffer : public X11OffScreenWindow {
-    WTF_MAKE_NONCOPYABLE(GLXPBuffer);
+class GLXPBuffer : public GLPlatformSurface {
 
 public:
     GLXPBuffer();
     virtual ~GLXPBuffer();
-    PlatformSurfaceConfig configuration();
-    void setGeometry(const IntRect&);
-    void destroy();
+    virtual PlatformSurfaceConfig configuration() OVERRIDE;
+    virtual void setGeometry(const IntRect&) OVERRIDE;
+    virtual void destroy() OVERRIDE;
 
 private:
     void initialize();
     void freeResources();
+    OwnPtr<X11OffScreenWindow> m_nativeResource;
+    OwnPtr<GLXConfigSelector> m_configSelector;
 };
 
 }

Deleted: trunk/Source/WebCore/platform/graphics/surfaces/glx/GLXWindowResources.h (138566 => 138567)


--- trunk/Source/WebCore/platform/graphics/surfaces/glx/GLXWindowResources.h	2012-12-29 17:02:21 UTC (rev 138566)
+++ trunk/Source/WebCore/platform/graphics/surfaces/glx/GLXWindowResources.h	2012-12-29 18:11:57 UTC (rev 138567)
@@ -1,188 +0,0 @@
-/*
- * Copyright (C) 2012 Intel Corporation. All rights reserved.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions
- * are met:
- * 1. Redistributions of source code must retain the above copyright
- *    notice, this list of conditions and the following disclaimer.
- * 2. Redistributions in binary form must reproduce the above copyright
- *    notice, this list of conditions and the following disclaimer in the
- *    documentation and/or other materials provided with the distribution.
- *
- * THIS SOFTWARE IS PROVIDED BY APPLE INC. AND ITS CONTRIBUTORS ``AS IS''
- * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
- * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
- * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE INC. OR ITS CONTRIBUTORS
- * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
- * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
- * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
- * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
- * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
- * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF
- * THE POSSIBILITY OF SUCH DAMAGE.
- */
-
-#ifndef GLXWindowResources_h
-#define GLXWindowResources_h
-
-#include "X11WindowResources.h"
-
-#if USE(ACCELERATED_COMPOSITING) && USE(GLX)
-
-namespace WebCore {
-
-class SharedGLXResources : public SharedX11Resources {
-    WTF_MAKE_NONCOPYABLE(SharedGLXResources);
-
-public:
-    static PassRefPtr<SharedGLXResources> create()
-    {
-        if (!m_staticSharedResource)
-            m_staticSharedResource = new SharedGLXResources();
-        else
-            m_staticSharedResource->ref();
-
-        return adoptRef(m_staticSharedResource);
-    }
-
-    PlatformDisplay nativeDisplay()
-    {
-        return SharedX11Resources::x11Display();
-    }
-
-    XVisualInfo* visualInfo()
-    {
-        if (!m_VisualInfo)
-            surfaceContextConfig();
-
-        return m_VisualInfo;
-    }
-
-    virtual GLXFBConfig pBufferContextConfig()
-    {
-        if (!m_pbufferfbConfig) {
-            static const int attributes[] = {
-                GLX_LEVEL, 0,
-                GLX_DRAWABLE_TYPE, GLX_PBUFFER_BIT,
-                GLX_RENDER_TYPE,   GLX_RGBA_BIT,
-                GLX_RED_SIZE,      1,
-                GLX_GREEN_SIZE,    1,
-                GLX_BLUE_SIZE,     1,
-                GLX_DOUBLEBUFFER,  GL_FALSE,
-                None
-            };
-
-            int numReturned;
-            GLXFBConfig* temp = glXChooseFBConfig(nativeDisplay(), DefaultScreen(nativeDisplay()), attributes, &numReturned);
-            if (numReturned)
-                m_pbufferfbConfig = temp[0];
-            XFree(temp);
-        }
-
-        return m_pbufferfbConfig;
-    }
-
-    virtual GLXFBConfig surfaceContextConfig()
-    {
-        if (!m_surfaceContextfbConfig) {
-            static int attributes[] = {
-                GLX_LEVEL, 0,
-                GLX_DRAWABLE_TYPE, GLX_WINDOW_BIT,
-                GLX_RENDER_TYPE,   GLX_RGBA_BIT,
-                GLX_RED_SIZE,      1,
-                GLX_GREEN_SIZE,    1,
-                GLX_BLUE_SIZE,     1,
-                GLX_ALPHA_SIZE,    1,
-                GLX_DEPTH_SIZE,    1,
-                GLX_X_VISUAL_TYPE, GLX_TRUE_COLOR,
-                GLX_DOUBLEBUFFER,  True,
-                None
-            };
-
-            m_surfaceContextfbConfig = createConfig(attributes);
-        }
-
-        return m_surfaceContextfbConfig;
-    }
-
-protected:
-    SharedGLXResources()
-        : SharedX11Resources()
-        , m_pbufferfbConfig(0)
-        , m_surfaceContextfbConfig(0)
-        , m_VisualInfo(0)
-    {
-    }
-
-    GLXFBConfig createConfig(const int attributes[])
-    {
-        int numReturned;
-        m_VisualInfo = 0;
-        GLXFBConfig* temp = glXChooseFBConfig(nativeDisplay(), DefaultScreen(nativeDisplay()), attributes, &numReturned);
-
-        if (!numReturned)
-            return 0;
-
-        GLXFBConfig selectedConfig = 0;
-        bool found = false;
-
-        for (int i = 0; i < numReturned; ++i) {
-            m_VisualInfo = glXGetVisualFromFBConfig(nativeDisplay(), temp[i]);
-            if (!m_VisualInfo)
-                continue;
-#if USE(GRAPHICS_SURFACE)
-            if (m_supportsXRenderExtension) {
-                XRenderPictFormat* format = XRenderFindVisualFormat(nativeDisplay(), m_VisualInfo->visual);
-                if (format && format->direct.alphaMask > 0) {
-                    selectedConfig = temp[i];
-                    found = true;
-                    break;
-                }
-            } else if (m_VisualInfo->depth == 32) {
-#else
-            if (m_VisualInfo->depth == 32) {
-#endif
-                selectedConfig = temp[i];
-                found = true;
-            }
-        }
-
-        // Did not find any visual supporting alpha, select the first available config.
-        if (!found) {
-            selectedConfig = temp[0];
-            m_VisualInfo = glXGetVisualFromFBConfig(m_display, temp[0]);
-        }
-
-        XFree(temp);
-
-        return selectedConfig;
-    }
-
-    virtual ~SharedGLXResources()
-    {
-        if (!m_display)
-            return;
-
-        if (m_pbufferfbConfig)
-            m_pbufferfbConfig = 0;
-
-        if (m_surfaceContextfbConfig)
-            m_surfaceContextfbConfig = 0;
-
-        if (m_VisualInfo) {
-            XFree(m_VisualInfo);
-            m_VisualInfo = 0;
-        }
-    }
-
-    GLXFBConfig m_pbufferfbConfig;
-    GLXFBConfig m_surfaceContextfbConfig;
-    XVisualInfo* m_VisualInfo;
-};
-
-}
-
-#endif
-
-#endif

Modified: trunk/Source/WebCore/platform/graphics/surfaces/glx/X11WindowResources.cpp (138566 => 138567)


--- trunk/Source/WebCore/platform/graphics/surfaces/glx/X11WindowResources.cpp	2012-12-29 17:02:21 UTC (rev 138566)
+++ trunk/Source/WebCore/platform/graphics/surfaces/glx/X11WindowResources.cpp	2012-12-29 18:11:57 UTC (rev 138567)
@@ -28,25 +28,15 @@
 
 #if USE(ACCELERATED_COMPOSITING)
 
-#if USE(GLX)
-#include "GLXWindowResources.h"
-#endif
-
 namespace WebCore {
 
-PlatformSharedResources* SharedX11Resources::m_staticSharedResource = 0;
+SharedX11Resources* SharedX11Resources::m_staticSharedResource = 0;
 
 X11OffScreenWindow::X11OffScreenWindow()
-    : GLPlatformSurface()
-    , m_sharedResources(0)
+    : m_sharedResources(0)
     , m_configVisualInfo(0)
 {
-    m_sharedResources = PlatformSharedResources::create();
-
-    if (!m_sharedResources)
-        return;
-
-    m_sharedDisplay = m_sharedResources->x11Display();
+    m_sharedResources = SharedX11Resources::create();
 }
 
 X11OffScreenWindow::~X11OffScreenWindow()
@@ -57,12 +47,12 @@
     }
 }
 
-void X11OffScreenWindow::reSizeWindow(const IntRect& newRect, PlatformBufferHandle windowId)
+void X11OffScreenWindow::reSizeWindow(const IntRect& newRect, const uint32_t windowId)
 {
     XResizeWindow(m_sharedResources->x11Display(), windowId, newRect.width(), newRect.height());
 }
 
-void X11OffScreenWindow::createOffscreenWindow(PlatformBufferHandle* handleId)
+void X11OffScreenWindow::createOffscreenWindow(uint32_t* handleId)
 {
     if (!m_sharedResources)
         return;
@@ -71,14 +61,8 @@
     if (!display)
         return;
 
-#if USE(GLX)
-    XVisualInfo* visInfo = m_sharedResources->visualInfo();
-#else
-    XVisualInfo* visInfo = m_configVisualInfo;
-#endif
-
-    if (!visInfo) {
-        LOG_ERROR("Failed to find valid XVisual");
+    if (!m_configVisualInfo) {
+        LOG_ERROR("Failed to find valid XVisual.");
         return;
     }
 
@@ -86,35 +70,33 @@
     if (!xWindow)
         return;
 
-    Colormap cmap = XCreateColormap(display, xWindow, visInfo->visual, AllocNone);
+    Colormap cmap = XCreateColormap(display, xWindow, m_configVisualInfo->visual, AllocNone);
     XSetWindowAttributes attribute;
     attribute.background_pixel = WhitePixel(display, 0);
     attribute.border_pixel = BlackPixel(display, 0);
     attribute.colormap = cmap;
-    PlatformBufferHandle tempHandleId;
-    tempHandleId = XCreateWindow(display, xWindow, 0, 0, 1, 1, 0, visInfo->depth, InputOutput, visInfo->visual, CWBackPixel | CWBorderPixel | CWColormap, &attribute);
+    uint32_t tempHandleId;
+    tempHandleId = XCreateWindow(display, xWindow, 0, 0, 1, 1, 0, m_configVisualInfo->depth, InputOutput, m_configVisualInfo->visual, CWBackPixel | CWBorderPixel | CWColormap, &attribute);
 
     if (!tempHandleId) {
-        LOG_ERROR("Failed to create offscreen window");
+        LOG_ERROR("Failed to create offscreen window.");
         return;
     }
 
     XSetWindowBackgroundPixmap(display, tempHandleId, 0);
     XCompositeRedirectWindow(display, tempHandleId, CompositeRedirectManual);
     *handleId = tempHandleId;
-    m_bufferHandle = tempHandleId;
 
     if (m_sharedResources->isXRenderExtensionSupported())
         XMapWindow(display, tempHandleId);
 
 }
 
-void X11OffScreenWindow::destroyWindow(PlatformBufferHandle windowId)
+void X11OffScreenWindow::destroyWindow(const uint32_t windowId)
 {
     if (!windowId)
         return;
 
-    GLPlatformSurface::destroy();
     Display* display = m_sharedResources->x11Display();
     if (!display)
         return;
@@ -122,7 +104,7 @@
     XDestroyWindow(display, windowId);
 }
 
-Display* X11OffScreenWindow::nativeSharedDisplay()
+Display* X11OffScreenWindow::nativeSharedDisplay() const
 {
     return m_sharedResources->x11Display();
 }
@@ -181,6 +163,16 @@
 }
 #endif
 
+void X11OffScreenWindow::setVisualInfo(XVisualInfo* visInfo)
+{
+    m_configVisualInfo = visInfo;
 }
 
+bool X11OffScreenWindow::isXRenderExtensionSupported() const
+{
+    return m_sharedResources->isXRenderExtensionSupported();
+}
+
+}
+
 #endif

Modified: trunk/Source/WebCore/platform/graphics/surfaces/glx/X11WindowResources.h (138566 => 138567)


--- trunk/Source/WebCore/platform/graphics/surfaces/glx/X11WindowResources.h	2012-12-29 17:02:21 UTC (rev 138566)
+++ trunk/Source/WebCore/platform/graphics/surfaces/glx/X11WindowResources.h	2012-12-29 18:11:57 UTC (rev 138567)
@@ -28,41 +28,33 @@
 
 #if USE(ACCELERATED_COMPOSITING)
 
-#include "GLPlatformSurface.h"
+#include "IntRect.h"
 
+#include <opengl/GLDefs.h>
+#include <wtf/Noncopyable.h>
+#include <wtf/PassRefPtr.h>
+#include <wtf/RefCounted.h>
+
 #if USE(GRAPHICS_SURFACE)
 #include <X11/extensions/Xcomposite.h>
 #include <X11/extensions/Xrender.h>
 #endif
 
-#include <wtf/Noncopyable.h>
-#include <wtf/RefCounted.h>
-
 namespace WebCore {
 
-#if USE(GLX)
-class SharedGLXResources;
-typedef SharedGLXResources PlatformSharedResources;
-#elif USE(EGL)
-class SharedX11Resources;
-typedef SharedX11Resources PlatformSharedResources;
-#endif
-
 class SharedX11Resources : public WTF::RefCountedBase {
     WTF_MAKE_NONCOPYABLE(SharedX11Resources);
 
 public:
-#if USE(EGL)
-    static PassRefPtr<PlatformSharedResources> create()
+    static PassRefPtr<SharedX11Resources> create()
     {
         if (!m_staticSharedResource)
-            m_staticSharedResource = new PlatformSharedResources();
+            m_staticSharedResource = new SharedX11Resources();
         else
             m_staticSharedResource->ref();
 
         return adoptRef(m_staticSharedResource);
     }
-#endif
 
     void deref()
     {
@@ -103,7 +95,7 @@
             XMapWindow(dpy, m_window);
 
             if (!m_window) {
-                LOG_ERROR("Failed to create SimpleWindow");
+                LOG_ERROR("Failed to create offscreen root window.");
                 return 0;
             }
         }
@@ -111,7 +103,7 @@
         return m_window;
     }
 
-    bool isXRenderExtensionSupported()
+    bool isXRenderExtensionSupported() const
     {
         return m_supportsXRenderExtension;
     }
@@ -139,28 +131,30 @@
         m_display = 0;
     }
 
-    static PlatformSharedResources* m_staticSharedResource;
+    static SharedX11Resources* m_staticSharedResource;
     bool m_supportsXRenderExtension;
     Window m_window;
     Display* m_display;
 };
 
-class X11OffScreenWindow : public GLPlatformSurface {
+class X11OffScreenWindow {
     WTF_MAKE_NONCOPYABLE(X11OffScreenWindow);
 
 public:
     X11OffScreenWindow();
     virtual ~X11OffScreenWindow();
-    void createOffscreenWindow(PlatformBufferHandle*);
-    void destroyWindow(PlatformBufferHandle);
-    void reSizeWindow(const IntRect&, PlatformBufferHandle);
-    Display* nativeSharedDisplay();
+    void createOffscreenWindow(uint32_t*);
+    void destroyWindow(const uint32_t);
+    void reSizeWindow(const IntRect&, const uint32_t);
+    Display* nativeSharedDisplay() const;
 #if USE(EGL)
     bool setVisualId(const EGLint);
 #endif
+    void setVisualInfo(XVisualInfo*);
+    bool isXRenderExtensionSupported() const;
 
-protected:
-    RefPtr<PlatformSharedResources> m_sharedResources;
+private:
+    RefPtr<SharedX11Resources> m_sharedResources;
     XVisualInfo* m_configVisualInfo;
 };
 
_______________________________________________
webkit-changes mailing list
[email protected]
http://lists.webkit.org/mailman/listinfo/webkit-changes

Reply via email to