Changeset 231940 in webkit


Ignore:
Timestamp:
May 17, 2018 8:29:19 PM (6 years ago)
Author:
ddkilzer@apple.com
Message:

Lazily create WebCore::Timer for WebCore::Image
<https://webkit.org/b/185752>

Reviewed by Simon Fraser.

Not every image is an animated image, so lazily creating
m_animationStartTimer saves 64 bytes per instance of
WebCore::Image.

  • platform/graphics/Image.cpp:

(WebCore::Image::Image): Remove default initializer for
m_animationStartTimer.
(WebCore::Image::startAnimationAsynchronously): Initialize
m_animationStartTimer if it's not already created.

  • platform/graphics/Image.h:

(WebCore::Image::animationPending const): Update to check if
m_animationStartTimer has been set before dereferencing it.
(WebCore::Image::m_animationStartTimer): Change type to
std::unique_ptr<Timer>.

Location:
trunk/Source/WebCore
Files:
3 edited

Legend:

Unmodified
Added
Removed
  • trunk/Source/WebCore/ChangeLog

    r231937 r231940  
     12018-05-17  David Kilzer  <ddkilzer@apple.com>
     2
     3        Lazily create WebCore::Timer for WebCore::Image
     4        <https://webkit.org/b/185752>
     5
     6        Reviewed by Simon Fraser.
     7
     8        Not every image is an animated image, so lazily creating
     9        m_animationStartTimer saves 64 bytes per instance of
     10        WebCore::Image.
     11
     12        * platform/graphics/Image.cpp:
     13        (WebCore::Image::Image): Remove default initializer for
     14        m_animationStartTimer.
     15        (WebCore::Image::startAnimationAsynchronously): Initialize
     16        m_animationStartTimer if it's not already created.
     17        * platform/graphics/Image.h:
     18        (WebCore::Image::animationPending const): Update to check if
     19        m_animationStartTimer has been set before dereferencing it.
     20        (WebCore::Image::m_animationStartTimer): Change type to
     21        std::unique_ptr<Timer>.
     22
    1232018-05-17  Nan Wang  <n_wang@apple.com>
    224
  • trunk/Source/WebCore/platform/graphics/Image.cpp

    r230350 r231940  
    5151Image::Image(ImageObserver* observer)
    5252    : m_imageObserver(observer)
    53     , m_animationStartTimer(*this, &Image::startAnimation)
    5453{
    5554}
     
    350349void Image::startAnimationAsynchronously()
    351350{
    352     if (m_animationStartTimer.isActive())
     351    if (!m_animationStartTimer)
     352        m_animationStartTimer = std::make_unique<Timer>(*this, &Image::startAnimation);
     353    if (m_animationStartTimer->isActive())
    353354        return;
    354     m_animationStartTimer.startOneShot(0_s);
     355    m_animationStartTimer->startOneShot(0_s);
    355356}
    356357
  • trunk/Source/WebCore/platform/graphics/Image.h

    r230350 r231940  
    139139    virtual void resetAnimation() {}
    140140    virtual bool isAnimating() const { return false; }
    141     bool animationPending() const { return m_animationStartTimer.isActive(); }
     141    bool animationPending() const { return m_animationStartTimer && m_animationStartTimer->isActive(); }
    142142
    143143    // Typically the CachedImage that owns us.
     
    201201    RefPtr<SharedBuffer> m_encodedImageData;
    202202    ImageObserver* m_imageObserver;
    203     Timer m_animationStartTimer;
     203    std::unique_ptr<Timer> m_animationStartTimer;
    204204};
    205205
Note: See TracChangeset for help on using the changeset viewer.