ifdef HWC2 functionality

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

Change-Id: I47e9aa09b8db3f0dca6d733e2c8f3b59c45547b2
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
 }
 
 // ---------------------------------------------------------------------------