Fixed compiler warning C4267 'conversion from 'size_t' to 'type', possible loss of data'

BUG=angleproject:1120

Change-Id: I01ef10bea7f487c2b394d030c76628f38d2ea645
Reviewed-on: https://chromium-review.googlesource.com/292780
Tested-by: Cooper Partin <coopp@microsoft.com>
Reviewed-by: Geoff Lang <geofflang@chromium.org>
Reviewed-by: Jamie Madill <jmadill@chromium.org>
diff --git a/src/libANGLE/renderer/gl/BufferGL.cpp b/src/libANGLE/renderer/gl/BufferGL.cpp
index 605cf021..cb57afd 100644
--- a/src/libANGLE/renderer/gl/BufferGL.cpp
+++ b/src/libANGLE/renderer/gl/BufferGL.cpp
@@ -107,7 +107,7 @@
 
     mStateManager->bindBuffer(DestBufferOperationTarget, mBufferID);
     const uint8_t *bufferData = reinterpret_cast<uint8_t*>(mFunctions->mapBuffer(DestBufferOperationTarget, GL_READ_ONLY));
-    *outRange = gl::ComputeIndexRange(type, bufferData + offset, count);
+    *outRange = gl::ComputeIndexRange(type, bufferData + offset, static_cast<GLsizei>(count));
     mFunctions->unmapBuffer(DestBufferOperationTarget);
 
     return gl::Error(GL_NO_ERROR);
diff --git a/src/libANGLE/renderer/gl/FramebufferGL.cpp b/src/libANGLE/renderer/gl/FramebufferGL.cpp
index 6c2101a..300980b 100644
--- a/src/libANGLE/renderer/gl/FramebufferGL.cpp
+++ b/src/libANGLE/renderer/gl/FramebufferGL.cpp
@@ -96,8 +96,7 @@
     if (!mIsDefault)
     {
         mStateManager->bindFramebuffer(GL_FRAMEBUFFER, mFramebufferID);
-        BindFramebufferAttachment(mFunctions,
-                                  GL_COLOR_ATTACHMENT0 + index,
+        BindFramebufferAttachment(mFunctions, GL_COLOR_ATTACHMENT0 + static_cast<GLenum>(index),
                                   mData.getColorAttachment(static_cast<unsigned int>(index)));
     }
 }
@@ -140,7 +139,7 @@
     if (!mIsDefault)
     {
         mStateManager->bindFramebuffer(GL_FRAMEBUFFER, mFramebufferID);
-        mFunctions->drawBuffers(count, buffers);
+        mFunctions->drawBuffers(static_cast<GLsizei>(count), buffers);
     }
 }
 
@@ -165,7 +164,7 @@
     if (mFunctions->invalidateFramebuffer)
     {
         mStateManager->bindFramebuffer(GL_FRAMEBUFFER, mFramebufferID);
-        mFunctions->invalidateFramebuffer(GL_FRAMEBUFFER, count, attachments);
+        mFunctions->invalidateFramebuffer(GL_FRAMEBUFFER, static_cast<GLsizei>(count), attachments);
     }
 
     return gl::Error(GL_NO_ERROR);
@@ -177,7 +176,8 @@
     if (mFunctions->invalidateSubFramebuffer)
     {
         mStateManager->bindFramebuffer(GL_FRAMEBUFFER, mFramebufferID);
-        mFunctions->invalidateSubFramebuffer(GL_FRAMEBUFFER, count, attachments, area.x, area.y, area.width, area.height);
+        mFunctions->invalidateSubFramebuffer(GL_FRAMEBUFFER, static_cast<GLsizei>(count),
+                                             attachments, area.x, area.y, area.width, area.height);
     }
 
     return gl::Error(GL_NO_ERROR);
diff --git a/src/libANGLE/renderer/gl/ProgramGL.cpp b/src/libANGLE/renderer/gl/ProgramGL.cpp
index f92ad6e..bb3571d 100644
--- a/src/libANGLE/renderer/gl/ProgramGL.cpp
+++ b/src/libANGLE/renderer/gl/ProgramGL.cpp
@@ -132,7 +132,9 @@
         GLsizei uniformNameLength = 0;
         GLint uniformSize = 0;
         GLenum uniformType = GL_NONE;
-        mFunctions->getActiveUniform(mProgramID, i, uniformNameBuffer.size(), &uniformNameLength, &uniformSize, &uniformType, &uniformNameBuffer[0]);
+        mFunctions->getActiveUniform(mProgramID, i, static_cast<GLsizei>(uniformNameBuffer.size()),
+                                     &uniformNameLength, &uniformSize, &uniformType,
+                                     &uniformNameBuffer[0]);
 
         size_t subscript = 0;
         std::string uniformName = gl::ParseUniformName(std::string(&uniformNameBuffer[0], uniformNameLength), &subscript);
@@ -144,13 +146,15 @@
             std::string locationName = uniformName;
             if (isArray)
             {
-                locationName += "[" + Str(arrayIndex) + "]";
+                locationName += "[" + Str(static_cast<int>(arrayIndex)) + "]";
             }
 
             GLint location = mFunctions->getUniformLocation(mProgramID, locationName.c_str());
             if (location >= 0)
             {
-                mUniformIndex[location] = gl::VariableLocation(uniformName, arrayIndex, static_cast<unsigned int>(mUniforms.size()));
+                mUniformIndex[location] =
+                    gl::VariableLocation(uniformName, static_cast<unsigned int>(arrayIndex),
+                                         static_cast<unsigned int>(mUniforms.size()));
 
                 // If the uniform is a sampler, track it in the sampler bindings array
                 if (gl::IsSamplerType(uniformType))
@@ -192,7 +196,9 @@
         GLsizei attributeNameLength = 0;
         GLint attributeSize = 0;
         GLenum attributeType = GL_NONE;
-        mFunctions->getActiveAttrib(mProgramID, i, attributeNameBuffer.size(), &attributeNameLength, &attributeSize, &attributeType, &attributeNameBuffer[0]);
+        mFunctions->getActiveAttrib(mProgramID, i, static_cast<GLsizei>(attributeNameBuffer.size()),
+                                    &attributeNameLength, &attributeSize, &attributeType,
+                                    &attributeNameBuffer[0]);
 
         std::string attributeName(&attributeNameBuffer[0], attributeNameLength);
 
diff --git a/src/libANGLE/renderer/gl/RenderbufferGL.cpp b/src/libANGLE/renderer/gl/RenderbufferGL.cpp
index 416fc29..bfc2bb2 100644
--- a/src/libANGLE/renderer/gl/RenderbufferGL.cpp
+++ b/src/libANGLE/renderer/gl/RenderbufferGL.cpp
@@ -45,8 +45,8 @@
 
     nativegl::RenderbufferFormat renderbufferFormat =
         nativegl::GetRenderbufferFormat(mFunctions, mWorkarounds, internalformat);
-    mFunctions->renderbufferStorage(GL_RENDERBUFFER, renderbufferFormat.internalFormat, width,
-                                    height);
+    mFunctions->renderbufferStorage(GL_RENDERBUFFER, renderbufferFormat.internalFormat,
+                                    static_cast<GLsizei>(width), static_cast<GLsizei>(height));
 
     return gl::Error(GL_NO_ERROR);
 }
@@ -57,8 +57,9 @@
 
     nativegl::RenderbufferFormat renderbufferFormat =
         nativegl::GetRenderbufferFormat(mFunctions, mWorkarounds, internalformat);
-    mFunctions->renderbufferStorageMultisample(GL_RENDERBUFFER, samples,
-                                               renderbufferFormat.internalFormat, width, height);
+    mFunctions->renderbufferStorageMultisample(
+        GL_RENDERBUFFER, static_cast<GLsizei>(samples), renderbufferFormat.internalFormat,
+        static_cast<GLsizei>(width), static_cast<GLsizei>(height));
 
     const gl::TextureCaps &formatCaps = mTextureCaps.get(internalformat);
     if (samples > formatCaps.getMaxSamples())
diff --git a/src/libANGLE/renderer/gl/StateManagerGL.cpp b/src/libANGLE/renderer/gl/StateManagerGL.cpp
index 99465ad..2f07074 100644
--- a/src/libANGLE/renderer/gl/StateManagerGL.cpp
+++ b/src/libANGLE/renderer/gl/StateManagerGL.cpp
@@ -238,7 +238,7 @@
     if (mTextureUnitIndex != unit)
     {
         mTextureUnitIndex = unit;
-        mFunctions->activeTexture(GL_TEXTURE0 + mTextureUnitIndex);
+        mFunctions->activeTexture(GL_TEXTURE0 + static_cast<GLenum>(mTextureUnitIndex));
     }
 }
 
@@ -470,9 +470,18 @@
         mVertexAttribCurrentValues[index] = data;
         switch (mVertexAttribCurrentValues[index].Type)
         {
-          case GL_FLOAT:        mFunctions->vertexAttrib4fv(index,  mVertexAttribCurrentValues[index].FloatValues);       break;
-          case GL_INT:          mFunctions->vertexAttrib4iv(index,  mVertexAttribCurrentValues[index].IntValues);         break;
-          case GL_UNSIGNED_INT: mFunctions->vertexAttrib4uiv(index, mVertexAttribCurrentValues[index].UnsignedIntValues); break;
+            case GL_FLOAT:
+                mFunctions->vertexAttrib4fv(static_cast<GLuint>(index),
+                                            mVertexAttribCurrentValues[index].FloatValues);
+                break;
+            case GL_INT:
+                mFunctions->vertexAttrib4iv(static_cast<GLuint>(index),
+                                            mVertexAttribCurrentValues[index].IntValues);
+                break;
+            case GL_UNSIGNED_INT:
+                mFunctions->vertexAttrib4uiv(static_cast<GLuint>(index),
+                                             mVertexAttribCurrentValues[index].UnsignedIntValues);
+                break;
           default: UNREACHABLE();
         }
     }
diff --git a/src/libANGLE/renderer/gl/TextureGL.cpp b/src/libANGLE/renderer/gl/TextureGL.cpp
index 6dca94a..9a18953 100644
--- a/src/libANGLE/renderer/gl/TextureGL.cpp
+++ b/src/libANGLE/renderer/gl/TextureGL.cpp
@@ -89,13 +89,14 @@
     if (UseTexImage2D(mTextureType))
     {
         ASSERT(size.depth == 1);
-        mFunctions->texImage2D(target, level, texImageFormat.internalFormat, size.width,
-                               size.height, 0, texImageFormat.format, texImageFormat.type, pixels);
+        mFunctions->texImage2D(target, static_cast<GLint>(level), texImageFormat.internalFormat,
+                               size.width, size.height, 0, texImageFormat.format,
+                               texImageFormat.type, pixels);
     }
     else if (UseTexImage3D(mTextureType))
     {
-        mFunctions->texImage3D(target, level, texImageFormat.internalFormat, size.width,
-                               size.height, size.depth, 0, texImageFormat.format,
+        mFunctions->texImage3D(target, static_cast<GLint>(level), texImageFormat.internalFormat,
+                               size.width, size.height, size.depth, 0, texImageFormat.format,
                                texImageFormat.type, pixels);
     }
     else
@@ -118,14 +119,15 @@
     if (UseTexImage2D(mTextureType))
     {
         ASSERT(area.z == 0 && area.depth == 1);
-        mFunctions->texSubImage2D(target, level, area.x, area.y, area.width, area.height,
-                                  texSubImageFormat.format, texSubImageFormat.type, pixels);
+        mFunctions->texSubImage2D(target, static_cast<GLint>(level), area.x, area.y, area.width,
+                                  area.height, texSubImageFormat.format, texSubImageFormat.type,
+                                  pixels);
     }
     else if (UseTexImage3D(mTextureType))
     {
-        mFunctions->texSubImage3D(target, level, area.x, area.y, area.z, area.width, area.height,
-                                  area.depth, texSubImageFormat.format, texSubImageFormat.type,
-                                  pixels);
+        mFunctions->texSubImage3D(target, static_cast<GLint>(level), area.x, area.y, area.z,
+                                  area.width, area.height, area.depth, texSubImageFormat.format,
+                                  texSubImageFormat.type, pixels);
     }
     else
     {
@@ -147,13 +149,15 @@
     if (UseTexImage2D(mTextureType))
     {
         ASSERT(size.depth == 1);
-        mFunctions->compressedTexImage2D(target, level, compressedTexImageFormat.internalFormat,
-                                         size.width, size.height, 0, imageSize, pixels);
+        mFunctions->compressedTexImage2D(target, static_cast<GLint>(level),
+                                         compressedTexImageFormat.internalFormat, size.width,
+                                         size.height, 0, static_cast<GLsizei>(imageSize), pixels);
     }
     else if (UseTexImage3D(mTextureType))
     {
-        mFunctions->compressedTexImage3D(target, level, compressedTexImageFormat.internalFormat,
-                                         size.width, size.height, size.depth, 0, imageSize, pixels);
+        mFunctions->compressedTexImage3D(
+            target, static_cast<GLint>(level), compressedTexImageFormat.internalFormat, size.width,
+            size.height, size.depth, 0, static_cast<GLsizei>(imageSize), pixels);
     }
     else
     {
@@ -175,14 +179,16 @@
     if (UseTexImage2D(mTextureType))
     {
         ASSERT(area.z == 0 && area.depth == 1);
-        mFunctions->compressedTexSubImage2D(target, level, area.x, area.y, area.width, area.height,
-                                            compressedTexSubImageFormat.format, imageSize, pixels);
+        mFunctions->compressedTexSubImage2D(
+            target, static_cast<GLint>(level), area.x, area.y, area.width, area.height,
+            compressedTexSubImageFormat.format, static_cast<GLsizei>(imageSize), pixels);
     }
     else if (UseTexImage3D(mTextureType))
     {
-        mFunctions->compressedTexSubImage3D(target, level, area.x, area.y, area.z, area.width,
-                                            area.height, area.depth,
-                                            compressedTexSubImageFormat.format, imageSize, pixels);
+        mFunctions->compressedTexSubImage3D(target, static_cast<GLint>(level), area.x, area.y,
+                                            area.z, area.width, area.height, area.depth,
+                                            compressedTexSubImageFormat.format,
+                                            static_cast<GLsizei>(imageSize), pixels);
     }
     else
     {
@@ -205,8 +211,9 @@
 
     if (UseTexImage2D(mTextureType))
     {
-        mFunctions->copyTexImage2D(target, level, copyTexImageFormat.internalFormat, sourceArea.x,
-                                   sourceArea.y, sourceArea.width, sourceArea.height, 0);
+        mFunctions->copyTexImage2D(target, static_cast<GLint>(level),
+                                   copyTexImageFormat.internalFormat, sourceArea.x, sourceArea.y,
+                                   sourceArea.width, sourceArea.height, 0);
     }
     else
     {
@@ -227,13 +234,15 @@
     if (UseTexImage2D(mTextureType))
     {
         ASSERT(destOffset.z == 0);
-        mFunctions->copyTexSubImage2D(target, level, destOffset.x, destOffset.y,
-                                      sourceArea.x, sourceArea.y, sourceArea.width, sourceArea.height);
+        mFunctions->copyTexSubImage2D(target, static_cast<GLint>(level), destOffset.x, destOffset.y,
+                                      sourceArea.x, sourceArea.y, sourceArea.width,
+                                      sourceArea.height);
     }
     else if (UseTexImage3D(mTextureType))
     {
-        mFunctions->copyTexSubImage3D(target, level, destOffset.x, destOffset.y, destOffset.z,
-                                      sourceArea.x, sourceArea.y, sourceArea.width, sourceArea.height);
+        mFunctions->copyTexSubImage3D(target, static_cast<GLint>(level), destOffset.x, destOffset.y,
+                                      destOffset.z, sourceArea.x, sourceArea.y, sourceArea.width,
+                                      sourceArea.height);
     }
     else
     {
@@ -257,8 +266,8 @@
         ASSERT(size.depth == 1);
         if (mFunctions->texStorage2D)
         {
-            mFunctions->texStorage2D(target, levels, texStorageFormat.internalFormat, size.width,
-                                     size.height);
+            mFunctions->texStorage2D(target, static_cast<GLsizei>(levels),
+                                     texStorageFormat.internalFormat, size.width, size.height);
         }
         else
         {
@@ -281,16 +290,17 @@
                     if (internalFormatInfo.compressed)
                     {
                         size_t dataSize = internalFormatInfo.computeBlockSize(GL_UNSIGNED_BYTE, levelSize.width, levelSize.height);
-                        mFunctions->compressedTexImage2D(
-                            target, level, texStorageFormat.internalFormat, levelSize.width,
-                            levelSize.height, 0, dataSize, nullptr);
+                        mFunctions->compressedTexImage2D(target, static_cast<GLint>(level),
+                                                         texStorageFormat.internalFormat,
+                                                         levelSize.width, levelSize.height, 0,
+                                                         static_cast<GLsizei>(dataSize), nullptr);
                     }
                     else
                     {
-                        mFunctions->texImage2D(target, level, texStorageFormat.internalFormat,
-                                               levelSize.width, levelSize.height, 0,
-                                               internalFormatInfo.format, internalFormatInfo.type,
-                                               nullptr);
+                        mFunctions->texImage2D(target, static_cast<GLint>(level),
+                                               texStorageFormat.internalFormat, levelSize.width,
+                                               levelSize.height, 0, internalFormatInfo.format,
+                                               internalFormatInfo.type, nullptr);
                     }
                 }
                 else if (mTextureType == GL_TEXTURE_CUBE_MAP)
@@ -301,14 +311,15 @@
                         {
                             size_t dataSize = internalFormatInfo.computeBlockSize(GL_UNSIGNED_BYTE, levelSize.width, levelSize.height);
                             mFunctions->compressedTexImage2D(
-                                face, level, texStorageFormat.internalFormat, levelSize.width,
-                                levelSize.height, 0, dataSize, nullptr);
+                                face, static_cast<GLint>(level), texStorageFormat.internalFormat,
+                                levelSize.width, levelSize.height, 0,
+                                static_cast<GLsizei>(dataSize), nullptr);
                         }
                         else
                         {
-                            mFunctions->texImage2D(face, level, texStorageFormat.internalFormat,
-                                                   levelSize.width, levelSize.height, 0,
-                                                   internalFormatInfo.format,
+                            mFunctions->texImage2D(face, static_cast<GLint>(level),
+                                                   texStorageFormat.internalFormat, levelSize.width,
+                                                   levelSize.height, 0, internalFormatInfo.format,
                                                    internalFormatInfo.type, nullptr);
                         }
                     }
@@ -324,8 +335,9 @@
     {
         if (mFunctions->texStorage3D)
         {
-            mFunctions->texStorage3D(target, levels, texStorageFormat.internalFormat, size.width,
-                                     size.height, size.depth);
+            mFunctions->texStorage3D(target, static_cast<GLsizei>(levels),
+                                     texStorageFormat.internalFormat, size.width, size.height,
+                                     size.depth);
         }
         else
         {
@@ -337,7 +349,7 @@
             // Internal format must be sized
             ASSERT(internalFormatInfo.pixelBytes != 0);
 
-            for (size_t i = 0; i < levels; i++)
+            for (GLsizei i = 0; i < static_cast<GLsizei>(levels); i++)
             {
                 gl::Extents levelSize(std::max(size.width >> i, 1),
                                       std::max(size.height >> i, 1),
@@ -345,7 +357,9 @@
 
                 if (internalFormatInfo.compressed)
                 {
-                    size_t dataSize = internalFormatInfo.computeBlockSize(GL_UNSIGNED_BYTE, levelSize.width, levelSize.height) * levelSize.depth;
+                    GLsizei dataSize = static_cast<GLsizei>(internalFormatInfo.computeBlockSize(
+                                           GL_UNSIGNED_BYTE, levelSize.width, levelSize.height)) *
+                                       levelSize.depth;
                     mFunctions->compressedTexImage3D(target, i, texStorageFormat.internalFormat,
                                                      levelSize.width, levelSize.height,
                                                      levelSize.depth, 0, dataSize, nullptr);
diff --git a/src/libANGLE/renderer/gl/VertexArrayGL.cpp b/src/libANGLE/renderer/gl/VertexArrayGL.cpp
index a2ca881..13c9539 100644
--- a/src/libANGLE/renderer/gl/VertexArrayGL.cpp
+++ b/src/libANGLE/renderer/gl/VertexArrayGL.cpp
@@ -384,9 +384,10 @@
                 // Compute where the 0-index vertex would be.
                 const size_t vertexStartOffset = curBufferOffset - (indexRange.start * destStride);
 
-                mFunctions->vertexAttribPointer(idx, attrib.size, attrib.type,
-                                                attrib.normalized, destStride,
-                                                reinterpret_cast<const GLvoid*>(vertexStartOffset));
+                mFunctions->vertexAttribPointer(
+                    idx, attrib.size, attrib.type, attrib.normalized,
+                    static_cast<GLsizei>(destStride),
+                    reinterpret_cast<const GLvoid *>(vertexStartOffset));
 
                 curBufferOffset += destStride * streamedVertexCount;
 
diff --git a/src/libANGLE/renderer/gl/renderergl_utils.cpp b/src/libANGLE/renderer/gl/renderergl_utils.cpp
index 371d94a..527f25a 100644
--- a/src/libANGLE/renderer/gl/renderergl_utils.cpp
+++ b/src/libANGLE/renderer/gl/renderergl_utils.cpp
@@ -97,7 +97,8 @@
         if (numSamples > 0)
         {
             std::vector<GLint> samples(numSamples);
-            functions->getInternalformativ(GL_RENDERBUFFER, internalFormat, GL_SAMPLES, samples.size(), &samples[0]);
+            functions->getInternalformativ(GL_RENDERBUFFER, internalFormat, GL_SAMPLES,
+                                           static_cast<GLsizei>(samples.size()), &samples[0]);
             for (size_t sampleIndex = 0; sampleIndex < samples.size(); sampleIndex++)
             {
                 textureCaps.sampleCounts.insert(samples[sampleIndex]);