| 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 523 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 534 // the other hand, it makes animations "less accurate" for pages that try to | 534 // the other hand, it makes animations "less accurate" for pages that try to |
| 535 // sync an image and some other resource (e.g. audio), especially if users | 535 // sync an image and some other resource (e.g. audio), especially if users |
| 536 // switch tabs (and thus stop drawing the animation, which will pause it) | 536 // switch tabs (and thus stop drawing the animation, which will pause it) |
| 537 // during that initial loop, then switch back later. | 537 // during that initial loop, then switch back later. |
| 538 if (nextFrame == 0 && m_repetitionsComplete == 0 && m_desiredFrameStartTime
< time) | 538 if (nextFrame == 0 && m_repetitionsComplete == 0 && m_desiredFrameStartTime
< time) |
| 539 m_desiredFrameStartTime = time; | 539 m_desiredFrameStartTime = time; |
| 540 | 540 |
| 541 if (catchUpIfNecessary == DoNotCatchUp || time < m_desiredFrameStartTime) { | 541 if (catchUpIfNecessary == DoNotCatchUp || time < m_desiredFrameStartTime) { |
| 542 // Haven't yet reached time for next frame to start; delay until then. | 542 // Haven't yet reached time for next frame to start; delay until then. |
| 543 m_frameTimer = adoptPtr(new Timer<BitmapImage>(this, &BitmapImage::advan
ceAnimation)); | 543 m_frameTimer = adoptPtr(new Timer<BitmapImage>(this, &BitmapImage::advan
ceAnimation)); |
| 544 m_frameTimer->startOneShot(std::max(m_desiredFrameStartTime - time, 0.),
FROM_HERE); | 544 m_frameTimer->startOneShot(std::max(m_desiredFrameStartTime - time, 0.),
BLINK_FROM_HERE); |
| 545 } else { | 545 } else { |
| 546 // We've already reached or passed the time for the next frame to start. | 546 // We've already reached or passed the time for the next frame to start. |
| 547 // See if we've also passed the time for frames after that to start, in | 547 // See if we've also passed the time for frames after that to start, in |
| 548 // case we need to skip some frames entirely. Remember not to advance | 548 // case we need to skip some frames entirely. Remember not to advance |
| 549 // to an incomplete frame. | 549 // to an incomplete frame. |
| 550 for (size_t frameAfterNext = (nextFrame + 1) % frameCount(); frameIsComp
leteAtIndex(frameAfterNext); frameAfterNext = (nextFrame + 1) % frameCount()) { | 550 for (size_t frameAfterNext = (nextFrame + 1) % frameCount(); frameIsComp
leteAtIndex(frameAfterNext); frameAfterNext = (nextFrame + 1) % frameCount()) { |
| 551 // Should we skip the next frame? | 551 // Should we skip the next frame? |
| 552 double frameAfterNextStartTime = m_desiredFrameStartTime + frameDura
tionAtIndex(nextFrame); | 552 double frameAfterNextStartTime = m_desiredFrameStartTime + frameDura
tionAtIndex(nextFrame); |
| 553 if (time < frameAfterNextStartTime) | 553 if (time < frameAfterNextStartTime) |
| 554 break; | 554 break; |
| (...skipping 108 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 663 destroyDecodedDataIfNecessary(); | 663 destroyDecodedDataIfNecessary(); |
| 664 | 664 |
| 665 // 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 |
| 666 // 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. |
| 667 if (skippingFrames != advancedAnimation) | 667 if (skippingFrames != advancedAnimation) |
| 668 imageObserver()->animationAdvanced(this); | 668 imageObserver()->animationAdvanced(this); |
| 669 return advancedAnimation; | 669 return advancedAnimation; |
| 670 } | 670 } |
| 671 | 671 |
| 672 } // namespace blink | 672 } // namespace blink |
| OLD | NEW |