Changeset 166997 in webkit


Ignore:
Timestamp:
Apr 8, 2014 10:01:54 PM (10 years ago)
Author:
Antti Koivisto
Message:

Factor tile coverage map into a class
https://bugs.webkit.org/show_bug.cgi?id=131417

Reviewed by Tim Horton.

  • WebCore.xcodeproj/project.pbxproj:
  • platform/graphics/ca/PlatformCALayerClient.h:

(WebCore::PlatformCALayerClient::platformCALayerLayoutSublayersOfLayer):
(WebCore::PlatformCALayerClient::platformCALayerRespondsToLayoutChanges):
(WebCore::PlatformCALayerClient::platformCALayerAnimationStarted):
(WebCore::PlatformCALayerClient::platformCALayerContentsOrientation):
(WebCore::PlatformCALayerClient::platformCALayerShowDebugBorders):
(WebCore::PlatformCALayerClient::platformCALayerShowRepaintCounter):
(WebCore::PlatformCALayerClient::platformCALayerIncrementRepaintCount):
(WebCore::PlatformCALayerClient::platformCALayerLayerDidDisplay):

Added default implementation to some of these to make clients less messy.

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

(WebCore::TileController::~TileController):
(WebCore::TileController::platformCALayerPaintContents):
(WebCore::TileController::setTiledScrollingIndicatorPosition):
(WebCore::TileController::updateTileCoverageMap):
(WebCore::TileController::tiledScrollingIndicatorLayer):

  • platform/graphics/ca/mac/TileCoverageMap.h: Added.

(WebCore::TileCoverageMap::setPosition):
(WebCore::TileCoverageMap::layer):

  • platform/graphics/ca/mac/TileCoverageMap.mm: Added.


The new class.

(WebCore::TileCoverageMap::TileCoverageMap):
(WebCore::TileCoverageMap::~TileCoverageMap):
(WebCore::TileCoverageMap::update):
(WebCore::TileCoverageMap::platformCALayerPaintContents):
(WebCore::TileCoverageMap::platformCALayerDeviceScaleFactor):

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

(WebCore::TileGrid::drawTileMapContents):

Location:
trunk/Source/WebCore
Files:
2 added
7 edited

Legend:

Unmodified
Added
Removed
  • trunk/Source/WebCore/ChangeLog

    r166996 r166997  
     12014-04-08  Antti Koivisto  <antti@apple.com>
     2
     3        Factor tile coverage map into a class
     4        https://bugs.webkit.org/show_bug.cgi?id=131417
     5
     6        Reviewed by Tim Horton.
     7
     8        * WebCore.xcodeproj/project.pbxproj:
     9        * platform/graphics/ca/PlatformCALayerClient.h:
     10        (WebCore::PlatformCALayerClient::platformCALayerLayoutSublayersOfLayer):
     11        (WebCore::PlatformCALayerClient::platformCALayerRespondsToLayoutChanges):
     12        (WebCore::PlatformCALayerClient::platformCALayerAnimationStarted):
     13        (WebCore::PlatformCALayerClient::platformCALayerContentsOrientation):
     14        (WebCore::PlatformCALayerClient::platformCALayerShowDebugBorders):
     15        (WebCore::PlatformCALayerClient::platformCALayerShowRepaintCounter):
     16        (WebCore::PlatformCALayerClient::platformCALayerIncrementRepaintCount):
     17        (WebCore::PlatformCALayerClient::platformCALayerLayerDidDisplay):
     18       
     19            Added default implementation to some of these to make clients less messy.
     20
     21        * platform/graphics/ca/mac/TileController.h:
     22        * platform/graphics/ca/mac/TileController.mm:
     23        (WebCore::TileController::~TileController):
     24        (WebCore::TileController::platformCALayerPaintContents):
     25        (WebCore::TileController::setTiledScrollingIndicatorPosition):
     26        (WebCore::TileController::updateTileCoverageMap):
     27        (WebCore::TileController::tiledScrollingIndicatorLayer):
     28        * platform/graphics/ca/mac/TileCoverageMap.h: Added.
     29        (WebCore::TileCoverageMap::setPosition):
     30        (WebCore::TileCoverageMap::layer):
     31        * platform/graphics/ca/mac/TileCoverageMap.mm: Added.
     32       
     33            The new class.
     34
     35        (WebCore::TileCoverageMap::TileCoverageMap):
     36        (WebCore::TileCoverageMap::~TileCoverageMap):
     37        (WebCore::TileCoverageMap::update):
     38        (WebCore::TileCoverageMap::platformCALayerPaintContents):
     39        (WebCore::TileCoverageMap::platformCALayerDeviceScaleFactor):
     40        * platform/graphics/ca/mac/TileGrid.h:
     41        * platform/graphics/ca/mac/TileGrid.mm:
     42        (WebCore::TileGrid::drawTileMapContents):
     43
    1442014-04-08  Zalan Bujtas  <zalan@apple.com>
    245
  • trunk/Source/WebCore/WebCore.xcodeproj/project.pbxproj

    r166965 r166997  
    60516051                E47E276516036ED200EE2AFB /* DocumentStyleSheetCollection.h in Headers */ = {isa = PBXBuildFile; fileRef = E47E276416036ED200EE2AFB /* DocumentStyleSheetCollection.h */; settings = {ATTRIBUTES = (Private, ); }; };
    60526052                E47E276816036EDC00EE2AFB /* DocumentStyleSheetCollection.cpp in Sources */ = {isa = PBXBuildFile; fileRef = E47E276716036EDC00EE2AFB /* DocumentStyleSheetCollection.cpp */; };
     6053                E4830A3918F4C59400154A1B /* TileCoverageMap.mm in Sources */ = {isa = PBXBuildFile; fileRef = E4830A3818F4C59400154A1B /* TileCoverageMap.mm */; };
     6054                E4830A3D18F4C5B700154A1B /* TileCoverageMap.h in Headers */ = {isa = PBXBuildFile; fileRef = E4830A3C18F4C5B700154A1B /* TileCoverageMap.h */; };
    60536055                E48944A2180B57D800F165D8 /* SimpleLineLayout.cpp in Sources */ = {isa = PBXBuildFile; fileRef = E48944A0180B57D800F165D8 /* SimpleLineLayout.cpp */; };
    60546056                E48944A3180B57D800F165D8 /* SimpleLineLayout.h in Headers */ = {isa = PBXBuildFile; fileRef = E48944A1180B57D800F165D8 /* SimpleLineLayout.h */; settings = {ATTRIBUTES = (Private, ); }; };
     
    1343613438                E47E276416036ED200EE2AFB /* DocumentStyleSheetCollection.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = DocumentStyleSheetCollection.h; sourceTree = "<group>"; };
    1343713439                E47E276716036EDC00EE2AFB /* DocumentStyleSheetCollection.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = DocumentStyleSheetCollection.cpp; sourceTree = "<group>"; };
     13440                E4830A3818F4C59400154A1B /* TileCoverageMap.mm */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.objcpp; name = TileCoverageMap.mm; path = ca/mac/TileCoverageMap.mm; sourceTree = "<group>"; };
     13441                E4830A3C18F4C5B700154A1B /* TileCoverageMap.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = TileCoverageMap.h; path = ca/mac/TileCoverageMap.h; sourceTree = "<group>"; };
    1343813442                E48944A0180B57D800F165D8 /* SimpleLineLayout.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = SimpleLineLayout.cpp; sourceTree = "<group>"; };
    1343913443                E48944A1180B57D800F165D8 /* SimpleLineLayout.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = SimpleLineLayout.h; sourceTree = "<group>"; };
     
    1562015624                                1AA71609149BC4DB0016EC19 /* TileController.h */,
    1562115625                                1AA71608149BC4DA0016EC19 /* TileController.mm */,
     15626                                E4830A3C18F4C5B700154A1B /* TileCoverageMap.h */,
     15627                                E4830A3818F4C59400154A1B /* TileCoverageMap.mm */,
    1562215628                                E4C274CB18E988F500602C76 /* TileGrid.h */,
    1562315629                                E4C274C918E988EA00602C76 /* TileGrid.mm */,
     
    2468524691                                B2FA3DB90AB75A6F000E5AC4 /* JSSVGPathSegArcAbs.h in Headers */,
    2468624692                                B2FA3DBB0AB75A6F000E5AC4 /* JSSVGPathSegArcRel.h in Headers */,
     24693                                E4830A3D18F4C5B700154A1B /* TileCoverageMap.h in Headers */,
    2468724694                                B2FA3DBD0AB75A6F000E5AC4 /* JSSVGPathSegClosePath.h in Headers */,
    2468824695                                B2FA3DBF0AB75A6F000E5AC4 /* JSSVGPathSegCurvetoCubicAbs.h in Headers */,
     
    2686726874                                E19AC3F9182566F700349426 /* CryptoKeyMac.cpp in Sources */,
    2686826875                                E1F80B8718317252007885C3 /* CryptoKeyPair.cpp in Sources */,
     26876                                E4830A3918F4C59400154A1B /* TileCoverageMap.mm in Sources */,
    2686926877                                E164FAA518315E1A00DB4E61 /* CryptoKeyRSAMac.cpp in Sources */,
    2687026878                                E125F859182C1AA600D84CD9 /* CryptoKeySerializationRaw.cpp in Sources */,
  • trunk/Source/WebCore/platform/graphics/ca/PlatformCALayerClient.h

    r166516 r166997  
    3737class PlatformCALayerClient {
    3838public:
    39     virtual void platformCALayerLayoutSublayersOfLayer(PlatformCALayer*) = 0;
    40     virtual bool platformCALayerRespondsToLayoutChanges() const = 0;
     39    virtual void platformCALayerLayoutSublayersOfLayer(PlatformCALayer*) { }
     40    virtual bool platformCALayerRespondsToLayoutChanges() const { return false; }
    4141
    42     virtual void platformCALayerAnimationStarted(CFTimeInterval beginTime) = 0;
    43     virtual GraphicsLayer::CompositingCoordinatesOrientation platformCALayerContentsOrientation() const = 0;
     42    virtual void platformCALayerAnimationStarted(CFTimeInterval) { }
     43    virtual GraphicsLayer::CompositingCoordinatesOrientation platformCALayerContentsOrientation() const { return GraphicsLayer::CompositingCoordinatesTopDown; }
    4444    virtual void platformCALayerPaintContents(PlatformCALayer*, GraphicsContext&, const FloatRect& inClip) = 0;
    45     virtual bool platformCALayerShowDebugBorders() const = 0;
    46     virtual bool platformCALayerShowRepaintCounter(PlatformCALayer*) const = 0;
    47     virtual int platformCALayerIncrementRepaintCount(PlatformCALayer*) = 0;
     45    virtual bool platformCALayerShowDebugBorders() const { return false; }
     46    virtual bool platformCALayerShowRepaintCounter(PlatformCALayer*) const { return false; }
     47    virtual int platformCALayerIncrementRepaintCount(PlatformCALayer*) { return 0; }
    4848   
    4949    virtual bool platformCALayerContentsOpaque() const = 0;
    5050    virtual bool platformCALayerDrawsContent() const = 0;
    51     virtual void platformCALayerLayerDidDisplay(PlatformLayer*) = 0;
     51    virtual void platformCALayerLayerDidDisplay(PlatformLayer*)  { }
    5252
    5353    virtual void platformCALayerSetNeedsToRevalidateTiles() { }
  • trunk/Source/WebCore/platform/graphics/ca/mac/TileController.h

    r166958 r166997  
    4444class IntPoint;
    4545class IntRect;
     46class TileCoverageMap;
    4647class TileGrid;
    4748
     
    7071
    7172    PlatformCALayer& rootLayer() { return *m_tileCacheLayer; }
     73    const PlatformCALayer& rootLayer() const { return *m_tileCacheLayer; }
    7274
    7375    void setTileDebugBorderWidth(float);
     
    8587
    8688public:
    87     // Public for TileGrid
     89    // Public for TileGrid and TileCoverageMap
    8890    bool isInWindow() const { return m_isInWindow; }
    8991
     
    9294    Color tileDebugBorderColor() const { return m_tileDebugBorderColor; }
    9395    float tileDebugBorderWidth() const { return m_tileDebugBorderWidth; }
     96    ScrollingModeIndication indicatorMode() const { return m_indicatorMode; }
    9497
    9598    virtual IntSize tileSize() const override { return m_tileSize; }
     
    122125    RefPtr<PlatformCALayer> createTileLayer(const IntRect&);
    123126
     127    const TileGrid& tileGrid() const { return *m_tileGrid; }
     128
    124129    Vector<RefPtr<PlatformCALayer>> containerLayers();
    125130
     
    128133
    129134    TileGrid& tileGrid() { return *m_tileGrid; }
    130     const TileGrid& tileGrid() const { return *m_tileGrid; }
    131135
    132136    // TiledBacking member functions.
     
    150154
    151155    // PlatformCALayerClient
    152     virtual void platformCALayerLayoutSublayersOfLayer(PlatformCALayer*) override { }
    153     virtual bool platformCALayerRespondsToLayoutChanges() const override { return false; }
    154     virtual void platformCALayerAnimationStarted(CFTimeInterval) override { }
    155     virtual GraphicsLayer::CompositingCoordinatesOrientation platformCALayerContentsOrientation() const override { return GraphicsLayer::CompositingCoordinatesTopDown; }
    156156    virtual void platformCALayerPaintContents(PlatformCALayer*, GraphicsContext&, const FloatRect&) override;
    157157    virtual bool platformCALayerShowDebugBorders() const override;
    158158    virtual bool platformCALayerShowRepaintCounter(PlatformCALayer*) const override;
    159159    virtual int platformCALayerIncrementRepaintCount(PlatformCALayer*) override;
    160 
    161160    virtual bool platformCALayerContentsOpaque() const override { return m_tilesAreOpaque; }
    162161    virtual bool platformCALayerDrawsContent() const override { return true; }
    163     virtual void platformCALayerLayerDidDisplay(PlatformLayer*) override { }
    164 
    165     virtual void platformCALayerSetNeedsToRevalidateTiles() override { }
    166162    virtual float platformCALayerDeviceScaleFactor() const override;
    167163
     
    171167    void setNeedsRevalidateTiles();
    172168
    173     void drawTileMapContents(CGContextRef, CGRect);
    174 
    175169    PlatformCALayerClient* owningGraphicsLayer() const { return m_tileCacheLayer->owner(); }
    176170
    177171    PlatformCALayer* m_tileCacheLayer;
    178     RefPtr<PlatformCALayer> m_tiledScrollingIndicatorLayer; // Used for coverage visualization.
    179     RefPtr<PlatformCALayer> m_visibleRectIndicatorLayer;
     172
     173    std::unique_ptr<TileCoverageMap> m_coverageMap;
    180174
    181175    std::unique_ptr<TileGrid> m_tileGrid;
     
    184178    FloatRect m_visibleRect;
    185179    FloatRect m_visibleRectAtLastRevalidate;
    186     FloatPoint m_tiledScrollingIndicatorPosition;
    187180    IntRect m_boundsAtLastRevalidate;
    188181
  • trunk/Source/WebCore/platform/graphics/ca/mac/TileController.mm

    r166958 r166997  
    3131#import "PlatformCALayer.h"
    3232#import "Region.h"
     33#import "TileCoverageMap.h"
    3334#import "TileGrid.h"
    3435#if !PLATFORM(IOS)
     
    8586    tileControllerMemoryHandler().removeTileController(this);
    8687#endif
    87 
    88     if (m_tiledScrollingIndicatorLayer)
    89         m_tiledScrollingIndicatorLayer->setOwner(nullptr);
    9088}
    9189
     
    113111#endif
    114112
    115     if (platformCALayer == m_tiledScrollingIndicatorLayer.get()) {
    116         tileGrid().drawTileMapContents(context.platformContext(), m_tiledScrollingIndicatorLayer->bounds());
    117         return;
    118     }
    119 
    120113    {
    121114        GraphicsContextStateSaver stateSaver(context);
     
    215208void TileController::setTiledScrollingIndicatorPosition(const FloatPoint& position)
    216209{
    217     if (m_tiledScrollingIndicatorPosition == position)
    218         return;
    219     m_tiledScrollingIndicatorPosition = position;
    220     updateTileCoverageMap();
     210    if (!m_coverageMap)
     211        return;
     212    m_coverageMap->setPosition(position);
     213    m_coverageMap->update();
    221214}
    222215
     
    413406void TileController::updateTileCoverageMap()
    414407{
    415     if (!m_tiledScrollingIndicatorLayer)
    416         return;
    417     FloatRect containerBounds = bounds();
    418     FloatRect visibleRect = this->visibleRect();
    419     visibleRect.contract(4, 4); // Layer is positioned 2px from top and left edges.
    420 
    421     float widthScale = 1;
    422     float scale = 1;
    423     if (!containerBounds.isEmpty()) {
    424         widthScale = std::min<float>(visibleRect.width() / containerBounds.width(), 0.1);
    425         scale = std::min(widthScale, visibleRect.height() / containerBounds.height());
    426     }
    427    
    428     float indicatorScale = scale * tileGrid().scale();
    429     FloatRect mapBounds = containerBounds;
    430     mapBounds.scale(indicatorScale, indicatorScale);
    431 
    432     m_tiledScrollingIndicatorLayer->setPosition(m_tiledScrollingIndicatorPosition + FloatPoint(2, 2));
    433     m_tiledScrollingIndicatorLayer->setBounds(mapBounds);
    434     m_tiledScrollingIndicatorLayer->setNeedsDisplay();
    435 
    436     visibleRect.scale(indicatorScale, indicatorScale);
    437     visibleRect.expand(2, 2);
    438     m_visibleRectIndicatorLayer->setPosition(visibleRect.location());
    439     m_visibleRectIndicatorLayer->setBounds(FloatRect(FloatPoint(), visibleRect.size()));
    440 
    441     Color visibleRectIndicatorColor;
    442     switch (m_indicatorMode) {
    443     case SynchronousScrollingBecauseOfStyleIndication:
    444         visibleRectIndicatorColor = Color(255, 0, 0);
    445         break;
    446     case SynchronousScrollingBecauseOfEventHandlersIndication:
    447         visibleRectIndicatorColor = Color(255, 255, 0);
    448         break;
    449     case AsyncScrollingIndication:
    450         visibleRectIndicatorColor = Color(0, 200, 0);
    451         break;
    452     }
    453 
    454     m_visibleRectIndicatorLayer->setBorderColor(visibleRectIndicatorColor);
     408    if (m_coverageMap)
     409        m_coverageMap->update();
    455410}
    456411
     
    473428PlatformCALayer* TileController::tiledScrollingIndicatorLayer()
    474429{
    475     if (!m_tiledScrollingIndicatorLayer) {
    476         m_tiledScrollingIndicatorLayer = m_tileCacheLayer->createCompatibleLayer(PlatformCALayer::LayerTypeSimpleLayer, this);
    477         m_tiledScrollingIndicatorLayer->setOpacity(0.75);
    478         m_tiledScrollingIndicatorLayer->setAnchorPoint(FloatPoint3D());
    479         m_tiledScrollingIndicatorLayer->setBorderColor(Color::black);
    480         m_tiledScrollingIndicatorLayer->setBorderWidth(1);
    481         m_tiledScrollingIndicatorLayer->setPosition(FloatPoint(2, 2));
    482 
    483         m_visibleRectIndicatorLayer = m_tileCacheLayer->createCompatibleLayer(PlatformCALayer::LayerTypeLayer, nullptr);
    484         m_visibleRectIndicatorLayer->setBorderWidth(2);
    485         m_visibleRectIndicatorLayer->setAnchorPoint(FloatPoint3D());
    486         m_visibleRectIndicatorLayer->setBorderColor(Color(255, 0, 0));
    487 
    488         m_tiledScrollingIndicatorLayer->appendSublayer(m_visibleRectIndicatorLayer.get());
    489 
    490         updateTileCoverageMap();
    491     }
    492 
    493     return m_tiledScrollingIndicatorLayer.get();
     430    if (!m_coverageMap)
     431        m_coverageMap = std::make_unique<TileCoverageMap>(*this);
     432
     433    return &m_coverageMap->layer();
    494434}
    495435
  • trunk/Source/WebCore/platform/graphics/ca/mac/TileGrid.h

    r166958 r166997  
    6868    unsigned blankPixelCount() const;
    6969
    70     void drawTileMapContents(CGContextRef, CGRect layerBounds);
     70    void drawTileMapContents(CGContextRef, CGRect layerBounds) const;
    7171
    7272#if PLATFORM(IOS)
  • trunk/Source/WebCore/platform/graphics/ca/mac/TileGrid.mm

    r166958 r166997  
    599599}
    600600
    601 void TileGrid::drawTileMapContents(CGContextRef context, CGRect layerBounds)
     601void TileGrid::drawTileMapContents(CGContextRef context, CGRect layerBounds) const
    602602{
    603603    CGContextSetRGBFillColor(context, 0.3, 0.3, 0.3, 1);
Note: See TracChangeset for help on using the changeset viewer.