WebKit Bugzilla
Attachment 340663 Details for
Bug 185752
: Lazily create WebCore::Timer for WebCore::Image
Home
|
New
|
Browse
|
Search
|
[?]
|
Reports
|
Requests
|
Help
|
New Account
|
Log In
Remember
[x]
|
Forgot Password
Login:
[x]
[patch]
Patch v1
bug-185752-20180517155403.patch (text/plain), 3.27 KB, created by
David Kilzer (:ddkilzer)
on 2018-05-17 15:54:03 PDT
(
hide
)
Description:
Patch v1
Filename:
MIME Type:
Creator:
David Kilzer (:ddkilzer)
Created:
2018-05-17 15:54:03 PDT
Size:
3.27 KB
patch
obsolete
>Subversion Revision: 231450 >diff --git a/Source/WebCore/ChangeLog b/Source/WebCore/ChangeLog >index fd142b5eb23aa67dab46fe5a586368ba2f066edb..998d8b139cc4276e61d28ad7a7900a63a5e42a38 100644 >--- a/Source/WebCore/ChangeLog >+++ b/Source/WebCore/ChangeLog >@@ -1,3 +1,25 @@ >+2018-05-17 David Kilzer <ddkilzer@apple.com> >+ >+ Lazily create WebCore::Timer for WebCore::Image >+ <https://webkit.org/b/185752> >+ >+ Reviewed by NOBODY (OOPS!). >+ >+ Not every image is an animated image, so lazily creating >+ m_animationStartTimer saves 56 bytes per instance of >+ WebCore::Image. >+ >+ * platform/graphics/Image.cpp: >+ (WebCore::Image::Image): Remove default initializer for >+ m_animationStartTimer. >+ (WebCore::Image::startAnimationAsynchronously): Use >+ std::call_once to initialize m_animationStartTimer. >+ * 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>. >+ > 2018-05-07 Chris Dumez <cdumez@apple.com> > > ASSERT(!childItemWithTarget(child->target())) is hit in HistoryItem::addChildItem() >diff --git a/Source/WebCore/platform/graphics/Image.cpp b/Source/WebCore/platform/graphics/Image.cpp >index 90e816f27f6dd2669dd047658e30ab50a4386a4e..bf4d98828a62787e8bd5d7f4a6327b9876d84339 100644 >--- a/Source/WebCore/platform/graphics/Image.cpp >+++ b/Source/WebCore/platform/graphics/Image.cpp >@@ -50,7 +50,6 @@ namespace WebCore { > > Image::Image(ImageObserver* observer) > : m_imageObserver(observer) >- , m_animationStartTimer(*this, &Image::startAnimation) > { > } > >@@ -349,9 +348,12 @@ void Image::computeIntrinsicDimensions(Length& intrinsicWidth, Length& intrinsic > > void Image::startAnimationAsynchronously() > { >- if (m_animationStartTimer.isActive()) >+ std::call_once(onceFlag, [this] { >+ m_animationStartTimer = std::make_unique<Timer>(*this, &Image::startAnimation); >+ }); >+ if (m_animationStartTimer->isActive()) > return; >- m_animationStartTimer.startOneShot(0_s); >+ m_animationStartTimer->startOneShot(0_s); > } > > void Image::dump(TextStream& ts) const >diff --git a/Source/WebCore/platform/graphics/Image.h b/Source/WebCore/platform/graphics/Image.h >index 65988f79bf26ecfe8f8d554cb4ca038df805cbf0..2450c7d7603c703d4a65d26b282245234b32d85e 100644 >--- a/Source/WebCore/platform/graphics/Image.h >+++ b/Source/WebCore/platform/graphics/Image.h >@@ -138,7 +138,7 @@ public: > virtual void stopAnimation() {} > virtual void resetAnimation() {} > virtual bool isAnimating() const { return false; } >- bool animationPending() const { return m_animationStartTimer.isActive(); } >+ bool animationPending() const { return m_animationStartTimer && m_animationStartTimer->isActive(); } > > // Typically the CachedImage that owns us. > ImageObserver* imageObserver() const { return m_imageObserver; } >@@ -200,7 +200,8 @@ protected: > private: > RefPtr<SharedBuffer> m_encodedImageData; > ImageObserver* m_imageObserver; >- Timer m_animationStartTimer; >+ std::once_flag onceFlag; >+ std::unique_ptr<Timer> m_animationStartTimer; > }; > > WTF::TextStream& operator<<(WTF::TextStream&, const Image&);
You cannot view the attachment while viewing its details because your browser does not support IFRAMEs.
View the attachment on a separate page
.
View Attachment As Diff
View Attachment As Raw
Actions:
View
|
Formatted Diff
|
Diff
Attachments on
bug 185752
: 340663