OLD | NEW |
---|---|
1 /* | 1 /* |
2 * Copyright (C) 2006 Samuel Weinig (sam.weinig@gmail.com) | 2 * Copyright (C) 2006 Samuel Weinig (sam.weinig@gmail.com) |
3 * Copyright (C) 2004, 2005, 2006, 2008 Apple Inc. All rights reserved. | 3 * Copyright (C) 2004, 2005, 2006, 2008 Apple Inc. All rights reserved. |
4 * | 4 * |
5 * Redistribution and use in source and binary forms, with or without | 5 * Redistribution and use in source and binary forms, with or without |
6 * modification, are permitted provided that the following conditions | 6 * modification, are permitted provided that the following conditions |
7 * are met: | 7 * are met: |
8 * 1. Redistributions of source code must retain the above copyright | 8 * 1. Redistributions of source code must retain the above copyright |
9 * notice, this list of conditions and the following disclaimer. | 9 * notice, this list of conditions and the following disclaimer. |
10 * 2. Redistributions in binary form must reproduce the above copyright | 10 * 2. Redistributions in binary form must reproduce the above copyright |
(...skipping 128 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
139 | 139 |
140 void BitmapImage::destroyDecodedDataIfNecessary() | 140 void BitmapImage::destroyDecodedDataIfNecessary() |
141 { | 141 { |
142 // Animated images >5MB are considered large enough that we'll only hang on | 142 // Animated images >5MB are considered large enough that we'll only hang on |
143 // to one frame at a time. | 143 // to one frame at a time. |
144 static const size_t cLargeAnimationCutoff = 5242880; | 144 static const size_t cLargeAnimationCutoff = 5242880; |
145 size_t allFrameBytes = 0; | 145 size_t allFrameBytes = 0; |
146 for (size_t i = 0; i < m_frames.size(); ++i) | 146 for (size_t i = 0; i < m_frames.size(); ++i) |
147 allFrameBytes += m_frames[i].m_frameBytes; | 147 allFrameBytes += m_frames[i].m_frameBytes; |
148 | 148 |
149 if (allFrameBytes > cLargeAnimationCutoff) | 149 if (allFrameBytes > cLargeAnimationCutoff) { |
150 destroyDecodedData(false); | 150 destroyDecodedData(false); |
151 } | |
151 } | 152 } |
152 | 153 |
153 void BitmapImage::destroyMetadataAndNotify(size_t frameBytesCleared) | 154 void BitmapImage::destroyMetadataAndNotify(size_t frameBytesCleared) |
154 { | 155 { |
155 m_isSolidColor = false; | 156 m_isSolidColor = false; |
156 m_checkedForSolidColor = false; | 157 m_checkedForSolidColor = false; |
157 | 158 |
158 if (frameBytesCleared && imageObserver()) | 159 if (frameBytesCleared && imageObserver()) |
159 imageObserver()->decodedSizeChanged(this, -safeCast<int>(frameBytesClear ed)); | 160 imageObserver()->decodedSizeChanged(this, -safeCast<int>(frameBytesClear ed)); |
160 } | 161 } |
(...skipping 143 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
304 } | 305 } |
305 | 306 |
306 image->draw(ctxt, normSrcRect, normDstRect, compositeOp); | 307 image->draw(ctxt, normSrcRect, normDstRect, compositeOp); |
307 | 308 |
308 if (ImageObserver* observer = imageObserver()) | 309 if (ImageObserver* observer = imageObserver()) |
309 observer->didDraw(this); | 310 observer->didDraw(this); |
310 | 311 |
311 startAnimation(); | 312 startAnimation(); |
312 } | 313 } |
313 | 314 |
314 void BitmapImage::resetDecoder() | |
315 { | |
316 ASSERT(isMainThread()); | |
317 | |
318 m_source.resetDecoder(); | |
319 } | |
320 | |
321 size_t BitmapImage::frameCount() | 315 size_t BitmapImage::frameCount() |
322 { | 316 { |
323 if (!m_haveFrameCount) { | 317 if (!m_haveFrameCount) { |
324 m_frameCount = m_source.frameCount(); | 318 m_frameCount = m_source.frameCount(); |
325 // If decoder is not initialized yet, m_source.frameCount() returns 0. | 319 // If decoder is not initialized yet, m_source.frameCount() returns 0. |
326 if (m_frameCount) | 320 if (m_frameCount) |
327 m_haveFrameCount = true; | 321 m_haveFrameCount = true; |
328 } | 322 } |
329 | 323 |
330 return m_frameCount; | 324 return m_frameCount; |
(...skipping 265 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
596 | 590 |
597 ++m_currentFrame; | 591 ++m_currentFrame; |
598 bool advancedAnimation = true; | 592 bool advancedAnimation = true; |
599 if (m_currentFrame >= frameCount()) { | 593 if (m_currentFrame >= frameCount()) { |
600 ++m_repetitionsComplete; | 594 ++m_repetitionsComplete; |
601 | 595 |
602 // Get the repetition count again. If we weren't able to get a | 596 // Get the repetition count again. If we weren't able to get a |
603 // repetition count before, we should have decoded the whole image by | 597 // repetition count before, we should have decoded the whole image by |
604 // now, so it should now be available. | 598 // now, so it should now be available. |
605 // Note that we don't need to special-case cAnimationLoopOnce here | 599 // Note that we don't need to special-case cAnimationLoopOnce here |
606 // because it is 0 (see comments on its declaration in ImageSource.h). | 600 // because it is 0 (see comments on its declaration in ImageDecoder.h). |
Stephen White
2015/03/13 20:21:41
ImageDecoder.h -> ImageAnimation.h
| |
607 if ((repetitionCount(true) != cAnimationLoopInfinite && m_repetitionsCom plete > m_repetitionCount) | 601 if ((repetitionCount(true) != cAnimationLoopInfinite && m_repetitionsCom plete > m_repetitionCount) |
608 || (m_animationPolicy == ImageAnimationPolicyAnimateOnce && m_repeti tionsComplete > 0)) { | 602 || (m_animationPolicy == ImageAnimationPolicyAnimateOnce && m_repeti tionsComplete > 0)) { |
609 m_animationFinished = true; | 603 m_animationFinished = true; |
610 m_desiredFrameStartTime = 0; | 604 m_desiredFrameStartTime = 0; |
611 --m_currentFrame; | 605 --m_currentFrame; |
612 advancedAnimation = false; | 606 advancedAnimation = false; |
613 } else | 607 } else |
614 m_currentFrame = 0; | 608 m_currentFrame = 0; |
615 } | 609 } |
616 destroyDecodedDataIfNecessary(); | 610 destroyDecodedDataIfNecessary(); |
(...skipping 34 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
651 | 645 |
652 return m_isSolidColor && !m_currentFrame; | 646 return m_isSolidColor && !m_currentFrame; |
653 } | 647 } |
654 | 648 |
655 Color BitmapImage::solidColor() const | 649 Color BitmapImage::solidColor() const |
656 { | 650 { |
657 return m_solidColor; | 651 return m_solidColor; |
658 } | 652 } |
659 | 653 |
660 } // namespace blink | 654 } // namespace blink |
OLD | NEW |