Snap for 9442415 from f98c943a53019a0afae57dbc4459ce610f48e331 to tm-qpr2-release

Change-Id: Ib195649ba2adbaa838b4ddada3c7e44a0e19c3a0
diff --git a/libvendorgraphicbuffer/gralloc4/vendor_graphicbuffer_meta.cpp b/libvendorgraphicbuffer/gralloc4/vendor_graphicbuffer_meta.cpp
index a155519..ac3fc93 100644
--- a/libvendorgraphicbuffer/gralloc4/vendor_graphicbuffer_meta.cpp
+++ b/libvendorgraphicbuffer/gralloc4/vendor_graphicbuffer_meta.cpp
@@ -45,8 +45,7 @@
 // libraries and should depend upon HAL (and it's extension) to call into
 // Gralloc.
 int mali_gralloc_reference_validate(buffer_handle_t handle) {
-	auto hnd = static_cast<const private_handle_t *>(handle);
-  return private_handle_t::validate(hnd);
+	return private_handle_t::validate(handle);
 }
 
 const private_handle_t * convertNativeHandleToPrivateHandle(buffer_handle_t handle) {
@@ -70,7 +69,7 @@
 
 int VendorGraphicBufferMeta::get_video_metadata_fd(buffer_handle_t hnd)
 {
-	const private_handle_t *gralloc_hnd = static_cast<const private_handle_t *>(hnd);
+	const auto *gralloc_hnd = convertNativeHandleToPrivateHandle(hnd);
 
 	if (!gralloc_hnd)
 		return -EINVAL;
@@ -136,7 +135,7 @@
 
 int VendorGraphicBufferMeta::is_afbc(buffer_handle_t hnd)
 {
-	const private_handle_t *gralloc_hnd = static_cast<const private_handle_t *>(hnd);
+	const auto *gralloc_hnd = convertNativeHandleToPrivateHandle(hnd);
 
 	if (!gralloc_hnd)
 		return 0;
@@ -147,11 +146,9 @@
 	return 0;
 }
 
-int VendorGraphicBufferMeta::is_sbwc(buffer_handle_t buffer_hnd_p)
+int VendorGraphicBufferMeta::is_sbwc(buffer_handle_t hnd)
 {
-	const private_handle_t *hnd = static_cast<const private_handle_t *>(buffer_hnd_p);
-
-	return is_sbwc_format(static_cast<uint32_t>(hnd->alloc_format & MALI_GRALLOC_INTFMT_FMT_MASK));
+	return is_sbwc_format(VendorGraphicBufferMeta::get_internal_format(hnd));
 }
 
 #define GRALLOC_META_GETTER(__type__, __name__, __member__) \
@@ -165,7 +162,8 @@
 
 uint32_t VendorGraphicBufferMeta::get_format(buffer_handle_t hnd)
 {
-	const private_handle_t *gralloc_hnd = static_cast<const private_handle_t *>(hnd);
+	const auto *gralloc_hnd = convertNativeHandleToPrivateHandle(hnd);
+
 	if (!gralloc_hnd)
 		return 0;
 
@@ -174,7 +172,8 @@
 
 uint64_t VendorGraphicBufferMeta::get_internal_format(buffer_handle_t hnd)
 {
-	const private_handle_t *gralloc_hnd = static_cast<const private_handle_t *>(hnd);
+	const auto *gralloc_hnd = convertNativeHandleToPrivateHandle(hnd);;
+
 	if (!gralloc_hnd)
 		return 0;
 
@@ -196,7 +195,7 @@
 
 int VendorGraphicBufferMeta::get_fd(buffer_handle_t hnd, int num)
 {
-	const private_handle_t *gralloc_hnd = static_cast<const private_handle_t *>(hnd);
+	const auto *gralloc_hnd = convertNativeHandleToPrivateHandle(hnd);
 
 	if (!gralloc_hnd)
 		return -1;
@@ -209,7 +208,7 @@
 
 int VendorGraphicBufferMeta::get_size(buffer_handle_t hnd, int num)
 {
-	const private_handle_t *gralloc_hnd = static_cast<const private_handle_t *>(hnd);
+	const auto *gralloc_hnd = convertNativeHandleToPrivateHandle(hnd);
 
 	if (!gralloc_hnd)
 		return 0;
@@ -223,7 +222,7 @@
 
 uint64_t VendorGraphicBufferMeta::get_usage(buffer_handle_t hnd)
 {
-	const private_handle_t *gralloc_hnd = static_cast<const private_handle_t *>(hnd);
+	const auto *gralloc_hnd = convertNativeHandleToPrivateHandle(hnd);
 
 	if (!gralloc_hnd)
 		return 0;
@@ -257,7 +256,7 @@
 
 void VendorGraphicBufferMeta::init(const buffer_handle_t handle)
 {
-	const private_handle_t *gralloc_hnd = static_cast<const private_handle_t *>(handle);
+	const auto *gralloc_hnd = convertNativeHandleToPrivateHandle(handle);
 
 	if (!gralloc_hnd)
 		return;