本文整理汇总了C++中ImageDecoder::clearCacheExceptFrame方法的典型用法代码示例。如果您正苦于以下问题:C++ ImageDecoder::clearCacheExceptFrame方法的具体用法?C++ ImageDecoder::clearCacheExceptFrame怎么用?C++ ImageDecoder::clearCacheExceptFrame使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类ImageDecoder
的用法示例。
在下文中一共展示了ImageDecoder::clearCacheExceptFrame方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: tryToResumeDecode
SkBitmap ImageFrameGenerator::tryToResumeDecode(size_t index, const SkISize& scaledSize)
{
TRACE_EVENT1("blink", "ImageFrameGenerator::tryToResumeDecode", "frame index", static_cast<int>(index));
ImageDecoder* decoder = 0;
const bool resumeDecoding = ImageDecodingStore::instance().lockDecoder(this, m_fullSize, &decoder);
ASSERT(!resumeDecoding || decoder);
SkBitmap fullSizeImage;
bool complete = decode(index, &decoder, &fullSizeImage);
if (!decoder)
return SkBitmap();
// If we are not resuming decoding that means the decoder is freshly
// created and we have ownership. If we are resuming decoding then
// the decoder is owned by ImageDecodingStore.
OwnPtr<ImageDecoder> decoderContainer;
if (!resumeDecoding)
decoderContainer = adoptPtr(decoder);
if (fullSizeImage.isNull()) {
// If decoding has failed, we can save work in the future by
// ignoring further requests to decode the image.
m_decodeFailed = decoder->failed();
if (resumeDecoding)
ImageDecodingStore::instance().unlockDecoder(this, decoder);
return SkBitmap();
}
bool removeDecoder = false;
if (complete) {
// Free as much memory as possible. For single-frame images, we can
// just delete the decoder entirely. For multi-frame images, we keep
// the decoder around in order to preserve decoded information such as
// the required previous frame indexes, but if we've reached the last
// frame we can at least delete all the cached frames. (If we were to
// do this before reaching the last frame, any subsequent requested
// frames which relied on the current frame would trigger extra
// re-decoding of all frames in the dependency chain.)
if (!m_isMultiFrame)
removeDecoder = true;
else if (index == m_frameCount - 1)
decoder->clearCacheExceptFrame(kNotFound);
}
if (resumeDecoding) {
if (removeDecoder)
ImageDecodingStore::instance().removeDecoder(this, decoder);
else
ImageDecodingStore::instance().unlockDecoder(this, decoder);
} else if (!removeDecoder) {
ImageDecodingStore::instance().insertDecoder(this, decoderContainer.release());
}
return fullSizeImage;
}