gpu_tonemapper: Fix compilation issue with GraphicBuffer

Handle different version of GraphicBuffer with a compile time
flag.

CRs-Fixed: 1111917
Change-Id: I11aa6d64a8e61a4d7658cb5f924ee4dc38c40bc9
diff --git a/common.mk b/common.mk
index fadc5d8..1044238 100644
--- a/common.mk
+++ b/common.mk
@@ -9,6 +9,14 @@
 common_flags += -DUSE_COLOR_METADATA
 endif
 
+CHECK_VERSION_LE = $(shell if [ $(1) -le $(2) ] ; then echo true ; else echo false ; fi)
+PLATFORM_SDK_NOUGAT = 25
+ifeq "REL" "$(PLATFORM_VERSION_CODENAME)"
+ifeq ($(call CHECK_VERSION_LE, $(PLATFORM_SDK_VERSION), $(PLATFORM_SDK_NOUGAT)), true)
+version_flag := -D__NOUGAT__
+endif
+endif
+
 use_hwc2 := false
 ifeq ($(TARGET_USES_HWC2), true)
     use_hwc2 := true
diff --git a/gpu_tonemapper/Android.mk b/gpu_tonemapper/Android.mk
index 9ae3840..4f716d2 100644
--- a/gpu_tonemapper/Android.mk
+++ b/gpu_tonemapper/Android.mk
@@ -11,7 +11,7 @@
 LOCAL_MODULE_TAGS         := optional
 LOCAL_C_INCLUDES          := $(TARGET_OUT_HEADERS)/qcom/display/
 
-LOCAL_CFLAGS              := -Wno-missing-field-initializers -Wall \
+LOCAL_CFLAGS              := $(version_flag) -Wno-missing-field-initializers -Wall \
                              -Wno-unused-parameter -std=c++11 -DLOG_TAG=\"GPU_TONEMAPPER\"
 
 LOCAL_SRC_FILES           := TonemapFactory.cpp \
diff --git a/gpu_tonemapper/EGLImageWrapper.cpp b/gpu_tonemapper/EGLImageWrapper.cpp
index 298475f..1d5d57e 100644
--- a/gpu_tonemapper/EGLImageWrapper.cpp
+++ b/gpu_tonemapper/EGLImageWrapper.cpp
@@ -41,8 +41,12 @@
     }
 
     android::sp<android::GraphicBuffer> graphicBuffer =
-        new android::GraphicBuffer(src->width, src->height, src->format, flags,
-                                   src->width /*src->stride*/, native_handle, false);
+        new android::GraphicBuffer(src->width, src->height, src->format,
+#ifndef __NOUGAT__
+                                   1, // Layer count
+#endif
+                                   flags, src->width /*src->stride*/,
+                                   native_handle, false);
 
     result = new EGLImageBuffer(graphicBuffer);