Pass gl::Context to more Buffer methods.

This will allow us to pull out the Renderer from the Context in more
places in Buffer11, for state update. Impacts a few method calls in
a few places.

BUG=angleproject:2151

Change-Id: I1360caea65a94d3de4cd9f52d1b74b10439b02b3
Reviewed-on: https://chromium-review.googlesource.com/673136
Reviewed-by: Geoff Lang <geofflang@chromium.org>
Reviewed-by: Frank Henigman <fjhenigman@chromium.org>
Commit-Queue: Jamie Madill <jmadill@chromium.org>
diff --git a/src/libANGLE/renderer/d3d/VertexDataManager.cpp b/src/libANGLE/renderer/d3d/VertexDataManager.cpp
index 34a4730..518fcd3 100644
--- a/src/libANGLE/renderer/d3d/VertexDataManager.cpp
+++ b/src/libANGLE/renderer/d3d/VertexDataManager.cpp
@@ -11,11 +11,12 @@
 
 #include "common/bitset_utils.h"
 #include "libANGLE/Buffer.h"
-#include "libANGLE/formatutils.h"
+#include "libANGLE/Context.h"
 #include "libANGLE/Program.h"
 #include "libANGLE/State.h"
-#include "libANGLE/VertexAttribute.h"
 #include "libANGLE/VertexArray.h"
+#include "libANGLE/VertexAttribute.h"
+#include "libANGLE/formatutils.h"
 #include "libANGLE/renderer/d3d/BufferD3D.h"
 #include "libANGLE/renderer/d3d/RendererD3D.h"
 #include "libANGLE/renderer/d3d/VertexBuffer.h"
@@ -217,7 +218,7 @@
     mCurrentValueCache.clear();
 }
 
-gl::Error VertexDataManager::prepareVertexData(const gl::State &state,
+gl::Error VertexDataManager::prepareVertexData(const gl::Context *context,
                                                GLint start,
                                                GLsizei count,
                                                std::vector<TranslatedAttribute> *translatedAttribs,
@@ -225,6 +226,7 @@
 {
     ASSERT(mStreamingBuffer);
 
+    const gl::State &state             = context->getGLState();
     const gl::VertexArray *vertexArray = state.getVertexArray();
     const auto &vertexAttributes       = vertexArray->getVertexAttributes();
     const auto &vertexBindings         = vertexArray->getVertexBindings();
@@ -261,7 +263,7 @@
             case VertexStorageType::STATIC:
             {
                 // Store static attribute.
-                ANGLE_TRY(StoreStaticAttrib(translated));
+                ANGLE_TRY(StoreStaticAttrib(context, translated));
                 break;
             }
             case VertexStorageType::DYNAMIC:
@@ -288,10 +290,10 @@
         return gl::NoError();
     }
 
-    ANGLE_TRY(
-        storeDynamicAttribs(translatedAttribs, mDynamicAttribsMaskCache, start, count, instances));
+    ANGLE_TRY(storeDynamicAttribs(context, translatedAttribs, mDynamicAttribsMaskCache, start,
+                                  count, instances));
 
-    PromoteDynamicAttribs(*translatedAttribs, mDynamicAttribsMaskCache, count);
+    PromoteDynamicAttribs(context, *translatedAttribs, mDynamicAttribsMaskCache, count);
 
     return gl::NoError();
 }
@@ -320,7 +322,8 @@
 }
 
 // static
-gl::Error VertexDataManager::StoreStaticAttrib(TranslatedAttribute *translated)
+gl::Error VertexDataManager::StoreStaticAttrib(const gl::Context *context,
+                                               TranslatedAttribute *translated)
 {
     ASSERT(translated->attribute && translated->binding);
     const auto &attrib  = *translated->attribute;
@@ -334,7 +337,7 @@
     const uint8_t *sourceData = nullptr;
     const int offset          = static_cast<int>(ComputeVertexAttributeOffset(attrib, binding));
 
-    ANGLE_TRY(bufferD3D->getData(&sourceData));
+    ANGLE_TRY(bufferD3D->getData(context, &sourceData));
     sourceData += offset;
 
     unsigned int streamOffset = 0;
@@ -383,6 +386,7 @@
 }
 
 gl::Error VertexDataManager::storeDynamicAttribs(
+    const gl::Context *context,
     std::vector<TranslatedAttribute> *translatedAttribs,
     const gl::AttributesMask &dynamicAttribsMask,
     GLint start,
@@ -418,13 +422,14 @@
     for (auto attribIndex : dynamicAttribsMask)
     {
         auto *dynamicAttrib = &(*translatedAttribs)[attribIndex];
-        ANGLE_TRY(storeDynamicAttrib(dynamicAttrib, start, count, instances));
+        ANGLE_TRY(storeDynamicAttrib(context, dynamicAttrib, start, count, instances));
     }
 
     return gl::NoError();
 }
 
 void VertexDataManager::PromoteDynamicAttribs(
+    const gl::Context *context,
     const std::vector<TranslatedAttribute> &translatedAttribs,
     const gl::AttributesMask &dynamicAttribsMask,
     GLsizei count)
@@ -440,7 +445,7 @@
         {
             BufferD3D *bufferD3D = GetImplAs<BufferD3D>(buffer);
             size_t typeSize      = ComputeVertexAttributeTypeSize(*dynamicAttrib.attribute);
-            bufferD3D->promoteStaticUsage(count * static_cast<int>(typeSize));
+            bufferD3D->promoteStaticUsage(context, count * static_cast<int>(typeSize));
         }
     }
 }
@@ -483,7 +488,8 @@
                                                 instances);
 }
 
-gl::Error VertexDataManager::storeDynamicAttrib(TranslatedAttribute *translated,
+gl::Error VertexDataManager::storeDynamicAttrib(const gl::Context *context,
+                                                TranslatedAttribute *translated,
                                                 GLint start,
                                                 GLsizei count,
                                                 GLsizei instances)
@@ -506,7 +512,7 @@
 
     if (buffer)
     {
-        ANGLE_TRY(storage->getData(&sourceData));
+        ANGLE_TRY(storage->getData(context, &sourceData));
         sourceData += static_cast<int>(ComputeVertexAttributeOffset(attrib, binding));
     }
     else