Feature: IgnoreHostOpenGLErrors

bug: 71853717

If you use the emulator and the UI works fine, do this to make the UI
faster.

Change-Id: I044a46956eadb17021d6cf2c7b87c6423a328051
diff --git a/system/OpenglSystemCommon/HostConnection.cpp b/system/OpenglSystemCommon/HostConnection.cpp
index 0b5304f..34ddef4 100644
--- a/system/OpenglSystemCommon/HostConnection.cpp
+++ b/system/OpenglSystemCommon/HostConnection.cpp
@@ -37,7 +37,8 @@
     m_rcEnc(NULL),
     m_checksumHelper(),
     m_glExtensions(),
-    m_grallocOnly(true)
+    m_grallocOnly(true),
+    m_noHostError(false)
 {
 }
 
@@ -146,6 +147,7 @@
         m_gl2Enc = new GL2Encoder(m_stream, checksumHelper());
         DBG("HostConnection::gl2Encoder new encoder %p, tid %d", m_gl2Enc, gettid());
         m_gl2Enc->setContextAccessor(s_getGL2Context);
+        m_gl2Enc->setNoHostError(m_noHostError);
     }
     return m_gl2Enc;
 }
@@ -158,6 +160,7 @@
         queryAndSetSyncImpl(m_rcEnc);
         queryAndSetDmaImpl(m_rcEnc);
         queryAndSetGLESMaxVersion(m_rcEnc);
+        queryAndSetNoErrorState(m_rcEnc);
         processPipeInit(m_rcEnc);
     }
     return m_rcEnc;
@@ -272,3 +275,10 @@
         rcEnc->setGLESMaxVersion(GLES_MAX_VERSION_2);
     }
 }
+
+void HostConnection::queryAndSetNoErrorState(ExtendedRCEncoderContext* rcEnc) {
+    std::string glExtensions = queryGLExtensions(rcEnc);
+    if (glExtensions.find(kGLESNoHostError) != std::string::npos) {
+        m_noHostError = true;
+    }
+}
diff --git a/system/OpenglSystemCommon/HostConnection.h b/system/OpenglSystemCommon/HostConnection.h
index 0924cf9..2b49857 100644
--- a/system/OpenglSystemCommon/HostConnection.h
+++ b/system/OpenglSystemCommon/HostConnection.h
@@ -71,6 +71,9 @@
 static const char kGLESMaxVersion_3_1[] = "ANDROID_EMU_gles_max_version_3_1";
 static const char kGLESMaxVersion_3_2[] = "ANDROID_EMU_gles_max_version_3_2";
 
+// No querying errors from host extension
+static const char kGLESNoHostError[] = "ANDROID_EMU_gles_no_host_error";
+
 // ExtendedRCEncoderContext is an extended version of renderControl_encoder_context_t
 // that will be used to track SyncImpl.
 class ExtendedRCEncoderContext : public renderControl_encoder_context_t {
@@ -148,6 +151,7 @@
     void queryAndSetSyncImpl(ExtendedRCEncoderContext *rcEnc);
     void queryAndSetDmaImpl(ExtendedRCEncoderContext *rcEnc);
     void queryAndSetGLESMaxVersion(ExtendedRCEncoderContext *rcEnc);
+    void queryAndSetNoErrorState(ExtendedRCEncoderContext *rcEnc);
 
 private:
     IOStream *m_stream;
@@ -158,6 +162,7 @@
     std::string m_glExtensions;
     bool m_grallocOnly;
     int m_pipeFd;
+    bool m_noHostError;
 };
 
 #endif