[go: nahoru, domu]

Reduce memory usage of FontCollection.

This is 2nd attempt at I9e01d237c9adcb05e200932401cb1a4780049f86.

The previous CL was reverted because 8-bit integers were too small to
store the indices of mFamilyVec. This CL changes it to 16-bit integers
since size_t is still unnecessary large.

Theoretically, 32-bit integers are necessary for the indices of
mFamilyVec since the size of mFamilyVec can be 0x10EE01. However, in
practice, 16-bit integers are enough for the indices of mFamilyVec.
The length of mFamilyVec for the system fonts is 2084. Even if the
developers load their own very large fonts, it can only increase the
number of elements in mFamilyVec to at most 0x10FF.

As the result, memory usage of the FontCollections for the system fonts
decreases as follows.
64-bit process: before: 398,264 bytes, after: 282,568 bytes (-115,696 bytes)
32-bit process: before: 199,132 bytes, after: 149,548 bytes (-49,584 bytes)

Bug: 33562608
Test: Verified Emoji and CJK characters are present.
Test: android.text.cts.EmojiTest passed
Test: Minikin unit tests passed
Change-Id: I6796fd55ac30fe30528a212ebf6097b1d672e2f8
2 files changed
tree: 70c7ec0a685e0886bd6459b6c41df70f0f4a933b
  1. app/
  2. doc/
  3. include/
  4. libs/
  5. tests/
  6. tools/