summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorLinux Build Service Account <lnxbuild@localhost>2018-07-12 05:36:57 -0700
committerGerrit - the friendly Code Review server <code-review@localhost>2018-07-12 05:36:57 -0700
commite0c168c3f6ec565d9f8050a54a062f7677696fd6 (patch)
treef4a0cc6b2b7836b299f5d6b227790f97b8530aa7
parenteba238bed64e5dd6db7eeb79a670a2178260cd03 (diff)
parent0957bedef83c372238cd71388fab11de8e5feb1b (diff)
downloaddisplay-e0c168c3f6ec565d9f8050a54a062f7677696fd6.tar.gz
Merge "qdMetaData: Add get/setMetaData variants that unmap metadata"
-rw-r--r--gralloc/gr_buf_mgr.cpp4
-rw-r--r--libqdutils/qdMetaData.cpp22
-rw-r--r--libqdutils/qdMetaData.h8
3 files changed, 32 insertions, 2 deletions
diff --git a/gralloc/gr_buf_mgr.cpp b/gralloc/gr_buf_mgr.cpp
index 8c8c66f8..c8309525 100644
--- a/gralloc/gr_buf_mgr.cpp
+++ b/gralloc/gr_buf_mgr.cpp
@@ -359,11 +359,11 @@ Error BufferManager::AllocateBuffer(const BufferDescriptor &descriptor, buffer_h
hnd->layer_count = layer_count;
ColorSpace_t colorSpace = ITU_R_601;
- setMetaData(hnd, UPDATE_COLOR_SPACE, reinterpret_cast<void *>(&colorSpace));
+ setMetaDataAndUnmap(hnd, UPDATE_COLOR_SPACE, reinterpret_cast<void *>(&colorSpace));
bool use_adreno_for_size = CanUseAdrenoForSize(buffer_type, usage);
if (use_adreno_for_size) {
- setMetaData(hnd, SET_GRAPHICS_METADATA, reinterpret_cast<void *>(&graphics_metadata));
+ setMetaDataAndUnmap(hnd, SET_GRAPHICS_METADATA, reinterpret_cast<void *>(&graphics_metadata));
}
*handle = hnd;
diff --git a/libqdutils/qdMetaData.cpp b/libqdutils/qdMetaData.cpp
index 3259ee23..a40ea629 100644
--- a/libqdutils/qdMetaData.cpp
+++ b/libqdutils/qdMetaData.cpp
@@ -64,6 +64,13 @@ static int validateAndMap(private_handle_t* handle) {
return 0;
}
+static void unmapAndReset(private_handle_t *handle) {
+ if (private_handle_t::validate(handle) == 0 && handle->base_metadata) {
+ munmap(reinterpret_cast<void *>(handle->base_metadata), getMetaDataSize());
+ handle->base_metadata = 0;
+ }
+}
+
int setMetaData(private_handle_t *handle, DispParamType paramType,
void *param) {
auto err = validateAndMap(handle);
@@ -346,3 +353,18 @@ int copyMetaDataVaToVa(MetaData_t *src_data, MetaData_t *dst_data) {
return 0;
}
+int setMetaDataAndUnmap(struct private_handle_t *handle, enum DispParamType paramType,
+ void *param) {
+ auto ret = setMetaData(handle, paramType, param);
+ unmapAndReset(handle);
+ return ret;
+}
+
+int getMetaDataAndUnmap(struct private_handle_t *handle,
+ enum DispFetchParamType paramType,
+ void *param) {
+ auto ret = getMetaData(handle, paramType, param);
+ unmapAndReset(handle);
+ return ret;
+}
+
diff --git a/libqdutils/qdMetaData.h b/libqdutils/qdMetaData.h
index 195fdd20..5739ceea 100644
--- a/libqdutils/qdMetaData.h
+++ b/libqdutils/qdMetaData.h
@@ -208,6 +208,14 @@ int clearMetaDataVa(struct MetaData_t *data, enum DispParamType paramType);
unsigned long getMetaDataSize();
+// Map, access metadata and unmap. Used by clients that do not import/free but
+// clone and delete native_handle
+int setMetaDataAndUnmap(struct private_handle_t *handle, enum DispParamType paramType,
+ void *param);
+int getMetaDataAndUnmap(struct private_handle_t *handle,
+ enum DispFetchParamType paramType,
+ void *param);
+
#ifdef __cplusplus
}
#endif