display: Use ion cookie in GPU Tonemapper
- The fd's used for book-keeping can change when the clients
close and reopen sessions, hence they are not reliable and
can lead to incorrect virtual address usage causing
corruption or stale data.
- Hence use ion cookie for book-keeping which is unique for a
given memory fd.
- Use LRU method free up/reuse on reaching max limit.
- Remove Tonemapper_destroy which is not needed anymore.
Change-Id: I5777649b34210977c18ce20c65e0aa2baa8e7d26
Crs-fixed: 1110175
diff --git a/gpu_tonemapper/EGLImageWrapper.h b/gpu_tonemapper/EGLImageWrapper.h
index 90aaf58..e9a4d68 100644
--- a/gpu_tonemapper/EGLImageWrapper.h
+++ b/gpu_tonemapper/EGLImageWrapper.h
@@ -20,15 +20,28 @@
#ifndef __TONEMAPPER_EGLIMAGEWRAPPER_H__
#define __TONEMAPPER_EGLIMAGEWRAPPER_H__
-#include <map>
+#include <utils/LruCache.h>
#include "EGLImageBuffer.h"
class EGLImageWrapper {
- std::map<int, EGLImageBuffer *> eglImageBufferMap;
+ private:
+ class DeleteEGLImageCallback : public android::OnEntryRemoved<int, EGLImageBuffer*>
+ {
+ private:
+ int ion_fd;
+ public:
+ DeleteEGLImageCallback(int ion_fd);
+ void operator()(int& ion_cookie, EGLImageBuffer*& eglImage);
+ };
- public:
- EGLImageBuffer *wrap(const void *pvt_handle);
- void destroy();
+ android::LruCache<int, EGLImageBuffer *>* eglImageBufferMap;
+ DeleteEGLImageCallback* callback;
+ int ion_fd;
+
+ public:
+ EGLImageWrapper();
+ ~EGLImageWrapper();
+ EGLImageBuffer* wrap(const void *pvt_handle);
};
#endif //__TONEMAPPER_EGLIMAGEWRAPPER_H__