From e14391e94c850b8bd03680c23b38978db68687a8 Mon Sep 17 00:00:00 2001 From: John Reck Date: Thu, 4 Nov 2010 12:00:17 -0700 Subject: Merge Webkit at r70949: Initial merge by git. Change-Id: I77b8645c083b5d0da8dba73ed01d4014aab9848e --- WebKit/qt/WebCoreSupport/PageClientQt.cpp | 144 +++++++++++++++++++++++++++++- 1 file changed, 142 insertions(+), 2 deletions(-) (limited to 'WebKit/qt/WebCoreSupport/PageClientQt.cpp') diff --git a/WebKit/qt/WebCoreSupport/PageClientQt.cpp b/WebKit/qt/WebCoreSupport/PageClientQt.cpp index 9aa01a2..4d42c39 100644 --- a/WebKit/qt/WebCoreSupport/PageClientQt.cpp +++ b/WebKit/qt/WebCoreSupport/PageClientQt.cpp @@ -21,13 +21,127 @@ #include "config.h" #include "PageClientQt.h" +#include "texmap/TextureMapperPlatformLayer.h" #if defined(Q_WS_X11) #include #endif +#ifdef QT_OPENGL_LIB +#include +#endif namespace WebCore { +#if USE(ACCELERATED_COMPOSITING) && USE(TEXTURE_MAPPER) +class PlatformLayerProxyQt : public QObject, public virtual TextureMapperLayerClient { +public: + PlatformLayerProxyQt(QWebFrame* frame, TextureMapperContentLayer* layer, QObject* object) + : QObject(object) + , m_frame(frame) + , m_layer(layer) + { + if (m_layer) + m_layer->setPlatformLayerClient(this); + m_frame->d->rootGraphicsLayer = m_layer; + } + + virtual ~PlatformLayerProxyQt() + { + if (m_layer) + m_layer->setPlatformLayerClient(0); + if (m_frame->d) + m_frame->d->rootGraphicsLayer = 0; + } + + // Since we just paint the composited tree and never create a special item for it, we don't have to handle its size changes. + void setSizeChanged(const IntSize&) { } + +private: + QWebFrame* m_frame; + TextureMapperContentLayer* m_layer; +}; + +class PlatformLayerProxyQWidget : public PlatformLayerProxyQt { +public: + PlatformLayerProxyQWidget(QWebFrame* frame, TextureMapperContentLayer* layer, QWidget* widget) + : PlatformLayerProxyQt(frame, layer, widget) + , m_widget(widget) + { + if (m_widget) + m_widget->installEventFilter(this); + } + + // We don't want a huge region-clip on the compositing layers; instead we unite the rectangles together + // and clear them when the paint actually occurs. + bool eventFilter(QObject* object, QEvent* event) + { + if (object == m_widget && event->type() == QEvent::Paint) + m_dirtyRect = QRect(); + return QObject::eventFilter(object, event); + } + + void setNeedsDisplay() + { + if (m_widget) + m_widget->update(); + } + + void setNeedsDisplayInRect(const IntRect& rect) + { + m_dirtyRect |= rect; + m_widget->update(m_dirtyRect); + } + +private: + QRect m_dirtyRect; + QWidget* m_widget; +}; + +class PlatformLayerProxyQGraphicsObject : public PlatformLayerProxyQt { +public: + PlatformLayerProxyQGraphicsObject(QWebFrame* frame, TextureMapperContentLayer* layer, QGraphicsObject* object) + : PlatformLayerProxyQt(frame, layer, object) + , m_graphicsItem(object) + { + } + + void setNeedsDisplay() + { + if (m_graphicsItem) + m_graphicsItem->update(); + } + + void setNeedsDisplayInRect(const IntRect& rect) + { + if (m_graphicsItem) + m_graphicsItem->update(QRectF(rect)); + } + +private: + QGraphicsItem* m_graphicsItem; +}; + +void PageClientQWidget::setRootGraphicsLayer(TextureMapperPlatformLayer* layer) +{ + if (layer) { + platformLayerProxy = new PlatformLayerProxyQWidget(page->mainFrame(), static_cast(layer), view); + return; + } + delete platformLayerProxy; + platformLayerProxy = 0; +} + +void PageClientQWidget::markForSync(bool scheduleSync) +{ + syncTimer.startOneShot(0); +} + +void PageClientQWidget::syncLayers(Timer*) +{ + QWebFramePrivate::core(page->mainFrame())->view()->syncCompositingStateRecursive(); +} +#endif + void PageClientQWidget::scroll(int dx, int dy, const QRect& rectToScroll) { view->scroll(qreal(dx), qreal(dy), rectToScroll); @@ -53,6 +167,13 @@ void PageClientQWidget::setInputMethodHints(Qt::InputMethodHints hints) view->setInputMethodHints(hints); } +PageClientQWidget::~PageClientQWidget() +{ +#if USE(ACCELERATED_COMPOSITING) && USE(TEXTURE_MAPPER) + delete platformLayerProxy; +#endif +} + #ifndef QT_NO_CURSOR QCursor PageClientQWidget::cursor() const { @@ -107,12 +228,16 @@ PageClientQGraphicsWidget::~PageClientQGraphicsWidget() { delete overlay; #if USE(ACCELERATED_COMPOSITING) +#if USE(TEXTURE_MAPPER) + delete platformLayerProxy; +#else if (!rootGraphicsLayer) return; // we don't need to delete the root graphics layer. The lifecycle is managed in GraphicsLayerQt.cpp. rootGraphicsLayer.data()->setParentItem(0); view->scene()->removeItem(rootGraphicsLayer.data()); #endif +#endif } void PageClientQGraphicsWidget::scroll(int dx, int dy, const QRect& rectToScroll) @@ -134,6 +259,8 @@ void PageClientQGraphicsWidget::update(const QRect& dirtyRect) void PageClientQGraphicsWidget::createOrDeleteOverlay() { + // We don't use an overlay with TextureMapper. Instead, the overlay is drawn inside QWebFrame. +#if !USE(TEXTURE_MAPPER) bool useOverlay = false; if (!viewResizesToContents) { #if USE(ACCELERATED_COMPOSITING) @@ -154,6 +281,7 @@ void PageClientQGraphicsWidget::createOrDeleteOverlay() overlay->deleteLater(); overlay = 0; } +#endif // !USE(TEXTURE_MAPPER) } #if USE(ACCELERATED_COMPOSITING) @@ -165,7 +293,18 @@ void PageClientQGraphicsWidget::syncLayers() } } -void PageClientQGraphicsWidget::setRootGraphicsLayer(QGraphicsItem* layer) +#if USE(TEXTURE_MAPPER) +void PageClientQGraphicsWidget::setRootGraphicsLayer(TextureMapperPlatformLayer* layer) +{ + if (layer) { + platformLayerProxy = new PlatformLayerProxyQGraphicsObject(page->mainFrame(), static_cast(layer), view); + return; + } + delete platformLayerProxy; + platformLayerProxy = 0; +} +#else +void PageClientQGraphicsWidget::setRootGraphicsLayer(QGraphicsObject* layer) { if (rootGraphicsLayer) { rootGraphicsLayer.data()->setParentItem(0); @@ -173,7 +312,7 @@ void PageClientQGraphicsWidget::setRootGraphicsLayer(QGraphicsItem* layer) QWebFramePrivate::core(page->mainFrame())->view()->syncCompositingStateRecursive(); } - rootGraphicsLayer = layer ? layer->toGraphicsObject() : 0; + rootGraphicsLayer = layer; if (layer) { layer->setFlag(QGraphicsItem::ItemClipsChildrenToShape, true); @@ -182,6 +321,7 @@ void PageClientQGraphicsWidget::setRootGraphicsLayer(QGraphicsItem* layer) } createOrDeleteOverlay(); } +#endif void PageClientQGraphicsWidget::markForSync(bool scheduleSync) { -- cgit v1.1