When I read Android source code SkiaRecordingCanvas
, I found that if a bitmap is marked as mutable, namely !isImmutable() == true
, the bitmap will be cached in GPU by function SkiaPipeline::pinImages
which calls the skia interface SKImage_pinAsTexture
. But after I commented these lines in pinImages
and re-compiled and pushed to the phone, I found the gifs displayed normally. The only difference is that the texture uploading is delayed from prepareTree
to renderFrameImpl
. So, why does Android use this method to cache the textures of mutable bitmaps?
bool SkiaPipeline::pinImages(std::vector<SkImage*>& mutableImages) {
// for (SkImage* image : mutableImages) {
// if (SkImage_pinAsTexture(image, mRenderThread.getGrContext())) {
// mPinnedImages.emplace_back(sk_ref_sp(image));
// } else {
// return false;
// }
// }
return true;
}