Title: [107817] trunk/Source
Revision
107817
Author
[email protected]
Date
2012-02-15 07:42:30 -0800 (Wed, 15 Feb 2012)

Log Message

[Qt] Replace use of QGLWidget/QGLContext with QOpenGLContext and QSurface for Qt 5
https://bugs.webkit.org/show_bug.cgi?id=78694

Reviewed by Noam Rosenthal.

Source/WebCore:

Typedef PlatformGraphicsContext3D and PlatformGraphicsSurface3D to QOpenGLContext
and QSurface for Qt 5. Use these APIs to change the current context and get the
procedure addresses. Removed QGraphicsObject inheritance remainder while we're at it,
because that code path is obsolete.

* platform/graphics/GraphicsContext3D.h:
* platform/graphics/cairo/OpenGLShims.cpp:
(WebCore::getProcAddress):
* platform/graphics/cairo/OpenGLShims.h:
* platform/graphics/qt/GraphicsContext3DQt.cpp:
(WebCore::GraphicsContext3DPrivate::~GraphicsContext3DPrivate):
(WebCore::GraphicsContext3DPrivate::blitMultisampleFramebufferAndRestoreContext):
(WebCore::GraphicsContext3DPrivate::makeCurrentIfNeeded):
(WebCore::GraphicsContext3D::~GraphicsContext3D):

Source/WebKit/qt:

* WebCoreSupport/PageClientQt.cpp:
(createPlatformGraphicsContext3DFromWidget): Return the QOpenGLContext and QSurface
from the QGLWidget when compiling with Qt 5, as that's what WebCore expects.

Modified Paths

Diff

Modified: trunk/Source/WebCore/ChangeLog (107816 => 107817)


--- trunk/Source/WebCore/ChangeLog	2012-02-15 15:38:06 UTC (rev 107816)
+++ trunk/Source/WebCore/ChangeLog	2012-02-15 15:42:30 UTC (rev 107817)
@@ -1,5 +1,27 @@
 2012-02-15  Simon Hausmann  <[email protected]>
 
+        [Qt] Replace use of QGLWidget/QGLContext with QOpenGLContext and QSurface for Qt 5
+        https://bugs.webkit.org/show_bug.cgi?id=78694
+
+        Reviewed by Noam Rosenthal.
+
+        Typedef PlatformGraphicsContext3D and PlatformGraphicsSurface3D to QOpenGLContext
+        and QSurface for Qt 5. Use these APIs to change the current context and get the
+        procedure addresses. Removed QGraphicsObject inheritance remainder while we're at it,
+        because that code path is obsolete.
+
+        * platform/graphics/GraphicsContext3D.h:
+        * platform/graphics/cairo/OpenGLShims.cpp:
+        (WebCore::getProcAddress):
+        * platform/graphics/cairo/OpenGLShims.h:
+        * platform/graphics/qt/GraphicsContext3DQt.cpp:
+        (WebCore::GraphicsContext3DPrivate::~GraphicsContext3DPrivate):
+        (WebCore::GraphicsContext3DPrivate::blitMultisampleFramebufferAndRestoreContext):
+        (WebCore::GraphicsContext3DPrivate::makeCurrentIfNeeded):
+        (WebCore::GraphicsContext3D::~GraphicsContext3D):
+
+2012-02-15  Simon Hausmann  <[email protected]>
+
         [Qt] Move Qt platform specific GL Context/Surface creation out of WebCore into WebKit
         https://bugs.webkit.org/show_bug.cgi?id=78692
 

Modified: trunk/Source/WebCore/platform/graphics/GraphicsContext3D.h (107816 => 107817)


--- trunk/Source/WebCore/platform/graphics/GraphicsContext3D.h	2012-02-15 15:38:06 UTC (rev 107816)
+++ trunk/Source/WebCore/platform/graphics/GraphicsContext3D.h	2012-02-15 15:42:30 UTC (rev 107817)
@@ -57,6 +57,8 @@
 class QRect;
 class QGLWidget;
 class QGLContext;
+class QOpenGLContext;
+class QSurface;
 QT_END_NAMESPACE
 #elif PLATFORM(GTK) || PLATFORM(EFL)
 typedef unsigned int GLuint;
@@ -65,8 +67,13 @@
 #if PLATFORM(MAC)
 typedef CGLContextObj PlatformGraphicsContext3D;
 #elif PLATFORM(QT)
+#if QT_VERSION >= QT_VERSION_CHECK(5, 0, 0)
+typedef QOpenGLContext* PlatformGraphicsContext3D;
+typedef QSurface* PlatformGraphicsSurface3D;
+#else
 typedef QGLContext* PlatformGraphicsContext3D;
 typedef QGLWidget* PlatformGraphicsSurface3D;
+#endif
 #else
 typedef void* PlatformGraphicsContext3D;
 #endif

Modified: trunk/Source/WebCore/platform/graphics/cairo/OpenGLShims.cpp (107816 => 107817)


--- trunk/Source/WebCore/platform/graphics/cairo/OpenGLShims.cpp	2012-02-15 15:38:06 UTC (rev 107816)
+++ trunk/Source/WebCore/platform/graphics/cairo/OpenGLShims.cpp	2012-02-15 15:42:30 UTC (rev 107817)
@@ -42,7 +42,11 @@
 #if PLATFORM(QT)
 static void* getProcAddress(const char* procName)
 {
+#if QT_VERSION >= QT_VERSION_CHECK(5, 0, 0)
+    return reinterpret_cast<void*>(QOpenGLContext::currentContext()->getProcAddress(procName));
+#else
     return reinterpret_cast<void*>(QGLContext::currentContext()->getProcAddress(QString::fromLatin1(procName)));
+#endif
 }
 #else
 typedef void* (*glGetProcAddressType) (const char* procName);

Modified: trunk/Source/WebCore/platform/graphics/cairo/OpenGLShims.h (107816 => 107817)


--- trunk/Source/WebCore/platform/graphics/cairo/OpenGLShims.h	2012-02-15 15:38:06 UTC (rev 107816)
+++ trunk/Source/WebCore/platform/graphics/cairo/OpenGLShims.h	2012-02-15 15:42:30 UTC (rev 107817)
@@ -18,7 +18,13 @@
  */
 
 #if PLATFORM(QT)
+#include <qglobal.h>
+#if QT_VERSION >= QT_VERSION_CHECK(5, 0, 0)
+#include <QOpenGLContext>
+#include <QSurface>
+#else
 #include <QGLContext>
+#endif
 #else
 #include <GL/gl.h>
 #endif

Modified: trunk/Source/WebCore/platform/graphics/qt/GraphicsContext3DQt.cpp (107816 => 107817)


--- trunk/Source/WebCore/platform/graphics/qt/GraphicsContext3DQt.cpp	2012-02-15 15:38:06 UTC (rev 107816)
+++ trunk/Source/WebCore/platform/graphics/qt/GraphicsContext3DQt.cpp	2012-02-15 15:42:30 UTC (rev 107817)
@@ -36,9 +36,6 @@
 #include "NotImplemented.h"
 #include "QWebPageClient.h"
 #include "SharedBuffer.h"
-#include <QAbstractScrollArea>
-#include <QGraphicsObject>
-#include <QGLContext>
 #include <wtf/UnusedParam.h>
 #include <wtf/text/CString.h>
 
@@ -59,13 +56,9 @@
 #endif
 
 class GraphicsContext3DPrivate
-#if USE(ACCELERATED_COMPOSITING)
-#if USE(TEXTURE_MAPPER)
+#if USE(ACCELERATED_COMPOSITING) && USE(TEXTURE_MAPPER)
         : public TextureMapperPlatformLayer
-#else
-        : public QGraphicsObject
 #endif
-#endif
 {
 public:
     GraphicsContext3DPrivate(GraphicsContext3D*, HostWindow*);
@@ -114,7 +107,7 @@
 {
     delete m_surface;
     m_surface = 0;
-    // ### Delete context?
+    // Platform context is assumed to be owned by surface.
     m_platformContext = 0;
 }
 
@@ -199,6 +192,17 @@
     if (!m_context->m_attrs.antialias)
         return;
 
+#if QT_VERSION >= QT_VERSION_CHECK(5, 0, 0)
+    const QOpenGLContext* currentContext = QOpenGLContext::currentContext();
+    QSurface* currentSurface = 0;
+    if (currentContext != m_platformContext) {
+        currentSurface = currentContext->surface();
+        m_platformContext->makeCurrent(m_surface);
+    }
+    blitMultisampleFramebuffer();
+    if (currentSurface)
+        const_cast<QOpenGLContext*>(currentContext)->makeCurrent(currentSurface);
+#else
     const QGLContext* currentContext = QGLContext::currentContext();
     const QGLContext* widgetContext = m_surface->context();
     if (currentContext != widgetContext)
@@ -209,16 +213,24 @@
             const_cast<QGLContext*>(currentContext)->makeCurrent();
     } else
         m_surface->doneCurrent();
+#endif
 }
 
 bool GraphicsContext3DPrivate::makeCurrentIfNeeded() const
 {
+#if QT_VERSION >= QT_VERSION_CHECK(5, 0, 0)
+    const QOpenGLContext* currentContext = QOpenGLContext::currentContext();
+    if (currentContext == m_platformContext)
+        return true;
+    return m_platformContext->makeCurrent(m_surface);
+#else
     const QGLContext* currentContext = QGLContext::currentContext();
     const QGLContext* widgetContext = m_surface->context();
     if (currentContext != widgetContext)
         m_surface->makeCurrent();
 
     return QGLContext::currentContext() == widgetContext;
+#endif
 }
 
 PassRefPtr<GraphicsContext3D> GraphicsContext3D::create(GraphicsContext3D::Attributes attrs, HostWindow* hostWindow, GraphicsContext3D::RenderStyle renderStyle)
@@ -335,8 +347,6 @@
 GraphicsContext3D::~GraphicsContext3D()
 {
     makeContextCurrent();
-    if (!m_private->m_surface->isValid())
-        return;
     glDeleteTextures(1, &m_texture);
     glDeleteFramebuffers(1, &m_fbo);
     if (m_attrs.antialias) {

Modified: trunk/Source/WebKit/qt/ChangeLog (107816 => 107817)


--- trunk/Source/WebKit/qt/ChangeLog	2012-02-15 15:38:06 UTC (rev 107816)
+++ trunk/Source/WebKit/qt/ChangeLog	2012-02-15 15:42:30 UTC (rev 107817)
@@ -1,5 +1,16 @@
 2012-02-15  Simon Hausmann  <[email protected]>
 
+        [Qt] Replace use of QGLWidget/QGLContext with QOpenGLContext and QSurface for Qt 5
+        https://bugs.webkit.org/show_bug.cgi?id=78694
+
+        Reviewed by Noam Rosenthal.
+
+        * WebCoreSupport/PageClientQt.cpp:
+        (createPlatformGraphicsContext3DFromWidget): Return the QOpenGLContext and QSurface
+        from the QGLWidget when compiling with Qt 5, as that's what WebCore expects.
+
+2012-02-15  Simon Hausmann  <[email protected]>
+
         [Qt] Move Qt platform specific GL Context/Surface creation out of WebCore into WebKit
         https://bugs.webkit.org/show_bug.cgi?id=78692
 

Modified: trunk/Source/WebKit/qt/WebCoreSupport/PageClientQt.cpp (107816 => 107817)


--- trunk/Source/WebKit/qt/WebCoreSupport/PageClientQt.cpp	2012-02-15 15:38:06 UTC (rev 107816)
+++ trunk/Source/WebKit/qt/WebCoreSupport/PageClientQt.cpp	2012-02-15 15:42:30 UTC (rev 107817)
@@ -30,6 +30,10 @@
 #if ENABLE(WEBGL)
 #include <QGLWidget>
 
+#if QT_VERSION_CHECK(5, 0, 0)
+#include <QWindow>
+#endif
+
 static void createPlatformGraphicsContext3DFromWidget(QWidget* widget, PlatformGraphicsContext3D* context,
                                                       PlatformGraphicsSurface3D* surface)
 {
@@ -46,8 +50,13 @@
     if (glWidget->isValid()) {
         // Geometry can be set to zero because m_glWidget is used only for its QGLContext.
         glWidget->setGeometry(0, 0, 0, 0);
+#if QT_VERSION >= QT_VERSION_CHECK(5, 0, 0)
+        *surface = glWidget->windowHandle();
+        *context = glWidget->context()->contextHandle();
+#else
         *surface = glWidget;
         *context = const_cast<QGLContext*>(glWidget->context());
+#endif
     } else {
         delete glWidget;
         glWidget = 0;
_______________________________________________
webkit-changes mailing list
[email protected]
http://lists.webkit.org/mailman/listinfo.cgi/webkit-changes

Reply via email to