Changeset 60375 in webkit
- Timestamp:
- May 28, 2010 2:15:19 PM (14 years ago)
- Location:
- trunk/WebCore
- Files:
-
- 7 edited
- 4 moved
Legend:
- Unmodified
- Added
- Removed
-
trunk/WebCore/ChangeLog
r60374 r60375 1 2010-05-28 Peter Kasting <pkasting@google.com> 2 3 Reviewed by Darin Adler. 4 5 https://bugs.webkit.org/show_bug.cgi?id=39857 6 Make GIFs loop the correct number of times. Previously, everyone looped 7 one time too few for non-infinitely-looping GIFs. 8 9 Modified a Qt manual test to be correct and moved it to the general 10 manual test directory. 11 12 * manual-tests/animated-gif-looping.html: Copied from WebCore/manual-tests/qt/qt-gif-test.html. 13 * manual-tests/qt/qt-10loop-anim.gif: Removed. 14 * manual-tests/qt/qt-anim.gif: Removed. 15 * manual-tests/qt/qt-gif-test.html: Removed. 16 * manual-tests/qt/qt-noanim.gif: Removed. 17 * manual-tests/resources/animated-10x.gif: Copied from WebCore/manual-tests/qt/qt-10loop-anim.gif and modified. 18 * manual-tests/resources/animated-infinite.gif: Copied from WebCore/manual-tests/qt/qt-anim.gif. 19 * manual-tests/resources/non-animated.gif: Copied from WebCore/manual-tests/qt/qt-noanim.gif. 20 * platform/graphics/BitmapImage.cpp: 21 (WebCore::BitmapImage::internalAdvanceAnimation): For a loop count of n, show a total of n + 1 animation cycles. 22 * platform/graphics/ImageSource.h: 23 * platform/graphics/cg/ImageSourceCG.cpp: 24 (WebCore::ImageSource::repetitionCount): 25 * platform/graphics/qt/ImageDecoderQt.cpp: 26 (WebCore::ImageDecoderQt::repetitionCount): Remove translation code now that WebCore matches Qt's internal handling of the loop count. Qt itself may still have a bug here. 27 * platform/image-decoders/gif/GIFImageDecoder.cpp: 28 (WebCore::GIFImageDecoder::repetitionCount): 29 * platform/image-decoders/gif/GIFImageReader.cpp: 30 (GIFImageReader::read): Translate loop count 0 to "loop infinitely" (by restoring one piece of the Mozilla code we'd removed). 31 1 32 2010-05-28 Ben Murdoch <benm@google.com> 2 33 -
trunk/WebCore/manual-tests/animated-gif-looping.html
r60323 r60375 2 2 <body> 3 3 <div> 4 <img src=" qt-anim.gif">4 <img src="./resources/animated-infinite.gif"> 5 5 <p>This should animate.</p> 6 6 </div> 7 7 <div> 8 <img src=" qt-noanim.gif">8 <img src="./resources/non-animated.gif"> 9 9 <p>This should not animate and you should see a cross.</p> 10 10 </div 11 11 <div> 12 <img src=" qt-10loop-anim.gif">12 <img src="./resources/animated-10x.gif"> 13 13 <p>This animation should loop 10 times.</p> 14 14 </div -
trunk/WebCore/platform/graphics/BitmapImage.cpp
r55199 r60375 405 405 // repetition count before, we should have decoded the whole image by 406 406 // now, so it should now be available. 407 if (repetitionCount(true) && m_repetitionsComplete >= m_repetitionCount) { 407 // Note that we don't need to special-case cAnimationLoopOnce here 408 // because it is 0 (see comments on its declaration in ImageSource.h). 409 if (repetitionCount(true) != cAnimationLoopInfinite && m_repetitionsComplete > m_repetitionCount) { 408 410 m_animationFinished = true; 409 411 m_desiredFrameStartTime = 0; -
trunk/WebCore/platform/graphics/ImageSource.h
r59619 r60375 92 92 #endif 93 93 94 const int cAnimationLoopOnce = -1; 94 // Right now GIFs are the only recognized image format that supports animation. 95 // The animation system and the constants below are designed with this in mind. 96 // GIFs have an optional 16-bit unsigned loop count that describes how an 97 // animated GIF should be cycled. If the loop count is absent, the animation 98 // cycles once; if it is 0, the animation cycles infinitely; otherwise the 99 // animation plays n + 1 cycles (where n is the specified loop count). If the 100 // GIF decoder defaults to cAnimationLoopOnce in the absence of any loop count 101 // and translates an explicit "0" loop count to cAnimationLoopInfinite, then we 102 // get a couple of nice side effects: 103 // * By making cAnimationLoopOnce be 0, we allow the animation cycling code in 104 // BitmapImage.cpp to avoid special-casing it, and simply treat all 105 // non-negative loop counts identically. 106 // * By making the other two constants negative, we avoid conflicts with any 107 // real loop count values. 108 const int cAnimationLoopOnce = 0; 109 const int cAnimationLoopInfinite = -1; 95 110 const int cAnimationNone = -2; 96 111 -
trunk/WebCore/platform/graphics/cg/ImageSourceCG.cpp
r58831 r60375 203 203 return result; 204 204 205 // A property with value 0 means loop forever.206 205 RetainPtr<CFDictionaryRef> properties(AdoptCF, CGImageSourceCopyProperties(m_decoder, imageSourceOptions())); 207 206 if (properties) { … … 209 208 if (gifProperties) { 210 209 CFNumberRef num = (CFNumberRef)CFDictionaryGetValue(gifProperties, kCGImagePropertyGIFLoopCount); 211 if (num) 210 if (num) { 211 // A property with value 0 means loop forever. 212 212 CFNumberGetValue(num, kCFNumberIntType, &result); 213 if (!result) 214 result = cAnimationLoopInfinite; 215 } 213 216 } else 214 217 result = cAnimationNone; // Turns out we're not a GIF after all, so we don't animate. -
trunk/WebCore/platform/graphics/qt/ImageDecoderQt.cpp
r58744 r60375 116 116 int ImageDecoderQt::repetitionCount() const 117 117 { 118 if (m_reader && m_reader->supportsAnimation()) {118 if (m_reader && m_reader->supportsAnimation()) 119 119 m_repetitionCount = m_reader->loopCount(); 120 121 // Qt and WebCore have a incompatible understanding of122 // the loop count and we can not completely map everything.123 // Qt | WebCore | description124 // -1 | 0 | infinite animation125 // 0 | cAnimationLoopOnce | show every frame once126 // n | n+1 | Qt returns the # of iterations - 1127 // n/a | cAnimationNone | show only the first frame128 if (m_repetitionCount == -1)129 m_repetitionCount = 0;130 else if (m_repetitionCount == 0)131 m_repetitionCount = cAnimationLoopOnce;132 else133 ++m_repetitionCount;134 }135 136 120 return m_repetitionCount; 137 121 } -
trunk/WebCore/platform/image-decoders/gif/GIFImageDecoder.cpp
r58589 r60375 99 99 // the result from the reader _less_ authoritative on future calls. To 100 100 // detect this, the reader returns cLoopCountNotSeen (-2) instead of 101 // cAnimationLoopOnce ( -1) when its current incarnation hasn't actually101 // cAnimationLoopOnce (0) when its current incarnation hasn't actually 102 102 // seen a loop count yet; in this case we return our previously-cached 103 103 // value. -
trunk/WebCore/platform/image-decoders/gif/GIFImageReader.cpp
r60255 r60375 78 78 #include <string.h> 79 79 #include "GIFImageDecoder.h" 80 #include "ImageSource.h" 80 81 81 82 using WebCore::GIFImageDecoder; … … 689 690 loop_count = GETINT16(q + 1); 690 691 692 /* Zero loop count is infinite animation loop request */ 693 if (loop_count == 0) 694 loop_count = WebCore::cAnimationLoopInfinite; 695 691 696 GETN(1, gif_netscape_extension_block); 692 697 }
Note: See TracChangeset
for help on using the changeset viewer.