Add a zero-filled scratch buffer to Context.

We need this in a few places for handling resource init.
Centralize this in the context so we don't have to recreate
and re-fill a large zero buffer.

BUG=angleproject:2107

Change-Id: Icf9ce417e7ee3498f03e47741dfff89e81b49519
Reviewed-on: https://chromium-review.googlesource.com/576057
Reviewed-by: Geoff Lang <geofflang@chromium.org>
Commit-Queue: Jamie Madill <jmadill@chromium.org>
diff --git a/src/libANGLE/Context.cpp b/src/libANGLE/Context.cpp
index 52c2176..35dcce6 100644
--- a/src/libANGLE/Context.cpp
+++ b/src/libANGLE/Context.cpp
@@ -272,7 +272,8 @@
       mSurfacelessFramebuffer(nullptr),
       mWebGLContext(GetWebGLContext(attribs)),
       mMemoryProgramCache(memoryProgramCache),
-      mScratchBuffer(1000u)
+      mScratchBuffer(1000u),
+      mZeroFilledBuffer(1000u)
 {
     if (mRobustAccess)
     {
@@ -4171,9 +4172,20 @@
     SetFramebufferParameteri(framebuffer, pname, param);
 }
 
-Error Context::getScratchBuffer(size_t requestedSize, angle::MemoryBuffer **scratchBufferOut) const
+Error Context::getScratchBuffer(size_t requstedSizeBytes,
+                                angle::MemoryBuffer **scratchBufferOut) const
 {
-    if (!mScratchBuffer.get(requestedSize, scratchBufferOut))
+    if (!mScratchBuffer.get(requstedSizeBytes, scratchBufferOut))
+    {
+        return OutOfMemory() << "Failed to allocate internal buffer.";
+    }
+    return NoError();
+}
+
+Error Context::getZeroFilledBuffer(size_t requstedSizeBytes,
+                                   angle::MemoryBuffer **zeroBufferOut) const
+{
+    if (!mZeroFilledBuffer.getInitialized(requstedSizeBytes, zeroBufferOut, 0))
     {
         return OutOfMemory() << "Failed to allocate internal buffer.";
     }