Changeset 167256 in webkit


Ignore:
Timestamp:
Apr 14, 2014 11:40:04 AM (10 years ago)
Author:
Antti Koivisto
Message:

Keep secondary tile grid for zoomed-out scale
https://bugs.webkit.org/show_bug.cgi?id=131586

Reviewed by Darin Adler.

Source/WebCore:

  • platform/graphics/ca/GraphicsLayerCA.cpp:

(WebCore::GraphicsLayerCA::updateContentsScale):

Don't repaint tiled backing with setNeedsDisplay, it invalidates itself correctly in setContentsScale.
Update custom child layers when tiled backing scale changes.

  • platform/graphics/ca/mac/TileController.h:
  • platform/graphics/ca/mac/TileController.mm:

(WebCore::TileController::TileController):
(WebCore::TileController::setNeedsDisplay):

Drop the whole zoomed-out grid on full repaint.

(WebCore::TileController::setNeedsDisplayInRect):

Drop changed zoomed-out tiles. A more sophisticated strategy is possible.

(WebCore::TileController::setContentsScale):

Swap the zoomed-out grid in and out as needed.
Repaint the active grid after scale change so the client does not have to.

(WebCore::TileController::contentsScale):

Get the content scale from the tile grid so it is not kept in two places.

(WebCore::TileController::zoomedOutContentsScale):
(WebCore::TileController::setZoomedOutContentsScale):

Drop the zoomed-out grid if it no longer matches the zoomed-out scale.

(WebCore::TileController::tileRevalidationTimerFired):
(WebCore::TileController::retainedTileBackingStoreMemory):
(WebCore::TileController::containerLayers):

Return both zoomed-out tiles and the active tiles. Active tiles are on top.

(WebCore::TileController::numberOfUnparentedTiles):
(WebCore::TileController::removeUnparentedTilesNow):

  • platform/graphics/ca/mac/TileGrid.h:
  • platform/graphics/ca/mac/TileGrid.mm:

(WebCore::TileGrid::dropTilesInRect):

Add a function for dropping tiles.

(WebCore::TileGrid::revalidateTiles):

Source/WebKit2:

  • WebProcess/WebPage/mac/PlatformCALayerRemoteTiledBacking.cpp:

(WebKit::PlatformCALayerRemoteTiledBacking::PlatformCALayerRemoteTiledBacking):
(WebKit::PlatformCALayerRemoteTiledBacking::customSublayers):

Always request new sublayer list from tile controller.

  • WebProcess/WebPage/mac/PlatformCALayerRemoteTiledBacking.h:
Location:
trunk/Source
Files:
9 edited

Legend:

Unmodified
Added
Removed
  • trunk/Source/WebCore/ChangeLog

    r167251 r167256  
     12014-04-12  Antti Koivisto  <antti@apple.com>
     2
     3        Keep secondary tile grid for zoomed-out scale
     4        https://bugs.webkit.org/show_bug.cgi?id=131586
     5
     6        Reviewed by Darin Adler.
     7
     8        * platform/graphics/ca/GraphicsLayerCA.cpp:
     9        (WebCore::GraphicsLayerCA::updateContentsScale):
     10       
     11            Don't repaint tiled backing with setNeedsDisplay, it invalidates itself correctly in setContentsScale.
     12            Update custom child layers when tiled backing scale changes.
     13
     14        * platform/graphics/ca/mac/TileController.h:
     15        * platform/graphics/ca/mac/TileController.mm:
     16        (WebCore::TileController::TileController):
     17        (WebCore::TileController::setNeedsDisplay):
     18       
     19            Drop the whole zoomed-out grid on full repaint.
     20
     21        (WebCore::TileController::setNeedsDisplayInRect):
     22           
     23            Drop changed zoomed-out tiles. A more sophisticated strategy is possible.
     24
     25        (WebCore::TileController::setContentsScale):
     26       
     27            Swap the zoomed-out grid in and out as needed.
     28            Repaint the active grid after scale change so the client does not have to.
     29
     30        (WebCore::TileController::contentsScale):
     31       
     32            Get the content scale from the tile grid so it is not kept in two places.
     33
     34        (WebCore::TileController::zoomedOutContentsScale):
     35        (WebCore::TileController::setZoomedOutContentsScale):
     36       
     37            Drop the zoomed-out grid if it no longer matches the zoomed-out scale.
     38
     39        (WebCore::TileController::tileRevalidationTimerFired):
     40        (WebCore::TileController::retainedTileBackingStoreMemory):
     41        (WebCore::TileController::containerLayers):
     42       
     43            Return both zoomed-out tiles and the active tiles. Active tiles are on top.
     44
     45        (WebCore::TileController::numberOfUnparentedTiles):
     46        (WebCore::TileController::removeUnparentedTilesNow):
     47        * platform/graphics/ca/mac/TileGrid.h:
     48        * platform/graphics/ca/mac/TileGrid.mm:
     49        (WebCore::TileGrid::dropTilesInRect):
     50       
     51            Add a function for dropping tiles.
     52
     53        (WebCore::TileGrid::revalidateTiles):
     54
    1552014-04-14  Oliver Hunt  <oliver@apple.com>
    256
  • trunk/Source/WebCore/platform/graphics/ca/GraphicsLayerCA.cpp

    r167196 r167256  
    29932993
    29942994    m_layer->setContentsScale(contentsScale);
     2995
     2996    if (tiledBacking()) {
     2997        // Scale change may swap in a different set of tiles changing the custom child layers.
     2998        if (m_isPageTiledBackingLayer)
     2999            m_uncommittedChanges |= ChildrenChanged;
     3000        // Tiled backing repaints automatically on scale change.
     3001        return;
     3002    }
    29953003    if (drawsContent())
    29963004        m_layer->setNeedsDisplay();
  • trunk/Source/WebCore/platform/graphics/ca/mac/TileController.h

    r167138 r167256  
    6161
    6262    void setContentsScale(float);
    63     float contentsScale() const { return m_contentsScale; }
     63    float contentsScale() const;
    6464
    6565    bool acceleratesDrawing() const { return m_acceleratesDrawing; }
     
    149149    virtual void setTileMargins(int marginTop, int marginBottom, int marginLeft, int marginRight) override;
    150150    virtual void setZoomedOutContentsScale(float) override;
    151     virtual float zoomedOutContentsScale() const override { return m_zoomedOutContentsScale; }
     151    virtual float zoomedOutContentsScale() const override;
    152152
    153153    void scheduleTileRevalidation(double interval);
     
    163163
    164164    std::unique_ptr<TileGrid> m_tileGrid;
     165    std::unique_ptr<TileGrid> m_zoomedOutTileGrid;
    165166
    166167    IntSize m_tileSize;
     
    171172    Timer<TileController> m_tileRevalidationTimer;
    172173
    173     float m_contentsScale;
    174174    float m_zoomedOutContentsScale;
    175175    float m_deviceScaleFactor;
  • trunk/Source/WebCore/platform/graphics/ca/mac/TileController.mm

    r167138 r167256  
    4545namespace WebCore {
    4646
    47 enum TileValidationPolicyFlag {
    48     PruneSecondaryTiles = 1 << 0,
    49     UnparentAllTiles = 1 << 1
    50 };
    51 
    5247PassOwnPtr<TileController> TileController::create(PlatformCALayer* rootPlatformLayer)
    5348{
     
    6055    , m_tileSize(defaultTileWidth, defaultTileHeight)
    6156    , m_tileRevalidationTimer(this, &TileController::tileRevalidationTimerFired)
    62     , m_contentsScale(1)
    6357    , m_zoomedOutContentsScale(0)
    6458    , m_deviceScaleFactor(1)
     
    9791{
    9892    tileGrid().setNeedsDisplay();
     93    m_zoomedOutTileGrid = nullptr;
    9994}
    10095
     
    10297{
    10398    tileGrid().setNeedsDisplayInRect(rect);
     99    if (m_zoomedOutTileGrid)
     100        m_zoomedOutTileGrid->dropTilesInRect(rect);
    104101}
    105102
     
    108105    ASSERT(owningGraphicsLayer()->isCommittingChanges());
    109106
    110     m_contentsScale = scale;
    111 
    112107    float deviceScaleFactor = owningGraphicsLayer()->platformCALayerDeviceScaleFactor();
    113 
    114108    // The scale we get is the product of the page scale factor and device scale factor.
    115109    // Divide by the device scale factor so we'll get the page scale factor.
     
    122116    m_deviceScaleFactor = deviceScaleFactor;
    123117
     118    if (m_zoomedOutTileGrid && m_zoomedOutTileGrid->scale() == scale) {
     119        m_tileGrid = std::move(m_zoomedOutTileGrid);
     120        m_tileGrid->revalidateTiles(0);
     121        return;
     122    }
     123
     124    if (m_zoomedOutContentsScale && m_zoomedOutContentsScale == tileGrid().scale() && tileGrid().scale() != scale && !m_hasTilesWithTemporaryScaleFactor) {
     125        m_zoomedOutTileGrid = std::move(m_tileGrid);
     126        m_tileGrid = std::make_unique<TileGrid>(*this);
     127    }
     128
    124129    tileGrid().setScale(scale);
     130    tileGrid().setNeedsDisplay();
     131}
     132
     133float TileController::contentsScale() const
     134{
     135    return tileGrid().scale() * m_deviceScaleFactor;
     136}
     137
     138float TileController::zoomedOutContentsScale() const
     139{
     140    return m_zoomedOutContentsScale * m_deviceScaleFactor;
    125141}
    126142
     
    129145    ASSERT(owningGraphicsLayer()->isCommittingChanges());
    130146
     147    float deviceScaleFactor = owningGraphicsLayer()->platformCALayerDeviceScaleFactor();
     148    scale /= deviceScaleFactor;
     149
    131150    if (m_zoomedOutContentsScale == scale)
    132151        return;
    133152    m_zoomedOutContentsScale = scale;
     153
     154    if (m_zoomedOutTileGrid && m_zoomedOutTileGrid->scale() != m_zoomedOutContentsScale)
     155        m_zoomedOutTileGrid = nullptr;
    134156}
    135157
     
    323345        return;
    324346    }
    325 
    326     TileGrid::TileValidationPolicyFlags validationPolicy = (shouldAggressivelyRetainTiles() ? 0 : PruneSecondaryTiles) | UnparentAllTiles;
     347    // If we are not visible get rid of the zoomed-out tiles.
     348    m_zoomedOutTileGrid = nullptr;
     349
     350    unsigned validationPolicy = (shouldAggressivelyRetainTiles() ? 0 : TileGrid::PruneSecondaryTiles) | TileGrid::UnparentAllTiles;
    327351
    328352    tileGrid().revalidateTiles(validationPolicy);
     
    380404double TileController::retainedTileBackingStoreMemory() const
    381405{
    382     return tileGrid().retainedTileBackingStoreMemory();
     406    double bytes = tileGrid().retainedTileBackingStoreMemory();
     407    if (m_zoomedOutTileGrid)
     408        bytes += m_zoomedOutTileGrid->retainedTileBackingStoreMemory();
     409    return bytes;
    383410}
    384411
     
    479506Vector<RefPtr<PlatformCALayer>> TileController::containerLayers()
    480507{
    481     Vector<RefPtr<PlatformCALayer>> layerList(1);
    482     layerList[0] = &tileGrid().containerLayer();
     508    Vector<RefPtr<PlatformCALayer>> layerList;
     509    if (m_zoomedOutTileGrid)
     510        layerList.append(&m_zoomedOutTileGrid->containerLayer());
     511    layerList.append(&tileGrid().containerLayer());
    483512    return layerList;
    484513}
    485    
     514
    486515#if PLATFORM(IOS)
    487516unsigned TileController::numberOfUnparentedTiles() const
    488517{
    489     return tileGrid().numberOfUnparentedTiles();
     518    unsigned count = tileGrid().numberOfUnparentedTiles();
     519    if (m_zoomedOutTileGrid)
     520        count += m_zoomedOutTileGrid->numberOfUnparentedTiles();
     521    return count;
    490522}
    491523
     
    493525{
    494526    tileGrid().removeUnparentedTilesNow();
     527    if (m_zoomedOutTileGrid)
     528        m_zoomedOutTileGrid->removeUnparentedTilesNow();
    495529
    496530    updateTileCoverageMap();
  • trunk/Source/WebCore/platform/graphics/ca/mac/TileGrid.h

    r167041 r167256  
    5555    void setNeedsDisplay();
    5656    void setNeedsDisplayInRect(const IntRect&);
     57    void dropTilesInRect(const IntRect&);
    5758
    5859    void updateTilerLayerProperties();
     
    6061    bool prepopulateRect(const FloatRect&);
    6162
    62     typedef unsigned TileValidationPolicyFlags;
    63     void revalidateTiles(TileValidationPolicyFlags);
     63    enum TileValidationPolicyFlag {
     64        PruneSecondaryTiles = 1 << 0,
     65        UnparentAllTiles = 1 << 1
     66    };
     67    void revalidateTiles(unsigned validationPolicyFlags);
    6468    bool tilesWouldChangeForVisibleRect(const FloatRect& newVisibleRect, const FloatRect& oldVisibleRect) const;
    6569
  • trunk/Source/WebCore/platform/graphics/ca/mac/TileGrid.mm

    r167047 r167256  
    4040namespace WebCore {
    4141
    42 enum TileValidationPolicyFlag {
    43     PruneSecondaryTiles = 1 << 0,
    44     UnparentAllTiles = 1 << 1
    45 };
    46 
    4742TileGrid::TileGrid(TileController& controller)
    4843    : m_controller(controller)
     
    125120}
    126121
     122void TileGrid::dropTilesInRect(const IntRect& rect)
     123{
     124    if (m_tiles.isEmpty())
     125        return;
     126
     127    FloatRect scaledRect(rect);
     128    scaledRect.scale(m_scale);
     129    IntRect dropRectInTileCoords(enclosingIntRect(scaledRect));
     130
     131    Vector<TileIndex> tilesToRemove;
     132
     133    for (auto& index : m_tiles.keys()) {
     134        if (rectForTileIndex(index).intersects(dropRectInTileCoords))
     135            tilesToRemove.append(index);
     136    }
     137
     138    removeTiles(tilesToRemove);
     139}
     140
    127141void TileGrid::setTileNeedsDisplayInRect(const TileIndex& tileIndex, TileInfo& tileInfo, const IntRect& repaintRectInTileCoords, const IntRect& coverageRectInTileCoords)
    128142{
     
    324338}
    325339
    326 void TileGrid::revalidateTiles(TileValidationPolicyFlags validationPolicy)
     340void TileGrid::revalidateTiles(unsigned validationPolicy)
    327341{
    328342    FloatRect visibleRect = m_controller.visibleRect();
  • trunk/Source/WebKit2/ChangeLog

    r167253 r167256  
     12014-04-12  Antti Koivisto  <antti@apple.com>
     2
     3        Keep secondary tile grid for zoomed-out scale
     4        https://bugs.webkit.org/show_bug.cgi?id=131586
     5
     6        Reviewed by Darin Adler.
     7
     8        * WebProcess/WebPage/mac/PlatformCALayerRemoteTiledBacking.cpp:
     9        (WebKit::PlatformCALayerRemoteTiledBacking::PlatformCALayerRemoteTiledBacking):
     10        (WebKit::PlatformCALayerRemoteTiledBacking::customSublayers):
     11       
     12            Always request new sublayer list from tile controller.
     13
     14        * WebProcess/WebPage/mac/PlatformCALayerRemoteTiledBacking.h:
     15
    1162014-04-14  Tim Horton  <timothy_horton@apple.com>
    217
  • trunk/Source/WebKit2/WebProcess/WebPage/mac/PlatformCALayerRemoteTiledBacking.cpp

    r166748 r167256  
    4141{
    4242    m_tileController = TileController::create(this);
    43     m_customSublayers = std::make_unique<PlatformCALayerList>(m_tileController->containerLayers());
    4443}
    4544
     
    5857const WebCore::PlatformCALayerList* PlatformCALayerRemoteTiledBacking::customSublayers() const
    5958{
    60     return m_customSublayers.get();
     59    m_customSublayers = m_tileController->containerLayers();
     60    return &m_customSublayers;
    6161}
    6262
  • trunk/Source/WebKit2/WebProcess/WebPage/mac/PlatformCALayerRemoteTiledBacking.h

    r166654 r167256  
    5555
    5656    OwnPtr<WebCore::TileController> m_tileController;
    57     std::unique_ptr<WebCore::PlatformCALayerList> m_customSublayers;
     57    mutable WebCore::PlatformCALayerList m_customSublayers;
    5858};
    5959
Note: See TracChangeset for help on using the changeset viewer.