Title: [183716] trunk/Source/WebCore
Revision
183716
Author
[email protected]
Date
2015-05-02 08:32:10 -0700 (Sat, 02 May 2015)

Log Message

Small cleanup in BitmapImage
https://bugs.webkit.org/show_bug.cgi?id=144515

Reviewed by Darin Adler.

Use an enum for the internalAdvanceAnimation() argument, with a default.

Wrap the clearing of the timer in a clearTimer() function, called from
stopAnimation(). This fixes the jarring reading of BitmapImage::internalAdvanceAnimation(),
which used to start by calling stopAnimation().

* platform/graphics/BitmapImage.cpp:
(WebCore::BitmapImage::clearTimer):
(WebCore::BitmapImage::startAnimation):
(WebCore::BitmapImage::stopAnimation):
(WebCore::BitmapImage::advanceAnimation):
(WebCore::BitmapImage::internalAdvanceAnimation):
* platform/graphics/BitmapImage.h:
* platform/graphics/Image.h:

Modified Paths

Diff

Modified: trunk/Source/WebCore/ChangeLog (183715 => 183716)


--- trunk/Source/WebCore/ChangeLog	2015-05-02 15:28:24 UTC (rev 183715)
+++ trunk/Source/WebCore/ChangeLog	2015-05-02 15:32:10 UTC (rev 183716)
@@ -1,3 +1,25 @@
+2015-05-02  Simon Fraser  <[email protected]>
+
+        Small cleanup in BitmapImage
+        https://bugs.webkit.org/show_bug.cgi?id=144515
+
+        Reviewed by Darin Adler.
+
+        Use an enum for the internalAdvanceAnimation() argument, with a default.
+        
+        Wrap the clearing of the timer in a clearTimer() function, called from
+        stopAnimation(). This fixes the jarring reading of BitmapImage::internalAdvanceAnimation(),
+        which used to start by calling stopAnimation().
+
+        * platform/graphics/BitmapImage.cpp:
+        (WebCore::BitmapImage::clearTimer):
+        (WebCore::BitmapImage::startAnimation):
+        (WebCore::BitmapImage::stopAnimation):
+        (WebCore::BitmapImage::advanceAnimation):
+        (WebCore::BitmapImage::internalAdvanceAnimation):
+        * platform/graphics/BitmapImage.h:
+        * platform/graphics/Image.h:
+
 2015-05-01  Simon Fraser  <[email protected]>
 
         Avoid compositing updates after style recalcs which have no compositing implications

Modified: trunk/Source/WebCore/platform/graphics/BitmapImage.cpp (183715 => 183716)


--- trunk/Source/WebCore/platform/graphics/BitmapImage.cpp	2015-05-02 15:28:24 UTC (rev 183715)
+++ trunk/Source/WebCore/platform/graphics/BitmapImage.cpp	2015-05-02 15:32:10 UTC (rev 183716)
@@ -83,6 +83,11 @@
     stopAnimation();
 }
 
+void BitmapImage::clearTimer()
+{
+    m_frameTimer = nullptr;
+}
+
 #if !USE(CG)
 bool BitmapImage::decodedDataIsPurgeable() const
 {
@@ -554,7 +559,7 @@
                 break;
 
             // Yes; skip over it without notifying our observers.
-            if (!internalAdvanceAnimation(true))
+            if (!internalAdvanceAnimation(SkippingFramesToCatchUp))
                 return;
             m_desiredFrameStartTime = frameAfterNextStartTime;
             nextFrame = frameAfterNext;
@@ -564,7 +569,7 @@
         // may be in the past, meaning the next time through this function we'll
         // kick off the next advancement sooner than this frame's duration would
         // suggest.
-        if (internalAdvanceAnimation(false)) {
+        if (internalAdvanceAnimation()) {
             // The image region has been marked dirty, but once we return to our
             // caller, draw() will clear it, and nothing will cause the
             // animation to advance again.  We need to start the timer for the
@@ -590,7 +595,7 @@
 {
     // This timer is used to animate all occurrences of this image.  Don't invalidate
     // the timer unless all renderers have stopped drawing.
-    m_frameTimer = nullptr;
+    clearTimer();
 }
 
 void BitmapImage::resetAnimation()
@@ -643,16 +648,15 @@
 
 void BitmapImage::advanceAnimation()
 {
-    internalAdvanceAnimation(false);
+    internalAdvanceAnimation();
     // At this point the image region has been marked dirty, and if it's
     // onscreen, we'll soon make a call to draw(), which will call
     // startAnimation() again to keep the animation moving.
 }
 
-bool BitmapImage::internalAdvanceAnimation(bool skippingFrames)
+bool BitmapImage::internalAdvanceAnimation(AnimationAdvancement advancement)
 {
-    // Stop the animation.
-    stopAnimation();
+    clearTimer();
     
     ++m_currentFrame;
     bool advancedAnimation = true;
@@ -679,8 +683,9 @@
 
     // We need to draw this frame if we advanced to it while not skipping, or if
     // while trying to skip frames we hit the last frame and thus had to stop.
-    if (skippingFrames != advancedAnimation)
+    if ((advancement == Normal && advancedAnimation) || (advancement == SkippingFramesToCatchUp && !advancedAnimation))
         imageObserver()->animationAdvanced(this);
+
     return advancedAnimation;
 }
 

Modified: trunk/Source/WebCore/platform/graphics/BitmapImage.h (183715 => 183716)


--- trunk/Source/WebCore/platform/graphics/BitmapImage.h	2015-05-02 15:28:24 UTC (rev 183715)
+++ trunk/Source/WebCore/platform/graphics/BitmapImage.h	2015-05-02 15:32:10 UTC (rev 183716)
@@ -265,7 +265,8 @@
     // a bunch of animation frames, so we should not do things like decode each
     // one or notify our observers.
     // Returns whether the animation was advanced.
-    bool internalAdvanceAnimation(bool skippingFrames);
+    enum AnimationAdvancement { Normal, SkippingFramesToCatchUp };
+    bool internalAdvanceAnimation(AnimationAdvancement = Normal);
 
     // Handle platform-specific data
     void invalidatePlatformData();
@@ -284,6 +285,7 @@
 
 private:
     virtual bool decodedDataIsPurgeable() const override;
+    void clearTimer();
 
     ImageSource m_source;
     mutable IntSize m_size; // The size to use for the overall image (will just be the size of the first image).

Modified: trunk/Source/WebCore/platform/graphics/Image.h (183715 => 183716)


--- trunk/Source/WebCore/platform/graphics/Image.h	2015-05-02 15:28:24 UTC (rev 183715)
+++ trunk/Source/WebCore/platform/graphics/Image.h	2015-05-02 15:32:10 UTC (rev 183716)
@@ -76,7 +76,7 @@
 public:
     virtual ~Image();
     
-    static PassRefPtr<Image> create(ImageObserver* = 0);
+    static PassRefPtr<Image> create(ImageObserver* = nullptr);
     WEBCORE_EXPORT static PassRefPtr<Image> loadPlatformResource(const char* name);
     WEBCORE_EXPORT static bool supportsType(const String&);
 
@@ -181,7 +181,7 @@
         m_space = space;
     }
 protected:
-    Image(ImageObserver* = 0);
+    Image(ImageObserver* = nullptr);
 
     static void fillWithSolidColor(GraphicsContext*, const FloatRect& dstRect, const Color&, ColorSpace styleColorSpace, CompositeOperator);
 
_______________________________________________
webkit-changes mailing list
[email protected]
https://lists.webkit.org/mailman/listinfo/webkit-changes

Reply via email to