drm_hwcomposer: Add HWC_DRM_BO_MAX_PLANES constant

Add HWC_DRM_BO_MAX_PLANES to avoid open coded num_gem_handles
calculations.

Change-Id: Iebdaa67518e75f5b7f4445d92b97ca72e625c04b
Signed-off-by: John Stultz <john.stultz@linaro.org>
diff --git a/drmhwcgralloc.h b/drmhwcgralloc.h
index 759746a..daa44dc 100644
--- a/drmhwcgralloc.h
+++ b/drmhwcgralloc.h
@@ -19,14 +19,15 @@
 
 #include <stdint.h>
 
+#define HWC_DRM_BO_MAX_PLANES 4
 typedef struct hwc_drm_bo {
   uint32_t width;
   uint32_t height;
   uint32_t format; /* DRM_FORMAT_* from drm_fourcc.h */
   uint32_t usage;
-  uint32_t pitches[4];
-  uint32_t offsets[4];
-  uint32_t gem_handles[4];
+  uint32_t pitches[HWC_DRM_BO_MAX_PLANES];
+  uint32_t offsets[HWC_DRM_BO_MAX_PLANES];
+  uint32_t gem_handles[HWC_DRM_BO_MAX_PLANES];
   uint32_t fb_id;
   int acquire_fence_fd;
   void *priv;
diff --git a/platformdrmgeneric.cpp b/platformdrmgeneric.cpp
index b0cb130..85b2a7f 100644
--- a/platformdrmgeneric.cpp
+++ b/platformdrmgeneric.cpp
@@ -121,8 +121,8 @@
 
   struct drm_gem_close gem_close;
   memset(&gem_close, 0, sizeof(gem_close));
-  int num_gem_handles = sizeof(bo->gem_handles) / sizeof(bo->gem_handles[0]);
-  for (int i = 0; i < num_gem_handles; i++) {
+
+  for (int i = 0; i < HWC_DRM_BO_MAX_PLANES; i++) {
     if (!bo->gem_handles[i])
       continue;
 
@@ -131,7 +131,7 @@
     if (ret) {
       ALOGE("Failed to close gem handle %d %d", i, ret);
     } else {
-      for (int j = i + 1; j < num_gem_handles; j++)
+      for (int j = i + 1; j < HWC_DRM_BO_MAX_PLANES; j++)
         if (bo->gem_handles[j] == bo->gem_handles[i])
           bo->gem_handles[j] = 0;
       bo->gem_handles[i] = 0;