Changeset 182985 in webkit


Ignore:
Timestamp:
Apr 18, 2015 12:39:13 PM (9 years ago)
Author:
Simon Fraser
Message:

REGRESSION (r181656): Animated tiled layers are missing content
https://bugs.webkit.org/show_bug.cgi?id=143911
rdar://problem/20596328

Reviewed by Darin Adler.
Source/WebCore:

After r181656, all requestAnimationFrame was falling back to timers, and not
using the platform's DisplayRefreshMonitor, because of a Nullopt vs nullptr
fumble. As a result, GraphicsLayerUpdater (which updates tiled layers during
animations) was failing to do any updates.

Replace this confusing Optional<> code with simpler code that just forces the
clients to make a DisplayRefreshMonitor if they can, first asking
ChromeClient, and then falling back to createDefaultDisplayRefreshMonitor().

Make lots of things into references, and use C++11 initialization in some places.

Add Internals API to allow a test to get the number of layer flushes that have
occurred.

  • dom/ScriptedAnimationController.cpp:

(WebCore::ScriptedAnimationController::ScriptedAnimationController):
(WebCore::ScriptedAnimationController::windowScreenDidChange):
(WebCore::ScriptedAnimationController::scheduleAnimation):
(WebCore::ScriptedAnimationController::createDisplayRefreshMonitor):

  • dom/ScriptedAnimationController.h:
  • page/ChromeClient.h:
  • platform/graphics/DisplayRefreshMonitor.cpp:

(WebCore::DisplayRefreshMonitor::createDefaultDisplayRefreshMonitor):
(WebCore::DisplayRefreshMonitor::create):
(WebCore::DisplayRefreshMonitor::addClient):
(WebCore::DisplayRefreshMonitor::removeClient):
(WebCore::DisplayRefreshMonitor::displayDidRefresh):

  • platform/graphics/DisplayRefreshMonitor.h:
  • platform/graphics/DisplayRefreshMonitorClient.cpp:

(WebCore::DisplayRefreshMonitorClient::~DisplayRefreshMonitorClient):

  • platform/graphics/DisplayRefreshMonitorClient.h:
  • platform/graphics/DisplayRefreshMonitorManager.cpp:

(WebCore::DisplayRefreshMonitorManager::createMonitorForClient):
(WebCore::DisplayRefreshMonitorManager::registerClient):
(WebCore::DisplayRefreshMonitorManager::unregisterClient):
(WebCore::DisplayRefreshMonitorManager::scheduleAnimation):
(WebCore::DisplayRefreshMonitorManager::displayDidRefresh):
(WebCore::DisplayRefreshMonitorManager::windowScreenDidChange):

  • platform/graphics/DisplayRefreshMonitorManager.h:
  • platform/graphics/GraphicsLayerUpdater.cpp:

(WebCore::GraphicsLayerUpdater::GraphicsLayerUpdater):
(WebCore::GraphicsLayerUpdater::scheduleUpdate):
(WebCore::GraphicsLayerUpdater::screenDidChange):
(WebCore::GraphicsLayerUpdater::displayRefreshFired):
(WebCore::GraphicsLayerUpdater::createDisplayRefreshMonitor):

  • platform/graphics/GraphicsLayerUpdater.h:
  • rendering/RenderLayerCompositor.cpp:

(WebCore::RenderLayerCompositor::RenderLayerCompositor):
(WebCore::RenderLayerCompositor::flushPendingLayerChanges):
(WebCore::RenderLayerCompositor::notifyFlushBeforeDisplayRefresh):
(WebCore::RenderLayerCompositor::flushLayersSoon):
(WebCore::RenderLayerCompositor::createDisplayRefreshMonitor):
(WebCore::RenderLayerCompositor::startTrackingLayerFlushes):
(WebCore::RenderLayerCompositor::layerFlushCount):

  • rendering/RenderLayerCompositor.h:
  • testing/Internals.cpp:

(WebCore::Internals::startTrackingLayerFlushes):
(WebCore::Internals::layerFlushCount):

  • testing/Internals.h:
  • testing/Internals.idl:

Source/WebKit2:

After r181656, all requestAnimationFrame was falling back to timers, and not
using the platform's DisplayRefreshMonitor, because of a Nullopt vs nullptr
fumble.

Replace this confusing Optional<> code with simpler code that just forces the
clients to make a DisplayRefreshMonitor if they can, first asking
ChromeClient, and then falling back to createDefaultDisplayRefreshMonitor().

Make lots of things into references, and use C++11 initialization in some places.

  • WebProcess/WebCoreSupport/WebChromeClient.cpp:

(WebKit::WebChromeClient::createDisplayRefreshMonitor):

  • WebProcess/WebCoreSupport/WebChromeClient.h:

LayoutTests:

Test that animates a tiled layer, and checks that layer flushes occur while the
animation is running.

  • compositing/animation/animation-backing-expected.txt: Added.
  • compositing/animation/animation-backing.html: Added.
Location:
trunk
Files:
2 added
25 edited

Legend:

Unmodified
Added
Removed
  • trunk/LayoutTests/ChangeLog

    r182974 r182985  
     12015-04-18  Simon Fraser  <simon.fraser@apple.com>
     2
     3        REGRESSION (r181656): Animated tiled layers are missing content
     4        https://bugs.webkit.org/show_bug.cgi?id=143911
     5        rdar://problem/20596328
     6
     7        Reviewed by Darin Adler.
     8       
     9        Test that animates a tiled layer, and checks that layer flushes occur while the
     10        animation is running.
     11
     12        * compositing/animation/animation-backing-expected.txt: Added.
     13        * compositing/animation/animation-backing.html: Added.
     14
    1152015-04-17  Bem Jones-Bey  <bjonesbe@adobe.com>
    216
  • trunk/Source/WebCore/ChangeLog

    r182974 r182985  
     12015-04-18  Simon Fraser  <simon.fraser@apple.com>
     2
     3        REGRESSION (r181656): Animated tiled layers are missing content
     4        https://bugs.webkit.org/show_bug.cgi?id=143911
     5        rdar://problem/20596328
     6
     7        Reviewed by Darin Adler.
     8
     9        After r181656, all requestAnimationFrame was falling back to timers, and not
     10        using the platform's DisplayRefreshMonitor, because of a Nullopt vs nullptr
     11        fumble. As a result, GraphicsLayerUpdater (which updates tiled layers during
     12        animations) was failing to do any updates.
     13       
     14        Replace this confusing Optional<> code with simpler code that just forces the
     15        clients to make a DisplayRefreshMonitor if they can, first asking
     16        ChromeClient, and then falling back to createDefaultDisplayRefreshMonitor().
     17       
     18        Make lots of things into references, and use C++11 initialization in some places.
     19       
     20        Add Internals API to allow a test to get the number of layer flushes that have
     21        occurred.
     22       
     23        * dom/ScriptedAnimationController.cpp:
     24        (WebCore::ScriptedAnimationController::ScriptedAnimationController):
     25        (WebCore::ScriptedAnimationController::windowScreenDidChange):
     26        (WebCore::ScriptedAnimationController::scheduleAnimation):
     27        (WebCore::ScriptedAnimationController::createDisplayRefreshMonitor):
     28        * dom/ScriptedAnimationController.h:
     29        * page/ChromeClient.h:
     30        * platform/graphics/DisplayRefreshMonitor.cpp:
     31        (WebCore::DisplayRefreshMonitor::createDefaultDisplayRefreshMonitor):
     32        (WebCore::DisplayRefreshMonitor::create):
     33        (WebCore::DisplayRefreshMonitor::addClient):
     34        (WebCore::DisplayRefreshMonitor::removeClient):
     35        (WebCore::DisplayRefreshMonitor::displayDidRefresh):
     36        * platform/graphics/DisplayRefreshMonitor.h:
     37        * platform/graphics/DisplayRefreshMonitorClient.cpp:
     38        (WebCore::DisplayRefreshMonitorClient::~DisplayRefreshMonitorClient):
     39        * platform/graphics/DisplayRefreshMonitorClient.h:
     40        * platform/graphics/DisplayRefreshMonitorManager.cpp:
     41        (WebCore::DisplayRefreshMonitorManager::createMonitorForClient):
     42        (WebCore::DisplayRefreshMonitorManager::registerClient):
     43        (WebCore::DisplayRefreshMonitorManager::unregisterClient):
     44        (WebCore::DisplayRefreshMonitorManager::scheduleAnimation):
     45        (WebCore::DisplayRefreshMonitorManager::displayDidRefresh):
     46        (WebCore::DisplayRefreshMonitorManager::windowScreenDidChange):
     47        * platform/graphics/DisplayRefreshMonitorManager.h:
     48        * platform/graphics/GraphicsLayerUpdater.cpp:
     49        (WebCore::GraphicsLayerUpdater::GraphicsLayerUpdater):
     50        (WebCore::GraphicsLayerUpdater::scheduleUpdate):
     51        (WebCore::GraphicsLayerUpdater::screenDidChange):
     52        (WebCore::GraphicsLayerUpdater::displayRefreshFired):
     53        (WebCore::GraphicsLayerUpdater::createDisplayRefreshMonitor):
     54        * platform/graphics/GraphicsLayerUpdater.h:
     55        * rendering/RenderLayerCompositor.cpp:
     56        (WebCore::RenderLayerCompositor::RenderLayerCompositor):
     57        (WebCore::RenderLayerCompositor::flushPendingLayerChanges):
     58        (WebCore::RenderLayerCompositor::notifyFlushBeforeDisplayRefresh):
     59        (WebCore::RenderLayerCompositor::flushLayersSoon):
     60        (WebCore::RenderLayerCompositor::createDisplayRefreshMonitor):
     61        (WebCore::RenderLayerCompositor::startTrackingLayerFlushes):
     62        (WebCore::RenderLayerCompositor::layerFlushCount):
     63        * rendering/RenderLayerCompositor.h:
     64        * testing/Internals.cpp:
     65        (WebCore::Internals::startTrackingLayerFlushes):
     66        (WebCore::Internals::layerFlushCount):
     67        * testing/Internals.h:
     68        * testing/Internals.idl:
     69
    1702015-04-17  Bem Jones-Bey  <bjonesbe@adobe.com>
    271
  • trunk/Source/WebCore/dom/ScriptedAnimationController.cpp

    r181656 r182985  
    5252ScriptedAnimationController::ScriptedAnimationController(Document* document, PlatformDisplayID displayID)
    5353    : m_document(document)
    54     , m_nextCallbackId(0)
    55     , m_suspendCount(0)
    5654#if USE(REQUEST_ANIMATION_FRAME_TIMER)
    5755    , m_animationTimer(*this, &ScriptedAnimationController::animationTimerFired)
    58     , m_lastAnimationFrameTimeMonotonic(0)
    59 #if USE(REQUEST_ANIMATION_FRAME_DISPLAY_MONITOR)
    60     , m_isUsingTimer(false)
    61     , m_isThrottled(false)
    62 #endif
    6356#endif
    6457{
     
    174167        return;
    175168#if USE(REQUEST_ANIMATION_FRAME_DISPLAY_MONITOR)
    176     DisplayRefreshMonitorManager::sharedManager().windowScreenDidChange(displayID, this);
     169    DisplayRefreshMonitorManager::sharedManager().windowScreenDidChange(displayID, *this);
    177170#else
    178171    UNUSED_PARAM(displayID);
     
    188181#if USE(REQUEST_ANIMATION_FRAME_DISPLAY_MONITOR)
    189182    if (!m_isUsingTimer && !m_isThrottled) {
    190         if (DisplayRefreshMonitorManager::sharedManager().scheduleAnimation(this))
     183        if (DisplayRefreshMonitorManager::sharedManager().scheduleAnimation(*this))
    191184            return;
    192185
     
    227220
    228221#if USE(REQUEST_ANIMATION_FRAME_DISPLAY_MONITOR)
    229 Optional<RefPtr<DisplayRefreshMonitor>> ScriptedAnimationController::createDisplayRefreshMonitor(PlatformDisplayID displayID) const
     222RefPtr<DisplayRefreshMonitor> ScriptedAnimationController::createDisplayRefreshMonitor(PlatformDisplayID displayID) const
    230223{
    231224    if (!m_document->page())
    232         return Optional<RefPtr<DisplayRefreshMonitor>>(nullptr);
    233     return Optional<RefPtr<DisplayRefreshMonitor>>(m_document->page()->chrome().client().createDisplayRefreshMonitor(displayID));
    234 }
    235 #endif
    236 
    237 
    238 }
    239 
    240 #endif
     225        return nullptr;
     226
     227    if (auto monitor = m_document->page()->chrome().client().createDisplayRefreshMonitor(displayID))
     228        return monitor;
     229
     230    return DisplayRefreshMonitor::createDefaultDisplayRefreshMonitor(displayID);
     231}
     232#endif
     233
     234
     235}
     236
     237#endif
  • trunk/Source/WebCore/dom/ScriptedAnimationController.h

    r181656 r182985  
    7979
    8080    Document* m_document;
    81     CallbackId m_nextCallbackId;
    82     int m_suspendCount;
     81    CallbackId m_nextCallbackId { 0 };
     82    int m_suspendCount { 0 };
    8383
    8484    void scheduleAnimation();
     
    8787    void animationTimerFired();
    8888    Timer m_animationTimer;
    89     double m_lastAnimationFrameTimeMonotonic;
     89    double m_lastAnimationFrameTimeMonotonic { 0 };
    9090
    9191#if USE(REQUEST_ANIMATION_FRAME_DISPLAY_MONITOR)
    9292    // Override for DisplayRefreshMonitorClient
    9393    virtual void displayRefreshFired(double timestamp) override;
    94     virtual Optional<RefPtr<DisplayRefreshMonitor>> createDisplayRefreshMonitor(PlatformDisplayID) const override;
     94    virtual RefPtr<DisplayRefreshMonitor> createDisplayRefreshMonitor(PlatformDisplayID) const override;
    9595
    96     bool m_isUsingTimer;
    97     bool m_isThrottled;
     96    bool m_isUsingTimer { false };
     97    bool m_isThrottled { false };
    9898#endif
    9999#endif
  • trunk/Source/WebCore/page/ChromeClient.h

    r182860 r182985  
    287287
    288288#if USE(REQUEST_ANIMATION_FRAME_DISPLAY_MONITOR)
    289     virtual Optional<RefPtr<DisplayRefreshMonitor>> createDisplayRefreshMonitor(PlatformDisplayID) const { return Nullopt; }
     289    virtual RefPtr<DisplayRefreshMonitor> createDisplayRefreshMonitor(PlatformDisplayID) const { return nullptr; }
    290290#endif
    291291
  • trunk/Source/WebCore/platform/graphics/DisplayRefreshMonitor.cpp

    r182364 r182985  
    3636namespace WebCore {
    3737
    38 RefPtr<DisplayRefreshMonitor> DisplayRefreshMonitor::create(DisplayRefreshMonitorClient* client)
     38RefPtr<DisplayRefreshMonitor> DisplayRefreshMonitor::createDefaultDisplayRefreshMonitor(PlatformDisplayID displayID)
    3939{
    40     PlatformDisplayID displayID = client->displayID();
    41 
    42     if (Optional<RefPtr<DisplayRefreshMonitor>> monitor = client->createDisplayRefreshMonitor(displayID))
    43         return monitor.value();
    44 
    45     // If ChromeClient returned Nullopt, we'll make one of the default type.
    46 
    4740#if PLATFORM(MAC)
    4841    return DisplayRefreshMonitorMac::create(displayID);
     
    5144    return DisplayRefreshMonitorIOS::create(displayID);
    5245#endif
     46    return nullptr;
     47}
     48
     49RefPtr<DisplayRefreshMonitor> DisplayRefreshMonitor::create(DisplayRefreshMonitorClient& client)
     50{
     51    return client.createDisplayRefreshMonitor(client.displayID());
    5352}
    5453
     
    7473}
    7574
    76 void DisplayRefreshMonitor::addClient(DisplayRefreshMonitorClient* client)
     75void DisplayRefreshMonitor::addClient(DisplayRefreshMonitorClient& client)
    7776{
    78     m_clients.add(client);
     77    m_clients.add(&client);
    7978}
    8079
    81 bool DisplayRefreshMonitor::removeClient(DisplayRefreshMonitorClient* client)
     80bool DisplayRefreshMonitor::removeClient(DisplayRefreshMonitorClient& client)
    8281{
    8382    if (m_clientsToBeNotified)
    84         m_clientsToBeNotified->remove(client);
    85     return m_clients.remove(client);
     83        m_clientsToBeNotified->remove(&client);
     84    return m_clients.remove(&client);
    8685}
    8786
     
    127126    }
    128127   
    129     DisplayRefreshMonitorManager::sharedManager().displayDidRefresh(this);
     128    DisplayRefreshMonitorManager::sharedManager().displayDidRefresh(*this);
    130129}
    131130
  • trunk/Source/WebCore/platform/graphics/DisplayRefreshMonitor.h

    r181656 r182985  
    4242class DisplayRefreshMonitor : public RefCounted<DisplayRefreshMonitor> {
    4343public:
    44     static RefPtr<DisplayRefreshMonitor> create(DisplayRefreshMonitorClient*);
     44    static RefPtr<DisplayRefreshMonitor> create(DisplayRefreshMonitorClient&);
    4545    WEBCORE_EXPORT virtual ~DisplayRefreshMonitor();
    4646   
     
    5151   
    5252    bool hasClients() const { return m_clients.size(); }
    53     void addClient(DisplayRefreshMonitorClient*);
    54     bool removeClient(DisplayRefreshMonitorClient*);
     53    void addClient(DisplayRefreshMonitorClient&);
     54    bool removeClient(DisplayRefreshMonitorClient&);
    5555   
    5656    PlatformDisplayID displayID() const { return m_displayID; }
     
    7474
    7575    Mutex& mutex() { return m_mutex; }
     76
     77    static RefPtr<DisplayRefreshMonitor> createDefaultDisplayRefreshMonitor(PlatformDisplayID);
    7678
    7779protected:
  • trunk/Source/WebCore/platform/graphics/DisplayRefreshMonitorClient.cpp

    r169299 r182985  
    4242DisplayRefreshMonitorClient::~DisplayRefreshMonitorClient()
    4343{
    44     DisplayRefreshMonitorManager::sharedManager().unregisterClient(this);
     44    DisplayRefreshMonitorManager::sharedManager().unregisterClient(*this);
    4545}
    4646
  • trunk/Source/WebCore/platform/graphics/DisplayRefreshMonitorClient.h

    r181656 r182985  
    4545    virtual void displayRefreshFired(double timestamp) = 0;
    4646
    47     // Returning nullopt indicates that WebCore should create whatever DisplayRefreshMonitor it deems
    48     // most appropriate for the current platform. Returning nullptr indicates that we should not try to
    49     // create a DisplayRefreshMonitor at all (and should instead fall back to using a timer).
    50     virtual Optional<RefPtr<DisplayRefreshMonitor>> createDisplayRefreshMonitor(PlatformDisplayID) const = 0;
     47    virtual RefPtr<DisplayRefreshMonitor> createDisplayRefreshMonitor(PlatformDisplayID) const = 0;
    5148
    5249    PlatformDisplayID displayID() const { return m_displayID; }
  • trunk/Source/WebCore/platform/graphics/DisplayRefreshMonitorManager.cpp

    r181656 r182985  
    4545}
    4646
    47 DisplayRefreshMonitor* DisplayRefreshMonitorManager::createMonitorForClient(DisplayRefreshMonitorClient* client)
     47DisplayRefreshMonitor* DisplayRefreshMonitorManager::createMonitorForClient(DisplayRefreshMonitorClient& client)
    4848{
    49     PlatformDisplayID clientDisplayID = client->displayID();
     49    PlatformDisplayID clientDisplayID = client.displayID();
    5050    for (const RefPtr<DisplayRefreshMonitor>& monitor : m_monitors) {
    5151        if (monitor->displayID() != clientDisplayID)
     
    5858    if (!monitor)
    5959        return nullptr;
     60
    6061    monitor->addClient(client);
    6162    DisplayRefreshMonitor* result = monitor.get();
     
    6465}
    6566
    66 void DisplayRefreshMonitorManager::registerClient(DisplayRefreshMonitorClient* client)
     67void DisplayRefreshMonitorManager::registerClient(DisplayRefreshMonitorClient& client)
    6768{
    68     if (!client->hasDisplayID())
     69    if (!client.hasDisplayID())
    6970        return;
    7071
     
    7273}
    7374
    74 void DisplayRefreshMonitorManager::unregisterClient(DisplayRefreshMonitorClient* client)
     75void DisplayRefreshMonitorManager::unregisterClient(DisplayRefreshMonitorClient& client)
    7576{
    76     if (!client->hasDisplayID())
     77    if (!client.hasDisplayID())
    7778        return;
    7879
    79     PlatformDisplayID clientDisplayID = client->displayID();
     80    PlatformDisplayID clientDisplayID = client.displayID();
    8081    for (size_t i = 0; i < m_monitors.size(); ++i) {
    8182        RefPtr<DisplayRefreshMonitor> monitor = m_monitors[i];
     
    9091}
    9192
    92 bool DisplayRefreshMonitorManager::scheduleAnimation(DisplayRefreshMonitorClient* client)
     93bool DisplayRefreshMonitorManager::scheduleAnimation(DisplayRefreshMonitorClient& client)
    9394{
    94     if (!client->hasDisplayID())
     95    if (!client.hasDisplayID())
    9596        return false;
    9697
     
    99100        return false;
    100101
    101     client->setIsScheduled(true);
     102    client.setIsScheduled(true);
    102103    return monitor->requestRefreshCallback();
    103104}
    104105
    105 void DisplayRefreshMonitorManager::displayDidRefresh(DisplayRefreshMonitor* monitor)
     106void DisplayRefreshMonitorManager::displayDidRefresh(DisplayRefreshMonitor& monitor)
    106107{
    107     if (!monitor->shouldBeTerminated())
     108    if (!monitor.shouldBeTerminated())
    108109        return;
    109110
    110     size_t monitorIndex = m_monitors.find(monitor);
     111    size_t monitorIndex = m_monitors.find(&monitor);
    111112    ASSERT(monitorIndex != notFound);
    112113    m_monitors.remove(monitorIndex);
    113114}
    114115
    115 void DisplayRefreshMonitorManager::windowScreenDidChange(PlatformDisplayID displayID, DisplayRefreshMonitorClient* client)
     116void DisplayRefreshMonitorManager::windowScreenDidChange(PlatformDisplayID displayID, DisplayRefreshMonitorClient& client)
    116117{
    117     if (client->hasDisplayID() && client->displayID() == displayID)
     118    if (client.hasDisplayID() && client.displayID() == displayID)
    118119        return;
    119120   
    120121    unregisterClient(client);
    121     client->setDisplayID(displayID);
     122    client.setDisplayID(displayID);
    122123    registerClient(client);
    123     if (client->isScheduled())
     124    if (client.isScheduled())
    124125        scheduleAnimation(client);
    125126}
  • trunk/Source/WebCore/platform/graphics/DisplayRefreshMonitorManager.h

    r181656 r182985  
    4242    static DisplayRefreshMonitorManager& sharedManager();
    4343   
    44     void registerClient(DisplayRefreshMonitorClient*);
    45     void unregisterClient(DisplayRefreshMonitorClient*);
     44    void registerClient(DisplayRefreshMonitorClient&);
     45    void unregisterClient(DisplayRefreshMonitorClient&);
    4646
    47     bool scheduleAnimation(DisplayRefreshMonitorClient*);
    48     void windowScreenDidChange(PlatformDisplayID, DisplayRefreshMonitorClient*);
     47    bool scheduleAnimation(DisplayRefreshMonitorClient&);
     48    void windowScreenDidChange(PlatformDisplayID, DisplayRefreshMonitorClient&);
    4949
    5050private:
    5151    friend class DisplayRefreshMonitor;
    52     void displayDidRefresh(DisplayRefreshMonitor*);
     52    void displayDidRefresh(DisplayRefreshMonitor&);
    5353   
    5454    DisplayRefreshMonitorManager() { }
    5555    virtual ~DisplayRefreshMonitorManager();
    5656
    57     DisplayRefreshMonitor* createMonitorForClient(DisplayRefreshMonitorClient*);
     57    DisplayRefreshMonitor* createMonitorForClient(DisplayRefreshMonitorClient&);
    5858
    5959    Vector<RefPtr<DisplayRefreshMonitor>> m_monitors;
  • trunk/Source/WebCore/platform/graphics/GraphicsLayerUpdater.cpp

    r181656 r182985  
    3232namespace WebCore {
    3333
    34 GraphicsLayerUpdater::GraphicsLayerUpdater(GraphicsLayerUpdaterClient* client, PlatformDisplayID displayID)
     34GraphicsLayerUpdater::GraphicsLayerUpdater(GraphicsLayerUpdaterClient& client, PlatformDisplayID displayID)
    3535    : m_client(client)
    36     , m_scheduled(false)
    3736{
    3837#if USE(REQUEST_ANIMATION_FRAME_DISPLAY_MONITOR)
    39     DisplayRefreshMonitorManager::sharedManager().registerClient(this);
    40     DisplayRefreshMonitorManager::sharedManager().windowScreenDidChange(displayID, this);
    41     DisplayRefreshMonitorManager::sharedManager().scheduleAnimation(this);
     38    DisplayRefreshMonitorManager::sharedManager().registerClient(*this);
     39    DisplayRefreshMonitorManager::sharedManager().windowScreenDidChange(displayID, *this);
     40    DisplayRefreshMonitorManager::sharedManager().scheduleAnimation(*this);
    4241#else
    4342    UNUSED_PARAM(displayID);
     
    5655
    5756#if USE(REQUEST_ANIMATION_FRAME_DISPLAY_MONITOR)
    58     DisplayRefreshMonitorManager::sharedManager().scheduleAnimation(this);
     57    DisplayRefreshMonitorManager::sharedManager().scheduleAnimation(*this);
    5958#endif
    6059    m_scheduled = true;
     
    6463{
    6564#if USE(REQUEST_ANIMATION_FRAME_DISPLAY_MONITOR)
    66     DisplayRefreshMonitorManager::sharedManager().windowScreenDidChange(displayID, this);
     65    DisplayRefreshMonitorManager::sharedManager().windowScreenDidChange(displayID, *this);
    6766#else
    6867    UNUSED_PARAM(displayID);
     
    7675    m_scheduled = false;
    7776   
    78     if (m_client)
    79         m_client->flushLayersSoon(this);
     77    m_client.flushLayersSoon(*this);
    8078}
    8179#endif
    8280
    8381#if USE(REQUEST_ANIMATION_FRAME_DISPLAY_MONITOR)
    84 Optional<RefPtr<DisplayRefreshMonitor>> GraphicsLayerUpdater::createDisplayRefreshMonitor(PlatformDisplayID displayID) const
     82RefPtr<DisplayRefreshMonitor> GraphicsLayerUpdater::createDisplayRefreshMonitor(PlatformDisplayID displayID) const
    8583{
    86     if (!m_client)
    87         return Optional<RefPtr<DisplayRefreshMonitor>>(nullptr);
    88     return m_client->createDisplayRefreshMonitor(displayID);
     84    return m_client.createDisplayRefreshMonitor(displayID);
    8985}
    9086#endif
  • trunk/Source/WebCore/platform/graphics/GraphicsLayerUpdater.h

    r181656 r182985  
    3737public:
    3838    virtual ~GraphicsLayerUpdaterClient() { }
    39     virtual void flushLayersSoon(GraphicsLayerUpdater*) = 0;
     39    virtual void flushLayersSoon(GraphicsLayerUpdater&) = 0;
    4040#if USE(REQUEST_ANIMATION_FRAME_DISPLAY_MONITOR)
    41     virtual Optional<RefPtr<DisplayRefreshMonitor>> createDisplayRefreshMonitor(PlatformDisplayID) const = 0;
     41    virtual RefPtr<DisplayRefreshMonitor> createDisplayRefreshMonitor(PlatformDisplayID) const = 0;
    4242#endif
    4343};
     
    4949{
    5050public:
    51     GraphicsLayerUpdater(GraphicsLayerUpdaterClient*, PlatformDisplayID);
     51    GraphicsLayerUpdater(GraphicsLayerUpdaterClient&, PlatformDisplayID);
    5252    virtual ~GraphicsLayerUpdater();
    5353
     
    5656
    5757#if USE(REQUEST_ANIMATION_FRAME_DISPLAY_MONITOR)
    58     virtual Optional<RefPtr<DisplayRefreshMonitor>> createDisplayRefreshMonitor(PlatformDisplayID) const override;
     58    virtual RefPtr<DisplayRefreshMonitor> createDisplayRefreshMonitor(PlatformDisplayID) const override;
    5959#endif
    6060
     
    6464#endif
    6565
    66     GraphicsLayerUpdaterClient* m_client;
    67     bool m_scheduled;
     66    GraphicsLayerUpdaterClient& m_client;
     67    bool m_scheduled { false };
    6868};
    6969
  • trunk/Source/WebCore/rendering/RenderLayerCompositor.cpp

    r182809 r182985  
    281281    , m_hasAcceleratedCompositing(true)
    282282    , m_compositingTriggers(static_cast<ChromeClient::CompositingTriggerFlags>(ChromeClient::AllTriggers))
    283     , m_compositedLayerCount(0)
    284283    , m_showDebugBorders(false)
    285284    , m_showRepaintCounter(false)
     
    294293    , m_subframeScrollLayersNeedReattach(false)
    295294    , m_isTrackingRepaints(false)
    296     , m_layersWithTiledBackingCount(0)
    297295    , m_rootLayerAttachment(RootLayerUnattached)
    298296    , m_layerFlushTimer(*this, &RenderLayerCompositor::layerFlushTimerFired)
     
    301299    , m_hasPendingLayerFlush(false)
    302300    , m_paintRelatedMilestonesTimer(*this, &RenderLayerCompositor::paintRelatedMilestonesTimerFired)
    303 #if !LOG_DISABLED
    304     , m_rootLayerUpdateCount(0)
    305     , m_obligateCompositedLayerCount(0)
    306     , m_secondaryCompositedLayerCount(0)
    307     , m_obligatoryBackingStoreBytes(0)
    308     , m_secondaryBackingStoreBytes(0)
    309 #endif
    310301{
    311302}
     
    492483#endif
    493484
     485    ++m_layerFlushCount;
    494486    startLayerFlushTimerIfNeeded();
    495487}
     
    609601            displayID = page->chrome().displayID();
    610602
    611         m_layerUpdater = std::make_unique<GraphicsLayerUpdater>(this, displayID);
     603        m_layerUpdater = std::make_unique<GraphicsLayerUpdater>(*this, displayID);
    612604    }
    613605   
     
    615607}
    616608
    617 void RenderLayerCompositor::flushLayersSoon(GraphicsLayerUpdater*)
     609void RenderLayerCompositor::flushLayersSoon(GraphicsLayerUpdater&)
    618610{
    619611    scheduleLayerFlush(true);
     
    41724164
    41734165#if USE(REQUEST_ANIMATION_FRAME_DISPLAY_MONITOR)
    4174 Optional<RefPtr<DisplayRefreshMonitor>> RenderLayerCompositor::createDisplayRefreshMonitor(PlatformDisplayID displayID) const
     4166RefPtr<DisplayRefreshMonitor> RenderLayerCompositor::createDisplayRefreshMonitor(PlatformDisplayID displayID) const
    41754167{
    41764168    Frame& frame = m_renderView.frameView().frame();
    41774169    Page* page = frame.page();
    41784170    if (!page)
    4179         return Optional<RefPtr<DisplayRefreshMonitor>>(nullptr);
    4180 
    4181     return Optional<RefPtr<DisplayRefreshMonitor>>(page->chrome().client().createDisplayRefreshMonitor(displayID));
    4182 }
    4183 #endif
     4171        return nullptr;
     4172
     4173    if (auto monitor = page->chrome().client().createDisplayRefreshMonitor(displayID))
     4174        return monitor;
     4175
     4176    return DisplayRefreshMonitor::createDefaultDisplayRefreshMonitor(displayID);
     4177}
     4178#endif
     4179
     4180void RenderLayerCompositor::startTrackingLayerFlushes()
     4181{
     4182    m_layerFlushCount = 0;
     4183}
     4184
     4185unsigned RenderLayerCompositor::layerFlushCount() const
     4186{
     4187    return m_layerFlushCount;
     4188}
    41844189
    41854190} // namespace WebCore
  • trunk/Source/WebCore/rendering/RenderLayerCompositor.h

    r182809 r182985  
    308308    Color rootExtendedBackgroundColor() const { return m_rootExtendedBackgroundColor; }
    309309
     310    // For testing.
     311    WEBCORE_EXPORT void startTrackingLayerFlushes();
     312    WEBCORE_EXPORT unsigned layerFlushCount() const;
     313
    310314private:
    311315    class OverlapMap;
     
    320324   
    321325    // GraphicsLayerUpdaterClient implementation
    322     virtual void flushLayersSoon(GraphicsLayerUpdater*) override;
     326    virtual void flushLayersSoon(GraphicsLayerUpdater&) override;
    323327
    324328    // Whether the given RL needs a compositing layer.
     
    400404
    401405#if USE(REQUEST_ANIMATION_FRAME_DISPLAY_MONITOR)
    402     Optional<RefPtr<DisplayRefreshMonitor>> createDisplayRefreshMonitor(PlatformDisplayID) const override;
     406    RefPtr<DisplayRefreshMonitor> createDisplayRefreshMonitor(PlatformDisplayID) const override;
    403407#endif
    404408
     
    474478    ChromeClient::CompositingTriggerFlags m_compositingTriggers;
    475479
    476     int m_compositedLayerCount;
    477480    bool m_showDebugBorders;
    478481    bool m_showRepaintCounter;
     
    493496    bool m_isTrackingRepaints; // Used for testing.
    494497
    495     unsigned m_layersWithTiledBackingCount;
     498    int m_compositedLayerCount { 0 };
     499    unsigned m_layersWithTiledBackingCount { 0 };
     500    unsigned m_layerFlushCount { 0 };
    496501
    497502    RootLayerAttachment m_rootLayerAttachment;
     
    534539
    535540#if !LOG_DISABLED
    536     int m_rootLayerUpdateCount;
    537     int m_obligateCompositedLayerCount; // count of layer that have to be composited.
    538     int m_secondaryCompositedLayerCount; // count of layers that have to be composited because of stacking or overlap.
    539     double m_obligatoryBackingStoreBytes;
    540     double m_secondaryBackingStoreBytes;
     541    int m_rootLayerUpdateCount { 0 };
     542    int m_obligateCompositedLayerCount { 0 }; // count of layer that have to be composited.
     543    int m_secondaryCompositedLayerCount { 0 }; // count of layers that have to be composited because of stacking or overlap.
     544    double m_obligatoryBackingStoreBytes { 0 };
     545    double m_secondaryBackingStoreBytes { 0 };
    541546#endif
    542547
  • trunk/Source/WebCore/testing/Internals.cpp

    r182449 r182985  
    9191#include "Range.h"
    9292#include "RenderEmbeddedObject.h"
     93#include "RenderLayerCompositor.h"
    9394#include "RenderMenuList.h"
    9495#include "RenderTreeAsText.h"
     
    20652066    FrameView* frameView = document->view();
    20662067    frameView->setTracksRepaints(false);
     2068}
     2069
     2070void Internals::startTrackingLayerFlushes(ExceptionCode& ec)
     2071{
     2072    Document* document = contextDocument();
     2073    if (!document || !document->renderView()) {
     2074        ec = INVALID_ACCESS_ERR;
     2075        return;
     2076    }
     2077
     2078    document->renderView()->compositor().startTrackingLayerFlushes();
     2079}
     2080
     2081unsigned long Internals::layerFlushCount(ExceptionCode& ec)
     2082{
     2083    Document* document = contextDocument();
     2084    if (!document || !document->renderView()) {
     2085        ec = INVALID_ACCESS_ERR;
     2086        return 0;
     2087    }
     2088
     2089    return document->renderView()->compositor().layerFlushCount();
    20672090}
    20682091
  • trunk/Source/WebCore/testing/Internals.h

    r182351 r182985  
    295295    void startTrackingRepaints(ExceptionCode&);
    296296    void stopTrackingRepaints(ExceptionCode&);
     297
     298    void startTrackingLayerFlushes(ExceptionCode&);
     299    unsigned long layerFlushCount(ExceptionCode&);
     300   
    297301    void updateLayoutIgnorePendingStylesheetsAndRunPostLayoutTasks(ExceptionCode&);
    298302    void updateLayoutIgnorePendingStylesheetsAndRunPostLayoutTasks(Node*, ExceptionCode&);
  • trunk/Source/WebCore/testing/Internals.idl

    r182351 r182985  
    272272    [RaisesException] void stopTrackingRepaints();
    273273
     274    [RaisesException] void startTrackingLayerFlushes();
     275    [RaisesException] unsigned long layerFlushCount();
     276
    274277    // Query if a timer is currently throttled, to debug timer throttling.
    275278    [RaisesException] boolean isTimerThrottled(long timerHandle);
  • trunk/Source/WebKit2/ChangeLog

    r182984 r182985  
     12015-04-18  Simon Fraser  <simon.fraser@apple.com>
     2
     3        REGRESSION (r181656): Animated tiled layers are missing content
     4        https://bugs.webkit.org/show_bug.cgi?id=143911
     5        rdar://problem/20596328
     6
     7        Reviewed by Darin Adler.
     8       
     9        After r181656, all requestAnimationFrame was falling back to timers, and not
     10        using the platform's DisplayRefreshMonitor, because of a Nullopt vs nullptr
     11        fumble.
     12       
     13        Replace this confusing Optional<> code with simpler code that just forces the
     14        clients to make a DisplayRefreshMonitor if they can, first asking
     15        ChromeClient, and then falling back to createDefaultDisplayRefreshMonitor().
     16       
     17        Make lots of things into references, and use C++11 initialization in some places.
     18
     19        * WebProcess/WebCoreSupport/WebChromeClient.cpp:
     20        (WebKit::WebChromeClient::createDisplayRefreshMonitor):
     21        * WebProcess/WebCoreSupport/WebChromeClient.h:
     22
    1232015-04-18  Dan Bernstein  <mitz@apple.com>
    224
  • trunk/Source/WebKit2/WebProcess/WebCoreSupport/WebChromeClient.cpp

    r182860 r182985  
    851851
    852852#if USE(REQUEST_ANIMATION_FRAME_DISPLAY_MONITOR)
    853 Optional<RefPtr<WebCore::DisplayRefreshMonitor>> WebChromeClient::createDisplayRefreshMonitor(PlatformDisplayID displayID) const
    854 {
    855     return Optional<RefPtr<WebCore::DisplayRefreshMonitor>>(m_page->drawingArea()->createDisplayRefreshMonitor(displayID));
     853RefPtr<WebCore::DisplayRefreshMonitor> WebChromeClient::createDisplayRefreshMonitor(PlatformDisplayID displayID) const
     854{
     855    return m_page->drawingArea()->createDisplayRefreshMonitor(displayID);
    856856}
    857857#endif
  • trunk/Source/WebKit2/WebProcess/WebCoreSupport/WebChromeClient.h

    r182860 r182985  
    218218
    219219#if USE(REQUEST_ANIMATION_FRAME_DISPLAY_MONITOR)
    220     virtual Optional<RefPtr<WebCore::DisplayRefreshMonitor>> createDisplayRefreshMonitor(PlatformDisplayID) const override;
     220    virtual RefPtr<WebCore::DisplayRefreshMonitor> createDisplayRefreshMonitor(PlatformDisplayID) const override;
    221221#endif
    222222
  • trunk/Source/WebKit2/WebProcess/WebPage/DrawingArea.cpp

    r179409 r182985  
    9797
    9898#if USE(REQUEST_ANIMATION_FRAME_DISPLAY_MONITOR)
    99 PassRefPtr<WebCore::DisplayRefreshMonitor> DrawingArea::createDisplayRefreshMonitor(PlatformDisplayID)
     99RefPtr<WebCore::DisplayRefreshMonitor> DrawingArea::createDisplayRefreshMonitor(PlatformDisplayID)
    100100{
    101101    return nullptr;
  • trunk/Source/WebKit2/WebProcess/WebPage/DrawingArea.h

    r180924 r182985  
    107107
    108108#if USE(REQUEST_ANIMATION_FRAME_DISPLAY_MONITOR)
    109     virtual PassRefPtr<WebCore::DisplayRefreshMonitor> createDisplayRefreshMonitor(PlatformDisplayID);
     109    virtual RefPtr<WebCore::DisplayRefreshMonitor> createDisplayRefreshMonitor(PlatformDisplayID);
    110110#endif
    111111
  • trunk/Source/WebKit2/WebProcess/WebPage/mac/RemoteLayerTreeDrawingArea.h

    r177104 r182985  
    7272    virtual void addTransactionCallbackID(uint64_t callbackID) override;
    7373
    74     virtual PassRefPtr<WebCore::DisplayRefreshMonitor> createDisplayRefreshMonitor(PlatformDisplayID) override;
     74    virtual RefPtr<WebCore::DisplayRefreshMonitor> createDisplayRefreshMonitor(PlatformDisplayID) override;
    7575    void willDestroyDisplayRefreshMonitor(WebCore::DisplayRefreshMonitor*);
    7676
  • trunk/Source/WebKit2/WebProcess/WebPage/mac/RemoteLayerTreeDrawingArea.mm

    r180031 r182985  
    109109}
    110110
    111 PassRefPtr<DisplayRefreshMonitor> RemoteLayerTreeDrawingArea::createDisplayRefreshMonitor(PlatformDisplayID displayID)
     111RefPtr<DisplayRefreshMonitor> RemoteLayerTreeDrawingArea::createDisplayRefreshMonitor(PlatformDisplayID displayID)
    112112{
    113113    RefPtr<RemoteLayerTreeDisplayRefreshMonitor> monitor = RemoteLayerTreeDisplayRefreshMonitor::create(displayID, *this);
Note: See TracChangeset for help on using the changeset viewer.