Cache glGetIntegerv(GL_MAX_VERTEX_ATTRIBS, int*).

BUG:27418143

If we don't, the chatter over the pipe will
kill framerate.

I believe this is OK for the emulator,
as the parameter is dependent on only the
GPU hardware.

Change-Id: I9bd74de6317316902bddf54b915ef509625cee52
diff --git a/opengl/shared/OpenglCodecCommon/GLClientState.cpp b/opengl/shared/OpenglCodecCommon/GLClientState.cpp
index 57637ae..638eb4c 100644
--- a/opengl/shared/OpenglCodecCommon/GLClientState.cpp
+++ b/opengl/shared/OpenglCodecCommon/GLClientState.cpp
@@ -65,6 +65,8 @@
     m_tex.textures = NULL;
     m_tex.numTextures = 0;
     m_tex.allocTextures = 0;
+
+    m_maxVertexAttribsDirty = true;
 }
 
 GLClientState::~GLClientState()
diff --git a/opengl/shared/OpenglCodecCommon/GLClientState.h b/opengl/shared/OpenglCodecCommon/GLClientState.h
index 09ee571..8e95c37 100644
--- a/opengl/shared/OpenglCodecCommon/GLClientState.h
+++ b/opengl/shared/OpenglCodecCommon/GLClientState.h
@@ -90,6 +90,10 @@
     int getLocation(GLenum loc);
     void setActiveTexture(int texUnit) {m_activeTexture = texUnit; };
     int getActiveTexture() const { return m_activeTexture; }
+    void setMaxVertexAttribs(int val) {
+        m_maxVertexAttribs = val;
+        m_maxVertexAttribsDirty = false;
+    }
 
     void unBindBuffer(GLuint id)
     {
@@ -184,6 +188,8 @@
 private:
     PixelStoreState m_pixelStore;
     VertexAttribState *m_states;
+    int m_maxVertexAttribs;
+    bool m_maxVertexAttribsDirty;
     int m_nLocations;
     GLuint m_currentArrayVbo;
     GLuint m_currentIndexVbo;
@@ -439,6 +445,15 @@
             isClientStateParam = true;
             break;
             }
+        case GL_MAX_VERTEX_ATTRIBS: {
+            if (m_maxVertexAttribsDirty) {
+                isClientStateParam = false;
+            } else {
+                *ptr = m_maxVertexAttribs;
+                isClientStateParam = true;
+            }
+            break;
+            }
         }
         return isClientStateParam;
     }
diff --git a/opengl/system/GLESv2_enc/GL2Encoder.cpp b/opengl/system/GLESv2_enc/GL2Encoder.cpp
index c367385..9280839 100755
--- a/opengl/system/GLESv2_enc/GL2Encoder.cpp
+++ b/opengl/system/GLESv2_enc/GL2Encoder.cpp
@@ -309,6 +309,12 @@
             ctx->m_max_textureSize = *ptr;
         }
         break;
+    case GL_MAX_VERTEX_ATTRIBS:
+        if (!ctx->m_state->getClientStateParameter<GLint>(param, ptr)) {
+            ctx->m_glGetIntegerv_enc(self, param, ptr);
+            ctx->m_state->setMaxVertexAttribs(*ptr);
+        }
+        break;
     default:
         if (!ctx->m_state->getClientStateParameter<GLint>(param, ptr)) {
             ctx->m_glGetIntegerv_enc(self, param, ptr);