gralloc: Add support for allocated width and height

The standard metadata types for width and height return the
values requested by the client, rather than the width and height
of the allocated buffer. This change adds support to get the
allocated width and height. It also fixes the width and height
returned through get() for PlaneLayout

CRs-Fixed: 2638621
Change-Id: Ifa394a92fcd4a9fe5b8e1d7327971167f991ec33
diff --git a/gralloc/QtiMapper4.h b/gralloc/QtiMapper4.h
index 8354c36..caf8d12 100644
--- a/gralloc/QtiMapper4.h
+++ b/gralloc/QtiMapper4.h
@@ -264,6 +264,8 @@
       {qtigralloc::MetadataType_VideoHistogramStats, "Video histogram stats", true, true},
       {qtigralloc::MetadataType_FD, "fd from private_handle_t", true, false},
       {qtigralloc::MetadataType_PrivateFlags, "Flags in private_handle_t", true, false},
+      {qtigralloc::MetadataType_AlignedWidthInPixels, "width in private_handle_t", true, false},
+      {qtigralloc::MetadataType_AlignedHeightInPixels, "height in private_handle_t", true, false}
   };
 };
 
diff --git a/gralloc/gr_buf_mgr.cpp b/gralloc/gr_buf_mgr.cpp
index 0b698ad..f22ca6c 100644
--- a/gralloc/gr_buf_mgr.cpp
+++ b/gralloc/gr_buf_mgr.cpp
@@ -995,6 +995,14 @@
     case QTI_PRIVATE_FLAGS:
       android::gralloc4::encodeInt32(qtigralloc::MetadataType_PrivateFlags, handle->flags, out);
       break;
+    case QTI_ALIGNED_WIDTH_IN_PIXELS:
+      android::gralloc4::encodeUint32(qtigralloc::MetadataType_AlignedWidthInPixels, handle->width,
+                                      out);
+      break;
+    case QTI_ALIGNED_HEIGHT_IN_PIXELS:
+      android::gralloc4::encodeUint32(qtigralloc::MetadataType_AlignedHeightInPixels,
+                                      handle->height, out);
+      break;
     default:
       error = Error::UNSUPPORTED;
   }
@@ -1042,6 +1050,8 @@
     case (int64_t)StandardMetadataType::COMPRESSION:
     case QTI_FD:
     case QTI_PRIVATE_FLAGS:
+    case QTI_ALIGNED_WIDTH_IN_PIXELS:
+    case QTI_ALIGNED_HEIGHT_IN_PIXELS:
       return Error::UNSUPPORTED;
     case (int64_t)StandardMetadataType::DATASPACE:
       Dataspace dataspace;