drm_hwcomposer: Add support for P+ environments

Originally-by: Alistair Strachan <astrachan@google.com>

With Android P, the GraphicBufferMapper ImportBuffer interface
has changed, which breaks the current drm_hwcomposer master
branch:
https://android.googlesource.com/platform/frameworks/native/+/dbbe33b95336efa74e8bb4ebcf6cba50919aa247

Alistair has updated the AOSP/master branch of drm_hwcomposer to
make it build:
https://android.googlesource.com/platform/external/drm_hwcomposer/+/4f73630dcdab6604a3f4b3e7d59068633d923745%5E2..4f73630dcdab6604a3f4b3e7d59068633d923745/

But since we need to keep older users working, so I've forward
ported and conditionalized the code so both new and old users
can properly build.

Change-Id: I2089c1105a7074ff13b5ddfe2d2eb7129917794f
Signed-off-by: John Stultz <john.stultz@linaro.org>
---
v2:
* Fix up LOCAL_CPPFLAGS typeo and unsued variable errors
  both found thanks to Alexandru Gheorghe
v3:
* Reordered so this patch comes last
* Squish layer_count calculation patch into this one
diff --git a/Android.mk b/Android.mk
index 65c0f3a..d5ee200 100644
--- a/Android.mk
+++ b/Android.mk
@@ -14,6 +14,8 @@
 
 ifeq ($(strip $(BOARD_USES_DRM_HWCOMPOSER)),true)
 
+DRM_HWC_ANDROID_MAJOR_VERSION := $(word 1, $(subst ., , $(PLATFORM_VERSION)))
+
 LOCAL_PATH := $(call my-dir)
 
 common_drm_hwcomposer_cflags := \
@@ -79,6 +81,10 @@
 	-DHWC2_USE_CPP11 \
 	-DHWC2_INCLUDE_STRINGIFICATION
 
+ifneq ($(filter 2 3 4 5 6 7 8, $(DRM_HWC_ANDROID_MAJOR_VERSION)),)
+LOCAL_CPPFLAGS += -DHWC2_USE_OLD_GB_IMPORT
+endif
+
 
 ifeq ($(TARGET_PRODUCT),hikey960)
 LOCAL_CPPFLAGS += -DUSE_HISI_IMPORTER