OSDN Git Service

Clear native shader when Paint shader changes
authorJohn Reck <jreck@google.com>
Tue, 6 Jun 2017 19:14:04 +0000 (12:14 -0700)
committerandroid-build-team Robot <android-build-team-robot@google.com>
Wed, 7 Jun 2017 20:11:33 +0000 (20:11 +0000)
commit1d0a954c8d71c5079609ad9152222f01e563a528
tree1b0f60b5ec08e49bac12de089b39853b935236bc
parentd9f1c9c7f2449c09b089fd7fefb1833a88322ab2
Clear native shader when Paint shader changes

Since Recents never goes away that means TaskViewThumbnail
never goes away which in turn means mDrawPaint never goes away.

mDrawPaint has a setShader(null) called on it to release
the BitmapShader it was previously drawn with, but that
change didn't push down to native until the next time the
paint was used. As a result, the Paint held on to a
reference to the bitmap.

The fix is simple, when the shader is changed simply
push down an immediate clear of the native shader. Since
the bitmap of a BitmapShader isn't changeable we don't
need to worry about clearing references for shader mutation,
merely when Paint#setShader() happens.

Bug: 38258699
Test: Open & close recents, observe EGL memory immediately returns
to sub-5MB.

Change-Id: I6742efa8ae8dfca76b62a06bc1a1a00646feba64
(cherry picked from commit fbff7117abac7a335c6bc2e2f8b927a8dac5753e)
graphics/java/android/graphics/Paint.java