ifdef HWC2 functionality

Fix build issue for devices that are not using HWC2.
Test: lunch hikey-userdebug; make

Change-Id: I47e9aa09b8db3f0dca6d733e2c8f3b59c45547b2
(cherry picked from commit 4f20f9cf3268dad96d9064dcb0e4a11aae96f6f3)
diff --git a/services/surfaceflinger/DisplayDevice.cpp b/services/surfaceflinger/DisplayDevice.cpp
index 87c4ea7..b5ffc60 100644
--- a/services/surfaceflinger/DisplayDevice.cpp
+++ b/services/surfaceflinger/DisplayDevice.cpp
@@ -113,10 +113,7 @@
       mLayerStack(NO_LAYER_STACK),
       mOrientation(),
       mPowerMode(HWC_POWER_MODE_OFF),
-      mActiveConfig(0),
-#ifdef USE_HWC2
-      mDisplayHasWideColor(supportWideColor)
-#endif
+      mActiveConfig(0)
 {
     // clang-format on
     Surface* surface;
@@ -125,6 +122,9 @@
 
 #ifdef USE_HWC2
     mActiveColorMode = static_cast<android_color_mode_t>(-1);
+    mDisplayHasWideColor = supportWideColor;
+#else
+    (void) supportWideColor;
 #endif
     /*
      * Create our display's surface
diff --git a/services/surfaceflinger/RenderEngine/GLES20RenderEngine.cpp b/services/surfaceflinger/RenderEngine/GLES20RenderEngine.cpp
index 413051d..04fe182 100644
--- a/services/surfaceflinger/RenderEngine/GLES20RenderEngine.cpp
+++ b/services/surfaceflinger/RenderEngine/GLES20RenderEngine.cpp
@@ -45,9 +45,8 @@
 
 #include <fstream>
 
-static constexpr bool outputDebugPPMs = false;
-
 // ---------------------------------------------------------------------------
+#ifdef USE_HWC2
 bool checkGlError(const char* op, int lineNumber) {
     bool errorFound = false;
     GLint error = glGetError();
@@ -59,6 +58,8 @@
     return errorFound;
 }
 
+static constexpr bool outputDebugPPMs = false;
+
 void writePPM(const char* basename, GLuint width, GLuint height) {
     ALOGV("writePPM #%s: %d x %d", basename, width, height);
 
@@ -104,6 +105,7 @@
     }
     file.write(reinterpret_cast<char*>(outBuffer.data()), outBuffer.size());
 }
+#endif
 
 // ---------------------------------------------------------------------------
 namespace android {
@@ -130,6 +132,7 @@
 
     //mColorBlindnessCorrection = M;
 
+#ifdef USE_HWC2
     // retrieve wide-color and hdr settings from configstore
     using namespace android::hardware::configstore;
     using namespace android::hardware::configstore::V1_0;
@@ -149,6 +152,7 @@
         mat4 gamutTransform(transpose(srgbToP3));
         mSrgbToDisplayP3 = gamutTransform;
     }
+#endif
 }
 
 GLES20RenderEngine::~GLES20RenderEngine() {
@@ -383,6 +387,7 @@
             mesh.getByteStride(),
             mesh.getPositions());
 
+#ifdef USE_HWC2
     if (usesWideColor()) {
         Description wideColorState = mState;
         if (mDataSpace != HAL_DATASPACE_DISPLAY_P3) {
@@ -403,6 +408,11 @@
 
         glDrawArrays(mesh.getPrimitive(), 0, mesh.getVertexCount());
     }
+#else
+    ProgramCache::getInstance().useProgram(mState);
+
+    glDrawArrays(mesh.getPrimitive(), 0, mesh.getVertexCount());
+#endif
 
     if (mesh.getTexCoordsSize()) {
         glDisableVertexAttribArray(Program::texCoords);
@@ -411,11 +421,13 @@
 
 void GLES20RenderEngine::dump(String8& result) {
     RenderEngine::dump(result);
+#ifdef USE_HWC2
     if (usesWideColor()) {
         result.append("Wide-color: On\n");
     } else {
         result.append("Wide-color: Off\n");
     }
+#endif
 }
 
 // ---------------------------------------------------------------------------
diff --git a/services/surfaceflinger/SurfaceFlinger_hwc1.cpp b/services/surfaceflinger/SurfaceFlinger_hwc1.cpp
index a6c0b9c..e640ef7 100644
--- a/services/surfaceflinger/SurfaceFlinger_hwc1.cpp
+++ b/services/surfaceflinger/SurfaceFlinger_hwc1.cpp
@@ -570,7 +570,7 @@
             sp<DisplayDevice> hw = new DisplayDevice(this,
                     type, hwcId, mHwc->getFormat(hwcId), isSecure, token,
                     fbs, producer,
-                    mRenderEngine->getEGLConfig());
+                    mRenderEngine->getEGLConfig(), false);
             if (i > DisplayDevice::DISPLAY_PRIMARY) {
                 // FIXME: currently we don't get blank/unblank requests
                 // for displays other than the main display, so we always
@@ -1740,7 +1740,7 @@
                                 state.type, hwcDisplayId,
                                 mHwc->getFormat(hwcDisplayId), state.isSecure,
                                 display, dispSurface, producer,
-                                mRenderEngine->getEGLConfig());
+                                mRenderEngine->getEGLConfig(), false);
                         hw->setLayerStack(state.layerStack);
                         hw->setProjection(state.orientation,
                                 state.viewport, state.frame);