gralloc1: Add support for layered buffers

Implements the gralloc1 capability GRALLOC1_CAPABILITY_LAYERED_BUFFERS.

CRs-Fixed: 2025988
Change-Id: I80c8ef6aa18844e33ecd8b019c6f4cf08872afb5
diff --git a/libgralloc1/gr_priv_handle.h b/libgralloc1/gr_priv_handle.h
index 27d405b..5948aab 100644
--- a/libgralloc1/gr_priv_handle.h
+++ b/libgralloc1/gr_priv_handle.h
@@ -83,6 +83,7 @@
   uint64_t id                              __attribute__((aligned(8)));
   gralloc1_producer_usage_t producer_usage __attribute__((aligned(8)));
   gralloc1_consumer_usage_t consumer_usage __attribute__((aligned(8)));
+  unsigned int layer_count;
 
   static const int kNumFds = 2;
   static const int kMagic = 'gmsm';
@@ -123,7 +124,8 @@
         gpuaddr(0),
         id(0),
         producer_usage(prod_usage),
-        consumer_usage(cons_usage) {
+        consumer_usage(cons_usage),
+        layer_count(1) {
     version = static_cast<int>(sizeof(native_handle));
     numInts = NumInts();
     numFds = kNumFds;
@@ -162,11 +164,11 @@
   }
 
   static void Dump(const private_handle_t *hnd) {
-    ALOGD("handle id:%" PRIu64 " wxh:%dx%d uwxuh:%dx%d size: %d fd:%d fd_meta:%d flags:0x%x"
-          "prod_usage:0x%" PRIx64" cons_usage:0x%" PRIx64 "format:0x%x",
+    ALOGD("handle id:%" PRIu64 " wxh:%dx%d uwxuh:%dx%d size: %d fd:%d fd_meta:%d flags:0x%x "
+          "prod_usage:0x%" PRIx64" cons_usage:0x%" PRIx64 " format:0x%x layer_count: %d",
           hnd->id, hnd->width, hnd->height, hnd->unaligned_width, hnd->unaligned_height, hnd->size,
           hnd->fd, hnd->fd_metadata, hnd->flags, hnd->producer_usage, hnd->consumer_usage,
-          hnd->format);
+          hnd->format, hnd->layer_count);
   }
 
   int GetUnalignedWidth() const { return unaligned_width; }
@@ -175,6 +177,8 @@
 
   int GetColorFormat() const { return format; }
 
+  unsigned int GetLayerCount() const { return layer_count; }
+
   int GetStride() const {
     // In handle we currently store aligned width after allocation.
     return width;