Reland Fixed compiler warning C4267 'conversion from 'size_t' to 'type', possible loss of data'
Additional warnings found with more testing and added C4267 warning disable only for angle_libpng
BUG=angleproject:1120
Change-Id: Ic403dcff5a8018056fa51a8c408e64207f3362eb
Reviewed-on: https://chromium-review.googlesource.com/293028
Reviewed-by: Jamie Madill <jmadill@chromium.org>
Reviewed-by: Geoff Lang <geofflang@chromium.org>
Tested-by: Geoff Lang <geofflang@chromium.org>
diff --git a/src/libANGLE/renderer/d3d/ProgramD3D.cpp b/src/libANGLE/renderer/d3d/ProgramD3D.cpp
index 3532634..9290914 100644
--- a/src/libANGLE/renderer/d3d/ProgramD3D.cpp
+++ b/src/libANGLE/renderer/d3d/ProgramD3D.cpp
@@ -90,7 +90,8 @@
if (!shaderOutputVars.empty())
{
- defaultPixelOutput.push_back(GL_COLOR_ATTACHMENT0 + shaderOutputVars[0].outputIndex);
+ defaultPixelOutput.push_back(GL_COLOR_ATTACHMENT0 +
+ static_cast<unsigned int>(shaderOutputVars[0].outputIndex));
}
return defaultPixelOutput;
@@ -948,7 +949,7 @@
else if (!infoLog)
{
std::vector<char> tempCharBuffer(tempInfoLog.getLength() + 3);
- tempInfoLog.getLog(tempInfoLog.getLength(), NULL, &tempCharBuffer[0]);
+ tempInfoLog.getLog(static_cast<GLsizei>(tempInfoLog.getLength()), NULL, &tempCharBuffer[0]);
ERR("Error compiling dynamic pixel executable:\n%s\n", &tempCharBuffer[0]);
}
@@ -996,7 +997,7 @@
else if (!infoLog)
{
std::vector<char> tempCharBuffer(tempInfoLog.getLength() + 3);
- tempInfoLog.getLog(tempInfoLog.getLength(), NULL, &tempCharBuffer[0]);
+ tempInfoLog.getLog(static_cast<GLsizei>(tempInfoLog.getLength()), NULL, &tempCharBuffer[0]);
ERR("Error compiling dynamic vertex executable:\n%s\n", &tempCharBuffer[0]);
}
@@ -1253,7 +1254,7 @@
void ProgramD3D::dirtyAllUniforms()
{
- unsigned int numUniforms = mUniforms.size();
+ unsigned int numUniforms = static_cast<unsigned int>(mUniforms.size());
for (unsigned int index = 0; index < numUniforms; index++)
{
mUniforms[index]->dirty = true;
@@ -1509,7 +1510,8 @@
ASSERT(linkedUniform);
if (encoder)
- linkedUniform->registerElement = sh::HLSLBlockEncoder::getBlockRegisterElement(blockInfo);
+ linkedUniform->registerElement = static_cast<unsigned int>(
+ sh::HLSLBlockEncoder::getBlockRegisterElement(blockInfo));
mUniforms.push_back(linkedUniform);
}
@@ -1517,11 +1519,13 @@
{
if (shader->getShaderType() == GL_FRAGMENT_SHADER)
{
- linkedUniform->psRegisterIndex = sh::HLSLBlockEncoder::getBlockRegister(blockInfo);
+ linkedUniform->psRegisterIndex =
+ static_cast<unsigned int>(sh::HLSLBlockEncoder::getBlockRegister(blockInfo));
}
else if (shader->getShaderType() == GL_VERTEX_SHADER)
{
- linkedUniform->vsRegisterIndex = sh::HLSLBlockEncoder::getBlockRegister(blockInfo);
+ linkedUniform->vsRegisterIndex =
+ static_cast<unsigned int>(sh::HLSLBlockEncoder::getBlockRegister(blockInfo));
}
else UNREACHABLE();
}
@@ -1821,7 +1825,7 @@
blockIndex, memberInfo);
// add to uniform list, but not index, since uniform block uniforms have no location
- blockUniformIndexes->push_back(mUniforms.size());
+ blockUniformIndexes->push_back(static_cast<GLenum>(mUniforms.size()));
mUniforms.push_back(newUniform);
}
}
@@ -1838,7 +1842,7 @@
if (getUniformBlockIndex(interfaceBlock.name) == GL_INVALID_INDEX)
{
std::vector<unsigned int> blockUniformIndexes;
- const unsigned int blockIndex = mUniformBlocks.size();
+ const unsigned int blockIndex = static_cast<unsigned int>(mUniformBlocks.size());
// define member uniforms
sh::BlockLayoutEncoder *encoder = NULL;
@@ -1855,7 +1859,7 @@
defineUniformBlockMembers(interfaceBlock.fields, "", blockIndex, encoder, &blockUniformIndexes, interfaceBlock.isRowMajorLayout);
- size_t dataSize = encoder->getBlockSize();
+ unsigned int dataSize = static_cast<unsigned int>(encoder->getBlockSize());
// create all the uniform blocks
if (interfaceBlock.arraySize > 0)
@@ -1995,7 +1999,8 @@
if (!uniform.isBuiltIn())
{
// Assign in-order uniform locations
- mUniformIndex[mUniformIndex.size()] = gl::VariableLocation(uniform.name, arrayIndex, uniformIndex);
+ mUniformIndex[static_cast<GLuint>(mUniformIndex.size())] = gl::VariableLocation(
+ uniform.name, arrayIndex, static_cast<unsigned int>(uniformIndex));
}
}
}