This is a part of my code.
The codec->getImage method is slow.
It take more than 100 milliseconds (more than fDuration time).
This makes my gif animation look slow.
I know
codec->getImage requires copying frame data.
But If I copy the frame data into memory before rendering.
A gif of around 3M consumes 1G of memory.
Is there a way to play gif smoothly without consuming too much memory and CPU resources? Just like Google Chrome.
What should I do?
Thanks very much.
```c++
auto skData = SkData::MakeFromFileName(path.c_str());
std::unique_ptr<SkCodec> codec = SkCodec::MakeFromData(skData);
auto imageInfo = codec->getInfo();
auto frameCount = codec->getFrameCount();
SkCodec::Options option;
auto frameInfo = codec->getFrameInfo();
while (running)
{
option.fFrameIndex = currentFrameIndex;
auto result = codec->getImage(imageInfo, &option);
currentFrameImage = std::get<0>(result);
auto span = frameInfo[currentFrameIndex].fDuration;
std::this_thread::sleep_for(std::chrono::milliseconds(span));
if (currentFrameIndex >= frameCount-1)
{
currentFrameIndex = 0;
}
else
{
currentFrameIndex += 1;
}
}
```