[EFL][WK2] Enable WebGL
authorcommit-queue@webkit.org <commit-queue@webkit.org@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Fri, 26 Oct 2012 10:22:02 +0000 (10:22 +0000)
committercommit-queue@webkit.org <commit-queue@webkit.org@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Fri, 26 Oct 2012 10:22:02 +0000 (10:22 +0000)
https://bugs.webkit.org/show_bug.cgi?id=97652

Patch by Regina Chung <heejin.r.chung@samsung.com> on 2012-10-26
Reviewed by Gyuyoung Kim.

.:

Use Graphics Surface to enable WebGL for WebKit2 EFL.

* Source/cmake/OptionsEfl.cmake:

Source/WebCore:

Implemented GraphicsSurface for EFL to enable WebGL for WebKit2.
Depends on GLX since Evas doesn't provide the necessary functionality.

No new tests. Covered by existing tests.

* PlatformEfl.cmake:
* platform/graphics/GraphicsContext3D.h:
* platform/graphics/efl/GraphicsContext3DEfl.cpp:
(WebCore::GraphicsContext3D::createGraphicsSurfaces):
* platform/graphics/efl/GraphicsContext3DPrivate.cpp:
(WebCore::GraphicsContext3DPrivate::GraphicsContext3DPrivate):
(WebCore::GraphicsContext3DPrivate::~GraphicsContext3DPrivate):
(WebCore):
(WebCore::GraphicsContext3DPrivate::createGraphicsSurfaces):
(WebCore::GraphicsContext3DPrivate::copyToGraphicsSurface):
(WebCore::GraphicsContext3DPrivate::graphicsSurfaceToken):
* platform/graphics/efl/GraphicsContext3DPrivate.h:
(GraphicsContext3DPrivate):
* platform/graphics/opengl/GraphicsContext3DOpenGLCommon.cpp:
(WebCore::GraphicsContext3D::reshape):
* platform/graphics/surfaces/efl: Added.
* platform/graphics/surfaces/efl/GraphicsSurfaceEfl.cpp: Added.
(WebCore):
(WebCore::OffScreenRootWindow::get):
(WebCore::OffScreenRootWindow::~OffScreenRootWindow):
(WebCore::GraphicsSurfacePrivate::GraphicsSurfacePrivate):
(WebCore::GraphicsSurfacePrivate::createSurface):
(WebCore::GraphicsSurfacePrivate::makeCurrent):
(WebCore::GraphicsSurfacePrivate::doneCurrent):
(WebCore::GraphicsSurfacePrivate::swapBuffers):
(WebCore::GraphicsSurface::platformBeginPaint):
(WebCore::GraphicsSurface::createReadOnlyImage):
* platform/graphics/surfaces/qt/GraphicsSurfaceGLX.cpp:
* platform/graphics/surfaces/qt/GraphicsSurfaceGLX.h: Added.
(WebCore):
(OffScreenRootWindow):
(WebCore::OffScreenRootWindow::OffScreenRootWindow):
(GraphicsSurfacePrivate):
(WebCore::GraphicsSurfacePrivate::~GraphicsSurfacePrivate):
(WebCore::GraphicsSurfacePrivate::createPixmap):
(WebCore::GraphicsSurfacePrivate::copyFromTexture):
(WebCore::GraphicsSurfacePrivate::display):
(WebCore::GraphicsSurfacePrivate::glxPixmap):
(WebCore::GraphicsSurfacePrivate::size):
(WebCore::GraphicsSurfacePrivate::glContext):
(WebCore::resolveGLMethods):
* platform/graphics/surfaces/qt/GraphicsSurfaceQt.cpp:
(WebCore):
(WebCore::OffScreenRootWindow::OffScreenRootWindow::get):
(WebCore::OffScreenRootWindow::~OffScreenRootWindow):
(WebCore::GraphicsSurfacePrivate::GraphicsSurfacePrivate):
(WebCore::GraphicsSurfacePrivate::createSurface):
(WebCore::GraphicsSurfacePrivate::makeCurrent):
(WebCore::GraphicsSurfacePrivate::doneCurrent):
(WebCore::GraphicsSurfacePrivate::swapBuffers):

Source/WebKit2:

Set WebGLEnabled to true when WebGL is enabled.

* UIProcess/API/efl/ewk_view.cpp:
(_ewk_view_initialize):

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

13 files changed:
ChangeLog
Source/WebCore/ChangeLog
Source/WebCore/PlatformEfl.cmake
Source/WebCore/platform/graphics/GraphicsContext3D.h
Source/WebCore/platform/graphics/efl/GraphicsContext3DEfl.cpp
Source/WebCore/platform/graphics/efl/GraphicsContext3DPrivate.cpp
Source/WebCore/platform/graphics/efl/GraphicsContext3DPrivate.h
Source/WebCore/platform/graphics/opengl/GraphicsContext3DOpenGLCommon.cpp
Source/WebCore/platform/graphics/surfaces/qt/GraphicsSurfaceGLX.cpp
Source/WebKit/PlatformEfl.cmake
Source/WebKit2/ChangeLog
Source/WebKit2/UIProcess/API/efl/ewk_view.cpp
Source/cmake/OptionsEfl.cmake

index febafcc..3d640ad 100644 (file)
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,14 @@
+2012-10-26  Regina Chung  <heejin.r.chung@samsung.com>
+
+        [EFL][WK2] Enable WebGL
+        https://bugs.webkit.org/show_bug.cgi?id=97652
+
+        Reviewed by Gyuyoung Kim.
+
+        Use Graphics Surface to enable WebGL for WebKit2 EFL.
+
+        * Source/cmake/OptionsEfl.cmake:
+
 2012-10-26  Thiago Marcos P. Santos  <thiago.santos@intel.com>
 
         Add feature flags for CSS Device Adaptation
index 684d941..528c789 100644 (file)
@@ -1,3 +1,66 @@
+2012-10-26  Regina Chung  <heejin.r.chung@samsung.com>
+
+        [EFL][WK2] Enable WebGL
+        https://bugs.webkit.org/show_bug.cgi?id=97652
+
+        Reviewed by Gyuyoung Kim.
+
+        Implemented GraphicsSurface for EFL to enable WebGL for WebKit2.
+        Depends on GLX since Evas doesn't provide the necessary functionality.
+
+        No new tests. Covered by existing tests.
+
+        * PlatformEfl.cmake:
+        * platform/graphics/GraphicsContext3D.h:
+        * platform/graphics/efl/GraphicsContext3DEfl.cpp:
+        (WebCore::GraphicsContext3D::createGraphicsSurfaces):
+        * platform/graphics/efl/GraphicsContext3DPrivate.cpp:
+        (WebCore::GraphicsContext3DPrivate::GraphicsContext3DPrivate):
+        (WebCore::GraphicsContext3DPrivate::~GraphicsContext3DPrivate):
+        (WebCore):
+        (WebCore::GraphicsContext3DPrivate::createGraphicsSurfaces):
+        (WebCore::GraphicsContext3DPrivate::copyToGraphicsSurface):
+        (WebCore::GraphicsContext3DPrivate::graphicsSurfaceToken):
+        * platform/graphics/efl/GraphicsContext3DPrivate.h:
+        (GraphicsContext3DPrivate):
+        * platform/graphics/opengl/GraphicsContext3DOpenGLCommon.cpp:
+        (WebCore::GraphicsContext3D::reshape):
+        * platform/graphics/surfaces/efl: Added.
+        * platform/graphics/surfaces/efl/GraphicsSurfaceEfl.cpp: Added.
+        (WebCore):
+        (WebCore::OffScreenRootWindow::get):
+        (WebCore::OffScreenRootWindow::~OffScreenRootWindow):
+        (WebCore::GraphicsSurfacePrivate::GraphicsSurfacePrivate):
+        (WebCore::GraphicsSurfacePrivate::createSurface):
+        (WebCore::GraphicsSurfacePrivate::makeCurrent):
+        (WebCore::GraphicsSurfacePrivate::doneCurrent):
+        (WebCore::GraphicsSurfacePrivate::swapBuffers):
+        (WebCore::GraphicsSurface::platformBeginPaint):
+        (WebCore::GraphicsSurface::createReadOnlyImage):
+        * platform/graphics/surfaces/qt/GraphicsSurfaceGLX.cpp:
+        * platform/graphics/surfaces/qt/GraphicsSurfaceGLX.h: Added.
+        (WebCore):
+        (OffScreenRootWindow):
+        (WebCore::OffScreenRootWindow::OffScreenRootWindow):
+        (GraphicsSurfacePrivate):
+        (WebCore::GraphicsSurfacePrivate::~GraphicsSurfacePrivate):
+        (WebCore::GraphicsSurfacePrivate::createPixmap):
+        (WebCore::GraphicsSurfacePrivate::copyFromTexture):
+        (WebCore::GraphicsSurfacePrivate::display):
+        (WebCore::GraphicsSurfacePrivate::glxPixmap):
+        (WebCore::GraphicsSurfacePrivate::size):
+        (WebCore::GraphicsSurfacePrivate::glContext):
+        (WebCore::resolveGLMethods):
+        * platform/graphics/surfaces/qt/GraphicsSurfaceQt.cpp:
+        (WebCore):
+        (WebCore::OffScreenRootWindow::OffScreenRootWindow::get):
+        (WebCore::OffScreenRootWindow::~OffScreenRootWindow):
+        (WebCore::GraphicsSurfacePrivate::GraphicsSurfacePrivate):
+        (WebCore::GraphicsSurfacePrivate::createSurface):
+        (WebCore::GraphicsSurfacePrivate::makeCurrent):
+        (WebCore::GraphicsSurfacePrivate::doneCurrent):
+        (WebCore::GraphicsSurfacePrivate::swapBuffers):
+
 2012-10-26  Thiago Marcos P. Santos  <thiago.santos@intel.com>
 
         Add feature flags for CSS Device Adaptation
index 332734f..387c37c 100644 (file)
@@ -283,6 +283,7 @@ IF (WTF_USE_3D_GRAPHICS)
   LIST(APPEND WebCore_INCLUDE_DIRECTORIES
     "${WEBCORE_DIR}/platform/graphics/cairo"
     "${WEBCORE_DIR}/platform/graphics/opengl"
+    "${WEBCORE_DIR}/platform/graphics/surfaces"
     "${WEBCORE_DIR}/platform/graphics/texmap"
   )
   LIST(APPEND WebCore_SOURCES
@@ -294,6 +295,8 @@ IF (WTF_USE_3D_GRAPHICS)
     platform/graphics/opengl/Extensions3DOpenGLCommon.cpp
     platform/graphics/opengl/GraphicsContext3DOpenGL.cpp
     platform/graphics/opengl/GraphicsContext3DOpenGLCommon.cpp
+    platform/graphics/surfaces/GraphicsSurface.cpp
+    platform/graphics/surfaces/qt/GraphicsSurfaceGLX.cpp
     platform/graphics/texmap/TextureMapperGL.cpp
     platform/graphics/texmap/TextureMapperShaderManager.cpp
   )
index 99a21a2..4ede0f8 100644 (file)
@@ -72,6 +72,7 @@ typedef QOpenGLContext* PlatformGraphicsContext3D;
 typedef QSurface* PlatformGraphicsSurface3D;
 #else
 typedef void* PlatformGraphicsContext3D;
+typedef void* PlatformGraphicsSurface3D;
 #endif
 
 #if (PLATFORM(CHROMIUM) || PLATFORM(BLACKBERRY)) && USE(SKIA)
@@ -947,7 +948,7 @@ public:
 
     bool reshapeFBOs(const IntSize&);
     void resolveMultisamplingIfNecessary(const IntRect& = IntRect());
-#if PLATFORM(QT) && USE(GRAPHICS_SURFACE)
+#if (PLATFORM(QT) || PLATFORM(EFL)) && USE(GRAPHICS_SURFACE)
     void createGraphicsSurfaces(const IntSize&);
 #endif
 
index 65f2d63..b4c1354 100644 (file)
@@ -226,7 +226,7 @@ void GraphicsContext3D::paintToCanvas(const unsigned char* imagePixels, int imag
 #if USE(GRAPHICS_SURFACE)
 void GraphicsContext3D::createGraphicsSurfaces(const IntSize& size)
 {
-    notImplemented();
+    m_private->createGraphicsSurfaces(size);
 }
 #endif
 
index 0ab9892..62d0a6e 100644 (file)
@@ -25,6 +25,7 @@
 #include "GraphicsContext.h"
 #include "HostWindow.h"
 #include "NotImplemented.h"
+#include "PlatformContextCairo.h"
 #include <Ecore_Evas.h>
 #include <Evas_GL.h>
 #include <wtf/OwnArrayPtr.h>
@@ -87,6 +88,13 @@ GraphicsContext3DPrivate::GraphicsContext3DPrivate(GraphicsContext3D* context, H
         return;
 
     makeContextCurrent();
+
+#if USE(GRAPHICS_SURFACE)
+    IntSize surfaceSize(m_context->m_currentWidth, m_context->m_currentHeight);
+    m_surfaceFlags = GraphicsSurface::SupportsTextureTarget | GraphicsSurface::SupportsSharing;
+    if (!surfaceSize.isEmpty())
+        m_graphicsSurface = GraphicsSurface::create(surfaceSize, m_surfaceFlags);
+#endif
 }
 
 GraphicsContext3DPrivate::~GraphicsContext3DPrivate()
@@ -101,8 +109,11 @@ GraphicsContext3DPrivate::~GraphicsContext3DPrivate()
         evas_gl_context_destroy(m_evasGL, m_evasGLContext);
 
     evas_gl_free(m_evasGL);
-}
 
+#if USE(GRAPHICS_SURFACE)
+    m_graphicsSurface.clear();
+#endif
+}
 
 bool GraphicsContext3DPrivate::createSurface(PageClientEfl* pageClient, bool renderDirectlyToHostWindow)
 {
@@ -169,6 +180,32 @@ void GraphicsContext3DPrivate::paintToTextureMapper(TextureMapper*, const FloatR
     notImplemented();
 }
 #endif
+
+#if USE(GRAPHICS_SURFACE)
+void GraphicsContext3DPrivate::createGraphicsSurfaces(const IntSize& size)
+{
+    if (size.isEmpty())
+        m_graphicsSurface.clear();
+    else
+        m_graphicsSurface = GraphicsSurface::create(size, m_surfaceFlags);
+}
+
+uint32_t GraphicsContext3DPrivate::copyToGraphicsSurface()
+{
+    if (!m_graphicsSurface)
+        return 0;
+
+    makeContextCurrent();
+    m_graphicsSurface->copyFromTexture(m_context->m_texture, IntRect(0, 0, m_context->m_currentWidth, m_context->m_currentHeight));
+    return m_graphicsSurface->swapBuffers();
+}
+
+GraphicsSurfaceToken GraphicsContext3DPrivate::graphicsSurfaceToken() const
+{
+    return m_graphicsSurface->exportToken();
+}
+#endif
+
 } // namespace WebCore
 
 #endif // USE(3D_GRAPHICS) || USE(ACCELERATED_COMPOSITING)
index 08ccf77..1ae4351 100644 (file)
 #include <texmap/TextureMapperPlatformLayer.h>
 #endif
 
+#if USE(GRAPHICS_SURFACE)
+#include "GraphicsSurface.h"
+#endif
+
 typedef struct _Evas_GL               Evas_GL;
 typedef struct _Evas_GL_Surface       Evas_GL_Surface;
 typedef struct _Evas_GL_Context       Evas_GL_Context;
@@ -52,6 +56,12 @@ public:
 #if USE(TEXTURE_MAPPER_GL)
     virtual void paintToTextureMapper(TextureMapper*, const FloatRect& target, const TransformationMatrix&, float opacity, BitmapTexture* mask);
 #endif
+#if USE(GRAPHICS_SURFACE)
+    virtual uint32_t copyToGraphicsSurface();
+    virtual GraphicsSurfaceToken graphicsSurfaceToken() const;
+    void createGraphicsSurfaces(const IntSize&);
+#endif
+
     bool makeContextCurrent();
     bool createSurface(PageClientEfl*, bool renderDirectlyToEvasGLObject);
     void setCurrentGLContext(void*, void*);
@@ -59,6 +69,10 @@ public:
     GraphicsContext3D::Attributes m_attributes;
     GraphicsContext3D* m_context;
     HostWindow* m_hostWindow;
+#if USE(GRAPHICS_SURFACE)
+    GraphicsSurface::Flags m_surfaceFlags;
+    RefPtr<GraphicsSurface> m_graphicsSurface;
+#endif
 
     ListHashSet<GC3Denum> m_syntheticErrors;
 
index 3ed2b56..58cfd7f 100644 (file)
@@ -222,7 +222,7 @@ void GraphicsContext3D::reshape(int width, int height)
     if (width == m_currentWidth && height == m_currentHeight)
         return;
 
-#if PLATFORM(QT) && USE(GRAPHICS_SURFACE)
+#if (PLATFORM(QT) || PLATFORM(EFL)) && USE(GRAPHICS_SURFACE)
     ::glFlush(); // Make sure all GL calls have been committed before resizing.
     createGraphicsSurfaces(IntSize(width, height));
 #endif
index fd62a00..929fa00 100644 (file)
 
 #if USE(GRAPHICS_SURFACE)
 
+#include "NotImplemented.h"
 #include "TextureMapperGL.h"
+
+#if PLATFORM(QT)
 // Qt headers must be included before glx headers.
 #include <QCoreApplication>
 #include <QOpenGLContext>
 #include <QVector>
 #include <QWindow>
 #include <qpa/qplatformwindow.h>
+#elif PLATFORM(EFL)
+#include <GL/gl.h>
+#endif
+
 #include <GL/glext.h>
 #include <GL/glx.h>
 #include <X11/extensions/Xcomposite.h>
@@ -53,6 +60,7 @@ public:
         ++refCount;
     }
 
+#if PLATFORM(QT) 
     QWindow* get(Display* dpy)
     {
         if (!window) {
@@ -67,22 +75,52 @@ public:
 
         return window;
     }
+#elif PLATFORM(EFL)
+    Window* get(Display* dpy)
+    {
+        if (!window) {
+            window = XCreateSimpleWindow(dpy, XDefaultRootWindow(dpy), -1, -1, 1, 1, 0, BlackPixel(dpy, 0), WhitePixel(dpy, 0));
+            XSetWindowAttributes attributes;
+            attributes.override_redirect = true;
+            XChangeWindowAttributes(dpy, window, X11OverrideRedirect, &attributes);
+            display = dpy;
+            // Map window to the screen
+            XMapWindow(dpy, window);
+        }
+
+        return &window;
+    }
+#endif
 
     ~OffScreenRootWindow()
     {
         if (!--refCount) {
+#if PLATFORM(QT)
             delete window;
             window = 0;
+#elif PLATFORM(EFL)
+            XUnmapWindow(display, window);
+            XDestroyWindow(display, window);
+#endif
         }
     }
 
 private:
     static int refCount;
+#if PLATFORM(QT)
     static QWindow* window;
+#elif PLATFORM(EFL)
+    static Window window;
+    Display* display;
+#endif
 };
 
 int OffScreenRootWindow::refCount = 0;
+#if PLATFORM(QT)
 QWindow* OffScreenRootWindow::window = 0;
+#elif PLATFORM(EFL)
+Window OffScreenRootWindow::window = 0;
+#endif
 
 static const int glxSpec[] = {
     // The specification is a set key value pairs stored in a simple array.
@@ -106,18 +144,20 @@ struct GraphicsSurfacePrivate {
         : m_display(0)
         , m_xPixmap(0)
         , m_glxPixmap(0)
-        , m_glContext(adoptPtr(new QOpenGLContext))
+        , m_glContext(0)
         , m_detachedContext(0)
         , m_detachedSurface(0)
         , m_textureIsYInverted(false)
         , m_hasAlpha(false)
     {
+#if PLATFORM(QT)
         QSurface* currentSurface = 0;
         QOpenGLContext* currentContext = QOpenGLContext::currentContext();
         if (currentContext)
             currentSurface = currentContext->surface();
 
         m_display = XOpenDisplay(0);
+        m_glContext = adoptPtr(new QOpenGLContext);
         m_glContext->setShareContext(shareContext);
         m_glContext->create();
 
@@ -125,6 +165,25 @@ struct GraphicsSurfacePrivate {
         // Therefore we have to make the previous context current again.
         if (currentContext)
             currentContext->makeCurrent(currentSurface);
+#elif PLATFORM(EFL)
+        m_display = XOpenDisplay(0);
+
+        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_DOUBLEBUFFER,  True,
+            None
+        };
+
+        int numReturned;
+        m_fbConfigs = glXChooseFBConfig(m_display, DefaultScreen(m_display), attributes, &numReturned);
+        // Create a GLX context for OpenGL rendering
+        m_glContext = glXCreateNewContext(m_display, m_fbConfigs[0], GLX_RGBA_TYPE, 0, true);
+#endif
     }
 
     ~GraphicsSurfacePrivate()
@@ -144,6 +203,7 @@ struct GraphicsSurfacePrivate {
 
     uint32_t createSurface(const IntSize& size)
     {
+#if PLATFORM(QT)
         m_surface = adoptPtr(new QWindow(m_offScreenWindow.get(m_display)));
         m_surface->setSurfaceType(QSurface::OpenGLSurface);
         m_surface->setGeometry(0, 0, size.width(), size.height());
@@ -158,6 +218,30 @@ struct GraphicsSurfacePrivate {
         m_surface->show();
 
         return m_surface->handle()->winId();
+#elif PLATFORM(EFL)
+        XVisualInfo* visualInfo = glXGetVisualFromFBConfig(m_display, m_fbConfigs[0]);
+        if (!visualInfo)
+            return 0;
+
+        Colormap cmap = XCreateColormap(m_display, *m_offScreenWindow.get(m_display), visualInfo->visual, AllocNone);
+        XSetWindowAttributes a;
+        a.background_pixel = WhitePixel(m_display, 0);
+        a.border_pixel = BlackPixel(m_display, 0);
+        a.colormap = cmap;
+        m_surface = XCreateWindow(m_display, *m_offScreenWindow.get(m_display), 0, 0, size.width(), size.height(),
+            0, visualInfo->depth, InputOutput, visualInfo->visual,
+            CWBackPixel | CWBorderPixel | CWColormap, &a);
+        XSetWindowBackgroundPixmap(m_display, m_surface, 0);
+        XCompositeRedirectWindow(m_display, m_surface, CompositeRedirectManual);
+
+        // Make sure the XRender Extension is available.
+        int eventBasep, errorBasep;
+        if (!XRenderQueryExtension(m_display, &eventBasep, &errorBasep))
+            return 0;
+
+        XMapWindow(m_display, m_surface);
+        return m_surface;
+#endif
     }
 
     void createPixmap(uint32_t winId)
@@ -184,18 +268,30 @@ struct GraphicsSurfacePrivate {
 
     void makeCurrent()
     {
+#if PLATFORM(QT)
         m_detachedContext = QOpenGLContext::currentContext();
         if (m_detachedContext)
             m_detachedSurface = m_detachedContext->surface();
 
         if (m_surface && m_glContext)
             m_glContext->makeCurrent(m_surface.get());
+#elif PLATFORM(EFL)
+        m_detachedContext = glXGetCurrentContext();
+        m_detachedSurface = glXGetCurrentDrawable();
+        if (m_surface && m_glContext)
+            glXMakeCurrent(m_display, m_surface, m_glContext);
+#endif
     }
 
     void doneCurrent()
     {
         if (m_detachedContext)
+#if PLATFORM(QT)
             m_detachedContext->makeCurrent(m_detachedSurface);
+#elif PLATFORM(EFL)
+            glXMakeCurrent(m_display, m_detachedSurface, m_detachedContext);    
+#endif
+        m_detachedContext = 0;
     }
 
     void swapBuffers()
@@ -206,6 +302,7 @@ struct GraphicsSurfacePrivate {
         if (m_xPixmap)
             return;
 
+#if PLATFORM(QT)
         if (!m_surface->isVisible())
             return;
 
@@ -222,6 +319,17 @@ struct GraphicsSurfacePrivate {
             glContext->swapBuffers(m_surface.get());
             pGlBindFramebuffer(GL_FRAMEBUFFER, oldFBO);
         }
+#elif PLATFORM(EFL)
+        GLXContext glContext = glXGetCurrentContext();
+
+        if (m_surface && glContext) {
+            GLint oldFBO;
+            glGetIntegerv(GL_FRAMEBUFFER_BINDING, &oldFBO);
+            pGlBindFramebuffer(GL_FRAMEBUFFER, 0);
+            glXSwapBuffers(m_display, m_surface);
+            pGlBindFramebuffer(GL_FRAMEBUFFER, oldFBO);
+        }
+#endif
     }
 
     void copyFromTexture(uint32_t texture, const IntRect& sourceRect)
@@ -242,7 +350,11 @@ struct GraphicsSurfacePrivate {
         glBindTexture(GL_TEXTURE_2D, texture);
         pGlFramebufferTexture2D(GL_READ_FRAMEBUFFER, GL_COLOR_ATTACHMENT0, GL_TEXTURE_2D, texture, 0);
 
+#if PLATFORM(QT)
         pGlBindFramebuffer(GL_DRAW_FRAMEBUFFER, glContext()->defaultFramebufferObject());
+#elif PLATFORM(EFL)
+        pGlBindFramebuffer(GL_DRAW_FRAMEBUFFER, 0);
+#endif
         pGlBlitFramebuffer(x, y, width, height, x, y, width, height, GL_COLOR_BUFFER_BIT, GL_LINEAR);
 
         pGlFramebufferTexture2D(GL_READ_FRAMEBUFFER, GL_COLOR_ATTACHMENT0, GL_TEXTURE_2D, 0, 0);
@@ -254,14 +366,15 @@ struct GraphicsSurfacePrivate {
         doneCurrent();
     }
 
-
     Display* display() const { return m_display; }
 
     GLXPixmap glxPixmap() const { return m_glxPixmap; }
 
     IntSize size() const { return m_size; }
 
+#if PLATFORM(QT)
     QOpenGLContext* glContext() { return m_glContext.get(); }
+#endif
 
 private:
     OffScreenRootWindow m_offScreenWindow;
@@ -269,10 +382,18 @@ private:
     Display* m_display;
     Pixmap m_xPixmap;
     GLXPixmap m_glxPixmap;
+#if PLATFORM(QT)
     OwnPtr<QWindow> m_surface;
     OwnPtr<QOpenGLContext> m_glContext;
     QOpenGLContext* m_detachedContext;
     QSurface* m_detachedSurface;
+#elif PLATFORM(EFL)
+    Window m_surface;
+    GLXContext m_glContext;
+    GLXContext m_detachedContext;
+    GLXDrawable m_detachedSurface;
+    GLXFBConfig* m_fbConfigs;
+#endif
     bool m_textureIsYInverted;
     bool m_hasAlpha;
 };
@@ -282,7 +403,7 @@ static bool resolveGLMethods(GraphicsSurfacePrivate* p)
     static bool resolved = false;
     if (resolved)
         return true;
-
+#if PLATFORM(QT)
     QOpenGLContext* glContext = p->glContext();
     pGlXBindTexImageEXT = reinterpret_cast<PFNGLXBINDTEXIMAGEEXTPROC>(glContext->getProcAddress("glXBindTexImageEXT"));
     pGlXReleaseTexImageEXT = reinterpret_cast<PFNGLXRELEASETEXIMAGEEXTPROC>(glContext->getProcAddress("glXReleaseTexImageEXT"));
@@ -292,7 +413,16 @@ static bool resolveGLMethods(GraphicsSurfacePrivate* p)
     pGlGenFramebuffers = reinterpret_cast<PFNGLGENFRAMEBUFFERSPROC>(glContext->getProcAddress("glGenFramebuffers"));
     pGlDeleteFramebuffers = reinterpret_cast<PFNGLDELETEFRAMEBUFFERSPROC>(glContext->getProcAddress("glDeleteFramebuffers"));
     pGlFramebufferTexture2D = reinterpret_cast<PFNGLFRAMEBUFFERTEXTURE2DPROC>(glContext->getProcAddress("glFramebufferTexture2D"));
-
+#elif PLATFORM(EFL)
+    pGlXBindTexImageEXT = reinterpret_cast<PFNGLXBINDTEXIMAGEEXTPROC>(glXGetProcAddress(reinterpret_cast<const GLubyte*>("glXBindTexImageEXT")));
+    pGlXReleaseTexImageEXT = reinterpret_cast<PFNGLXRELEASETEXIMAGEEXTPROC>(glXGetProcAddress(reinterpret_cast<const GLubyte*>("glXReleaseTexImageEXT")));
+    pGlBindFramebuffer = reinterpret_cast<PFNGLBINDFRAMEBUFFERPROC>(glXGetProcAddress(reinterpret_cast<const GLubyte*>("glBindFramebuffer")));
+    pGlBlitFramebuffer = reinterpret_cast<PFNGLBLITFRAMEBUFFERPROC>(glXGetProcAddress(reinterpret_cast<const GLubyte*>("glBlitFramebuffer")));
+
+    pGlGenFramebuffers = reinterpret_cast<PFNGLGENFRAMEBUFFERSPROC>(glXGetProcAddress(reinterpret_cast<const GLubyte*>("glGenFramebuffers")));
+    pGlDeleteFramebuffers = reinterpret_cast<PFNGLDELETEFRAMEBUFFERSPROC>(glXGetProcAddress(reinterpret_cast<const GLubyte*>("glDeleteFramebuffers")));
+    pGlFramebufferTexture2D = reinterpret_cast<PFNGLFRAMEBUFFERTEXTURE2DPROC>(glXGetProcAddress(reinterpret_cast<const GLubyte*>("glFramebufferTexture2D")));
+#endif
     resolved = pGlBlitFramebuffer && pGlBindFramebuffer && pGlXBindTexImageEXT && pGlXReleaseTexImageEXT;
 
     return resolved;
@@ -410,5 +540,18 @@ void GraphicsSurface::platformDestroy()
     m_private = 0;
 }
 
+#if !PLATFORM(QT)
+PassOwnPtr<GraphicsContext> GraphicsSurface::platformBeginPaint(const IntSize&, char*, int)
+{
+    notImplemented();
+    return nullptr;
+}
+
+PassRefPtr<Image> GraphicsSurface::createReadOnlyImage(const IntRect&)
+{
+    notImplemented();
+    return 0;
+}
+#endif
 }
 #endif
index 0491fb7..e8c0307 100644 (file)
@@ -80,6 +80,7 @@ ENDIF ()
 
 IF (WTF_USE_TEXTURE_MAPPER_GL)
   LIST(APPEND WebKit_INCLUDE_DIRECTORIES
+    "${WEBCORE_DIR}/platform/graphics/surfaces"
     "${WEBCORE_DIR}/platform/graphics/texmap"
     "${THIRDPARTY_DIR}/ANGLE/include/GLSLANG"
   )
index 67d4d58..61665d7 100644 (file)
@@ -1,3 +1,15 @@
+2012-10-26  Regina Chung  <heejin.r.chung@samsung.com>
+
+        [EFL][WK2] Enable WebGL
+        https://bugs.webkit.org/show_bug.cgi?id=97652
+
+        Reviewed by Gyuyoung Kim.
+
+        Set WebGLEnabled to true when WebGL is enabled.
+
+        * UIProcess/API/efl/ewk_view.cpp:
+        (_ewk_view_initialize):
+
 2012-10-26  Thiago Marcos P. Santos  <thiago.santos@intel.com>
 
         Add feature flags for CSS Device Adaptation
index 5530acb..b31d3b2 100644 (file)
@@ -572,6 +572,9 @@ static void _ewk_view_initialize(Evas_Object* ewkView, PassRefPtr<Ewk_Context> c
     impl->pageProxy->pageGroup()->preferences()->setAcceleratedCompositingEnabled(true);
     impl->pageProxy->pageGroup()->preferences()->setForceCompositingMode(true);
     impl->pageProxy->setUseFixedLayout(true);
+#if ENABLE(WEBGL)
+    impl->pageProxy->pageGroup()->preferences()->setWebGLEnabled(true);
+#endif
 #endif
     impl->pageProxy->initializeWebPage();
 
index 23c8525..996af5b 100644 (file)
@@ -192,6 +192,11 @@ IF (WTF_USE_TILED_BACKING_STORE)
   SET(ENABLE_3D_RENDERING 1)
   ADD_DEFINITIONS(-DENABLE_3D_RENDERING=1)
 
+  SET (ENABLE_WEBGL 1)
+  SET (WTF_USE_GRAPHICS_SURFACE 1)
+  ADD_DEFINITIONS(-DWTF_USE_GRAPHICS_SURFACE=1)
+  ADD_DEFINITIONS(-DHAVE_GLX)
+
   FIND_PACKAGE(OpenGL REQUIRED)
 ENDIF()