Commit e59cdf30 authored by Maurice Lam's avatar Maurice Lam
Browse files

Share GlifPatternDrawable bitmap cache

Reduce memory usage of GlifPatternDrawable by
- Setting max bitmap cache scale to 1.5x (similar to
  VectorDrawableCompat, which caps at 2048px)
- Use ALPHA_8 mask instead of ARGB8888
- Share the cache across all pattern drawables, using a SoftReference

The memory allocation of a single bitmap cache, measured on Pixel C,
dropped from 17MB to 2.3MB.

Memory consumption was measured in Android studio.
    1. Open SetupLibrarySample app in Android Studio
    2. Run app
    3. Open "Android Monitor" tab, and go to Monitors tab
    4. Press "Trigger GC" in Studio
    5. Press "Start Allocation Tracking"
    6. Start a new activity in the test app
    7. press "Stop Allocation Tracking"

Test: ./gradlew connectedAndroidTest
Bug: 30813561
Change-Id: Ic78d6f2bdfa6a18a7dd2afc73f9647e2a7ed4cf1
(cherry picked from commit 515c0b15)
parent 8695624c
Loading
Loading
Loading
Loading
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please to comment