Changeset 71253 in webkit
- Timestamp:
- Nov 3, 2010 11:33:20 AM (13 years ago)
- Location:
- trunk/WebCore
- Files:
-
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/WebCore/ChangeLog
r71252 r71253 1 2010-11-03 Noam Rosenthal <noam.rosenthal@nokia.com> 2 3 Reviewed by Kenneth Rohde Christiansen. 4 5 [Qt] GraphicsLayer: support tiling 6 https://bugs.webkit.org/show_bug.cgi?id=39691 7 8 Add support for TiledBackingStore in GraphicsLayerQt, when a layer is too large. 9 10 No new tests. Tests in LayoutTests/compositing/tiling now work with OpenGL enabled. 11 12 * platform/graphics/qt/GraphicsLayerQt.cpp: 13 (WebCore::GraphicsLayerQtImpl::GraphicsLayerQtImpl): 14 (WebCore::GraphicsLayerQtImpl::~GraphicsLayerQtImpl): 15 (WebCore::GraphicsLayerQtImpl::recache): 16 (WebCore::GraphicsLayerQtImpl::paint): 17 (WebCore::GraphicsLayerQtImpl::tiledBackingStorePaintBegin): 18 (WebCore::GraphicsLayerQtImpl::tiledBackingStorePaint): 19 (WebCore::GraphicsLayerQtImpl::tiledBackingStorePaintEnd): 20 (WebCore::GraphicsLayerQtImpl::tiledBackingStoreContentsRect): 21 (WebCore::GraphicsLayerQtImpl::tiledBackingStoreBackgroundColor): 22 (WebCore::GraphicsLayerQtImpl::tiledBackingStoreVisibleRect): 23 1 24 2010-11-03 Tony Chang <tony@chromium.org> 2 25 -
trunk/WebCore/platform/graphics/qt/GraphicsLayerQt.cpp
r70868 r71253 38 38 #include <QtGui/qgraphicsitem.h> 39 39 #include <QtGui/qgraphicsscene.h> 40 #include <QtGui/qgraphicsview.h> 40 41 #include <QtGui/qgraphicswidget.h> 41 42 #include <QtGui/qpainter.h> … … 43 44 #include <QtGui/qpixmapcache.h> 44 45 #include <QtGui/qstyleoption.h> 46 47 #if ENABLE(TILED_BACKING_STORE) 48 #include "TiledBackingStore.h" 49 #include "TiledBackingStoreClient.h" 50 51 // The minimum width/height for tiling. We use the same value as the Windows implementation. 52 #define GRAPHICS_LAYER_TILING_THRESHOLD 2000 53 #endif 45 54 46 55 … … 113 122 #endif // QT_NO_GRAPHICSEFFECT 114 123 115 class GraphicsLayerQtImpl : public QGraphicsObject { 124 class GraphicsLayerQtImpl : public QGraphicsObject 125 #if ENABLE(TILED_BACKING_STORE) 126 , public virtual TiledBackingStoreClient 127 #endif 128 { 116 129 Q_OBJECT 117 130 … … 182 195 // ChromeClientQt::scheduleCompositingLayerSync (meaning the sync will happen ASAP) 183 196 void flushChanges(bool recursive = true, bool forceTransformUpdate = false); 197 198 #if ENABLE(TILED_BACKING_STORE) 199 // reimplementations from TiledBackingStoreClient 200 virtual void tiledBackingStorePaintBegin(); 201 virtual void tiledBackingStorePaint(GraphicsContext*, const IntRect&); 202 virtual void tiledBackingStorePaintEnd(const Vector<IntRect>& paintedArea); 203 virtual IntRect tiledBackingStoreContentsRect(); 204 virtual IntRect tiledBackingStoreVisibleRect(); 205 virtual Color tiledBackingStoreBackgroundColor() const; 206 #endif 184 207 185 208 public slots: … … 232 255 233 256 int m_changeMask; 257 258 #if ENABLE(TILED_BACKING_STORE) 259 TiledBackingStore* m_tiledBackingStore; 260 #endif 234 261 235 262 QSizeF m_size; … … 304 331 , m_blockNotifySyncRequired(false) 305 332 , m_changeMask(NoChanges) 333 #if ENABLE(TILED_BACKING_STORE) 334 , m_tiledBackingStore(0) 335 #endif 306 336 #if ENABLE(3D_CANVAS) 307 337 , m_gc3D(0) … … 331 361 } 332 362 } 333 363 #if ENABLE(TILED_BACKING_STORE) 364 delete m_tiledBackingStore; 365 #endif 334 366 #ifndef QT_NO_ANIMATION 335 367 // We do, however, own the animations. … … 352 384 if (!m_layer->drawsContent() || m_size.isEmpty() || !m_size.isValid()) 353 385 return QPixmap(); 386 387 #if ENABLE(TILED_BACKING_STORE) 388 const bool requiresTiling = (m_state.drawsContent && m_currentContent.contentType == HTMLContentType) && (m_size.width() > GRAPHICS_LAYER_TILING_THRESHOLD || m_size.height() > GRAPHICS_LAYER_TILING_THRESHOLD); 389 if (requiresTiling && !m_tiledBackingStore) { 390 m_tiledBackingStore = new TiledBackingStore(this); 391 m_tiledBackingStore->setTileCreationDelay(0); 392 setFlag(ItemUsesExtendedStyleOption, true); 393 } else if (!requiresTiling && m_tiledBackingStore) { 394 delete m_tiledBackingStore; 395 m_tiledBackingStore = 0; 396 setFlag(ItemUsesExtendedStyleOption, false); 397 } 398 399 if (m_tiledBackingStore) { 400 m_tiledBackingStore->adjustVisibleRect(); 401 const QVector<QRect> rects = regionToUpdate.rects(); 402 for (int i = 0; i < rects.size(); ++i) 403 m_tiledBackingStore->invalidate(rects[i]); 404 return QPixmap(); 405 } 406 #endif 354 407 355 408 QPixmap pixmap; … … 563 616 void GraphicsLayerQtImpl::paint(QPainter* painter, const QStyleOptionGraphicsItem* option, QWidget* widget) 564 617 { 618 #if ENABLE(TILED_BACKING_STORE) 619 // FIXME: There's currently no Qt API to know if a new region of an item is exposed outside of the paint event. 620 // Suggested for Qt: http://bugreports.qt.nokia.com/browse/QTBUG-14877. 621 if (m_tiledBackingStore) 622 m_tiledBackingStore->adjustVisibleRect(); 623 #endif 624 565 625 if (m_currentContent.backgroundColor.isValid()) 566 painter->fillRect(option-> rect, QColor(m_currentContent.backgroundColor));626 painter->fillRect(option->exposedRect, QColor(m_currentContent.backgroundColor)); 567 627 568 628 switch (m_currentContent.contentType) { … … 829 889 } 830 890 891 #if ENABLE(TILED_BACKING_STORE) 892 /* \reimp (TiledBackingStoreClient.h) 893 */ 894 void GraphicsLayerQtImpl::tiledBackingStorePaintBegin() 895 { 896 } 897 898 /* \reimp (TiledBackingStoreClient.h) 899 */ 900 void GraphicsLayerQtImpl::tiledBackingStorePaint(GraphicsContext* gc, const IntRect& rect) 901 { 902 m_layer->paintGraphicsLayerContents(*gc, rect); 903 } 904 905 /* \reimp (TiledBackingStoreClient.h) 906 */ 907 void GraphicsLayerQtImpl::tiledBackingStorePaintEnd(const Vector<IntRect>& paintedArea) 908 { 909 for (int i = 0; i < paintedArea.size(); ++i) 910 update(QRectF(paintedArea[i])); 911 } 912 913 /* \reimp (TiledBackingStoreClient.h) 914 */ 915 IntRect GraphicsLayerQtImpl::tiledBackingStoreContentsRect() 916 { 917 return m_layer->contentsRect(); 918 } 919 920 /* \reimp (TiledBackingStoreClient.h) 921 */ 922 Color GraphicsLayerQtImpl::tiledBackingStoreBackgroundColor() const 923 { 924 if (m_currentContent.contentType == PixmapContentType && !m_currentContent.pixmap.hasAlphaChannel()) 925 return Color(0, 0, 0); 926 // We return a transparent color so that the tiles initialize with alpha. 927 return Color(0, 0, 0, 0); 928 } 929 #endif 930 931 IntRect GraphicsLayerQtImpl::tiledBackingStoreVisibleRect() 932 { 933 const QGraphicsView* view = scene()->views().isEmpty() ? 0 : scene()->views().first(); 934 if (!view) 935 return mapFromScene(scene()->sceneRect()).boundingRect().toAlignedRect(); 936 937 // All we get is the viewport's visible region. We have to map it to the scene and then to item coordinates. 938 return mapFromScene(view->mapToScene(view->viewport()->visibleRegion().boundingRect()).boundingRect()).boundingRect().toAlignedRect(); 939 } 940 831 941 void GraphicsLayerQtImpl::notifyAnimationStarted() 832 942 {
Note: See TracChangeset
for help on using the changeset viewer.