OSDN Git Service

Decouple GLES20RecordingCanvas lifetime from GLES20DisplayList.
authorJeff Brown <jeffbrown@google.com>
Fri, 22 Jul 2011 00:02:54 +0000 (17:02 -0700)
committerJeff Brown <jeffbrown@google.com>
Fri, 22 Jul 2011 00:15:48 +0000 (17:15 -0700)
commit162a0217563f4665da6eb183dfce0fef740f641f
treeee9130762f9873df9118dfd05b1f4f8987feb406
parentac1fe6f8460448d379721677a064868e103a2260
Decouple GLES20RecordingCanvas lifetime from GLES20DisplayList.
Bug: 5062011

Previously, each GLES20DisplayList would hold onto an instance of
GLES20RecordingCanvas.  In turn, each GLES20RecordingCanvas
held onto an SkWriter with a 16Kb buffer along with several other
objects.  With one display list per view and hundreds of views,
the overhead could add up to a few megabytes.

Ensured that the GLES20RecordingCanvas is reset as soon as
the display list has been constructed, thereby promptly freeing
the 16Kb buffer.

Changed GLES20DisplayList so that it acquires a GLES20RecordingCanvas
from a pool as needed and recycles it when done.

Removed some dead code and cruft related to the construction of
GLES20Canvas objects in general.  Some code was written with the
assumption that the underlying renderer object could change
behind the scenes or might be lazily constructed, but that isn't
actually the case so we can simplify things.

Removed an unnecessary weak reference from GLES20DisplayList
to the View.  It isn't actually used anywhere.

Fixed a bug in GLES20DisplayList where isValid() would return
true while the display list was being recorded.  This is incorrect
because the native display list might not actually exist.  Worse,
even if the native display list does exist, it is stale and
potentially refers to old Bitmaps that have been GC'd (because the
mBitmaps list was cleared when recording started).

Change-Id: Ib12d5483688cb253478edeb0156d34c476c2566b
core/java/android/view/DisplayList.java
core/java/android/view/GLES20Canvas.java
core/java/android/view/GLES20DisplayList.java
core/java/android/view/GLES20RecordingCanvas.java
core/java/android/view/HardwareRenderer.java
core/java/android/view/View.java
core/jni/android_view_GLES20Canvas.cpp
libs/hwui/DisplayListRenderer.cpp
libs/hwui/DisplayListRenderer.h