ImageDecoder: use kYes_ZeroInitialized memory
Bug: 183115528
Test: (A)ImageDecoderTest(s) (verify correctness)
Test: monitor showmap_pss_bytes dashboards (verify memory impact)
This lets the decoder leave zero initialized memory untouched. An
Android feature makes untouched zero initialized memory cheaper, and
BitmapFactory takes advantage of it. Do the same for ImageDecoder.
This feature was originally brought up in b/10016979. ImageDecoder saved
memory in other ways, and as I understand it, Android has shifted
towards using (Animated)VectorDrawables. Both of these may have
contributed to us not noticing when we switched from BitmapFactory to
ImageDecoder.
Change-Id: Iecfd1bbfdcc38e1f0bf380b4f4ea5b861cfcf08a
diff --git a/libs/hwui/jni/ImageDecoder.cpp b/libs/hwui/jni/ImageDecoder.cpp
index ad7741b..f7b8c01 100644
--- a/libs/hwui/jni/ImageDecoder.cpp
+++ b/libs/hwui/jni/ImageDecoder.cpp
@@ -141,7 +141,8 @@
}
const bool isNinePatch = peeker->mPatch != nullptr;
- ImageDecoder* decoder = new ImageDecoder(std::move(androidCodec), std::move(peeker));
+ ImageDecoder* decoder = new ImageDecoder(std::move(androidCodec), std::move(peeker),
+ SkCodec::kYes_ZeroInitialized);
return env->NewObject(gImageDecoder_class, gImageDecoder_constructorMethodID,
reinterpret_cast<jlong>(decoder), decoder->width(), decoder->height(),
animated, isNinePatch);