Add Context::getActiveBufferedAttribsMask.

This will enable more caching for ValidateDrawAttribs. It requires some
minor refactoring of the GLES 1 code.

Bug: angleproject:1391
Change-Id: I52b73c9384d14cdb90ba6337bfc1ab345866fff0
Reviewed-on: https://chromium-review.googlesource.com/1147436
Commit-Queue: Jamie Madill <jmadill@chromium.org>
Reviewed-by: Frank Henigman <fjhenigman@chromium.org>
Reviewed-by: Geoff Lang <geofflang@chromium.org>
diff --git a/src/libANGLE/Context.cpp b/src/libANGLE/Context.cpp
index 1bdd2bb..15c44e8 100644
--- a/src/libANGLE/Context.cpp
+++ b/src/libANGLE/Context.cpp
@@ -7531,6 +7531,28 @@
     mGLState.setMaxShaderCompilerThreads(count);
 }
 
+bool Context::isGLES1() const
+{
+    return mState.getClientVersion() < Version(2, 0);
+}
+
+AttributesMask Context::getActiveBufferedAttribsMask() const
+{
+    // TODO(jmadill): Cache this. http://anglebug.com/1391
+    ASSERT(mGLState.getProgram() || isGLES1());
+
+    const AttributesMask &activeAttribs =
+        isGLES1() ? mGLState.gles1().getVertexArraysAttributeMask()
+                  : mGLState.getProgram()->getActiveAttribLocationsMask();
+
+    const VertexArray *vao = mGLState.getVertexArray();
+    ASSERT(vao);
+
+    const AttributesMask &clientAttribs = vao->getEnabledClientMemoryAttribsMask();
+
+    return (activeAttribs & vao->getEnabledAttributesMask() & ~clientAttribs);
+}
+
 // ErrorSet implementation.
 ErrorSet::ErrorSet(Context *context) : mContext(context)
 {