diff options
Diffstat (limited to 'Source/WebKit/qt/WidgetSupport/PageClientQt.cpp')
-rw-r--r-- | Source/WebKit/qt/WidgetSupport/PageClientQt.cpp | 50 |
1 files changed, 42 insertions, 8 deletions
diff --git a/Source/WebKit/qt/WidgetSupport/PageClientQt.cpp b/Source/WebKit/qt/WidgetSupport/PageClientQt.cpp index 6ae5f12c4..7e5cb1fb7 100644 --- a/Source/WebKit/qt/WidgetSupport/PageClientQt.cpp +++ b/Source/WebKit/qt/WidgetSupport/PageClientQt.cpp @@ -33,6 +33,9 @@ #ifdef QT_OPENGL_LIB #include <QGLWidget> #endif +#if QT_VERSION >= QT_VERSION_CHECK(5, 4, 0) +#include <QOpenGLWidget> +#endif QWindow* QWebPageClient::ownerWindow() const { @@ -140,7 +143,7 @@ QStyle* PageClientQWidget::style() const QRectF PageClientQWidget::windowRect() const { - return QRectF(view->window()->geometry()); + return QRectF(view->window()->frameGeometry()); } void PageClientQWidget::setWidgetVisible(Widget* widget, bool visible) @@ -183,20 +186,53 @@ void PageClientQGraphicsWidget::repaintViewport() bool PageClientQGraphicsWidget::makeOpenGLContextCurrentIfAvailable() { -#if USE(TEXTURE_MAPPER_GL) && defined(QT_OPENGL_LIB) +#if USE(TEXTURE_MAPPER_GL) QGraphicsView* graphicsView = firstGraphicsView(); if (graphicsView && graphicsView->viewport()) { - QGLWidget* glWidget = qobject_cast<QGLWidget*>(graphicsView->viewport()); - if (glWidget) { + QWidget* widget = graphicsView->viewport(); +#if defined(QT_OPENGL_LIB) + if (widget->inherits("QGLWidget")) { + QGLWidget* glWidget = static_cast<QGLWidget*>(widget); // The GL context belonging to the QGLWidget viewport must be current when TextureMapper is being created. glWidget->makeCurrent(); return true; } +#endif +#if QT_VERSION >= QT_VERSION_CHECK(5, 4, 0) + if (widget->inherits("QOpenGLWidget")) { + QOpenGLWidget* qoglWidget = static_cast<QOpenGLWidget*>(widget); + qoglWidget->makeCurrent(); + return true; + } +#endif } #endif return false; } +QOpenGLContext* PageClientQGraphicsWidget::openGLContextIfAvailable() +{ +#if USE(TEXTURE_MAPPER_GL) + QGraphicsView* graphicsView = firstGraphicsView(); + if (graphicsView && graphicsView->viewport()) { + QWidget* widget = graphicsView->viewport(); +#if defined(QT_OPENGL_LIB) + if (widget->inherits("QGLWidget")) { + QGLWidget* glWidget = static_cast<QGLWidget*>(widget); + return glWidget->context()->contextHandle(); + } +#endif +#if QT_VERSION >= QT_VERSION_CHECK(5, 4, 0) + if (widget->inherits("QOpenGLWidget")) { + QOpenGLWidget* qoglWidget = static_cast<QOpenGLWidget*>(widget); + return qoglWidget->context(); + } +#endif + } +#endif + return 0; +} + void PageClientQGraphicsWidget::setInputMethodEnabled(bool enable) { view->setFlag(QGraphicsItem::ItemAcceptsInputMethod, enable); @@ -257,10 +293,9 @@ QRect PageClientQGraphicsWidget::geometryRelativeToOwnerWidget() const QPoint PageClientQGraphicsWidget::mapToOwnerWindow(const QPoint& point) const { if (const QGraphicsView* graphicsView = firstGraphicsView()) { - if (const QWidget *nativeParent = graphicsView->nativeParentWidget()) + if (const QWidget* nativeParent = graphicsView->nativeParentWidget()) return graphicsView->mapTo(nativeParent, graphicsView->mapFromScene(view->mapToScene(point))); - else - return graphicsView->mapFromScene(view->mapToScene(point)); + return graphicsView->mapFromScene(view->mapToScene(point)); } return point; } @@ -316,4 +351,3 @@ bool PageClientQGraphicsWidget::isViewVisible() #endif // QT_NO_GRAPHICSVIEW } // namespace WebCore - |