| 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 447 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 458 // the other hand, it makes animations "less accurate" for pages that try to | 458 // the other hand, it makes animations "less accurate" for pages that try to |
| 459 // sync an image and some other resource (e.g. audio), especially if users | 459 // sync an image and some other resource (e.g. audio), especially if users |
| 460 // switch tabs (and thus stop drawing the animation, which will pause it) | 460 // switch tabs (and thus stop drawing the animation, which will pause it) |
| 461 // during that initial loop, then switch back later. | 461 // during that initial loop, then switch back later. |
| 462 if (nextFrame == 0 && m_repetitionsComplete == 0 && m_desiredFrameStartTime
< time) | 462 if (nextFrame == 0 && m_repetitionsComplete == 0 && m_desiredFrameStartTime
< time) |
| 463 m_desiredFrameStartTime = time; | 463 m_desiredFrameStartTime = time; |
| 464 | 464 |
| 465 if (!catchUpIfNecessary || time < m_desiredFrameStartTime) { | 465 if (!catchUpIfNecessary || time < m_desiredFrameStartTime) { |
| 466 // Haven't yet reached time for next frame to start; delay until then. | 466 // Haven't yet reached time for next frame to start; delay until then. |
| 467 m_frameTimer = new Timer<BitmapImage>(this, &BitmapImage::advanceAnimati
on); | 467 m_frameTimer = new Timer<BitmapImage>(this, &BitmapImage::advanceAnimati
on); |
| 468 m_frameTimer->startOneShot(std::max(m_desiredFrameStartTime - time, 0.))
; | 468 m_frameTimer->startOneShot(std::max(m_desiredFrameStartTime - time, 0.),
FROM_HERE); |
| 469 } else { | 469 } else { |
| 470 // We've already reached or passed the time for the next frame to start. | 470 // We've already reached or passed the time for the next frame to start. |
| 471 // See if we've also passed the time for frames after that to start, in | 471 // See if we've also passed the time for frames after that to start, in |
| 472 // case we need to skip some frames entirely. Remember not to advance | 472 // case we need to skip some frames entirely. Remember not to advance |
| 473 // to an incomplete frame. | 473 // to an incomplete frame. |
| 474 for (size_t frameAfterNext = (nextFrame + 1) % frameCount(); frameIsComp
leteAtIndex(frameAfterNext); frameAfterNext = (nextFrame + 1) % frameCount()) { | 474 for (size_t frameAfterNext = (nextFrame + 1) % frameCount(); frameIsComp
leteAtIndex(frameAfterNext); frameAfterNext = (nextFrame + 1) % frameCount()) { |
| 475 // Should we skip the next frame? | 475 // Should we skip the next frame? |
| 476 double frameAfterNextStartTime = m_desiredFrameStartTime + frameDura
tionAtIndex(nextFrame); | 476 double frameAfterNextStartTime = m_desiredFrameStartTime + frameDura
tionAtIndex(nextFrame); |
| 477 if (time < frameAfterNextStartTime) | 477 if (time < frameAfterNextStartTime) |
| 478 break; | 478 break; |
| (...skipping 124 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 603 } | 603 } |
| 604 return m_isSolidColor && !m_currentFrame; | 604 return m_isSolidColor && !m_currentFrame; |
| 605 } | 605 } |
| 606 | 606 |
| 607 Color BitmapImage::solidColor() const | 607 Color BitmapImage::solidColor() const |
| 608 { | 608 { |
| 609 return m_solidColor; | 609 return m_solidColor; |
| 610 } | 610 } |
| 611 | 611 |
| 612 } | 612 } |
| OLD | NEW |