summaryrefslogtreecommitdiffstats
path: root/WebKit/qt/WebCoreSupport/PageClientQt.cpp
diff options
context:
space:
mode:
authorJohn Reck <jreck@google.com>2010-11-04 12:00:17 -0700
committerJohn Reck <jreck@google.com>2010-11-09 11:35:04 -0800
commite14391e94c850b8bd03680c23b38978db68687a8 (patch)
tree3fed87e6620fecaf3edc7259ae58a11662bedcb2 /WebKit/qt/WebCoreSupport/PageClientQt.cpp
parent1bd705833a68f07850cf7e204b26f8d328d16951 (diff)
downloadexternal_webkit-e14391e94c850b8bd03680c23b38978db68687a8.zip
external_webkit-e14391e94c850b8bd03680c23b38978db68687a8.tar.gz
external_webkit-e14391e94c850b8bd03680c23b38978db68687a8.tar.bz2
Merge Webkit at r70949: Initial merge by git.
Change-Id: I77b8645c083b5d0da8dba73ed01d4014aab9848e
Diffstat (limited to 'WebKit/qt/WebCoreSupport/PageClientQt.cpp')
-rw-r--r--WebKit/qt/WebCoreSupport/PageClientQt.cpp144
1 files changed, 142 insertions, 2 deletions
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 <QX11Info>
#endif
+#ifdef QT_OPENGL_LIB
+#include <QGLWidget>
+#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<TextureMapperContentLayer*>(layer), view);
+ return;
+ }
+ delete platformLayerProxy;
+ platformLayerProxy = 0;
+}
+
+void PageClientQWidget::markForSync(bool scheduleSync)
+{
+ syncTimer.startOneShot(0);
+}
+
+void PageClientQWidget::syncLayers(Timer<PageClientQWidget>*)
+{
+ 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<TextureMapperContentLayer*>(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)
{