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.
git-svn-id: http://svn.webkit.org/repository/webkit/trunk@107817
268f45cc-cd09-0410-ab3c-
d52691b4dbfc
2012-02-15 Simon Hausmann <simon.hausmann@nokia.com>
+ [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 <simon.hausmann@nokia.com>
+
[Qt] Move Qt platform specific GL Context/Surface creation out of WebCore into WebKit
https://bugs.webkit.org/show_bug.cgi?id=78692
class QRect;
class QGLWidget;
class QGLContext;
+class QOpenGLContext;
+class QSurface;
QT_END_NAMESPACE
#elif PLATFORM(GTK) || PLATFORM(EFL)
typedef unsigned int GLuint;
#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
#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);
*/
#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
#include "NotImplemented.h"
#include "QWebPageClient.h"
#include "SharedBuffer.h"
-#include <QAbstractScrollArea>
-#include <QGraphicsObject>
-#include <QGLContext>
#include <wtf/UnusedParam.h>
#include <wtf/text/CString.h>
#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:
{
delete m_surface;
m_surface = 0;
- // ### Delete context?
+ // Platform context is assumed to be owned by surface.
m_platformContext = 0;
}
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)
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)
GraphicsContext3D::~GraphicsContext3D()
{
makeContextCurrent();
- if (!m_private->m_surface->isValid())
- return;
glDeleteTextures(1, &m_texture);
glDeleteFramebuffers(1, &m_fbo);
if (m_attrs.antialias) {
2012-02-15 Simon Hausmann <simon.hausmann@nokia.com>
+ [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 <simon.hausmann@nokia.com>
+
[Qt] Move Qt platform specific GL Context/Surface creation out of WebCore into WebKit
https://bugs.webkit.org/show_bug.cgi?id=78692
#if ENABLE(WEBGL)
#include <QGLWidget>
+#if QT_VERSION_CHECK(5, 0, 0)
+#include <QWindow>
+#endif
+
static void createPlatformGraphicsContext3DFromWidget(QWidget* widget, PlatformGraphicsContext3D* context,
PlatformGraphicsSurface3D* surface)
{
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;