Changeset 167041 in webkit


Ignore:
Timestamp:
Apr 9, 2014 3:29:15 PM (10 years ago)
Author:
Antti Koivisto
Message:

TileGrid should be PlatformCALayerClient instead of TileController
https://bugs.webkit.org/show_bug.cgi?id=131456

Reviewed by Tim Horton.

The client interface is for the tiles in the grid.

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

(WebCore::TileController::setContentsScale):
(WebCore::TileController::createTileLayer):
(WebCore::TileController::platformCALayerPaintContents): Deleted.
(WebCore::TileController::platformCALayerDeviceScaleFactor): Deleted.
(WebCore::TileController::platformCALayerShowDebugBorders): Deleted.
(WebCore::TileController::platformCALayerShowRepaintCounter): Deleted.
(WebCore::TileController::platformCALayerIncrementRepaintCount): Deleted.

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


Move repaint counter to TileGrid too.

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

(WebCore::TileGrid::removeTiles):
(WebCore::TileGrid::removeAllSecondaryTiles):
(WebCore::TileGrid::removeTilesInCohort):

Cleaned up tile removal.

(WebCore::TileGrid::revalidateTiles):
(WebCore::TileGrid::ensureTilesForRect):
(WebCore::TileGrid::platformCALayerPaintContents):
(WebCore::TileGrid::platformCALayerDeviceScaleFactor):
(WebCore::TileGrid::platformCALayerShowDebugBorders):
(WebCore::TileGrid::platformCALayerShowRepaintCounter):
(WebCore::TileGrid::platformCALayerContentsOpaque):
(WebCore::TileGrid::platformCALayerIncrementRepaintCount):
(WebCore::queueTileForRemoval): Deleted.

Location:
trunk/Source/WebCore
Files:
5 edited

Legend:

Unmodified
Added
Removed
  • trunk/Source/WebCore/ChangeLog

    r167040 r167041  
     12014-04-09  Antti Koivisto  <antti@apple.com>
     2
     3        TileGrid should be PlatformCALayerClient instead of TileController
     4        https://bugs.webkit.org/show_bug.cgi?id=131456
     5
     6        Reviewed by Tim Horton.
     7
     8        The client interface is for the tiles in the grid.
     9
     10        * platform/graphics/ca/mac/TileController.h:
     11        * platform/graphics/ca/mac/TileController.mm:
     12        (WebCore::TileController::setContentsScale):
     13        (WebCore::TileController::createTileLayer):
     14        (WebCore::TileController::platformCALayerPaintContents): Deleted.
     15        (WebCore::TileController::platformCALayerDeviceScaleFactor): Deleted.
     16        (WebCore::TileController::platformCALayerShowDebugBorders): Deleted.
     17        (WebCore::TileController::platformCALayerShowRepaintCounter): Deleted.
     18        (WebCore::TileController::platformCALayerIncrementRepaintCount): Deleted.
     19        * platform/graphics/ca/mac/TileGrid.h:
     20       
     21            Move repaint counter to TileGrid too.
     22
     23        * platform/graphics/ca/mac/TileGrid.mm:
     24        (WebCore::TileGrid::removeTiles):
     25        (WebCore::TileGrid::removeAllSecondaryTiles):
     26        (WebCore::TileGrid::removeTilesInCohort):
     27       
     28           Cleaned up tile removal.
     29
     30        (WebCore::TileGrid::revalidateTiles):
     31        (WebCore::TileGrid::ensureTilesForRect):
     32        (WebCore::TileGrid::platformCALayerPaintContents):
     33        (WebCore::TileGrid::platformCALayerDeviceScaleFactor):
     34        (WebCore::TileGrid::platformCALayerShowDebugBorders):
     35        (WebCore::TileGrid::platformCALayerShowRepaintCounter):
     36        (WebCore::TileGrid::platformCALayerContentsOpaque):
     37        (WebCore::TileGrid::platformCALayerIncrementRepaintCount):
     38        (WebCore::queueTileForRemoval): Deleted.
     39
    1402014-04-09  Alexey Proskuryakov  <ap@apple.com>
    241
  • trunk/Source/WebCore/platform/graphics/ca/mac/TileController.h

    r166997 r167041  
    4949typedef Vector<RetainPtr<PlatformLayer>> PlatformLayerList;
    5050
    51 class TileController final : public TiledBacking, public PlatformCALayerClient {
    52     WTF_MAKE_NONCOPYABLE(TileController);
    53 
     51class TileController final : public TiledBacking {
     52    WTF_MAKE_NONCOPYABLE(TileController); WTF_MAKE_FAST_ALLOCATED;
    5453public:
    5554    static PassOwnPtr<TileController> create(PlatformCALayer*);
     
    105104    virtual TileCoverage tileCoverage() const override { return m_tileCoverage; }
    106105    virtual bool unparentsOffscreenTiles() const override { return m_unparentsOffscreenTiles; }
     106    virtual bool scrollingPerformanceLoggingEnabled() const override { return m_scrollingPerformanceLoggingEnabled; }
    107107
    108108    IntRect boundsWithoutMargin() const;
     
    118118    bool shouldTemporarilyRetainTileCohorts() const;
    119119
    120     typedef HashMap<PlatformCALayer*, int> RepaintCountMap;
    121     RepaintCountMap& repaintCountMap() { return m_tileRepaintCounts; }
    122 
    123120    void updateTileCoverageMap();
    124121
    125     RefPtr<PlatformCALayer> createTileLayer(const IntRect&);
     122    RefPtr<PlatformCALayer> createTileLayer(const IntRect&, TileGrid&);
    126123
    127124    const TileGrid& tileGrid() const { return *m_tileGrid; }
     
    145142    virtual IntRect tileGridExtent() const override;
    146143    virtual void setScrollingPerformanceLoggingEnabled(bool flag) override { m_scrollingPerformanceLoggingEnabled = flag; }
    147     virtual bool scrollingPerformanceLoggingEnabled() const override { return m_scrollingPerformanceLoggingEnabled; }
    148144    virtual void setUnparentsOffscreenTiles(bool flag) override { m_unparentsOffscreenTiles = flag; }
    149145    virtual double retainedTileBackingStoreMemory() const override;
     
    152148    virtual void setScrollingModeIndication(ScrollingModeIndication) override;
    153149    virtual void setTileMargins(int marginTop, int marginBottom, int marginLeft, int marginRight) override;
    154 
    155     // PlatformCALayerClient
    156     virtual void platformCALayerPaintContents(PlatformCALayer*, GraphicsContext&, const FloatRect&) override;
    157     virtual bool platformCALayerShowDebugBorders() const override;
    158     virtual bool platformCALayerShowRepaintCounter(PlatformCALayer*) const override;
    159     virtual int platformCALayerIncrementRepaintCount(PlatformCALayer*) override;
    160     virtual bool platformCALayerContentsOpaque() const override { return m_tilesAreOpaque; }
    161     virtual bool platformCALayerDrawsContent() const override { return true; }
    162     virtual float platformCALayerDeviceScaleFactor() const override;
    163150
    164151    void scheduleTileRevalidation(double interval);
     
    181168
    182169    Timer<TileController> m_tileRevalidationTimer;
    183 
    184     RepaintCountMap m_tileRepaintCounts;
    185170
    186171    float m_contentsScale;
  • trunk/Source/WebCore/platform/graphics/ca/mac/TileController.mm

    r166997 r167041  
    2727#import "TileController.h"
    2828
    29 #import "GraphicsContext.h"
    3029#import "IntRect.h"
    3130#import "PlatformCALayer.h"
     
    3635#import "LayerPool.h"
    3736#endif
    38 #import "WebLayer.h"
    3937#import <wtf/MainThread.h>
    4038#import <utility>
     
    104102}
    105103
    106 void TileController::platformCALayerPaintContents(PlatformCALayer* platformCALayer, GraphicsContext& context, const FloatRect&)
    107 {
    108 #if PLATFORM(IOS)
    109     if (pthread_main_np())
    110         WebThreadLock();
    111 #endif
    112 
    113     {
    114         GraphicsContextStateSaver stateSaver(context);
    115 
    116         FloatPoint3D layerOrigin = platformCALayer->position();
    117         context.translate(-layerOrigin.x(), -layerOrigin.y());
    118         context.scale(FloatSize(tileGrid().scale(), tileGrid().scale()));
    119 
    120         RepaintRectList dirtyRects = collectRectsToPaint(context.platformContext(), platformCALayer);
    121         drawLayerContents(context.platformContext(), m_tileCacheLayer, dirtyRects);
    122     }
    123 
    124     int repaintCount = platformCALayerIncrementRepaintCount(platformCALayer);
    125     if (owningGraphicsLayer()->platformCALayerShowRepaintCounter(0))
    126         drawRepaintIndicator(context.platformContext(), platformCALayer, repaintCount, cachedCGColor(m_tileDebugBorderColor, ColorSpaceDeviceRGB));
    127 
    128     if (scrollingPerformanceLoggingEnabled()) {
    129         FloatRect visiblePart(platformCALayer->position().x(), platformCALayer->position().y(), platformCALayer->bounds().size().width(), platformCALayer->bounds().size().height());
    130         visiblePart.intersect(visibleRect());
    131 
    132         if (repaintCount == 1 && !visiblePart.isEmpty())
    133             WTFLogAlways("SCROLLING: Filled visible fresh tile. Time: %f Unfilled Pixels: %u\n", WTF::monotonicallyIncreasingTime(), blankPixelCount());
    134     }
    135 }
    136 
    137 float TileController::platformCALayerDeviceScaleFactor() const
    138 {
    139     return owningGraphicsLayer()->platformCALayerDeviceScaleFactor();
    140 }
    141 
    142 bool TileController::platformCALayerShowDebugBorders() const
    143 {
    144     return owningGraphicsLayer()->platformCALayerShowDebugBorders();
    145 }
    146 
    147 bool TileController::platformCALayerShowRepaintCounter(PlatformCALayer*) const
    148 {
    149     return owningGraphicsLayer()->platformCALayerShowRepaintCounter(0);
    150 }
    151 
    152104void TileController::setContentsScale(float scale)
    153105{
     
    156108    ASSERT(owningGraphicsLayer()->isCommittingChanges());
    157109
    158     float deviceScaleFactor = platformCALayerDeviceScaleFactor();
     110    float deviceScaleFactor = owningGraphicsLayer()->platformCALayerDeviceScaleFactor();
    159111
    160112    // The scale we get is the product of the page scale factor and device scale factor.
     
    479431}
    480432
    481 RefPtr<PlatformCALayer> TileController::createTileLayer(const IntRect& tileRect)
     433RefPtr<PlatformCALayer> TileController::createTileLayer(const IntRect& tileRect, TileGrid& grid)
    482434{
    483435#if PLATFORM(IOS)
     
    487439#endif
    488440
    489     if (layer) {
    490         m_tileRepaintCounts.remove(layer.get());
    491         layer->setOwner(this);
    492     } else
    493         layer = m_tileCacheLayer->createCompatibleLayer(PlatformCALayer::LayerTypeTiledBackingTileLayer, this);
     441    if (layer)
     442        layer->setOwner(&grid);
     443    else
     444        layer = m_tileCacheLayer->createCompatibleLayer(PlatformCALayer::LayerTypeTiledBackingTileLayer, &grid);
    494445
    495446    layer->setAnchorPoint(FloatPoint3D());
     
    515466}
    516467
    517 int TileController::platformCALayerIncrementRepaintCount(PlatformCALayer* platformCALayer)
    518 {
    519     int repaintCount = 0;
    520 
    521     if (m_tileRepaintCounts.contains(platformCALayer))
    522         repaintCount = m_tileRepaintCounts.get(platformCALayer);
    523 
    524     m_tileRepaintCounts.set(platformCALayer, ++repaintCount);
    525 
    526     return repaintCount;
    527 }
    528 
    529468Vector<RefPtr<PlatformCALayer>> TileController::containerLayers()
    530469{
  • trunk/Source/WebCore/platform/graphics/ca/mac/TileGrid.h

    r166997 r167041  
    2929#include "IntPointHash.h"
    3030#include "IntRect.h"
     31#include "PlatformCALayerClient.h"
    3132#include "Timer.h"
    3233#include <wtf/Deque.h>
     
    3738namespace WebCore {
    3839
     40class GraphicsContext;
    3941class PlatformCALayer;
    4042class TileController;
    4143
    42 class TileGrid {
    43     WTF_MAKE_NONCOPYABLE(TileGrid);
     44class TileGrid : public PlatformCALayerClient {
     45    WTF_MAKE_NONCOPYABLE(TileGrid); WTF_MAKE_FAST_ALLOCATED;
    4446public:
    4547    TileGrid(TileController&);
     
    110112    TileCohort oldestTileCohort() const;
    111113
     114    void removeTiles(Vector<TileGrid::TileIndex>& toRemove);
     115
     116    // PlatformCALayerClient
     117    virtual void platformCALayerPaintContents(PlatformCALayer*, GraphicsContext&, const FloatRect&) override;
     118    virtual bool platformCALayerShowDebugBorders() const override;
     119    virtual bool platformCALayerShowRepaintCounter(PlatformCALayer*) const override;
     120    virtual int platformCALayerIncrementRepaintCount(PlatformCALayer*) override;
     121    virtual bool platformCALayerContentsOpaque() const override;
     122    virtual bool platformCALayerDrawsContent() const override { return true; }
     123    virtual float platformCALayerDeviceScaleFactor() const override;
     124
    112125    TileController& m_controller;
    113126    Ref<PlatformCALayer> m_containerLayer;
     
    133146
    134147    Timer<TileGrid> m_cohortRemovalTimer;
     148
     149    typedef HashMap<PlatformCALayer*, int> RepaintCountMap;
     150    RepaintCountMap m_tileRepaintCounts;
    135151};
    136152
  • trunk/Source/WebCore/platform/graphics/ca/mac/TileGrid.mm

    r166997 r167041  
    2727#import "TileGrid.h"
    2828
     29#import "GraphicsContext.h"
    2930#import "LayerPool.h"
    3031#import "PlatformCALayer.h"
    3132#import "TileController.h"
     33#import "WebLayer.h"
    3234#import <wtf/MainThread.h>
    3335
     
    281283}
    282284
    283 static inline void queueTileForRemoval(const TileGrid::TileIndex& tileIndex, const TileGrid::TileInfo& tileInfo, Vector<TileGrid::TileIndex>& tilesToRemove, TileController::RepaintCountMap& repaintCounts)
    284 {
    285     tileInfo.layer->removeFromSuperlayer();
    286     repaintCounts.remove(tileInfo.layer.get());
    287     tilesToRemove.append(tileIndex);
    288 }
    289 
    290 void TileGrid::removeAllSecondaryTiles()
    291 {
    292     Vector<TileIndex> tilesToRemove;
    293 
    294     for (TileMap::iterator it = m_tiles.begin(), end = m_tiles.end(); it != end; ++it) {
    295         const TileInfo& tileInfo = it->value;
    296         if (tileInfo.cohort == VisibleTileCohort)
    297             continue;
    298 
    299         queueTileForRemoval(it->key, it->value, tilesToRemove, m_controller.repaintCountMap());
    300     }
    301 
    302     for (size_t i = 0; i < tilesToRemove.size(); ++i) {
    303         TileInfo tileInfo = m_tiles.take(tilesToRemove[i]);
     285void TileGrid::removeTiles(Vector<TileGrid::TileIndex>& toRemove)
     286{
     287    for (size_t i = 0; i < toRemove.size(); ++i) {
     288        TileInfo tileInfo = m_tiles.take(toRemove[i]);
     289        tileInfo.layer->removeFromSuperlayer();
     290        m_tileRepaintCounts.remove(tileInfo.layer.get());
    304291#if !PLATFORM(IOS)
    305292        LayerPool::sharedPool()->addLayer(tileInfo.layer);
     
    308295}
    309296
     297void TileGrid::removeAllSecondaryTiles()
     298{
     299    Vector<TileIndex> tilesToRemove;
     300
     301    for (auto& entry : m_tiles) {
     302        const TileInfo& tileInfo = entry.value;
     303        if (tileInfo.cohort == VisibleTileCohort)
     304            continue;
     305        tilesToRemove.append(entry.key);
     306    }
     307
     308    removeTiles(tilesToRemove);
     309}
     310
    310311void TileGrid::removeTilesInCohort(TileCohort cohort)
    311312{
     
    313314    Vector<TileIndex> tilesToRemove;
    314315
    315     for (TileMap::iterator it = m_tiles.begin(), end = m_tiles.end(); it != end; ++it) {
    316         const TileInfo& tileInfo = it->value;
     316    for (auto& entry : m_tiles) {
     317        const TileInfo& tileInfo = entry.value;
    317318        if (tileInfo.cohort != cohort)
    318319            continue;
    319 
    320         queueTileForRemoval(it->key, it->value, tilesToRemove, m_controller.repaintCountMap());
    321     }
    322 
    323     for (size_t i = 0; i < tilesToRemove.size(); ++i) {
    324         TileInfo tileInfo = m_tiles.take(tilesToRemove[i]);
    325 #if !PLATFORM(IOS)
    326         LayerPool::sharedPool()->addLayer(tileInfo.layer);
    327 #endif
    328     }
     320        tilesToRemove.append(entry.key);
     321    }
     322
     323    removeTiles(tilesToRemove);
    329324}
    330325
     
    430425
    431426        Vector<TileIndex> tilesToRemove;
    432         for (TileMap::iterator it = m_tiles.begin(), end = m_tiles.end(); it != end; ++it) {
    433             const TileIndex& index = it->key;
    434             if (index.y() < topLeftForBounds.y()
    435                 || index.y() > bottomRightForBounds.y()
    436                 || index.x() < topLeftForBounds.x()
    437                 || index.x() > bottomRightForBounds.x())
    438                 queueTileForRemoval(index, it->value, tilesToRemove, m_controller.repaintCountMap());
     427        for (auto& index : m_tiles.keys()) {
     428            if (index.y() < topLeftForBounds.y() || index.y() > bottomRightForBounds.y() || index.x() < topLeftForBounds.x() || index.x() > bottomRightForBounds.x())
     429                tilesToRemove.append(index);
    439430        }
    440431
     
    533524            bool shouldChangeTileLayerFrame = false;
    534525
    535             if (!tileInfo.layer)
    536                 tileInfo.layer = m_controller.createTileLayer(tileRect);
    537             else {
     526            if (!tileInfo.layer) {
     527                tileInfo.layer = m_controller.createTileLayer(tileRect, *this);
     528                ASSERT(!m_tileRepaintCounts.contains(tileInfo.layer.get()));
     529            } else {
    538530                // We already have a layer for this tile. Ensure that its size is correct.
    539531                FloatSize tileLayerSize(tileInfo.layer->bounds().size());
     
    645637}
    646638
     639void TileGrid::platformCALayerPaintContents(PlatformCALayer* platformCALayer, GraphicsContext& context, const FloatRect&)
     640{
     641#if PLATFORM(IOS)
     642    if (pthread_main_np())
     643        WebThreadLock();
     644#endif
     645
     646    {
     647        GraphicsContextStateSaver stateSaver(context);
     648
     649        FloatPoint3D layerOrigin = platformCALayer->position();
     650        context.translate(-layerOrigin.x(), -layerOrigin.y());
     651        context.scale(FloatSize(m_scale, m_scale));
     652
     653        RepaintRectList dirtyRects = collectRectsToPaint(context.platformContext(), platformCALayer);
     654        drawLayerContents(context.platformContext(), &m_controller.rootLayer(), dirtyRects);
     655    }
     656
     657    int repaintCount = platformCALayerIncrementRepaintCount(platformCALayer);
     658    if (m_controller.rootLayer().owner()->platformCALayerShowRepaintCounter(0))
     659        drawRepaintIndicator(context.platformContext(), platformCALayer, repaintCount, cachedCGColor(m_controller.tileDebugBorderColor(), ColorSpaceDeviceRGB));
     660
     661    if (m_controller.scrollingPerformanceLoggingEnabled()) {
     662        FloatRect visiblePart(platformCALayer->position().x(), platformCALayer->position().y(), platformCALayer->bounds().size().width(), platformCALayer->bounds().size().height());
     663        visiblePart.intersect(m_controller.visibleRect());
     664
     665        if (repaintCount == 1 && !visiblePart.isEmpty())
     666            WTFLogAlways("SCROLLING: Filled visible fresh tile. Time: %f Unfilled Pixels: %u\n", WTF::monotonicallyIncreasingTime(), blankPixelCount());
     667    }
     668}
     669
     670float TileGrid::platformCALayerDeviceScaleFactor() const
     671{
     672    return m_controller.rootLayer().owner()->platformCALayerDeviceScaleFactor();
     673}
     674
     675bool TileGrid::platformCALayerShowDebugBorders() const
     676{
     677    return m_controller.rootLayer().owner()->platformCALayerShowDebugBorders();
     678}
     679
     680bool TileGrid::platformCALayerShowRepaintCounter(PlatformCALayer*) const
     681{
     682    return m_controller.rootLayer().owner()->platformCALayerShowRepaintCounter(0);
     683}
     684
     685bool TileGrid::platformCALayerContentsOpaque() const
     686{
     687    return m_controller.tilesAreOpaque();
     688}
     689
     690int TileGrid::platformCALayerIncrementRepaintCount(PlatformCALayer* platformCALayer)
     691{
     692    int repaintCount = 0;
     693
     694    if (m_tileRepaintCounts.contains(platformCALayer))
     695        repaintCount = m_tileRepaintCounts.get(platformCALayer);
     696
     697    m_tileRepaintCounts.set(platformCALayer, ++repaintCount);
     698
     699    return repaintCount;
     700}
     701
    647702#if PLATFORM(IOS)
    648703void TileGrid::removeUnparentedTilesNow()
Note: See TracChangeset for help on using the changeset viewer.