diff options
author | Lloyd Pique <lpique@google.com> | 2018-11-02 15:35:50 -0700 |
---|---|---|
committer | Lloyd Pique <lpique@google.com> | 2018-11-02 23:08:08 +0000 |
commit | 79d6d0c1d02e319f89645e509dc7eb1bf07af8b6 (patch) | |
tree | 7b81eac6009002d62a1b0d130669de929eb34e73 /graphics | |
parent | 7304f95d9ecc37bca47b67ba0545e20e2e9b70c6 (diff) | |
download | platform_hardware_interfaces-79d6d0c1d02e319f89645e509dc7eb1bf07af8b6.tar.gz platform_hardware_interfaces-79d6d0c1d02e319f89645e509dc7eb1bf07af8b6.tar.bz2 platform_hardware_interfaces-79d6d0c1d02e319f89645e509dc7eb1bf07af8b6.zip |
graphics: Base resource classes need virtual dtor
ComposerResources allows a derived class to define specializations of
the ComposerDisplayResource and ComposerLayerResource classes, which are
returned by overrides of the createDisplayResources() and
createLayerResources() member functions. The pointers are wrapped using
a std::unique_ptr, which destroys the owned instance via the base class
destructor.
As the destructor was not virtual, this meant that only the base class
destructor functionality would be used. Any additional cleanup done by
the derived class destructor would not be run!
This impacts the composer-hal 2.2 utility code for example, which adds a
readback buffer cache as a display resource. Any readback buffers that
are imported there will not be released, effectively leaking graphic
buffer memory.
It also affected an ARC++ specialization where a similar per-layer buffer
resource cache was added, and where the leak was observable since layers
are created and destroyed much more often than displays.
Bug: 117877825
Test: No leaks for ARC++ devices
Change-Id: I6e604b415d3ed787c2e51729a77278594e41e7a9
Diffstat (limited to 'graphics')
-rw-r--r-- | graphics/composer/2.1/utils/hal/include/composer-hal/2.1/ComposerResources.h | 4 |
1 files changed, 4 insertions, 0 deletions
diff --git a/graphics/composer/2.1/utils/hal/include/composer-hal/2.1/ComposerResources.h b/graphics/composer/2.1/utils/hal/include/composer-hal/2.1/ComposerResources.h index 2cbf044604..f249f1ada7 100644 --- a/graphics/composer/2.1/utils/hal/include/composer-hal/2.1/ComposerResources.h +++ b/graphics/composer/2.1/utils/hal/include/composer-hal/2.1/ComposerResources.h @@ -186,6 +186,8 @@ class ComposerLayerResource { : mBufferCache(importer, ComposerHandleCache::HandleType::BUFFER, bufferCacheSize), mSidebandStreamCache(importer, ComposerHandleCache::HandleType::STREAM, 1) {} + virtual ~ComposerLayerResource() = default; + Error getBuffer(uint32_t slot, bool fromCache, const native_handle_t* inHandle, const native_handle_t** outHandle, const native_handle** outReplacedHandle) { return mBufferCache.getHandle(slot, fromCache, inHandle, outHandle, outReplacedHandle); @@ -211,6 +213,8 @@ class ComposerDisplayResource { VIRTUAL, }; + virtual ~ComposerDisplayResource() = default; + ComposerDisplayResource(DisplayType type, ComposerHandleImporter& importer, uint32_t outputBufferCacheSize) : mType(type), |