diff options
| author | Chet Haase <chet@google.com> | 2011-02-03 16:32:46 -0800 |
|---|---|---|
| committer | Chet Haase <chet@google.com> | 2011-02-03 16:33:26 -0800 |
| commit | d63cbd10765e8f48e39b07b15f0a4b70bf853ec8 (patch) | |
| tree | 8ecb0a81a06b464a270e54564e505a2bc16b39b7 /libs/hwui/DisplayListRenderer.cpp | |
| parent | 87465f02e4113542bb203232fed0c0f1f67f9a17 (diff) | |
| download | frameworks_base-d63cbd10765e8f48e39b07b15f0a4b70bf853ec8.zip frameworks_base-d63cbd10765e8f48e39b07b15f0a4b70bf853ec8.tar.gz frameworks_base-d63cbd10765e8f48e39b07b15f0a4b70bf853ec8.tar.bz2 | |
Fix leak in reused display lists
Change-Id: I32a9c41abf8f8cbcaaaa6fcc82d296800014a1b2
Diffstat (limited to 'libs/hwui/DisplayListRenderer.cpp')
| -rw-r--r-- | libs/hwui/DisplayListRenderer.cpp | 13 |
1 files changed, 11 insertions, 2 deletions
diff --git a/libs/hwui/DisplayListRenderer.cpp b/libs/hwui/DisplayListRenderer.cpp index 51c81b0..2df52ae 100644 --- a/libs/hwui/DisplayListRenderer.cpp +++ b/libs/hwui/DisplayListRenderer.cpp @@ -68,6 +68,10 @@ DisplayList::DisplayList(const DisplayListRenderer& recorder) { } DisplayList::~DisplayList() { + clearResources(); +} + +void DisplayList::clearResources() { sk_free((void*) mReader.base()); Caches& caches = Caches::getInstance(); @@ -98,7 +102,7 @@ DisplayList::~DisplayList() { mMatrices.clear(); } -void DisplayList::initFromDisplayListRenderer(const DisplayListRenderer& recorder) { +void DisplayList::initFromDisplayListRenderer(const DisplayListRenderer& recorder, bool reusing) { const SkWriter32& writer = recorder.writeStream(); init(); @@ -106,6 +110,11 @@ void DisplayList::initFromDisplayListRenderer(const DisplayListRenderer& recorde return; } + if (reusing) { + // re-using display list - clear out previous allocations + clearResources(); + } + size_t size = writer.size(); void* buffer = sk_malloc_throw(size); writer.flatten(buffer); @@ -531,7 +540,7 @@ DisplayList* DisplayListRenderer::getDisplayList() { if (mDisplayList == NULL) { mDisplayList = new DisplayList(*this); } else { - mDisplayList->initFromDisplayListRenderer(*this); + mDisplayList->initFromDisplayListRenderer(*this, true); } return mDisplayList; } |
