bool SkGIFMovie::onGetInfo(Info* info) { if (NULL == fGIF) return false; SkMSec dur = 0; for (int i = 0; i < fGIF->ImageCount; i++) dur += savedimage_duration(&fGIF->SavedImages[i]); info->fDuration = dur; info->fWidth = fGIF->SWidth; info->fHeight = fGIF->SHeight; info->fIsOpaque = false; // how to compute? return true; }
bool SkGIFMovie::onSetTime(SkMSec time) { if (NULL == fGIF) return false; SkMSec dur = 0; for (int i = 0; i < fGIF->ImageCount; i++) { dur += savedimage_duration(&fGIF->SavedImages[i]); if (dur >= time) { fCurrIndex = i; return fLastDrawIndex != fCurrIndex; } } fCurrIndex = fGIF->ImageCount - 1; return true; }
GifFrame GIFMovie::getGifFrameByIndex(unsigned int frameIndex) { GifFrame gif; if(fGIF == NULL || frameIndex > getGifCount()) { return gif; } int duration = savedimage_duration(&fGIF->SavedImages[frameIndex]); fCurrIndex = frameIndex; onGetBitmap(&m_bitmap); gif.m_frameData.m_duration = duration; gif.m_frameData.m_index = frameIndex; gif.m_bm = &m_bitmap; return gif; }