Changeset 110388 in webkit
- Timestamp:
- Mar 11, 2012 12:26:07 AM (12 years ago)
- Location:
- trunk
- Files:
-
- 1 added
- 9 edited
- 1 copied
- 1 moved
Legend:
- Unmodified
- Added
- Removed
-
trunk/Source/WebCore/ChangeLog
r110381 r110388 1 2012-03-11 Viatcheslav Ostapenko <ostapenko.viatcheslav@nokia.com> 2 3 [Qt] [WK2] Support threaded renderer in WK2 4 https://bugs.webkit.org/show_bug.cgi?id=76661 5 6 Reviewed by Noam Rosenthal. 7 8 Add TransformationMatrix conversions from/to Qt QMatrix4x4. Used by Qt WebKit2 9 rendering and tested by Qt WebKit2 API tests. 10 11 * platform/graphics/qt/TransformationMatrixQt.cpp: 12 (WebCore::TransformationMatrix::operator QMatrix4x4): 13 (WebCore): 14 (WebCore::TransformationMatrix::TransformationMatrix): 15 * platform/graphics/transforms/TransformationMatrix.h: 16 (TransformationMatrix): 17 1 18 2012-03-09 Jon Lee <jonlee@apple.com> 2 19 -
trunk/Source/WebCore/platform/graphics/qt/TransformationMatrixQt.cpp
r94188 r110388 51 51 } 52 52 53 TransformationMatrix::operator QMatrix4x4() const 54 { 55 return QMatrix4x4(m11(), m12(), m13(), m14(), 56 m21(), m22(), m23(), m24(), 57 m31(), m32(), m33(), m34(), 58 m41(), m42(), m43(), m44()); 59 } 60 61 TransformationMatrix::TransformationMatrix(const QMatrix4x4& matrix) 62 { 63 setMatrix(matrix(0, 0), matrix(1, 0), matrix(2, 0), matrix(3, 0), 64 matrix(0, 1), matrix(1, 1), matrix(2, 1), matrix(3, 1), 65 matrix(0, 2), matrix(1, 2), matrix(2, 2), matrix(3, 2), 66 matrix(0, 3), matrix(1, 3), matrix(2, 3), matrix(3, 3)); 67 } 68 53 69 } 54 70 -
trunk/Source/WebCore/platform/graphics/transforms/TransformationMatrix.h
r110322 r110388 43 43 #include "VGUtils.h" 44 44 #elif PLATFORM(QT) 45 #include <QMatrix4x4> 45 46 #include <QTransform> 46 47 #elif USE(SKIA) … … 85 86 #if PLATFORM(QT) 86 87 TransformationMatrix(const QTransform&); 88 TransformationMatrix(const QMatrix4x4&); 87 89 #endif 88 90 … … 332 334 #elif PLATFORM(QT) 333 335 operator QTransform() const; 336 operator QMatrix4x4() const; 334 337 #elif USE(SKIA) 335 338 operator SkMatrix() const; -
trunk/Source/WebKit2/ChangeLog
r110381 r110388 1 2012-03-11 Viatcheslav Ostapenko <ostapenko.viatcheslav@nokia.com> 2 3 [Qt] [WK2] Support threaded renderer in WK2 4 https://bugs.webkit.org/show_bug.cgi?id=76661 5 6 Reviewed by Noam Rosenthal. 7 8 Implement Qt5 threaded rendering support for Qt WebKit2. 9 Parts of LayerTreeHostProxy which contain layer tree and layer painting objects 10 are moved to separate class called WebLayerTreeRenderer. WebLayerTreeRenderer is 11 thread safe ref counted and referenced by LayerTreeHostProxy and paint node. 12 All layer tree and graphics objects are created, accessed and deallocated from Qt 13 Scenegraph's paint thread only. 14 Layer tree updates from render queue are fetched in updatePaintNode call stack when 15 main thread is locked. 16 Messages from paint thread to web process are passed through MainThreadGuardedInvoker 17 call gate (implemented by Noam Rosenthal and previously reviewed by Kenneth Rohde 18 Christiansen). 19 20 * Target.pri: 21 * UIProcess/API/qt/qquickwebpage.cpp: 22 (PageProxyNode::PageProxyNode): 23 (PageProxyNode::render): 24 (PageProxyNode::~PageProxyNode): 25 (PageProxyNode::layerTreeRenderer): 26 (PageProxyNode): 27 (PageProxyNode::setScale): 28 (QQuickWebPage::updatePaintNode): 29 (QQuickWebPagePrivate::~QQuickWebPagePrivate): 30 * UIProcess/LayerTreeHostProxy.cpp: Added. 31 (WebKit): 32 (WebKit::LayerTreeHostProxy::LayerTreeHostProxy): 33 (WebKit::LayerTreeHostProxy::~LayerTreeHostProxy): 34 (WebKit::LayerTreeHostProxy::paintToCurrentGLContext): 35 (WebKit::LayerTreeHostProxy::paintToGraphicsContext): 36 (WebKit::LayerTreeHostProxy::updateViewport): 37 (WebKit::LayerTreeHostProxy::dispatchUpdate): 38 (WebKit::LayerTreeHostProxy::createTileForLayer): 39 (WebKit::LayerTreeHostProxy::updateTileForLayer): 40 (WebKit::LayerTreeHostProxy::removeTileForLayer): 41 (WebKit::LayerTreeHostProxy::deleteCompositingLayer): 42 (WebKit::LayerTreeHostProxy::setRootCompositingLayer): 43 (WebKit::LayerTreeHostProxy::syncCompositingLayerState): 44 (WebKit::LayerTreeHostProxy::didRenderFrame): 45 (WebKit::LayerTreeHostProxy::createDirectlyCompositedImage): 46 (WebKit::LayerTreeHostProxy::destroyDirectlyCompositedImage): 47 (WebKit::LayerTreeHostProxy::setVisibleContentsRectForPanning): 48 (WebKit::LayerTreeHostProxy::setVisibleContentsRectForScaling): 49 (WebKit::LayerTreeHostProxy::renderNextFrame): 50 (WebKit::LayerTreeHostProxy::purgeBackingStores): 51 * UIProcess/LayerTreeHostProxy.h: 52 (WebKit): 53 (LayerTreeHostProxy): 54 (WebKit::LayerTreeHostProxy::layerTreeRenderer): 55 * UIProcess/WebLayerTreeRenderer.cpp: Renamed from Source/WebKit2/UIProcess/qt/LayerTreeHostProxyQt.cpp. 56 (WebKit): 57 (MainThreadGuardedInvoker): 58 (WebKit::MainThreadGuardedInvoker::call): 59 (WebKit::MainThreadGuardedInvoker::MainThreadGuardedInvoker): 60 (WebKit::MainThreadGuardedInvoker::invoke): 61 (WebKit::WebLayerTreeRenderer::callOnMainTread): 62 (WebKit::WebLayerTreeRenderer::WebLayerTreeRenderer): 63 (WebKit::WebLayerTreeRenderer::~WebLayerTreeRenderer): 64 (WebKit::WebLayerTreeRenderer::createLayer): 65 (WebKit::WebLayerTreeRenderer::paintToCurrentGLContext): 66 (WebKit::WebLayerTreeRenderer::syncAnimations): 67 (WebKit::WebLayerTreeRenderer::paintToGraphicsContext): 68 (WebKit::WebLayerTreeRenderer::setVisibleContentsRectForScaling): 69 (WebKit::WebLayerTreeRenderer::updateViewport): 70 (WebKit::WebLayerTreeRenderer::syncLayerParameters): 71 (WebKit::WebLayerTreeRenderer::deleteLayer): 72 (WebKit::WebLayerTreeRenderer::ensureLayer): 73 (WebKit::WebLayerTreeRenderer::setRootLayerID): 74 (WebKit::WebLayerTreeRenderer::getBackingStore): 75 (WebKit::WebLayerTreeRenderer::createTile): 76 (WebKit::WebLayerTreeRenderer::removeTile): 77 (WebKit::WebLayerTreeRenderer::updateTile): 78 (WebKit::WebLayerTreeRenderer::createImage): 79 (WebKit::WebLayerTreeRenderer::destroyImage): 80 (WebKit::WebLayerTreeRenderer::assignImageToLayer): 81 (WebKit::WebLayerTreeRenderer::swapBuffers): 82 (WebKit::WebLayerTreeRenderer::flushLayerChanges): 83 (WebKit::WebLayerTreeRenderer::renderNextFrame): 84 (WebKit::WebLayerTreeRenderer::ensureRootLayer): 85 (WebKit::WebLayerTreeRenderer::syncRemoteContent): 86 (WebKit::WebLayerTreeRenderer::purgeGLResources): 87 (WebKit::WebLayerTreeRenderer::purgeBackingStores): 88 (WebKit::WebLayerTreeRenderer::detach): 89 (WebKit::WebLayerTreeRenderer::appendUpdate): 90 * UIProcess/WebLayerTreeRenderer.h: Copied from Source/WebKit2/UIProcess/LayerTreeHostProxy.h. 91 (WebKit): 92 (WebLayerTreeRenderer): 93 (WebKit::WebLayerTreeRenderer::layerByID): 94 (WebKit::WebLayerTreeRenderer::rootLayer): 95 (WebKit::WebLayerTreeRenderer::notifyAnimationStarted): 96 (WebKit::WebLayerTreeRenderer::notifySyncRequired): 97 (WebKit::WebLayerTreeRenderer::showDebugBorders): 98 (WebKit::WebLayerTreeRenderer::showRepaintCounter): 99 (WebKit::WebLayerTreeRenderer::paintContents): 100 1 101 2012-03-09 Jon Lee <jonlee@apple.com> 2 102 -
trunk/Source/WebKit2/Target.pri
r110214 r110388 245 245 UIProcess/WebInspectorProxy.h \ 246 246 UIProcess/WebKeyValueStorageManagerProxy.h \ 247 UIProcess/WebLayerTreeRenderer.h \ 247 248 UIProcess/WebLoaderClient.h \ 248 249 UIProcess/WebMediaCacheManagerProxy.h \ … … 536 537 UIProcess/Launcher/qt/ProcessLauncherQt.cpp \ 537 538 UIProcess/Launcher/qt/ThreadLauncherQt.cpp \ 539 UIProcess/LayerTreeHostProxy.cpp \ 538 540 UIProcess/Notifications/NotificationPermissionRequest.cpp \ 539 541 UIProcess/Notifications/NotificationPermissionRequestManagerProxy.cpp \ … … 576 578 UIProcess/WebInspectorProxy.cpp \ 577 579 UIProcess/WebKeyValueStorageManagerProxy.cpp \ 580 UIProcess/WebLayerTreeRenderer.cpp \ 578 581 UIProcess/WebLoaderClient.cpp \ 579 582 UIProcess/WebMediaCacheManagerProxy.cpp \ … … 591 594 UIProcess/qt/QtWebContext.cpp \ 592 595 UIProcess/qt/LayerBackingStore.cpp \ 593 UIProcess/qt/LayerTreeHostProxyQt.cpp \594 596 UIProcess/qt/QtWebPageEventHandler.cpp \ 595 597 UIProcess/qt/QtGestureRecognizer.cpp \ -
trunk/Source/WebKit2/UIProcess/API/qt/qquickwebpage.cpp
r110368 r110388 25 25 #include "QtWebPageEventHandler.h" 26 26 #include "TransformationMatrix.h" 27 #include "WebLayerTreeRenderer.h" 27 28 #include "qquickwebpage_p_p.h" 28 29 #include "qquickwebview_p.h" … … 80 81 } 81 82 82 void QQuickWebPagePrivate::paintToCurrentGLContext(const QTransform& transform, float opacity, const QRectF& clipRect)83 {84 if (!q->isVisible())85 return;86 87 if (!clipRect.isValid())88 return;89 90 DrawingAreaProxy* drawingArea = webPageProxy->drawingArea();91 if (!drawingArea)92 return;93 94 drawingArea->paintToCurrentGLContext(QTransform(transform).scale(contentsScale, contentsScale), opacity, clipRect);95 }96 97 83 struct PageProxyNode : public QSGRenderNode { 98 PageProxyNode(QQuickWebPagePrivate* page) 99 : m_pagePrivate(page) 84 PageProxyNode(PassRefPtr<WebLayerTreeRenderer> renderer) 85 : m_renderer(renderer) 86 , m_scale(1) 100 87 { 101 88 } … … 108 95 virtual void render(const RenderState&) 109 96 { 110 if (!m_pagePrivate) 111 return; 112 QTransform transform = matrix() ? matrix()->toTransform() : QTransform(); 97 QMatrix4x4 renderMatrix = matrix() ? *matrix() : QMatrix4x4(); 98 99 // Have to apply render scale manualy because it is not applied on page item. 100 // http://trac.webkit.org/changeset/104450 101 renderMatrix.scale(m_scale); 113 102 114 103 // FIXME: Support non-rectangular clippings. 115 m_pagePrivate->paintToCurrentGLContext(transform, inheritedOpacity(), clipRect());104 layerTreeRenderer()->paintToCurrentGLContext(renderMatrix, inheritedOpacity(), clipRect()); 116 105 } 117 106 118 107 ~PageProxyNode() 119 108 { 120 if (m_pagePrivate) 121 m_pagePrivate->resetPaintNode(); 122 } 123 109 layerTreeRenderer()->purgeGLResources(); 110 } 111 112 WebLayerTreeRenderer* layerTreeRenderer() const { return m_renderer.get(); } 113 void setScale(float scale) { m_scale = scale; } 114 115 private: 124 116 QRectF clipRect() const 125 117 { … … 163 155 } 164 156 165 QQuickWebPagePrivate* m_pagePrivate; 157 RefPtr<WebLayerTreeRenderer> m_renderer; 158 float m_scale; 166 159 }; 167 160 168 161 QSGNode* QQuickWebPage::updatePaintNode(QSGNode* oldNode, UpdatePaintNodeData*) 169 162 { 170 if (!(flags() & ItemHasContents)) { 171 if (oldNode) 172 delete oldNode; 173 return 0; 174 } 175 176 PageProxyNode* proxyNode = static_cast<PageProxyNode*>(oldNode); 177 if (!proxyNode) { 178 proxyNode = new PageProxyNode(d); 179 d->m_paintNode = proxyNode; 180 } 181 182 return proxyNode; 163 if (!d->webPageProxy->drawingArea()) 164 return oldNode; 165 166 LayerTreeHostProxy* layerTreeHostProxy = d->webPageProxy->drawingArea()->layerTreeHostProxy(); 167 WebLayerTreeRenderer* renderer = layerTreeHostProxy->layerTreeRenderer(); 168 169 PageProxyNode* node = static_cast<PageProxyNode*>(oldNode); 170 171 if (node && node->layerTreeRenderer() != renderer) { 172 // This means that LayerTreeHostProxy was deleted and recreated while old paint node survived. 173 // This could happen if web process have crashed. In this case we have to recreate paint node. 174 delete node; 175 node = 0; 176 } 177 178 renderer->syncRemoteContent(); 179 180 if (!node) 181 node = new PageProxyNode(renderer); 182 183 node->setScale(d->contentsScale); 184 185 return node; 183 186 } 184 187 … … 234 237 } 235 238 236 void QQuickWebPagePrivate::resetPaintNode()237 {238 m_paintNode = 0;239 DrawingAreaProxy* drawingArea = webPageProxy->drawingArea();240 if (drawingArea && drawingArea->layerTreeHostProxy())241 drawingArea->layerTreeHostProxy()->purgeGLResources();242 }243 244 239 QQuickWebPagePrivate::~QQuickWebPagePrivate() 245 240 { 246 if (m_paintNode)247 static_cast<PageProxyNode*>(m_paintNode)->m_pagePrivate = 0;248 241 } 249 242 -
trunk/Source/WebKit2/UIProcess/LayerTreeHostProxy.h
r109755 r110388 26 26 #include "DrawingAreaProxy.h" 27 27 #include "Region.h" 28 #include "TextureMapper.h"29 #include "TextureMapperBackingStore.h"30 28 #include "WebLayerTreeInfo.h" 31 29 #include <WebCore/GraphicsContext.h> … … 38 36 #include <wtf/HashSet.h> 39 37 38 class QSGNode; 40 39 41 40 namespace WebKit { 42 41 43 class LayerBackingStore;44 42 class WebLayerInfo; 43 class WebLayerTreeRenderer; 45 44 class WebLayerUpdateInfo; 46 45 47 class LayerTreeHostProxy : public WebCore::GraphicsLayerClient{46 class LayerTreeHostProxy { 48 47 public: 49 48 LayerTreeHostProxy(DrawingAreaProxy*); … … 53 52 void setRootCompositingLayer(WebLayerID); 54 53 void didReceiveMessage(CoreIPC::Connection*, CoreIPC::MessageID, CoreIPC::ArgumentDecoder*); 55 void paintToCurrentGLContext(const WebCore::TransformationMatrix&, float , const WebCore::FloatRect&);54 void paintToCurrentGLContext(const WebCore::TransformationMatrix&, float opacity, const WebCore::FloatRect& clip); 56 55 void paintToGraphicsContext(BackingStore::PlatformGraphicsContext); 57 56 void purgeGLResources(); 58 57 void setVisibleContentsRectForScaling(const WebCore::IntRect&, float); 59 58 void setVisibleContentsRectForPanning(const WebCore::IntRect&, const WebCore::FloatPoint&); 60 void syncRemoteContent();61 void swapContentBuffers();62 59 void didRenderFrame(); 63 60 void createTileForLayer(int layerID, int tileID, const WebKit::UpdateInfo&); … … 68 65 void didReceiveLayerTreeHostProxyMessage(CoreIPC::Connection*, CoreIPC::MessageID, CoreIPC::ArgumentDecoder*); 69 66 void updateViewport(); 67 void renderNextFrame(); 68 void purgeBackingStores(); 69 WebLayerTreeRenderer* layerTreeRenderer() const { return m_renderer.get(); } 70 70 71 71 protected: 72 PassOwnPtr<WebCore::GraphicsLayer> createLayer(WebLayerID); 73 74 WebCore::GraphicsLayer* layerByID(WebLayerID id) { return (id == InvalidWebLayerID) ? 0 : m_layers.get(id); } 75 WebCore::GraphicsLayer* rootLayer() { return m_rootLayer.get(); } 76 77 // Reimplementations from WebCore::GraphicsLayerClient. 78 virtual void notifyAnimationStarted(const WebCore::GraphicsLayer*, double) { } 79 virtual void notifySyncRequired(const WebCore::GraphicsLayer*) { } 80 virtual bool showDebugBorders(const WebCore::GraphicsLayer*) const { return false; } 81 virtual bool showRepaintCounter(const WebCore::GraphicsLayer*) const { return false; } 82 void paintContents(const WebCore::GraphicsLayer*, WebCore::GraphicsContext&, WebCore::GraphicsLayerPaintingPhase, const WebCore::IntRect&) { } 72 void dispatchUpdate(const Function<void()>&); 83 73 84 74 DrawingAreaProxy* m_drawingAreaProxy; 85 86 typedef HashMap<WebLayerID, WebCore::GraphicsLayer*> LayerMap; 87 WebCore::IntRect m_visibleContentsRect; 88 float m_contentsScale; 89 90 Vector<Function<void()> > m_renderQueue; 91 void dispatchUpdate(const Function<void()>&); 92 93 #if USE(TEXTURE_MAPPER) 94 OwnPtr<WebCore::TextureMapper> m_textureMapper; 95 PassRefPtr<LayerBackingStore> getBackingStore(WebLayerID); 96 HashMap<int64_t, RefPtr<WebCore::TextureMapperBackingStore> > m_directlyCompositedImages; 97 HashSet<RefPtr<LayerBackingStore> > m_backingStoresWithPendingBuffers; 98 #endif 99 100 void scheduleWebViewUpdate(); 101 void synchronizeViewport(); 102 void deleteLayer(WebLayerID); 103 void setRootLayerID(WebLayerID); 104 void syncLayerParameters(const WebLayerInfo&); 105 void createTile(WebLayerID, int, float scale); 106 void removeTile(WebLayerID, int); 107 void updateTile(WebLayerID, int, const WebCore::IntRect&, const WebCore::IntRect&, PassRefPtr<ShareableBitmap>); 108 void createImage(int64_t, PassRefPtr<ShareableBitmap>); 109 void destroyImage(int64_t); 110 void assignImageToLayer(WebCore::GraphicsLayer*, int64_t imageID); 111 void flushLayerChanges(); 112 void ensureRootLayer(); 113 void ensureLayer(WebLayerID); 114 void swapBuffers(); 115 void syncAnimations(); 116 117 OwnPtr<WebCore::GraphicsLayer> m_rootLayer; 118 Vector<WebLayerID> m_layersToDelete; 119 120 LayerMap m_layers; 121 WebLayerID m_rootLayerID; 122 int m_id; 75 RefPtr<WebLayerTreeRenderer> m_renderer; 123 76 }; 124 77 -
trunk/Source/WebKit2/UIProcess/WebLayerTreeRenderer.cpp
r110387 r110388 1 1 /* 2 Copyright (C) 201 1Nokia Corporation and/or its subsidiary(-ies)2 Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies) 3 3 4 4 This library is free software; you can redistribute it and/or … … 20 20 #include "config.h" 21 21 22 #include "LayerTreeHostProxy.h" 22 #if USE(UI_SIDE_COMPOSITING) 23 24 #include "WebLayerTreeRenderer.h" 23 25 24 26 #include "GraphicsLayerTextureMapper.h" 25 27 #include "LayerBackingStore.h" 26 #include "LayerTreeHost Messages.h"28 #include "LayerTreeHostProxy.h" 27 29 #include "MainThread.h" 28 30 #include "MessageID.h" … … 32 34 #include "TextureMapperLayer.h" 33 35 #include "UpdateInfo.h" 34 #include "WebCoreArgumentCoders.h"35 #include "WebLayerTreeInfo.h"36 #include "WebPageProxy.h"37 #include "WebProcessProxy.h"38 36 #include <OpenGLShims.h> 39 #include < QDateTime>37 #include <wtf/Atomics.h> 40 38 41 39 namespace WebKit { … … 43 41 using namespace WebCore; 44 42 45 PassOwnPtr<GraphicsLayer> LayerTreeHostProxy::createLayer(WebLayerID layerID) 43 template<class T> class MainThreadGuardedInvoker { 44 public: 45 static void call(PassRefPtr<T> objectToGuard, const Function<void()>& function) 46 { 47 MainThreadGuardedInvoker<T>* invoker = new MainThreadGuardedInvoker<T>(objectToGuard, function); 48 callOnMainThread(invoke, invoker); 49 } 50 51 private: 52 MainThreadGuardedInvoker(PassRefPtr<T> object, const Function<void()>& newFunction) 53 : objectToGuard(object) 54 , function(newFunction) 55 { 56 } 57 58 RefPtr<T> objectToGuard; 59 Function<void()> function; 60 static void invoke(void* data) 61 { 62 MainThreadGuardedInvoker<T>* invoker = static_cast<MainThreadGuardedInvoker<T>*>(data); 63 invoker->function(); 64 delete invoker; 65 } 66 }; 67 68 void WebLayerTreeRenderer::callOnMainTread(const Function<void()>& function) 69 { 70 if (isMainThread()) 71 function(); 72 else 73 MainThreadGuardedInvoker<WebLayerTreeRenderer>::call(this, function); 74 } 75 76 WebLayerTreeRenderer::WebLayerTreeRenderer(LayerTreeHostProxy* layerTreeHostProxy) 77 : m_layerTreeHostProxy(layerTreeHostProxy) 78 , m_rootLayerID(0) 79 { 80 } 81 82 WebLayerTreeRenderer::~WebLayerTreeRenderer() 83 { 84 } 85 86 PassOwnPtr<GraphicsLayer> WebLayerTreeRenderer::createLayer(WebLayerID layerID) 46 87 { 47 88 GraphicsLayer* newLayer = new GraphicsLayerTextureMapper(this); … … 51 92 } 52 93 53 LayerTreeHostProxy::LayerTreeHostProxy(DrawingAreaProxy* drawingAreaProxy) 54 : m_drawingAreaProxy(drawingAreaProxy) 55 , m_rootLayerID(0) 56 { 57 } 58 59 LayerTreeHostProxy::~LayerTreeHostProxy() 60 { 61 } 62 63 // This function needs to be reentrant. 64 void LayerTreeHostProxy::paintToCurrentGLContext(const TransformationMatrix& matrix, float opacity, const FloatRect& clipRect) 94 void WebLayerTreeRenderer::paintToCurrentGLContext(const TransformationMatrix& matrix, float opacity, const FloatRect& clipRect) 65 95 { 66 96 if (!m_textureMapper) … … 96 126 } 97 127 98 void LayerTreeHostProxy::syncAnimations()128 void WebLayerTreeRenderer::syncAnimations() 99 129 { 100 130 TextureMapperLayer* layer = toTextureMapperLayer(rootLayer()); … … 103 133 layer->syncAnimationsRecursively(); 104 134 if (layer->descendantsOrSelfHaveRunningAnimations()) 105 updateViewport();106 } 107 108 void LayerTreeHostProxy::paintToGraphicsContext(QPainter* painter)135 callOnMainThread(bind(&WebLayerTreeRenderer::updateViewport, this)); 136 } 137 138 void WebLayerTreeRenderer::paintToGraphicsContext(QPainter* painter) 109 139 { 110 140 if (!m_textureMapper) … … 126 156 } 127 157 128 void LayerTreeHostProxy::updateViewport() 129 { 130 m_drawingAreaProxy->updateViewport(); 131 } 132 133 void LayerTreeHostProxy::syncLayerParameters(const WebLayerInfo& layerInfo) 158 void WebLayerTreeRenderer::setVisibleContentsRectForScaling(const IntRect& rect, float scale) 159 { 160 m_visibleContentsRect = rect; 161 m_contentsScale = scale; 162 } 163 164 void WebLayerTreeRenderer::updateViewport() 165 { 166 if (m_layerTreeHostProxy) 167 m_layerTreeHostProxy->updateViewport(); 168 } 169 170 void WebLayerTreeRenderer::syncLayerParameters(const WebLayerInfo& layerInfo) 134 171 { 135 172 WebLayerID id = layerInfo.id; … … 197 234 } 198 235 199 void LayerTreeHostProxy::deleteLayer(WebLayerID layerID)236 void WebLayerTreeRenderer::deleteLayer(WebLayerID layerID) 200 237 { 201 238 GraphicsLayer* layer = layerByID(layerID); … … 209 246 210 247 211 void LayerTreeHostProxy::ensureLayer(WebLayerID id)248 void WebLayerTreeRenderer::ensureLayer(WebLayerID id) 212 249 { 213 250 // We have to leak the new layer's pointer and manage it ourselves, … … 217 254 } 218 255 219 void LayerTreeHostProxy::setRootLayerID(WebLayerID layerID)256 void WebLayerTreeRenderer::setRootLayerID(WebLayerID layerID) 220 257 { 221 258 if (layerID == m_rootLayerID) … … 236 273 } 237 274 238 PassRefPtr<LayerBackingStore> LayerTreeHostProxy::getBackingStore(WebLayerID id)275 PassRefPtr<LayerBackingStore> WebLayerTreeRenderer::getBackingStore(WebLayerID id) 239 276 { 240 277 ensureLayer(id); … … 249 286 } 250 287 251 void LayerTreeHostProxy::createTile(WebLayerID layerID, int tileID, float scale)288 void WebLayerTreeRenderer::createTile(WebLayerID layerID, int tileID, float scale) 252 289 { 253 290 getBackingStore(layerID)->createTile(tileID, scale); 254 291 } 255 292 256 void LayerTreeHostProxy::removeTile(WebLayerID layerID, int tileID)293 void WebLayerTreeRenderer::removeTile(WebLayerID layerID, int tileID) 257 294 { 258 295 getBackingStore(layerID)->removeTile(tileID); 259 296 } 260 297 261 void LayerTreeHostProxy::updateTile(WebLayerID layerID, int tileID, const IntRect& sourceRect, const IntRect& targetRect, PassRefPtr<ShareableBitmap> weakBitmap)298 void WebLayerTreeRenderer::updateTile(WebLayerID layerID, int tileID, const IntRect& sourceRect, const IntRect& targetRect, PassRefPtr<ShareableBitmap> weakBitmap) 262 299 { 263 300 RefPtr<ShareableBitmap> bitmap = weakBitmap; … … 267 304 } 268 305 269 void LayerTreeHostProxy::createImage(int64_t imageID, PassRefPtr<ShareableBitmap> weakBitmap)306 void WebLayerTreeRenderer::createImage(int64_t imageID, PassRefPtr<ShareableBitmap> weakBitmap) 270 307 { 271 308 RefPtr<ShareableBitmap> bitmap = weakBitmap; … … 275 312 } 276 313 277 void LayerTreeHostProxy::destroyImage(int64_t imageID)314 void WebLayerTreeRenderer::destroyImage(int64_t imageID) 278 315 { 279 316 m_directlyCompositedImages.remove(imageID); 280 317 } 281 318 282 void LayerTreeHostProxy::assignImageToLayer(GraphicsLayer* layer, int64_t imageID)319 void WebLayerTreeRenderer::assignImageToLayer(GraphicsLayer* layer, int64_t imageID) 283 320 { 284 321 HashMap<int64_t, RefPtr<TextureMapperBackingStore> >::iterator it = m_directlyCompositedImages.find(imageID); … … 287 324 } 288 325 289 void LayerTreeHostProxy::swapBuffers()326 void WebLayerTreeRenderer::swapBuffers() 290 327 { 291 328 HashSet<RefPtr<LayerBackingStore> >::iterator end = m_backingStoresWithPendingBuffers.end(); … … 296 333 } 297 334 298 void LayerTreeHostProxy::flushLayerChanges()335 void WebLayerTreeRenderer::flushLayerChanges() 299 336 { 300 337 m_rootLayer->syncCompositingState(FloatRect()); … … 302 339 303 340 // The pending tiles state is on its way for the screen, tell the web process to render the next one. 304 m_drawingAreaProxy->page()->process()->send(Messages::LayerTreeHost::RenderNextFrame(), m_drawingAreaProxy->page()->pageID()); 305 } 306 307 void LayerTreeHostProxy::ensureRootLayer() 341 callOnMainThread(bind(&WebLayerTreeRenderer::renderNextFrame, this)); 342 } 343 344 void WebLayerTreeRenderer::renderNextFrame() 345 { 346 if (m_layerTreeHostProxy) 347 m_layerTreeHostProxy->renderNextFrame(); 348 } 349 350 void WebLayerTreeRenderer::ensureRootLayer() 308 351 { 309 352 if (m_rootLayer) 310 353 return; 354 if (!m_textureMapper) 355 m_textureMapper = TextureMapper::create(TextureMapper::OpenGLMode); 356 311 357 m_rootLayer = createLayer(InvalidWebLayerID); 312 358 m_rootLayer->setMasksToBounds(false); … … 316 362 // The root layer should not have zero size, or it would be optimized out. 317 363 m_rootLayer->setSize(FloatSize(1.0, 1.0)); 318 if (!m_textureMapper)319 m_textureMapper = TextureMapper::create(TextureMapper::OpenGLMode);320 364 toTextureMapperLayer(m_rootLayer.get())->setTextureMapper(m_textureMapper.get()); 321 365 } 322 366 323 void LayerTreeHostProxy::syncRemoteContent()367 void WebLayerTreeRenderer::syncRemoteContent() 324 368 { 325 369 // We enqueue messages and execute them during paint, as they require an active GL context. … … 332 376 } 333 377 334 void LayerTreeHostProxy::dispatchUpdate(const Function<void()>& function) 335 { 336 m_renderQueue.append(function); 337 updateViewport(); 338 } 339 340 void LayerTreeHostProxy::createTileForLayer(int layerID, int tileID, const WebKit::UpdateInfo& updateInfo) 341 { 342 dispatchUpdate(bind(&LayerTreeHostProxy::createTile, this, layerID, tileID, updateInfo.updateScaleFactor)); 343 updateTileForLayer(layerID, tileID, updateInfo); 344 } 345 346 void LayerTreeHostProxy::updateTileForLayer(int layerID, int tileID, const WebKit::UpdateInfo& updateInfo) 347 { 348 ASSERT(updateInfo.updateRects.size() == 1); 349 IntRect sourceRect = updateInfo.updateRects.first(); 350 IntRect targetRect = updateInfo.updateRectBounds; 351 RefPtr<ShareableBitmap> bitmap = ShareableBitmap::create(updateInfo.bitmapHandle); 352 dispatchUpdate(bind(&LayerTreeHostProxy::updateTile, this, layerID, tileID, sourceRect, targetRect, bitmap)); 353 } 354 355 void LayerTreeHostProxy::removeTileForLayer(int layerID, int tileID) 356 { 357 dispatchUpdate(bind(&LayerTreeHostProxy::removeTile, this, layerID, tileID)); 358 } 359 360 361 void LayerTreeHostProxy::deleteCompositingLayer(WebLayerID id) 362 { 363 dispatchUpdate(bind(&LayerTreeHostProxy::deleteLayer, this, id)); 364 } 365 366 void LayerTreeHostProxy::setRootCompositingLayer(WebLayerID id) 367 { 368 dispatchUpdate(bind(&LayerTreeHostProxy::setRootLayerID, this, id)); 369 } 370 371 void LayerTreeHostProxy::syncCompositingLayerState(const WebLayerInfo& info) 372 { 373 dispatchUpdate(bind(&LayerTreeHostProxy::syncLayerParameters, this, info)); 374 } 375 376 void LayerTreeHostProxy::didRenderFrame() 377 { 378 dispatchUpdate(bind(&LayerTreeHostProxy::flushLayerChanges, this)); 379 } 380 381 void LayerTreeHostProxy::createDirectlyCompositedImage(int64_t key, const WebKit::ShareableBitmap::Handle& handle) 382 { 383 RefPtr<ShareableBitmap> bitmap = ShareableBitmap::create(handle); 384 dispatchUpdate(bind(&LayerTreeHostProxy::createImage, this, key, bitmap)); 385 } 386 387 void LayerTreeHostProxy::destroyDirectlyCompositedImage(int64_t key) 388 { 389 dispatchUpdate(bind(&LayerTreeHostProxy::destroyImage, this, key)); 390 } 391 392 void LayerTreeHostProxy::setVisibleContentsRectForPanning(const IntRect& rect, const FloatPoint& trajectoryVector) 393 { 394 m_drawingAreaProxy->page()->process()->send(Messages::LayerTreeHost::SetVisibleContentsRectForPanning(rect, trajectoryVector), m_drawingAreaProxy->page()->pageID()); 395 } 396 397 void LayerTreeHostProxy::setVisibleContentsRectForScaling(const IntRect& rect, float scale) 398 { 399 m_visibleContentsRect = rect; 400 m_contentsScale = scale; 401 m_drawingAreaProxy->page()->process()->send(Messages::LayerTreeHost::SetVisibleContentsRectForScaling(rect, scale), m_drawingAreaProxy->page()->pageID()); 402 } 403 404 void LayerTreeHostProxy::purgeGLResources() 378 void WebLayerTreeRenderer::purgeGLResources() 405 379 { 406 380 TextureMapperLayer* layer = toTextureMapperLayer(rootLayer()); … … 412 386 m_textureMapper.clear(); 413 387 m_backingStoresWithPendingBuffers.clear(); 414 m_drawingAreaProxy->page()->process()->send(Messages::LayerTreeHost::PurgeBackingStores(), m_drawingAreaProxy->page()->pageID()); 415 } 416 417 } 388 389 callOnMainThread(bind(&WebLayerTreeRenderer::purgeBackingStores, this)); 390 } 391 392 void WebLayerTreeRenderer::purgeBackingStores() 393 { 394 if (m_layerTreeHostProxy) 395 m_layerTreeHostProxy->purgeBackingStores(); 396 } 397 398 void WebLayerTreeRenderer::detach() 399 { 400 m_layerTreeHostProxy = 0; 401 } 402 403 void WebLayerTreeRenderer::appendUpdate(const Function<void()>& function) 404 { 405 m_renderQueue.append(function); 406 } 407 408 } // namespace WebKit 409 410 #endif // USE(UI_SIDE_COMPOSITING) -
trunk/Source/WebKit2/UIProcess/WebLayerTreeRenderer.h
r110387 r110388 1 1 /* 2 Copyright (C) 201 1Nokia Corporation and/or its subsidiary(-ies)2 Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies) 3 3 4 4 This library is free software; you can redistribute it and/or … … 18 18 */ 19 19 20 #ifndef LayerTreeHostProxy_h21 #define LayerTreeHostProxy_h20 #ifndef WebLayerTreeRenderer_h 21 #define WebLayerTreeRenderer_h 22 22 23 23 #if USE(UI_SIDE_COMPOSITING) 24 24 25 25 #include "BackingStore.h" 26 #include "DrawingAreaProxy.h"27 #include "Region.h"28 26 #include "TextureMapper.h" 29 27 #include "TextureMapperBackingStore.h" … … 37 35 #include <wtf/Functional.h> 38 36 #include <wtf/HashSet.h> 39 37 #include <wtf/ThreadingPrimitives.h> 40 38 41 39 namespace WebKit { 42 40 43 41 class LayerBackingStore; 42 class LayerTreeHostProxy; 44 43 class WebLayerInfo; 45 44 class WebLayerUpdateInfo; 46 45 47 class LayerTreeHostProxy :public WebCore::GraphicsLayerClient {46 class WebLayerTreeRenderer : public ThreadSafeRefCounted<WebLayerTreeRenderer>, public WebCore::GraphicsLayerClient { 48 47 public: 49 LayerTreeHostProxy(DrawingAreaProxy*); 50 virtual ~LayerTreeHostProxy(); 51 void syncCompositingLayerState(const WebLayerInfo&); 52 void deleteCompositingLayer(WebLayerID); 53 void setRootCompositingLayer(WebLayerID); 54 void didReceiveMessage(CoreIPC::Connection*, CoreIPC::MessageID, CoreIPC::ArgumentDecoder*); 48 WebLayerTreeRenderer(LayerTreeHostProxy*); 49 virtual ~WebLayerTreeRenderer(); 50 void purgeGLResources(); 55 51 void paintToCurrentGLContext(const WebCore::TransformationMatrix&, float, const WebCore::FloatRect&); 56 52 void paintToGraphicsContext(BackingStore::PlatformGraphicsContext); 57 void purgeGLResources();53 void syncRemoteContent(); 58 54 void setVisibleContentsRectForScaling(const WebCore::IntRect&, float); 59 void setVisibleContentsRectForPanning(const WebCore::IntRect&, const WebCore::FloatPoint&); 60 void syncRemoteContent(); 61 void swapContentBuffers(); 62 void didRenderFrame(); 63 void createTileForLayer(int layerID, int tileID, const WebKit::UpdateInfo&); 64 void updateTileForLayer(int layerID, int tileID, const WebKit::UpdateInfo&); 65 void removeTileForLayer(int layerID, int tileID); 66 void createDirectlyCompositedImage(int64_t, const WebKit::ShareableBitmap::Handle&); 67 void destroyDirectlyCompositedImage(int64_t); 68 void didReceiveLayerTreeHostProxyMessage(CoreIPC::Connection*, CoreIPC::MessageID, CoreIPC::ArgumentDecoder*); 55 56 void detach(); 57 void appendUpdate(const Function<void()>&); 69 58 void updateViewport(); 70 59 71 protected: 60 void deleteLayer(WebLayerID); 61 void setRootLayerID(WebLayerID); 62 void syncLayerParameters(const WebLayerInfo&); 63 void createTile(WebLayerID, int, float scale); 64 void removeTile(WebLayerID, int); 65 void updateTile(WebLayerID, int, const WebCore::IntRect&, const WebCore::IntRect&, PassRefPtr<ShareableBitmap>); 66 void flushLayerChanges(); 67 void createImage(int64_t, PassRefPtr<ShareableBitmap>); 68 void destroyImage(int64_t); 69 70 private: 72 71 PassOwnPtr<WebCore::GraphicsLayer> createLayer(WebLayerID); 73 72 … … 81 80 virtual bool showRepaintCounter(const WebCore::GraphicsLayer*) const { return false; } 82 81 void paintContents(const WebCore::GraphicsLayer*, WebCore::GraphicsContext&, WebCore::GraphicsLayerPaintingPhase, const WebCore::IntRect&) { } 83 84 DrawingAreaProxy* m_drawingAreaProxy; 82 void callOnMainTread(const Function<void()>&); 85 83 86 84 typedef HashMap<WebLayerID, WebCore::GraphicsLayer*> LayerMap; … … 88 86 float m_contentsScale; 89 87 88 // Render queue can be accessed ony from main thread or updatePaintNode call stack! 90 89 Vector<Function<void()> > m_renderQueue; 91 void dispatchUpdate(const Function<void()>&);92 90 93 91 #if USE(TEXTURE_MAPPER) … … 100 98 void scheduleWebViewUpdate(); 101 99 void synchronizeViewport(); 102 void deleteLayer(WebLayerID);103 void setRootLayerID(WebLayerID);104 void syncLayerParameters(const WebLayerInfo&);105 void createTile(WebLayerID, int, float scale);106 void removeTile(WebLayerID, int);107 void updateTile(WebLayerID, int, const WebCore::IntRect&, const WebCore::IntRect&, PassRefPtr<ShareableBitmap>);108 void createImage(int64_t, PassRefPtr<ShareableBitmap>);109 void destroyImage(int64_t);110 100 void assignImageToLayer(WebCore::GraphicsLayer*, int64_t imageID); 111 void flushLayerChanges();112 101 void ensureRootLayer(); 113 102 void ensureLayer(WebLayerID); 114 103 void swapBuffers(); 115 104 void syncAnimations(); 105 void renderNextFrame(); 106 void purgeBackingStores(); 116 107 108 LayerTreeHostProxy* m_layerTreeHostProxy; 117 109 OwnPtr<WebCore::GraphicsLayer> m_rootLayer; 118 110 Vector<WebLayerID> m_layersToDelete; … … 120 112 LayerMap m_layers; 121 113 WebLayerID m_rootLayerID; 122 int m_id;123 114 }; 124 115 125 } 116 }; 126 117 127 #endif 118 #endif // USE(UI_SIDE_COMPOSITING) 128 119 129 #endif // LayerTreeHostProxy_h 120 #endif // WebLayerTreeRenderer_h 121 122 -
trunk/Tools/ChangeLog
r110382 r110388 1 2012-03-11 Viatcheslav Ostapenko <ostapenko.viatcheslav@nokia.com> 2 3 [Qt] [WK2] Support threaded renderer in WK2 4 https://bugs.webkit.org/show_bug.cgi?id=76661 5 6 Remove disabling of threaded rendering. 7 8 Reviewed by Noam Rosenthal. 9 10 * MiniBrowser/qt/main.cpp: 11 (main): 12 1 13 2012-03-09 Zan Dobersek <zandobersek@gmail.com> 2 14 -
trunk/Tools/MiniBrowser/qt/main.cpp
r109755 r110388 40 40 int main(int argc, char** argv) 41 41 { 42 // FIXME: We must add support for the threaded rendering as it is the default.43 qputenv("QML_NO_THREADED_RENDERER", QByteArray("1"));44 45 42 MiniBrowserApplication app(argc, argv); 46 43
Note: See TracChangeset
for help on using the changeset viewer.