Changeset 71253 in webkit


Ignore:
Timestamp:
Nov 3, 2010 11:33:20 AM (13 years ago)
Author:
noam.rosenthal@nokia.com
Message:

[Qt] GraphicsLayer: support tiling
https://bugs.webkit.org/show_bug.cgi?id=39691

Reviewed by Kenneth Rohde Christiansen.

Add support for TiledBackingStore in GraphicsLayerQt, when a layer is too large.

No new tests. Tests in LayoutTests/compositing/tiling now work with OpenGL enabled.

  • platform/graphics/qt/GraphicsLayerQt.cpp:

(WebCore::GraphicsLayerQtImpl::GraphicsLayerQtImpl):
(WebCore::GraphicsLayerQtImpl::~GraphicsLayerQtImpl):
(WebCore::GraphicsLayerQtImpl::recache):
(WebCore::GraphicsLayerQtImpl::paint):
(WebCore::GraphicsLayerQtImpl::tiledBackingStorePaintBegin):
(WebCore::GraphicsLayerQtImpl::tiledBackingStorePaint):
(WebCore::GraphicsLayerQtImpl::tiledBackingStorePaintEnd):
(WebCore::GraphicsLayerQtImpl::tiledBackingStoreContentsRect):
(WebCore::GraphicsLayerQtImpl::tiledBackingStoreBackgroundColor):
(WebCore::GraphicsLayerQtImpl::tiledBackingStoreVisibleRect):

Location:
trunk/WebCore
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • trunk/WebCore/ChangeLog

    r71252 r71253  
     12010-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
    1242010-11-03  Tony Chang  <tony@chromium.org>
    225
  • trunk/WebCore/platform/graphics/qt/GraphicsLayerQt.cpp

    r70868 r71253  
    3838#include <QtGui/qgraphicsitem.h>
    3939#include <QtGui/qgraphicsscene.h>
     40#include <QtGui/qgraphicsview.h>
    4041#include <QtGui/qgraphicswidget.h>
    4142#include <QtGui/qpainter.h>
     
    4344#include <QtGui/qpixmapcache.h>
    4445#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
    4554
    4655
     
    113122#endif // QT_NO_GRAPHICSEFFECT
    114123
    115 class GraphicsLayerQtImpl : public QGraphicsObject {
     124class GraphicsLayerQtImpl : public QGraphicsObject
     125#if ENABLE(TILED_BACKING_STORE)
     126, public virtual TiledBackingStoreClient
     127#endif
     128{
    116129    Q_OBJECT
    117130
     
    182195    // ChromeClientQt::scheduleCompositingLayerSync (meaning the sync will happen ASAP)
    183196    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
    184207
    185208public slots:
     
    232255
    233256    int m_changeMask;
     257
     258#if ENABLE(TILED_BACKING_STORE)
     259    TiledBackingStore* m_tiledBackingStore;
     260#endif
    234261
    235262    QSizeF m_size;
     
    304331    , m_blockNotifySyncRequired(false)
    305332    , m_changeMask(NoChanges)
     333#if ENABLE(TILED_BACKING_STORE)
     334    , m_tiledBackingStore(0)
     335#endif
    306336#if ENABLE(3D_CANVAS)
    307337    , m_gc3D(0)
     
    331361        }
    332362    }
    333 
     363#if ENABLE(TILED_BACKING_STORE)
     364    delete m_tiledBackingStore;
     365#endif
    334366#ifndef QT_NO_ANIMATION
    335367    // We do, however, own the animations.
     
    352384    if (!m_layer->drawsContent() || m_size.isEmpty() || !m_size.isValid())
    353385        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
    354407
    355408    QPixmap pixmap;
     
    563616void GraphicsLayerQtImpl::paint(QPainter* painter, const QStyleOptionGraphicsItem* option, QWidget* widget)
    564617{
     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
    565625    if (m_currentContent.backgroundColor.isValid())
    566         painter->fillRect(option->rect, QColor(m_currentContent.backgroundColor));
     626        painter->fillRect(option->exposedRect, QColor(m_currentContent.backgroundColor));
    567627
    568628    switch (m_currentContent.contentType) {
     
    829889}
    830890
     891#if ENABLE(TILED_BACKING_STORE)
     892/* \reimp (TiledBackingStoreClient.h)
     893*/
     894void GraphicsLayerQtImpl::tiledBackingStorePaintBegin()
     895{
     896}
     897
     898/* \reimp (TiledBackingStoreClient.h)
     899*/
     900void GraphicsLayerQtImpl::tiledBackingStorePaint(GraphicsContext* gc,  const IntRect& rect)
     901{
     902    m_layer->paintGraphicsLayerContents(*gc, rect);
     903}
     904
     905/* \reimp (TiledBackingStoreClient.h)
     906*/
     907void 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*/
     915IntRect GraphicsLayerQtImpl::tiledBackingStoreContentsRect()
     916{
     917    return m_layer->contentsRect();
     918}
     919
     920/* \reimp (TiledBackingStoreClient.h)
     921*/
     922Color 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
     931IntRect 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
    831941void GraphicsLayerQtImpl::notifyAnimationStarted()
    832942{
Note: See TracChangeset for help on using the changeset viewer.