Title: [117612] trunk/Source
Revision
117612
Author
[email protected]
Date
2012-05-18 12:16:49 -0700 (Fri, 18 May 2012)

Log Message

OOM running webgl/sdk/tests/conformance/context/context-creation-and-destruction.html
https://bugs.webkit.org/show_bug.cgi?id=80509

Reviewed by Alejandro G. Castro.

Source/WebCore:

No new tests. This is covered by by context-creation-and-destruction.html
Khronos conformance test which will be part of the WebKit repository once
bug 44310 is closed.

Rework the ownership of GLContexts. Instead of having them managed by the
state of window mapping or removed by calling a static method, always have
them owned by the callers. This makes all GLContext creators factory methods
that return PassOwnPtr.

This change also switches the sharing context for a WebView from the window
context to a global shared context. This simplifies things greatly, allowing
the removal of GLContextGtk and makes the factory change easier.

* GNUmakefile.list.am: Remove GLContextGtk.cpp from the source list.
* platform/graphics/cairo/GLContext.cpp:
(WebCore::GLContext::sharingContext): Added, getter for the global sharing context.
(WebCore::GLContext::createContextForWindow): Added, a factory method for creating
window contexts.
(WebCore::GLContext::createOffscreenContext): Allow passing a sharing context here.
(WebCore::GLContext::makeContextCurrent): Assert that this is the main thread, to
increase the guarantee that we are only using these contexts on the main thread.
(WebCore::GLContext::getCurrent): Ditto.
* platform/graphics/cairo/GLContext.h: Update the above method signatures and remove
createOffscreenContext, which has just been subsumed into the other factory methods.
* platform/graphics/cairo/GraphicsContext3DCairo.cpp: The HostWindow is no longer needed
to get the sharing context, so we can simplify things quite a bit and make a platform
independent implementation here.
* platform/graphics/cairo/GraphicsContext3DPrivate.cpp: Ditto.
* platform/graphics/glx/GLContextGLX.cpp: Modify all the factory methods to return PassOwnPtr.
* platform/graphics/glx/GLContextGLX.h: Ditto.
* platform/graphics/gtk/GLContextGtk.cpp: Removed.

Source/WebKit/gtk:

AcceleratedCompositingContext context now fully owns the GLContext for its
window. This simplifies this quite a bit. We also properly clean it up when
destroying the layer tree, to go more easily on resources.

* WebCoreSupport/AcceleratedCompositingContext.h:
(AcceleratedCompositingContext):
* WebCoreSupport/AcceleratedCompositingContextGL.cpp:
(WebKit::AcceleratedCompositingContext::glContext):
(WebKit::AcceleratedCompositingContext::attachRootGraphicsLayer):

Modified Paths

Removed Paths

Diff

Modified: trunk/Source/WebCore/ChangeLog (117611 => 117612)


--- trunk/Source/WebCore/ChangeLog	2012-05-18 19:12:27 UTC (rev 117611)
+++ trunk/Source/WebCore/ChangeLog	2012-05-18 19:16:49 UTC (rev 117612)
@@ -1,3 +1,42 @@
+2012-05-18  Martin Robinson  <[email protected]>
+
+        OOM running webgl/sdk/tests/conformance/context/context-creation-and-destruction.html
+        https://bugs.webkit.org/show_bug.cgi?id=80509
+
+        Reviewed by Alejandro G. Castro.
+
+        No new tests. This is covered by by context-creation-and-destruction.html
+        Khronos conformance test which will be part of the WebKit repository once
+        bug 44310 is closed.
+
+        Rework the ownership of GLContexts. Instead of having them managed by the
+        state of window mapping or removed by calling a static method, always have
+        them owned by the callers. This makes all GLContext creators factory methods
+        that return PassOwnPtr.
+
+        This change also switches the sharing context for a WebView from the window
+        context to a global shared context. This simplifies things greatly, allowing
+        the removal of GLContextGtk and makes the factory change easier.
+
+        * GNUmakefile.list.am: Remove GLContextGtk.cpp from the source list.
+        * platform/graphics/cairo/GLContext.cpp:
+        (WebCore::GLContext::sharingContext): Added, getter for the global sharing context.
+        (WebCore::GLContext::createContextForWindow): Added, a factory method for creating
+        window contexts.
+        (WebCore::GLContext::createOffscreenContext): Allow passing a sharing context here.
+        (WebCore::GLContext::makeContextCurrent): Assert that this is the main thread, to
+        increase the guarantee that we are only using these contexts on the main thread.
+        (WebCore::GLContext::getCurrent): Ditto.
+        * platform/graphics/cairo/GLContext.h: Update the above method signatures and remove
+        createOffscreenContext, which has just been subsumed into the other factory methods.
+        * platform/graphics/cairo/GraphicsContext3DCairo.cpp: The HostWindow is no longer needed
+        to get the sharing context, so we can simplify things quite a bit and make a platform
+        independent implementation here.
+        * platform/graphics/cairo/GraphicsContext3DPrivate.cpp: Ditto.
+        * platform/graphics/glx/GLContextGLX.cpp: Modify all the factory methods to return PassOwnPtr.
+        * platform/graphics/glx/GLContextGLX.h: Ditto.
+        * platform/graphics/gtk/GLContextGtk.cpp: Removed.
+
 2012-05-18  Pablo Flouret  <[email protected]>
 
         Script elements inserted while fragment parsing should have their "already started" flag set.

Modified: trunk/Source/WebCore/GNUmakefile.list.am (117611 => 117612)


--- trunk/Source/WebCore/GNUmakefile.list.am	2012-05-18 19:12:27 UTC (rev 117611)
+++ trunk/Source/WebCore/GNUmakefile.list.am	2012-05-18 19:16:49 UTC (rev 117612)
@@ -4788,7 +4788,6 @@
 webcoregtk_sources += \
 	Source/WebCore/platform/graphics/glx/GLContextGLX.cpp \
 	Source/WebCore/platform/graphics/glx/GLContextGLX.h \
-	Source/WebCore/platform/graphics/gtk/GLContextGtk.cpp \
 	Source/WebCore/platform/graphics/cairo/GLContext.cpp \
 	Source/WebCore/platform/graphics/cairo/GLContext.h \
 	Source/WebCore/platform/gtk/GtkWidgetBackingStoreX11.cpp \

Modified: trunk/Source/WebCore/platform/graphics/cairo/GLContext.cpp (117611 => 117612)


--- trunk/Source/WebCore/platform/graphics/cairo/GLContext.cpp	2012-05-18 19:12:27 UTC (rev 117611)
+++ trunk/Source/WebCore/platform/graphics/cairo/GLContext.cpp	2012-05-18 19:16:49 UTC (rev 117612)
@@ -21,23 +21,37 @@
 
 #if USE(OPENGL)
 
+#include <wtf/MainThread.h>
+
 #if USE(GLX)
 #include "GLContextGLX.h"
 #endif
 
 namespace WebCore {
 
+GLContext* GLContext::sharingContext()
+{
+    ASSERT(isMainThread());
+    DEFINE_STATIC_LOCAL(OwnPtr<GLContext>, sharing, (createOffscreenContext()));
+    return sharing.get();
+}
+
+PassOwnPtr<GLContext> GLContext::createContextForWindow(uint64_t windowHandle, GLContext* sharingContext)
+{
+#if USE(GLX)
+    return GLContextGLX::createContext(windowHandle, sharingContext);
+#endif
+    return nullptr;
+}
+
 GLContext::GLContext()
 {
 }
 
-GLContext* GLContext::createOffscreenContext(GLContext* sharing)
+PassOwnPtr<GLContext> GLContext::createOffscreenContext(GLContext* sharing)
 {
-    if (sharing)
-        return sharing->createOffscreenSharingContext();
-
 #if USE(GLX)
-    return GLContextGLX::createContext(0, 0);
+    return GLContextGLX::createContext(0, sharing);
 #endif
 }
 
@@ -53,12 +67,14 @@
 
 bool GLContext::makeContextCurrent()
 {
+    ASSERT(isMainThread());
     gCurrentContext = this;
     return true;
 }
 
 GLContext* GLContext::getCurrent()
 {
+    ASSERT(isMainThread());
     return gCurrentContext;
 }
 

Modified: trunk/Source/WebCore/platform/graphics/cairo/GLContext.h (117611 => 117612)


--- trunk/Source/WebCore/platform/graphics/cairo/GLContext.h	2012-05-18 19:12:27 UTC (rev 117611)
+++ trunk/Source/WebCore/platform/graphics/cairo/GLContext.h	2012-05-18 19:16:49 UTC (rev 117612)
@@ -30,13 +30,13 @@
 class GLContext {
     WTF_MAKE_NONCOPYABLE(GLContext);
 public:
-    static GLContext* getContextForWidget(PlatformWidget);
-    static GLContext* createOffscreenContext(GLContext* sharing = 0);
+    static PassOwnPtr<GLContext> createContextForWindow(uint64_t windowHandle, GLContext* sharingContext);
+    static PassOwnPtr<GLContext> createOffscreenContext(GLContext* sharing = 0);
     static GLContext* getCurrent();
+    static GLContext* sharingContext();
 
     GLContext();
     virtual ~GLContext();
-    virtual GLContext* createOffscreenSharingContext() = 0;
     virtual bool makeContextCurrent();
     virtual void swapBuffers() = 0;
     virtual bool canRenderToDefaultFramebuffer() = 0;

Modified: trunk/Source/WebCore/platform/graphics/cairo/GraphicsContext3DCairo.cpp (117611 => 117612)


--- trunk/Source/WebCore/platform/graphics/cairo/GraphicsContext3DCairo.cpp	2012-05-18 19:12:27 UTC (rev 117611)
+++ trunk/Source/WebCore/platform/graphics/cairo/GraphicsContext3DCairo.cpp	2012-05-18 19:16:49 UTC (rev 117612)
@@ -63,7 +63,7 @@
     return context.release();
 }
 
-GraphicsContext3D::GraphicsContext3D(GraphicsContext3D::Attributes attributes, HostWindow* hostWindow, bool)
+GraphicsContext3D::GraphicsContext3D(GraphicsContext3D::Attributes attributes, HostWindow*, bool)
     : m_currentWidth(0)
     , m_currentHeight(0)
     , m_attrs(attributes)
@@ -74,7 +74,7 @@
     , m_multisampleFBO(0)
     , m_multisampleDepthStencilBuffer(0)
     , m_multisampleColorBuffer(0)
-    , m_private(GraphicsContext3DPrivate::create(this, hostWindow))
+    , m_private(GraphicsContext3DPrivate::create(this))
 {
     makeContextCurrent();
 

Modified: trunk/Source/WebCore/platform/graphics/cairo/GraphicsContext3DPrivate.cpp (117611 => 117612)


--- trunk/Source/WebCore/platform/graphics/cairo/GraphicsContext3DPrivate.cpp	2012-05-18 19:12:27 UTC (rev 117611)
+++ trunk/Source/WebCore/platform/graphics/cairo/GraphicsContext3DPrivate.cpp	2012-05-18 19:16:49 UTC (rev 117612)
@@ -31,19 +31,14 @@
 
 namespace WebCore {
 
-PassOwnPtr<GraphicsContext3DPrivate> GraphicsContext3DPrivate::create(GraphicsContext3D* context, HostWindow* window)
+PassOwnPtr<GraphicsContext3DPrivate> GraphicsContext3DPrivate::create(GraphicsContext3D* context)
 {
-    return adoptPtr(new GraphicsContext3DPrivate(context, window));
+    return adoptPtr(new GraphicsContext3DPrivate(context));
 }
 
-GraphicsContext3DPrivate::GraphicsContext3DPrivate(GraphicsContext3D* context, HostWindow* window)
+GraphicsContext3DPrivate::GraphicsContext3DPrivate(GraphicsContext3D* context)
     : m_context(context)
-    , m_window(window)
-#if PLATFORM(GTK)
-    , m_glContext(GLContext::createOffscreenContext(GLContext::getContextForWidget(m_window->platformPageClient())))
-#else
-    , m_glContext(GLContext::createOffscreenContext())
-#endif
+    , m_glContext(GLContext::createOffscreenContext(GLContext::sharingContext()))
 {
 }
 

Modified: trunk/Source/WebCore/platform/graphics/cairo/GraphicsContext3DPrivate.h (117611 => 117612)


--- trunk/Source/WebCore/platform/graphics/cairo/GraphicsContext3DPrivate.h	2012-05-18 19:12:27 UTC (rev 117611)
+++ trunk/Source/WebCore/platform/graphics/cairo/GraphicsContext3DPrivate.h	2012-05-18 19:16:49 UTC (rev 117612)
@@ -36,7 +36,7 @@
 #endif
 {
 public:
-    static PassOwnPtr<GraphicsContext3DPrivate> create(GraphicsContext3D*, HostWindow*);
+    static PassOwnPtr<GraphicsContext3DPrivate> create(GraphicsContext3D*);
     ~GraphicsContext3DPrivate();
     bool makeContextCurrent();
     PlatformGraphicsContext3D platformContext();
@@ -46,11 +46,10 @@
 #endif
 
 private:
-    GraphicsContext3DPrivate(GraphicsContext3D*, HostWindow*);
+    GraphicsContext3DPrivate(GraphicsContext3D*);
 
     GraphicsContext3D* m_context;
-    HostWindow* m_window;
-    GLContext* m_glContext;
+    OwnPtr<GLContext> m_glContext;
 };
 
 }

Modified: trunk/Source/WebCore/platform/graphics/glx/GLContextGLX.cpp (117611 => 117612)


--- trunk/Source/WebCore/platform/graphics/glx/GLContextGLX.cpp	2012-05-18 19:12:27 UTC (rev 117611)
+++ trunk/Source/WebCore/platform/graphics/glx/GLContextGLX.cpp	2012-05-18 19:16:49 UTC (rev 117612)
@@ -80,37 +80,34 @@
     gSharedDisplay = 0;
 }
 
-GLContext* GLContextGLX::createOffscreenSharingContext()
+PassOwnPtr<GLContextGLX> GLContextGLX::createWindowContext(XID window, GLContext* sharingContext)
 {
-    return createContext(0, m_context);
-}
-
-GLContextGLX* GLContextGLX::createWindowContext(XID window, GLXContext sharingContext)
-{
     Display* display = sharedDisplay();
     XWindowAttributes attributes;
     if (!XGetWindowAttributes(display, window, &attributes))
-        return 0;
+        return nullptr;
 
     XVisualInfo visualInfo;
     visualInfo.visualid = XVisualIDFromVisual(attributes.visual);
 
     int numReturned = 0;
     XVisualInfo* visualInfoList = XGetVisualInfo(display, VisualIDMask, &visualInfo, &numReturned);
-    GLXContext context = glXCreateContext(display, visualInfoList, sharingContext, True);
+
+    GLXContext glxSharingContext = sharingContext ? static_cast<GLContextGLX*>(sharingContext)->m_context : 0;
+    GLXContext context = glXCreateContext(display, visualInfoList, glxSharingContext, True);
     XFree(visualInfoList);
 
     if (!context)
-        return 0;
+        return nullptr;
 
     // GLXPbuffer and XID are both the same types underneath, so we have to share
     // a constructor here with the window path.
     GLContextGLX* contextWrapper = new GLContextGLX(context);
     contextWrapper->m_window = window;
-    return contextWrapper;
+    return adoptPtr(contextWrapper);
 }
 
-GLContextGLX* GLContextGLX::createPbufferContext(GLXContext sharingContext)
+PassOwnPtr<GLContextGLX> GLContextGLX::createPbufferContext(GLXContext sharingContext)
 {
     int fbConfigAttributes[] = {
         GLX_DRAWABLE_TYPE, GLX_PBUFFER_BIT,
@@ -128,7 +125,7 @@
     GLXFBConfig* configs = glXChooseFBConfig(display, 0, fbConfigAttributes, &returnedElements);
     if (!returnedElements) {
         XFree(configs);
-        return 0;
+        return nullptr;
     }
 
     // We will be rendering to a texture, so our pbuffer does not need to be large.
@@ -136,22 +133,22 @@
     GLXPbuffer pbuffer = glXCreatePbuffer(display, configs[0], pbufferAttributes);
     if (!pbuffer) {
         XFree(configs);
-        return 0;
+        return nullptr;
     }
 
     GLXContext context = glXCreateNewContext(display, configs[0], GLX_RGBA_TYPE, sharingContext, GL_TRUE);
     XFree(configs);
     if (!context)
-        return 0;
+        return nullptr;
 
     // GLXPbuffer and XID are both the same types underneath, so we have to share
     // a constructor here with the window path.
     GLContextGLX* contextWrapper = new GLContextGLX(context);
     contextWrapper->m_pbuffer = pbuffer;
-    return contextWrapper;
+    return adoptPtr(contextWrapper);
 }
 
-GLContextGLX* GLContextGLX::createPixmapContext(GLXContext sharingContext)
+PassOwnPtr<GLContextGLX> GLContextGLX::createPixmapContext(GLXContext sharingContext)
 {
     static int visualAttributes[] = {
         GLX_RGBA,
@@ -165,34 +162,34 @@
     Display* display = sharedDisplay();
     XVisualInfo* visualInfo = glXChooseVisual(display, DefaultScreen(display), visualAttributes);
     if (!visualInfo)
-        return 0;
+        return nullptr;
 
     GLXContext context = glXCreateContext(display, visualInfo, sharingContext, GL_TRUE);
     if (!context) {
         XFree(visualInfo);
-        return 0;
+        return nullptr;
     }
 
     Pixmap pixmap = XCreatePixmap(display, DefaultRootWindow(display), 1, 1, visualInfo->depth);
     if (!pixmap) {
         XFree(visualInfo);
-        return 0;
+        return nullptr;
     }
 
     GLXPixmap glxPixmap = glXCreateGLXPixmap(display, visualInfo, pixmap);
     if (!glxPixmap) {
         XFreePixmap(display, pixmap);
         XFree(visualInfo);
-        return 0;
+        return nullptr;
     }
 
-    return new GLContextGLX(context, pixmap, glxPixmap);
+    return adoptPtr(new GLContextGLX(context, pixmap, glxPixmap));
 }
 
-GLContextGLX* GLContextGLX::createContext(XID window, GLXContext sharingContext)
+PassOwnPtr<GLContextGLX> GLContextGLX::createContext(XID window, GLContext* sharingContext)
 {
     if (!sharedDisplay())
-        return 0;
+        return nullptr;
 
     static bool initialized = false;
     static bool success = true;
@@ -201,17 +198,18 @@
         initialized = true;
     }
     if (!success)
-        return 0;
+        return nullptr;
 
-    GLContextGLX* context = window ? createWindowContext(window, sharingContext) : 0;
+    GLXContext glxSharingContext = sharingContext ? static_cast<GLContextGLX*>(sharingContext)->m_context : 0;
+    OwnPtr<GLContextGLX> context = window ? createWindowContext(window, sharingContext) : nullptr;
     if (!context)
-        context = createPbufferContext(sharingContext);
+        context = createPbufferContext(glxSharingContext);
     if (!context)
-        context = createPixmapContext(sharingContext);
+        context = createPixmapContext(glxSharingContext);
     if (!context)
-        return 0;
+        return nullptr;
 
-    return context;
+    return context.release();
 }
 
 GLContextGLX::GLContextGLX(GLXContext context)

Modified: trunk/Source/WebCore/platform/graphics/glx/GLContextGLX.h (117611 => 117612)


--- trunk/Source/WebCore/platform/graphics/glx/GLContextGLX.h	2012-05-18 19:12:27 UTC (rev 117611)
+++ trunk/Source/WebCore/platform/graphics/glx/GLContextGLX.h	2012-05-18 19:16:49 UTC (rev 117612)
@@ -39,14 +39,10 @@
 class GLContextGLX : public GLContext {
     WTF_MAKE_NONCOPYABLE(GLContextGLX);
 public:
-    static GLContextGLX* createContext(XID, GLXContext sharingContext = 0);
-    static GLContextGLX* createWindowContext(XID window, GLXContext sharingContext);
-    static GLContextGLX* createPbufferContext(GLXContext sharingContext);
-    static GLContextGLX* createPixmapContext(GLXContext sharingContext);
-    static void removeActiveContext(GLContext*);
+    static PassOwnPtr<GLContextGLX> createContext(XID, GLContext* sharingContext = 0);
+    static PassOwnPtr<GLContextGLX> createWindowContext(XID window, GLContext* sharingContext);
 
     virtual ~GLContextGLX();
-    virtual GLContext* createOffscreenSharingContext();
     virtual bool makeContextCurrent();
     virtual void swapBuffers();
     virtual bool canRenderToDefaultFramebuffer();
@@ -56,6 +52,10 @@
 #endif
 
 private:
+    static PassOwnPtr<GLContextGLX> createPbufferContext(GLXContext sharingContext);
+    static PassOwnPtr<GLContextGLX> createPixmapContext(GLXContext sharingContext);
+    static void removeActiveContext(GLContext*);
+
     static void addActiveContext(GLContextGLX*);
     static void cleanupActiveContextsAtExit();
 

Deleted: trunk/Source/WebCore/platform/graphics/gtk/GLContextGtk.cpp (117611 => 117612)


--- trunk/Source/WebCore/platform/graphics/gtk/GLContextGtk.cpp	2012-05-18 19:12:27 UTC (rev 117611)
+++ trunk/Source/WebCore/platform/graphics/gtk/GLContextGtk.cpp	2012-05-18 19:16:49 UTC (rev 117612)
@@ -1,74 +0,0 @@
-/*
- * Copyright (C) 2012 Igalia, S.L.
- *
- *  This library is free software; you can redistribute it and/or
- *  modify it under the terms of the GNU Lesser General Public
- *  License as published by the Free Software Foundation; either
- *  version 2 of the License, or (at your option) any later version.
- *
- *  This library is distributed in the hope that it will be useful,
- *  but WITHOUT ANY WARRANTY; without even the implied warranty of
- *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
- *  Lesser General Public License for more details.
- *
- *  You should have received a copy of the GNU Lesser General Public
- *  License along with this library; if not, write to the Free Software
- *  Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301  USA
- */
-
-#include "config.h"
-#include "GLContext.h"
-
-#include "GLContextGLX.h"
-#include <gdk/gdk.h>
-#include <gdk/gdkx.h>
-#include <gtk/gtk.h>
-
-namespace WebCore {
-
-typedef HashMap<GtkWidget*, OwnPtr<GLContext> > WindowContextMap;
-static WindowContextMap& windowContextsMap()
-{
-    DEFINE_STATIC_LOCAL(WindowContextMap, windowContexts, ());
-    return windowContexts;
-}
-
-static void shutdownGLContext(GtkWidget* widget, void*)
-{
-    WindowContextMap& windowContexts = windowContextsMap();
-    WindowContextMap::iterator i = windowContexts.find(widget);
-    if (i != windowContexts.end())
-        windowContexts.remove(i);
-}
-
-GLContext* GLContext::getContextForWidget(GtkWidget* widget)
-{
-    ASSERT(widget);
-
-    WindowContextMap& windowContexts = windowContextsMap();
-    WindowContextMap::iterator i = windowContextsMap().find(widget);
-    if (i != windowContexts.end())
-        return i->second.get();
-
-    // It's important that this context doesn't hang around after the window
-    // is unmapped, so we make sure to clean it up once that happens.
-    if (!g_signal_handler_find(widget, G_SIGNAL_MATCH_FUNC, 0, 0, 0, reinterpret_cast<void*>(shutdownGLContext), 0))
-        g_signal_connect(widget, "unmap", G_CALLBACK(shutdownGLContext), 0);
-
-    GLContext* context = 0;
-
-#if USE(GLX)
-    // If this GDK window doesn't have its own native window then, we don't want
-    // to use it for rendering, since we'll be drawing over some other widget's area.
-    GdkWindow* gdkWindow = gtk_widget_get_window(widget);
-    context = gdkWindow && gdk_window_has_native(gdkWindow) ?  GLContextGLX::createContext(GDK_WINDOW_XID(gdkWindow)) : GLContextGLX::createContext(0);
-#endif
-
-    if (!context)
-        return 0;
-
-    windowContexts.set(widget, adoptPtr(context));
-    return context;
-}
-
-} // namespace WebCore

Modified: trunk/Source/WebKit/gtk/ChangeLog (117611 => 117612)


--- trunk/Source/WebKit/gtk/ChangeLog	2012-05-18 19:12:27 UTC (rev 117611)
+++ trunk/Source/WebKit/gtk/ChangeLog	2012-05-18 19:16:49 UTC (rev 117612)
@@ -1,3 +1,20 @@
+2012-05-18  Martin Robinson  <[email protected]>
+
+        OOM running webgl/sdk/tests/conformance/context/context-creation-and-destruction.html
+        https://bugs.webkit.org/show_bug.cgi?id=80509
+
+        Reviewed by Alejandro G. Castro.
+
+        AcceleratedCompositingContext context now fully owns the GLContext for its
+        window. This simplifies this quite a bit. We also properly clean it up when
+        destroying the layer tree, to go more easily on resources.
+
+        * WebCoreSupport/AcceleratedCompositingContext.h:
+        (AcceleratedCompositingContext):
+        * WebCoreSupport/AcceleratedCompositingContextGL.cpp:
+        (WebKit::AcceleratedCompositingContext::glContext):
+        (WebKit::AcceleratedCompositingContext::attachRootGraphicsLayer):
+
 2012-05-18  MORITA Hajime <[email protected]>
 
         Another unreviewed attempt to fix build breakage on r117572.

Modified: trunk/Source/WebKit/gtk/WebCoreSupport/AcceleratedCompositingContext.h (117611 => 117612)


--- trunk/Source/WebKit/gtk/WebCoreSupport/AcceleratedCompositingContext.h	2012-05-18 19:12:27 UTC (rev 117611)
+++ trunk/Source/WebKit/gtk/WebCoreSupport/AcceleratedCompositingContext.h	2012-05-18 19:16:49 UTC (rev 117612)
@@ -73,6 +73,7 @@
     WebCore::TextureMapperLayer* m_rootTextureMapperLayer;
     OwnPtr<WebCore::GraphicsLayer> m_rootGraphicsLayer;
     OwnPtr<WebCore::TextureMapper> m_textureMapper;
+    OwnPtr<WebCore::GLContext> m_context;
 #endif
 
     AcceleratedCompositingContext(WebKitWebView*);

Modified: trunk/Source/WebKit/gtk/WebCoreSupport/AcceleratedCompositingContextGL.cpp (117611 => 117612)


--- trunk/Source/WebKit/gtk/WebCoreSupport/AcceleratedCompositingContextGL.cpp	2012-05-18 19:12:27 UTC (rev 117611)
+++ trunk/Source/WebKit/gtk/WebCoreSupport/AcceleratedCompositingContextGL.cpp	2012-05-18 19:16:49 UTC (rev 117612)
@@ -35,6 +35,14 @@
 #include <gdk/gdk.h>
 #include <gtk/gtk.h>
 
+#if defined(GDK_WINDOWING_X11)
+#define Region XRegion
+#define Font XFont
+#define Cursor XCursor
+#define Screen XScreen
+#include <gdk/gdkx.h>
+#endif
+
 using namespace WebCore;
 
 namespace WebKit {
@@ -59,10 +67,17 @@
 
 GLContext* AcceleratedCompositingContext::glContext()
 {
-    GLContext* context = GLContext::getContextForWidget(GTK_WIDGET(m_webView));
-    if (!context->canRenderToDefaultFramebuffer())
-        return 0;
-    return context;
+    if (m_context)
+        return m_context.get();
+
+#if defined(GDK_WINDOWING_X11)
+    // FIXME: Gracefully account for situations where we do not have a realized window.
+    GdkWindow* gdkWindow = gtk_widget_get_window(GTK_WIDGET(m_webView));
+    if (gdkWindow && gdk_window_has_native(gdkWindow))
+        m_context = GLContext::createContextForWindow(GDK_WINDOW_XID(gdkWindow), GLContext::sharingContext());
+#endif
+
+    return m_context.get();
 }
 
 bool AcceleratedCompositingContext::renderLayersToWindow(const IntRect& clipRect)
@@ -94,6 +109,7 @@
     if (!graphicsLayer) {
         m_rootGraphicsLayer.clear();
         m_rootTextureMapperLayer = 0;
+        m_context.clear();
         return;
     }
 
_______________________________________________
webkit-changes mailing list
[email protected]
http://lists.webkit.org/mailman/listinfo.cgi/webkit-changes

Reply via email to