bool preMultiplyOnLoad)
: ImageCache(textureManager, size, fittingMode, samplingMode, maskingData, observer, batchSize, interval, preMultiplyOnLoad),
mImageUrls(urlList),
- mFront(FIRST_FRAME_INDEX)
+ mCurrentFrameIndex(FIRST_FRAME_INDEX)
{
mReadyFlags.reserve(mImageUrls.size());
}
}
while(mReadyFlags.size() < mImageUrls.size() &&
- (frameIndex > mFront || mReadyFlags.empty()))
+ (frameIndex > mCurrentFrameIndex || mReadyFlags.empty()))
{
- ++mFront;
+ ++mCurrentFrameIndex;
LoadBatch();
}
- mFront = frameIndex;
+ mCurrentFrameIndex = frameIndex;
- if(IsFrontReady() && mLoadState != TextureManager::LoadState::LOAD_FAILED)
+ if(IsFrameReady(mCurrentFrameIndex) && mLoadState != TextureManager::LoadState::LOAD_FAILED)
{
- textureSet = GetFrontTextureSet();
+ textureSet = GetTextureSet(mCurrentFrameIndex);
}
return textureSet;
int32_t FixedImageCache::GetCurrentFrameIndex() const
{
- return static_cast<int32_t>(mFront);
+ return static_cast<int32_t>(mCurrentFrameIndex);
}
int32_t FixedImageCache::GetTotalFrameCount() const
return mImageUrls.size();
}
-bool FixedImageCache::IsFrontReady() const
+bool FixedImageCache::IsFrameReady(uint32_t frameIndex) const
{
- return (mReadyFlags.size() > 0 && mReadyFlags[mFront] == true);
+ return (mReadyFlags.size() > 0 && mReadyFlags[frameIndex] == true);
}
void FixedImageCache::LoadBatch()
}
}
-TextureSet FixedImageCache::GetFrontTextureSet() const
+TextureSet FixedImageCache::GetTextureSet(uint32_t frameIndex) const
{
- TextureSet textureSet = mTextureManager.GetTextureSet(mImageUrls[mFront].mTextureId);
+ TextureSet textureSet = mTextureManager.GetTextureSet(mImageUrls[frameIndex].mTextureId);
if(textureSet)
{
Sampler sampler = Sampler::New();
return textureSet;
}
-void FixedImageCache::CheckFrontFrame(bool wasReady, bool preMultiplied)
+void FixedImageCache::MakeReady(bool wasReady, uint32_t frameIndex, bool preMultiplied)
{
- if(wasReady == false && IsFrontReady())
+ if(wasReady == false && IsFrameReady(frameIndex))
{
- mObserver.FrameReady(GetFrontTextureSet(), mInterval, preMultiplied);
+ mObserver.FrameReady(GetTextureSet(frameIndex), mInterval, preMultiplied);
}
}
if(loadSuccess)
{
mLoadState = TextureManager::LoadState::LOAD_FINISHED;
- bool frontFrameReady = IsFrontReady();
+ bool isCurrentFrameReady = IsFrameReady(mCurrentFrameIndex);
if(!mRequestingLoad)
{
for(std::size_t i = 0; i < mImageUrls.size(); ++i)
{
mReadyFlags.back() = true;
}
- CheckFrontFrame(frontFrameReady, textureInformation.preMultiplied);
+ MakeReady(isCurrentFrameReady, mCurrentFrameIndex, textureInformation.preMultiplied);
}
else
{
private:
/**
- * @brief Check whether the front frame is ready or not.
+ * @brief Check whether the frame is ready or not.
+ * @param[in] frameIndex The frame index to check the frame is ready or not.
*
- * @return true if the front frame is ready
+ * @return true if the frame is ready
*/
- bool IsFrontReady() const;
+ bool IsFrameReady(uint32_t frameIndex) const;
/**
* @brief Load the next batch of images
void LoadBatch();
/**
- * @brief Get the texture set of the front frame.
+ * @brief Get the texture set at the input frame index
+ * @param[in] frameIndex The frame index to retrieve texture set.
*
* @return the texture set of the front of Cache.
*/
- TextureSet GetFrontTextureSet() const;
+ TextureSet GetTextureSet(uint32_t frameIndex) const;
/**
* @brief Check if the front frame has become ready - if so, inform observer
*
* @param[in] wasReady Readiness before call.
+ * @param[in] frameIndex The frame index for this frame
* @param[in] preMultiplied whether the texture is premultied alpha or not.
*/
- void CheckFrontFrame(bool wasReady, bool preMultiplied);
+ void MakeReady(bool wasReady, uint32_t frameIndex, bool preMultiplied);
protected:
/**
std::vector<UrlStore>& mImageUrls;
std::vector<bool> mReadyFlags;
std::vector<TextureManager::LoadState> mLoadStates;
- uint32_t mFront;
+ uint32_t mCurrentFrameIndex;
};
} //namespace Internal