Changeset 56184 in webkit


Ignore:
Timestamp:
Mar 18, 2010 1:19:42 PM (14 years ago)
Author:
Simon Hausmann
Message:

2010-03-18 Antti Koivisto <koivisto@iki.fi>

Reviewed by Kenneth Rohde Christiansen.

https://bugs.webkit.org/show_bug.cgi?id=36102
[Qt] Scaling control API for tiled backing store

Commit the new scale synchronously after unfreeze to avoid ugliness.

  • platform/graphics/TiledBackingStore.cpp: (WebCore::TiledBackingStore::TiledBackingStore): (WebCore::TiledBackingStore::setContentsScale): (WebCore::TiledBackingStore::commitScaleChange): (WebCore::TiledBackingStore::setContentsFrozen):
  • platform/graphics/TiledBackingStore.h:

2010-03-18 Antti Koivisto <koivisto@iki.fi>

Reviewed by Kenneth Rohde Christiansen.

https://bugs.webkit.org/show_bug.cgi?id=36102
[Qt] Scaling control API for tiled backing store

The scale is set by passing the QGraphicsWebView scale to the backing store. The
only new API is the tiledBackingStoreFrozen property which allows disabling
all updates (for example during zoom animation).

  • Api/qgraphicswebview.cpp: (QGraphicsWebViewPrivate::_q_scaleChanged): (QGraphicsWebViewPrivate::updateTiledBackingStoreScale): (QGraphicsWebView::QGraphicsWebView): (QGraphicsWebView::isTiledBackingStoreFrozen): (QGraphicsWebView::setTiledBackingStoreFrozen):
  • Api/qgraphicswebview.h:
  • Api/qwebframe.cpp:
  • Api/qwebframe_p.h:
Location:
trunk
Files:
6 edited

Legend:

Unmodified
Added
Removed
  • trunk/WebCore/ChangeLog

    r56182 r56184  
     12010-03-18  Antti Koivisto  <koivisto@iki.fi>
     2
     3        Reviewed by Kenneth Rohde Christiansen.
     4
     5        https://bugs.webkit.org/show_bug.cgi?id=36102
     6        [Qt] Scaling control API for tiled backing store
     7       
     8        Commit the new scale synchronously after unfreeze to avoid ugliness.
     9
     10        * platform/graphics/TiledBackingStore.cpp:
     11        (WebCore::TiledBackingStore::TiledBackingStore):
     12        (WebCore::TiledBackingStore::setContentsScale):
     13        (WebCore::TiledBackingStore::commitScaleChange):
     14        (WebCore::TiledBackingStore::setContentsFrozen):
     15        * platform/graphics/TiledBackingStore.h:
     16
    1172010-03-18  David Hyatt  <hyatt@apple.com>
    218
  • trunk/WebCore/platform/graphics/TiledBackingStore.cpp

    r55976 r56184  
    3737    , m_tileSize(defaultTileWidth, defaultTileHeight)
    3838    , m_contentsScale(1.f)
     39    , m_pendingScale(0)
    3940    , m_contentsFrozen(false)
    4041{
     
    142143void TiledBackingStore::setContentsScale(float scale)
    143144{
    144     if (m_contentsScale == scale)
    145         return;
    146     m_contentsScale = scale;
    147 
    148     invalidate(m_client->tiledBackingStoreContentsRect());
    149 }
    150    
     145    if (m_pendingScale == m_contentsScale) {
     146        m_pendingScale = 0;
     147        return;
     148    }
     149    m_pendingScale = scale;
     150    if (m_contentsFrozen)
     151        return;
     152    commitScaleChange();
     153}
     154   
     155void TiledBackingStore::commitScaleChange()
     156{
     157    m_contentsScale = m_pendingScale;
     158    m_pendingScale = 0;
     159    m_tiles.clear();
     160    createTiles();
     161}
     162
    151163double TiledBackingStore::tileDistance(const IntRect& viewport, const Tile::Coordinate& tileCoordinate)
    152164{
     
    352364    // were not painted or created because tiles are not created or
    353365    // painted when in frozen state.
    354     if (!m_contentsFrozen) {
     366    if (m_contentsFrozen)
     367        return;
     368    if (m_pendingScale)
     369        commitScaleChange();
     370    else {
    355371        startTileCreationTimer();
    356372        startTileBufferUpdateTimer();
    357373    }
    358     // stopping is handled when the timers fire
    359374}
    360375
  • trunk/WebCore/platform/graphics/TiledBackingStore.h

    r55976 r56184  
    6464    void updateTileBuffers();
    6565    void createTiles();
     66   
     67    void commitScaleChange();
    6668
    6769    void dropOverhangingTiles();
     
    9698    IntRect m_viewport;
    9799    float m_contentsScale;
     100    float m_pendingScale;
    98101
    99102    bool m_contentsFrozen;
  • trunk/WebKit/qt/Api/qgraphicswebview.cpp

    r56068 r56184  
    122122    void updateResizesToContentsForPage();
    123123    QRectF graphicsItemVisibleRect() const;
     124#if ENABLE(TILED_BACKING_STORE)
     125    void updateTiledBackingStoreScale();
     126#endif
    124127
    125128    void createOrDeleteOverlay();
     
    128131    void _q_doLoadFinished(bool success);
    129132    void _q_contentsSizeChanged(const QSize&);
     133    void _q_scaleChanged();
    130134
    131135    QGraphicsWebView* q;
     
    359363}
    360364
     365void QGraphicsWebViewPrivate::_q_scaleChanged()
     366{
     367#if ENABLE(TILED_BACKING_STORE)
     368    updateTiledBackingStoreScale();
     369#endif
     370}
     371
    361372QRectF QGraphicsWebViewPrivate::graphicsItemVisibleRect() const
    362373{
     
    376387}
    377388
     389#if ENABLE(TILED_BACKING_STORE)
     390void QGraphicsWebViewPrivate::updateTiledBackingStoreScale()
     391{
     392    WebCore::TiledBackingStore* backingStore = QWebFramePrivate::core(page->mainFrame())->tiledBackingStore();
     393    if (!backingStore)
     394        return;
     395    backingStore->setContentsScale(q->scale());
     396}
     397#endif
     398
    378399/*!
    379400    \class QGraphicsWebView
     
    469490    setFocusPolicy(Qt::StrongFocus);
    470491    setFlag(QGraphicsItem::ItemClipsChildrenToShape, true);
     492#if ENABLE(TILED_BACKING_STORE)
     493    QObject::connect(this, SIGNAL(scaleChanged()), this, SLOT(_q_scaleChanged()));
     494#endif
    471495}
    472496
     
    10291053}
    10301054
     1055/*!
     1056    \property QGraphicsWebView::tiledBackingStoreFrozen
     1057    \brief whether the tiled backing store updates its contents
     1058    \since 4.7
     1059
     1060    If the tiled backing store is enabled using QWebSettings::TiledBackingStoreEnabled attribute, this property
     1061    can be used to disable backing store updates temporarily. This can be useful for example for running
     1062    a smooth animation that changes the scale of the QGraphicsWebView.
     1063 
     1064    When the backing store is unfrozen, its contents will be automatically updated to match the current
     1065    state of the document. If the QGraphicsWebView scale was changed, the backing store is also
     1066    re-rendered using the new scale.
     1067 
     1068    If the tiled backing store is not enabled, this property does nothing.
     1069
     1070    \sa QWebSettings::TiledBackingStoreEnabled
     1071    \sa QGraphicsObject::scale
     1072*/
     1073bool QGraphicsWebView::isTiledBackingStoreFrozen() const
     1074{
     1075#if ENABLE(TILED_BACKING_STORE)
     1076    WebCore::TiledBackingStore* backingStore = QWebFramePrivate::core(page()->mainFrame())->tiledBackingStore();
     1077    if (!backingStore)
     1078        return false;
     1079    return backingStore->contentsFrozen();
     1080#else
     1081    return false;
     1082#endif
     1083}
     1084
     1085void QGraphicsWebView::setTiledBackingStoreFrozen(bool frozen)
     1086{
     1087#if ENABLE(TILED_BACKING_STORE)
     1088    WebCore::TiledBackingStore* backingStore = QWebFramePrivate::core(page()->mainFrame())->tiledBackingStore();
     1089    if (!backingStore)
     1090        return;
     1091    backingStore->setContentsFrozen(frozen);
     1092#else
     1093    UNUSED_PARAM(frozen);
     1094#endif
     1095}
     1096
    10311097/*! \reimp
    10321098*/
  • trunk/WebKit/qt/Api/qgraphicswebview.h

    r54767 r56184  
    4747    Q_PROPERTY(bool modified READ isModified)
    4848    Q_PROPERTY(bool resizesToContents READ resizesToContents WRITE setResizesToContents)
     49    Q_PROPERTY(bool tiledBackingStoreFrozen READ isTiledBackingStoreFrozen WRITE setTiledBackingStoreFrozen)
    4950
    5051public:
     
    8384    bool resizesToContents() const;
    8485    void setResizesToContents(bool enabled);
     86   
     87    bool isTiledBackingStoreFrozen() const;
     88    void setTiledBackingStoreFrozen(bool frozen);
    8589
    8690    virtual void setGeometry(const QRectF& rect);
     
    143147    Q_PRIVATE_SLOT(d, void syncLayers())
    144148    Q_PRIVATE_SLOT(d, void _q_contentsSizeChanged(const QSize&))
     149    Q_PRIVATE_SLOT(d, void _q_scaleChanged())
    145150
    146151    QGraphicsWebViewPrivate* const d;
  • trunk/WebKit/qt/ChangeLog

    r56141 r56184  
     12010-03-18  Antti Koivisto  <koivisto@iki.fi>
     2
     3        Reviewed by Kenneth Rohde Christiansen.
     4
     5        https://bugs.webkit.org/show_bug.cgi?id=36102
     6        [Qt] Scaling control API for tiled backing store
     7       
     8        The scale is set by passing the QGraphicsWebView scale to the backing store. The
     9        only new API is the tiledBackingStoreFrozen property which allows disabling
     10        all updates (for example during zoom animation).
     11
     12        * Api/qgraphicswebview.cpp:
     13        (QGraphicsWebViewPrivate::_q_scaleChanged):
     14        (QGraphicsWebViewPrivate::updateTiledBackingStoreScale):
     15        (QGraphicsWebView::QGraphicsWebView):
     16        (QGraphicsWebView::isTiledBackingStoreFrozen):
     17        (QGraphicsWebView::setTiledBackingStoreFrozen):
     18        * Api/qgraphicswebview.h:
     19        * Api/qwebframe.cpp:
     20        * Api/qwebframe_p.h:
     21
    1222010-03-17  Antti Koivisto  <koivisto@iki.fi>
    223
Note: See TracChangeset for help on using the changeset viewer.