Cache gl::Data in Context to speed up validation.

This avoids creating a new Data object and copying it around.
Gives a noticable performance increase in the benchmark which
tests validation-only draw calls. Gives about a 8% increase
in the benchmark.

BUG=angleproject:959

Change-Id: Id3a7459753b1b466a06da89f3f8b03b2c2c7a5c1
Reviewed-on: https://chromium-review.googlesource.com/267752
Tested-by: Jamie Madill <jmadill@chromium.org>
Reviewed-by: Geoff Lang <geofflang@chromium.org>
Reviewed-by: Brandon Jones <bajones@chromium.org>
diff --git a/src/libANGLE/Context.cpp b/src/libANGLE/Context.cpp
index a79cf2d..d944f8b 100644
--- a/src/libANGLE/Context.cpp
+++ b/src/libANGLE/Context.cpp
@@ -37,7 +37,8 @@
 {
 
 Context::Context(const egl::Config *config, int clientVersion, const Context *shareContext, rx::Renderer *renderer, bool notifyResets, bool robustAccess)
-    : mRenderer(renderer)
+    : mRenderer(renderer),
+      mData(clientVersion, mState, mCaps, mTextureCaps, mExtensions, nullptr)
 {
     ASSERT(robustAccess == false);   // Unimplemented
 
@@ -62,6 +63,8 @@
         mResourceManager = new ResourceManager(mRenderer);
     }
 
+    mData.resourceManager = mResourceManager;
+
     // [OpenGL ES 2.0.24] section 3.7 page 83:
     // In the initial state, TEXTURE_2D and TEXTURE_CUBE_MAP have twodimensional
     // and cube map texture state vectors respectively associated with them.
@@ -1578,9 +1581,4 @@
     }
 }
 
-Data Context::getData() const
-{
-    return Data(mClientVersion, mState, mCaps, mTextureCaps, mExtensions, mResourceManager);
-}
-
 }
diff --git a/src/libANGLE/Context.h b/src/libANGLE/Context.h
index 32bfa08..2151fc8 100644
--- a/src/libANGLE/Context.h
+++ b/src/libANGLE/Context.h
@@ -200,7 +200,7 @@
     State &getState() { return mState; }
     const State &getState() const { return mState; }
 
-    Data getData() const;
+    const Data &getData() const { return mData; }
 
   private:
     void detachBuffer(GLuint buffer);
@@ -272,7 +272,11 @@
     bool mRobustAccess;
 
     ResourceManager *mResourceManager;
+
+    // Cache the Data object to avoid re-calling the constructor
+    Data mData;
 };
+
 }
 
 #endif   // LIBANGLE_CONTEXT_H_
diff --git a/src/libANGLE/State.cpp b/src/libANGLE/State.cpp
index e1ef393..f731774 100644
--- a/src/libANGLE/State.cpp
+++ b/src/libANGLE/State.cpp
@@ -30,7 +30,7 @@
     reset();
 }
 
-void State::initialize(const Caps& caps, GLuint clientVersion)
+void State::initialize(const Caps &caps, GLuint clientVersion)
 {
     mMaxDrawBuffers = caps.maxDrawBuffers;
     mMaxCombinedTextureImageUnits = caps.maxCombinedTextureImageUnits;