aboutsummaryrefslogtreecommitdiff
path: root/nvimporter.h
diff options
context:
space:
mode:
authorSean Paul <seanpaul@chromium.org>2015-06-10 14:30:47 -0400
committerSean Paul <seanpaul@chromium.org>2015-06-10 14:54:19 -0400
commit419b5e015b78f28838a4f270c906afcc3b2e429c (patch)
tree4aa2003121b56c329d668c6efa65f0145cf83846 /nvimporter.h
parent1eb6006fb7d950c5aefb202459234c96f8bf2895 (diff)
downloaddrm_hwcomposer-419b5e015b78f28838a4f270c906afcc3b2e429c.tar.gz
drm_hwcomposer: Reference count NvImporter buffers
Instead of directly freeing buffers from the NvImporter release callback, use reference counting to ensure that we: (a) don't free the buffer while NvGralloc is still using it (b) don't free the buffer while HWC is still using it Before this patch, we weren't satisifying (b). This would cause us to free a buffer before and while it was on the screen. Change-Id: I6bbc541c72df4d5f12a8734de2f2e68168b73a07 Signed-off-by: Sean Paul <seanpaul@chromium.org>
Diffstat (limited to 'nvimporter.h')
-rw-r--r--nvimporter.h5
1 files changed, 4 insertions, 1 deletions
diff --git a/nvimporter.h b/nvimporter.h
index e3bdd1c..a07f577 100644
--- a/nvimporter.h
+++ b/nvimporter.h
@@ -20,6 +20,8 @@
#include "drmresources.h"
#include "importer.h"
+#include <stdatomic.h>
+
#include <hardware/gralloc.h>
namespace android {
@@ -38,9 +40,10 @@ class NvImporter : public Importer {
typedef struct NvBuffer {
NvImporter *importer;
hwc_drm_bo_t bo;
+ atomic_int ref;
} NvBuffer_t;
- static void ReleaseBufferCallback(void *nv_buffer);
+ static void NvGrallocRelease(void *nv_buffer);
void ReleaseBufferImpl(hwc_drm_bo_t *bo);
NvBuffer_t *GrallocGetNvBuffer(buffer_handle_t handle);