Commit ecdfeac3 authored by noam.rosenthal@nokia.com's avatar noam.rosenthal@nokia.com
Browse files

2010-10-25 No'am Rosenthal <noam.rosenthal@nokia.com>

        Reviewed by Kenneth Rohde Christiansen.

        [Texmap] [Qt] Texture mapper initial implementation
        https://bugs.webkit.org/show_bug.cgi?id=47070

        Glue layer (WebCoreSupport) changes to allow connecting TextureMapper to a Qt PageClient, i.e.
        a QWebView or a QGraphicsWebView. This enables the new type, TextureMapperPlatformLayer, to be recognized both by
        the compositor and by the page client.
        Note that this is temporarily an opt-in, under USE(TEXTURE_MAPPER)

        No new tests: the existing tests under LayoutTests/compositing already cover this.

        * platform/graphics/GraphicsLayer.h:
        * platform/qt/QWebPageClient.h:
        (QWebPageClient::setRootGraphicsLayer):
2010-10-25  No'am Rosenthal  <noam.rosenthal@nokia.com>

        Reviewed by Kenneth Rohde Christiansen.

        [Texmap] [Qt] Texture mapper initial implementation
        https://bugs.webkit.org/show_bug.cgi?id=47070

        Glue layer (WebCoreSupport) changes to allow connecting TextureMapper to a Qt PageClient, i.e.
        a QWebView or a QGraphicsWebView. This enables the new type, TextureMapperPlatformLayer, to be recognized both by
        the compositor and by the page client.
        Note that this is temporarily an opt-in, under USE(TEXTURE_MAPPER)

        * Api/qwebframe.h:
        * Api/qwebframe_p.h:
        (QWebFramePrivate::QWebFramePrivate):
        * Api/qwebpage.cpp:
        (QWebPage::setView):
        * WebCoreSupport/ChromeClientQt.cpp:
        (WebCore::ChromeClientQt::attachRootGraphicsLayer):
        * WebCoreSupport/PageClientQt.cpp:
        (WebCore::PlatformLayerProxyQt::PlatformLayerProxyQt):
        (WebCore::PlatformLayerProxyQt::~PlatformLayerProxyQt):
        (WebCore::PlatformLayerProxyQt::setSizeChanged):
        (WebCore::PlatformLayerProxyQWidget::PlatformLayerProxyQWidget):
        (WebCore::PlatformLayerProxyQWidget::eventFilter):
        (WebCore::PlatformLayerProxyQWidget::setNeedsDisplay):
        (WebCore::PlatformLayerProxyQWidget::setNeedsDisplayInRect):
        (WebCore::PlatformLayerProxyQGraphicsObject::PlatformLayerProxyQGraphicsWidget):
        (WebCore::PlatformLayerProxyQGraphicsObject::setNeedsDisplay):
        (WebCore::PlatformLayerProxyQGraphicsObject::setNeedsDisplayInRect):
        (WebCore::PageClientQWidget::setRootGraphicsLayer):
        (WebCore::PageClientQWidget::markForSync):
        (WebCore::PageClientQWidget::syncLayers):
        (WebCore::PageClientQGraphicsWidget::updateCompositingScrollPosition):
        (WebCore::PageClientQGraphicsWidget::createOrDeleteOverlay):
        (WebCore::PageClientQGraphicsWidget::setRootGraphicsLayer):
        * WebCoreSupport/PageClientQt.h:
        (WebCore::PageClientQWidget::PageClientQWidget):
        (WebCore::PageClientQWidget::allowsAcceleratedCompositing):
        (WebCore::PageClientQGraphicsWidget::PageClientQGraphicsWidget):

git-svn-id: http://svn.webkit.org/repository/webkit/trunk@70487 268f45cc-cd09-0410-ab3c-d52691b4dbfc
parent 34cc78a0
2010-10-25 No'am Rosenthal <noam.rosenthal@nokia.com>
Reviewed by Kenneth Rohde Christiansen.
[Texmap] [Qt] Texture mapper initial implementation
https://bugs.webkit.org/show_bug.cgi?id=47070
Glue layer (WebCoreSupport) changes to allow connecting TextureMapper to a Qt PageClient, i.e.
a QWebView or a QGraphicsWebView. This enables the new type, TextureMapperPlatformLayer, to be recognized both by
the compositor and by the page client.
Note that this is temporarily an opt-in, under USE(TEXTURE_MAPPER)
No new tests: the existing tests under LayoutTests/compositing already cover this.
* platform/graphics/GraphicsLayer.h:
* platform/qt/QWebPageClient.h:
(QWebPageClient::setRootGraphicsLayer):
2010-10-25 No'am Rosenthal <noam.rosenthal@nokia.com>
 
Reviewed by Kenneth Rohde Christiansen.
......@@ -57,11 +57,19 @@ typedef WKCACFLayer PlatformLayer;
typedef void* NativeLayer;
}
#elif PLATFORM(QT)
#if USE(TEXTURE_MAPPER)
namespace WebCore {
class TextureMapperPlatformLayer;
typedef TextureMapperPlatformLayer PlatformLayer;
typedef TextureMapperPlatformLayer* NativeLayer;
};
#else
QT_BEGIN_NAMESPACE
class QGraphicsItem;
class QGraphicsObject;
QT_END_NAMESPACE
typedef QGraphicsItem PlatformLayer;
typedef QGraphicsItem* NativeLayer;
typedef QGraphicsObject PlatformLayer;
typedef QGraphicsObject* NativeLayer;
#endif
#elif PLATFORM(CHROMIUM)
namespace WebCore {
class LayerChromium;
......
......@@ -30,11 +30,14 @@
#include <QCursor>
#endif
#if USE(ACCELERATED_COMPOSITING)
#include <GraphicsLayer.h>
#endif
#include <QPalette>
#include <QRect>
QT_BEGIN_NAMESPACE
class QGraphicsItem;
class QStyle;
QT_END_NAMESPACE
......@@ -49,8 +52,7 @@ public:
virtual void setInputMethodEnabled(bool enable) = 0;
virtual bool inputMethodEnabled() const = 0;
#if USE(ACCELERATED_COMPOSITING)
// this gets called when we start/stop compositing.
virtual void setRootGraphicsLayer(QGraphicsItem* layer) {}
virtual void setRootGraphicsLayer(PlatformLayer* layer) { }
// this gets called when the compositor wants us to sync the layers
// if scheduleSync is true, we schedule a sync ourselves. otherwise,
......
......@@ -56,6 +56,7 @@ namespace WebCore {
class WidgetPrivate;
class FrameLoaderClientQt;
class ChromeClientQt;
class PlatformLayerProxyQt;
}
class QWebFrameData;
class QWebHitTestResultPrivate;
......@@ -231,6 +232,7 @@ private:
friend class WebCore::WidgetPrivate;
friend class WebCore::FrameLoaderClientQt;
friend class WebCore::ChromeClientQt;
friend class WebCore::PlatformLayerProxyQt;
QWebFramePrivate *d;
};
......
......@@ -38,6 +38,7 @@ namespace WebCore {
class FrameView;
class HTMLFrameOwnerElement;
class Scrollbar;
class TextureMapperContentLayer;
}
class QWebPage;
......@@ -72,6 +73,9 @@ public:
, allowsScrolling(true)
, marginWidth(-1)
, marginHeight(-1)
#if USE(ACCELERATED_COMPOSITING) && USE(TEXTURE_MAPPER)
, rootGraphicsLayer(0)
#endif
, zoomTextOnly(false)
{}
void init(QWebFrame* qframe, QWebFrameData* frameData);
......@@ -100,6 +104,9 @@ public:
bool allowsScrolling;
int marginWidth;
int marginHeight;
#if USE(ACCELERATED_COMPOSITING) && USE(TEXTURE_MAPPER)
WebCore::TextureMapperContentLayer* rootGraphicsLayer;
#endif
bool zoomTextOnly;
};
......
......@@ -1850,7 +1850,7 @@ void QWebPage::setView(QWidget* view)
}
if (view)
d->client = new PageClientQWidget(view);
d->client = new PageClientQWidget(view, this);
}
/*!
......
2010-10-25 No'am Rosenthal <noam.rosenthal@nokia.com>
Reviewed by Kenneth Rohde Christiansen.
[Texmap] [Qt] Texture mapper initial implementation
https://bugs.webkit.org/show_bug.cgi?id=47070
Glue layer (WebCoreSupport) changes to allow connecting TextureMapper to a Qt PageClient, i.e.
a QWebView or a QGraphicsWebView. This enables the new type, TextureMapperPlatformLayer, to be recognized both by
the compositor and by the page client.
Note that this is temporarily an opt-in, under USE(TEXTURE_MAPPER)
* Api/qwebframe.h:
* Api/qwebframe_p.h:
(QWebFramePrivate::QWebFramePrivate):
* Api/qwebpage.cpp:
(QWebPage::setView):
* WebCoreSupport/ChromeClientQt.cpp:
(WebCore::ChromeClientQt::attachRootGraphicsLayer):
* WebCoreSupport/PageClientQt.cpp:
(WebCore::PlatformLayerProxyQt::PlatformLayerProxyQt):
(WebCore::PlatformLayerProxyQt::~PlatformLayerProxyQt):
(WebCore::PlatformLayerProxyQt::setSizeChanged):
(WebCore::PlatformLayerProxyQWidget::PlatformLayerProxyQWidget):
(WebCore::PlatformLayerProxyQWidget::eventFilter):
(WebCore::PlatformLayerProxyQWidget::setNeedsDisplay):
(WebCore::PlatformLayerProxyQWidget::setNeedsDisplayInRect):
(WebCore::PlatformLayerProxyQGraphicsObject::PlatformLayerProxyQGraphicsWidget):
(WebCore::PlatformLayerProxyQGraphicsObject::setNeedsDisplay):
(WebCore::PlatformLayerProxyQGraphicsObject::setNeedsDisplayInRect):
(WebCore::PageClientQWidget::setRootGraphicsLayer):
(WebCore::PageClientQWidget::markForSync):
(WebCore::PageClientQWidget::syncLayers):
(WebCore::PageClientQGraphicsWidget::updateCompositingScrollPosition):
(WebCore::PageClientQGraphicsWidget::createOrDeleteOverlay):
(WebCore::PageClientQGraphicsWidget::setRootGraphicsLayer):
* WebCoreSupport/PageClientQt.h:
(WebCore::PageClientQWidget::PageClientQWidget):
(WebCore::PageClientQWidget::allowsAcceleratedCompositing):
(WebCore::PageClientQGraphicsWidget::PageClientQGraphicsWidget):
2010-10-25 Johnny Ding <jnd@chromium.org>
 
Reviewed by Tony Chang.
......
......@@ -39,7 +39,7 @@
#include "FrameView.h"
#include "Geolocation.h"
#if USE(ACCELERATED_COMPOSITING)
#include "GraphicsLayerQt.h"
#include "GraphicsLayer.h"
#endif
#include "GeolocationPermissionClientQt.h"
#include "HitTestResult.h"
......@@ -591,7 +591,7 @@ void ChromeClientQt::cancelGeolocationPermissionRequestForFrame(Frame* frame, Ge
void ChromeClientQt::attachRootGraphicsLayer(Frame* frame, GraphicsLayer* graphicsLayer)
{
if (platformPageClient())
platformPageClient()->setRootGraphicsLayer(graphicsLayer ? graphicsLayer->nativeLayer() : 0);
platformPageClient()->setRootGraphicsLayer(graphicsLayer ? graphicsLayer->platformLayer() : 0);
}
void ChromeClientQt::setNeedsOneShotDrawingSynchronization()
......
......@@ -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 PlatfromLayerProxyQt {
public:
PlatformLayerProxyQGraphicsWidget(QWebFrame* frame, TextureMapperContentLayer* layer, QGraphicsObject* object)
: QObject(object)
, m_graphicsItem(graphicsObject)
{
}
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
{
......@@ -134,6 +255,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 +277,7 @@ void PageClientQGraphicsWidget::createOrDeleteOverlay()
overlay->deleteLater();
overlay = 0;
}
#endif // !USE(TEXTURE_MAPPER)
}
#if USE(ACCELERATED_COMPOSITING)
......@@ -165,7 +289,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), 0, view);
return;
}
delete platformLayerProxy;
platformLayerProxy = 0;
}
#else
void PageClientQGraphicsWidget::setRootGraphicsLayer(QGraphicsObject* layer)
{
if (rootGraphicsLayer) {
rootGraphicsLayer.data()->setParentItem(0);
......@@ -173,7 +308,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 +317,7 @@ void PageClientQGraphicsWidget::setRootGraphicsLayer(QGraphicsItem* layer)
}
createOrDeleteOverlay();
}
#endif
void PageClientQGraphicsWidget::markForSync(bool scheduleSync)
{
......
......@@ -41,15 +41,29 @@
#include <Settings.h>
#if USE(ACCELERATED_COMPOSITING) && USE(TEXTURE_MAPPER)
#include "texmap/TextureMapperPlatformLayer.h"
#endif
namespace WebCore {
class PageClientQWidget : public QWebPageClient {
class PageClientQWidget : public QWebPageClient
#if USE(ACCELERATED_COMPOSITING) && USE(TEXTURE_MAPPER)
, public virtual TextureMapperLayerClient
#endif
{
public:
PageClientQWidget(QWidget* view)
: view(view)
PageClientQWidget(QWidget* newView, QWebPage* newPage)
: view(newView)
, page(newPage)
#if USE(ACCELERATED_COMPOSITING) && USE(TEXTURE_MAPPER)
, syncTimer(this, &PageClientQWidget::syncLayers)
, platformLayerProxy(0)
#endif
{
Q_ASSERT(view);
}
virtual ~PageClientQWidget();
virtual bool isQWidgetClient() const { return true; }
......@@ -78,6 +92,21 @@ public:
virtual QRectF windowRect() const;
QWidget* view;
QWebPage* page;
#if USE(ACCELERATED_COMPOSITING) && USE(TEXTURE_MAPPER)
virtual void setRootGraphicsLayer(TextureMapperPlatformLayer* layer);
virtual void markForSync(bool scheduleSync);
void syncLayers(Timer<PageClientQWidget>*);
#endif
// QGraphicsWebView can render composited layers
virtual bool allowsAcceleratedCompositing() const { return true; }
#if USE(ACCELERATED_COMPOSITING) && USE(TEXTURE_MAPPER)
Timer<PageClientQWidget> syncTimer;
PlatformLayerProxyQt* platformLayerProxy;
#endif
};
// the overlay is here for one reason only: to have the scroll-bars and other
......@@ -114,13 +143,20 @@ class QGraphicsItemOverlay : public QGraphicsObject {
};
class PageClientQGraphicsWidget : public QWebPageClient {
class PageClientQGraphicsWidget : public QWebPageClient
#if USE(ACCELERATED_COMPOSITING) && USE(TEXTURE_MAPPER)
, public virtual TextureMapperLayerClient
#endif
{
public:
PageClientQGraphicsWidget(QGraphicsWebView* v, QWebPage* p)
: view(v)
, page(p)
PageClientQGraphicsWidget(QGraphicsWebView* newView, QWebPage* newPage)
: view(newView)
, page(newPage)
, viewResizesToContents(false)
#if USE(ACCELERATED_COMPOSITING)
#if USE(TEXTURE_MAPPER)
, platformLayerProxy(0)
#endif
, shouldSync(false)
#endif
, overlay(0)
......@@ -168,7 +204,7 @@ public:
#endif
#if USE(ACCELERATED_COMPOSITING)
virtual void setRootGraphicsLayer(QGraphicsItem* layer);
virtual void setRootGraphicsLayer(PlatformLayer* layer);
virtual void markForSync(bool scheduleSync);
void syncLayers();
......@@ -183,8 +219,11 @@ public:
bool viewResizesToContents;
#if USE(ACCELERATED_COMPOSITING)
#if USE(TEXTURE_MAPPER)
PlatformLayerProxyQt* platformLayerProxy;
#else
QWeakPointer<QGraphicsObject> rootGraphicsLayer;
#endif
// we have to flush quite often, so we use a meta-method instead of QTimer::singleShot for putting the event in the queue
QMetaMethod syncMetaMethod;
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment