| 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 154 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 165 // We are caching frame snapshots. This is OK even for partially decoded fr
ames, | 165 // We are caching frame snapshots. This is OK even for partially decoded fr
ames, |
| 166 // as they are cleared by dataChanged() when new data arrives. | 166 // as they are cleared by dataChanged() when new data arrives. |
| 167 m_frames[index].m_frame = m_source.createFrameAtIndex(index); | 167 m_frames[index].m_frame = m_source.createFrameAtIndex(index); |
| 168 | 168 |
| 169 m_frames[index].m_orientation = m_source.orientationAtIndex(index); | 169 m_frames[index].m_orientation = m_source.orientationAtIndex(index); |
| 170 m_frames[index].m_haveMetadata = true; | 170 m_frames[index].m_haveMetadata = true; |
| 171 m_frames[index].m_isComplete = m_source.frameIsCompleteAtIndex(index); | 171 m_frames[index].m_isComplete = m_source.frameIsCompleteAtIndex(index); |
| 172 if (repetitionCount(false) != cAnimationNone) | 172 if (repetitionCount(false) != cAnimationNone) |
| 173 m_frames[index].m_duration = m_source.frameDurationAtIndex(index); | 173 m_frames[index].m_duration = m_source.frameDurationAtIndex(index); |
| 174 m_frames[index].m_hasAlpha = m_source.frameHasAlphaAtIndex(index); | 174 m_frames[index].m_hasAlpha = m_source.frameHasAlphaAtIndex(index); |
| 175 m_frames[index].m_isLazyDecoded = m_source.frameIsLazyDecodedAtIndex(index); | |
| 176 m_frames[index].m_frameBytes = m_source.frameBytesAtIndex(index); | 175 m_frames[index].m_frameBytes = m_source.frameBytesAtIndex(index); |
| 177 | 176 |
| 178 const IntSize frameSize(index ? m_source.frameSizeAtIndex(index) : m_size); | 177 const IntSize frameSize(index ? m_source.frameSizeAtIndex(index) : m_size); |
| 179 if (frameSize != m_size) | 178 if (frameSize != m_size) |
| 180 m_hasUniformFrameSize = false; | 179 m_hasUniformFrameSize = false; |
| 181 | 180 |
| 182 // We need to check the total bytes before and after the decode call, not | 181 // We need to check the total bytes before and after the decode call, not |
| 183 // just the current frame size, because some multi-frame images may require | 182 // just the current frame size, because some multi-frame images may require |
| 184 // decoding multiple frames to decode the current frame. | 183 // decoding multiple frames to decode the current frame. |
| 185 deltaBytes = totalFrameBytes() - deltaBytes; | 184 deltaBytes = totalFrameBytes() - deltaBytes; |
| (...skipping 255 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 441 return !frameHasAlphaAtIndex(currentFrame()); | 440 return !frameHasAlphaAtIndex(currentFrame()); |
| 442 } | 441 } |
| 443 | 442 |
| 444 bool BitmapImage::currentFrameIsComplete() | 443 bool BitmapImage::currentFrameIsComplete() |
| 445 { | 444 { |
| 446 return frameIsCompleteAtIndex(currentFrame()); | 445 return frameIsCompleteAtIndex(currentFrame()); |
| 447 } | 446 } |
| 448 | 447 |
| 449 bool BitmapImage::currentFrameIsLazyDecoded() | 448 bool BitmapImage::currentFrameIsLazyDecoded() |
| 450 { | 449 { |
| 451 return ensureFrameIsCached(currentFrame()) && frameIsLazyDecodedAtIndex(curr
entFrame()); | 450 RefPtr<SkImage> image = frameAtIndex(currentFrame()); |
| 451 return image && image->isLazyGenerated(); |
| 452 } | 452 } |
| 453 | 453 |
| 454 ImageOrientation BitmapImage::currentFrameOrientation() | 454 ImageOrientation BitmapImage::currentFrameOrientation() |
| 455 { | 455 { |
| 456 return frameOrientationAtIndex(currentFrame()); | 456 return frameOrientationAtIndex(currentFrame()); |
| 457 } | 457 } |
| 458 | 458 |
| 459 ImageOrientation BitmapImage::frameOrientationAtIndex(size_t index) | 459 ImageOrientation BitmapImage::frameOrientationAtIndex(size_t index) |
| 460 { | 460 { |
| 461 if (m_frames.size() <= index) | 461 if (m_frames.size() <= index) |
| 462 return DefaultImageOrientation; | 462 return DefaultImageOrientation; |
| 463 | 463 |
| 464 if (m_frames[index].m_haveMetadata) | 464 if (m_frames[index].m_haveMetadata) |
| 465 return m_frames[index].m_orientation; | 465 return m_frames[index].m_orientation; |
| 466 | 466 |
| 467 return m_source.orientationAtIndex(index); | 467 return m_source.orientationAtIndex(index); |
| 468 } | 468 } |
| 469 | 469 |
| 470 bool BitmapImage::frameIsLazyDecodedAtIndex(size_t index) const | |
| 471 { | |
| 472 if (m_frames.size() <= index) | |
| 473 return false; | |
| 474 | |
| 475 if (m_frames[index].m_haveMetadata) | |
| 476 return m_frames[index].m_isLazyDecoded; | |
| 477 | |
| 478 return m_source.frameIsLazyDecodedAtIndex(index); | |
| 479 } | |
| 480 | |
| 481 int BitmapImage::repetitionCount(bool imageKnownToBeComplete) | 470 int BitmapImage::repetitionCount(bool imageKnownToBeComplete) |
| 482 { | 471 { |
| 483 if ((m_repetitionCountStatus == Unknown) || ((m_repetitionCountStatus == Unc
ertain) && imageKnownToBeComplete)) { | 472 if ((m_repetitionCountStatus == Unknown) || ((m_repetitionCountStatus == Unc
ertain) && imageKnownToBeComplete)) { |
| 484 // Snag the repetition count. If |imageKnownToBeComplete| is false, the | 473 // Snag the repetition count. If |imageKnownToBeComplete| is false, the |
| 485 // repetition count may not be accurate yet for GIFs; in this case the | 474 // repetition count may not be accurate yet for GIFs; in this case the |
| 486 // decoder will default to cAnimationLoopOnce, and we'll try and read | 475 // decoder will default to cAnimationLoopOnce, and we'll try and read |
| 487 // the count again once the whole image is decoded. | 476 // the count again once the whole image is decoded. |
| 488 m_repetitionCount = m_source.repetitionCount(); | 477 m_repetitionCount = m_source.repetitionCount(); |
| 489 m_repetitionCountStatus = (imageKnownToBeComplete || m_repetitionCount =
= cAnimationNone) ? Certain : Uncertain; | 478 m_repetitionCountStatus = (imageKnownToBeComplete || m_repetitionCount =
= cAnimationNone) ? Certain : Uncertain; |
| 490 } | 479 } |
| (...skipping 183 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 674 destroyDecodedDataIfNecessary(); | 663 destroyDecodedDataIfNecessary(); |
| 675 | 664 |
| 676 // We need to draw this frame if we advanced to it while not skipping, or if | 665 // We need to draw this frame if we advanced to it while not skipping, or if |
| 677 // while trying to skip frames we hit the last frame and thus had to stop. | 666 // while trying to skip frames we hit the last frame and thus had to stop. |
| 678 if (skippingFrames != advancedAnimation) | 667 if (skippingFrames != advancedAnimation) |
| 679 imageObserver()->animationAdvanced(this); | 668 imageObserver()->animationAdvanced(this); |
| 680 return advancedAnimation; | 669 return advancedAnimation; |
| 681 } | 670 } |
| 682 | 671 |
| 683 } // namespace blink | 672 } // namespace blink |
| OLD | NEW |