Replace reinterpret_cast with safer or no cast
When casting types to one another in C++, the weaker the cast,
the better.
This change replaces instances of reinterpret_cast with static_cast
or no cast where it safe and correct to do so.
BUG=angleproject:2683
Change-Id: I99c9033614a65282ae1d78cf0f4b80fabd75877a
Reviewed-on: https://chromium-review.googlesource.com/1109396
Commit-Queue: Rafael Cintron <rafael.cintron@microsoft.com>
Reviewed-by: Jamie Madill <jmadill@chromium.org>
diff --git a/src/common/MemoryBuffer.cpp b/src/common/MemoryBuffer.cpp
index 6f5188c..3f02124 100644
--- a/src/common/MemoryBuffer.cpp
+++ b/src/common/MemoryBuffer.cpp
@@ -41,7 +41,7 @@
}
// Only reallocate if the size has changed.
- uint8_t *newMemory = reinterpret_cast<uint8_t *>(malloc(sizeof(uint8_t) * size));
+ uint8_t *newMemory = static_cast<uint8_t *>(malloc(sizeof(uint8_t) * size));
if (newMemory == nullptr)
{
return false;
diff --git a/src/common/vector_utils.h b/src/common/vector_utils.h
index 9f5bee1..d23a836 100644
--- a/src/common/vector_utils.h
+++ b/src/common/vector_utils.h
@@ -367,7 +367,7 @@
{
mData[i] += other.mData[i];
}
- return *reinterpret_cast<Vector<Dimension, Type> *>(this);
+ return *static_cast<Vector<Dimension, Type> *>(this);
}
template <size_t Dimension, typename Type>
@@ -378,7 +378,7 @@
{
mData[i] -= other.mData[i];
}
- return *reinterpret_cast<Vector<Dimension, Type> *>(this);
+ return *static_cast<Vector<Dimension, Type> *>(this);
}
template <size_t Dimension, typename Type>
@@ -389,7 +389,7 @@
{
mData[i] *= other.mData[i];
}
- return *reinterpret_cast<Vector<Dimension, Type> *>(this);
+ return *static_cast<Vector<Dimension, Type> *>(this);
}
template <size_t Dimension, typename Type>
@@ -400,7 +400,7 @@
{
mData[i] /= other.mData[i];
}
- return *reinterpret_cast<Vector<Dimension, Type> *>(this);
+ return *static_cast<Vector<Dimension, Type> *>(this);
}
template <size_t Dimension, typename Type>
@@ -410,7 +410,7 @@
{
mData[i] *= other;
}
- return *reinterpret_cast<Vector<Dimension, Type> *>(this);
+ return *static_cast<Vector<Dimension, Type> *>(this);
}
template <size_t Dimension, typename Type>
@@ -420,7 +420,7 @@
{
mData[i] /= other;
}
- return *reinterpret_cast<Vector<Dimension, Type> *>(this);
+ return *static_cast<Vector<Dimension, Type> *>(this);
}
// Implementation of comparison operators
diff --git a/src/compiler/translator/Common.h b/src/compiler/translator/Common.h
index b606e85..f2dfc6a 100644
--- a/src/compiler/translator/Common.h
+++ b/src/compiler/translator/Common.h
@@ -121,7 +121,7 @@
inline const char *AllocatePoolCharArray(const char *str, size_t strLength)
{
size_t requiredSize = strLength + 1;
- char *buffer = reinterpret_cast<char *>(GetGlobalPoolAllocator()->allocate(requiredSize));
+ char *buffer = static_cast<char *>(GetGlobalPoolAllocator()->allocate(requiredSize));
memcpy(buffer, str, requiredSize);
ASSERT(buffer[strLength] == '\0');
return buffer;
diff --git a/src/compiler/translator/ImmutableStringBuilder.h b/src/compiler/translator/ImmutableStringBuilder.h
index 09fcc71..f7ed515 100644
--- a/src/compiler/translator/ImmutableStringBuilder.h
+++ b/src/compiler/translator/ImmutableStringBuilder.h
@@ -58,7 +58,7 @@
inline static char *AllocateEmptyPoolCharArray(size_t strLength)
{
size_t requiredSize = strLength + 1u;
- return reinterpret_cast<char *>(GetGlobalPoolAllocator()->allocate(requiredSize));
+ return static_cast<char *>(GetGlobalPoolAllocator()->allocate(requiredSize));
}
size_t mPos;
diff --git a/src/compiler/translator/PoolAlloc.h b/src/compiler/translator/PoolAlloc.h
index ad63bc4..5373264 100644
--- a/src/compiler/translator/PoolAlloc.h
+++ b/src/compiler/translator/PoolAlloc.h
@@ -295,11 +295,11 @@
#else
pointer allocate(size_type n)
{
- return reinterpret_cast<pointer>(getAllocator().allocate(n * sizeof(T)));
+ return static_cast<pointer>(getAllocator().allocate(n * sizeof(T)));
}
pointer allocate(size_type n, const void *)
{
- return reinterpret_cast<pointer>(getAllocator().allocate(n * sizeof(T)));
+ return static_cast<pointer>(getAllocator().allocate(n * sizeof(T)));
}
void deallocate(pointer, size_type) {}
#endif // _RWSTD_ALLOCATOR
diff --git a/src/compiler/translator/ShaderLang.cpp b/src/compiler/translator/ShaderLang.cpp
index e1f814b..d8aff5f 100644
--- a/src/compiler/translator/ShaderLang.cpp
+++ b/src/compiler/translator/ShaderLang.cpp
@@ -313,7 +313,7 @@
return 0;
}
- return reinterpret_cast<void *>(base);
+ return base;
}
void Destruct(ShHandle handle)
diff --git a/src/compiler/translator/tree_util/IntermNode_util.cpp b/src/compiler/translator/tree_util/IntermNode_util.cpp
index cb3029d..d5c822a 100644
--- a/src/compiler/translator/tree_util/IntermNode_util.cpp
+++ b/src/compiler/translator/tree_util/IntermNode_util.cpp
@@ -236,7 +236,7 @@
TIntermSymbol *ReferenceGlobalVariable(const ImmutableString &name, const TSymbolTable &symbolTable)
{
- const TVariable *var = reinterpret_cast<const TVariable *>(symbolTable.findGlobal(name));
+ const TVariable *var = static_cast<const TVariable *>(symbolTable.findGlobal(name));
ASSERT(var);
return new TIntermSymbol(var);
}
@@ -246,7 +246,7 @@
int shaderVersion)
{
const TVariable *var =
- reinterpret_cast<const TVariable *>(symbolTable.findBuiltIn(name, shaderVersion));
+ static_cast<const TVariable *>(symbolTable.findBuiltIn(name, shaderVersion));
ASSERT(var);
return new TIntermSymbol(var);
}
diff --git a/src/libANGLE/Context.cpp b/src/libANGLE/Context.cpp
index 910e249..20ef5e9 100644
--- a/src/libANGLE/Context.cpp
+++ b/src/libANGLE/Context.cpp
@@ -3815,7 +3815,7 @@
Extents size(width, height, 1);
Texture *texture = getTargetTexture(TextureTargetToType(target));
handleError(texture->setImage(this, mGLState.getUnpackState(), target, level, internalformat,
- size, format, type, reinterpret_cast<const uint8_t *>(pixels)));
+ size, format, type, static_cast<const uint8_t *>(pixels)));
}
void Context::texImage2DRobust(TextureTarget target,
@@ -3849,7 +3849,7 @@
Texture *texture = getTargetTexture(target);
handleError(texture->setImage(this, mGLState.getUnpackState(),
NonCubeTextureTypeToTarget(target), level, internalformat, size,
- format, type, reinterpret_cast<const uint8_t *>(pixels)));
+ format, type, static_cast<const uint8_t *>(pixels)));
}
void Context::texImage3DRobust(TextureType target,
@@ -3888,7 +3888,7 @@
Box area(xoffset, yoffset, 0, width, height, 1);
Texture *texture = getTargetTexture(TextureTargetToType(target));
handleError(texture->setSubImage(this, mGLState.getUnpackState(), target, level, area, format,
- type, reinterpret_cast<const uint8_t *>(pixels)));
+ type, static_cast<const uint8_t *>(pixels)));
}
void Context::texSubImage2DRobust(TextureTarget target,
@@ -3929,7 +3929,7 @@
Texture *texture = getTargetTexture(target);
handleError(texture->setSubImage(this, mGLState.getUnpackState(),
NonCubeTextureTypeToTarget(target), level, area, format, type,
- reinterpret_cast<const uint8_t *>(pixels)));
+ static_cast<const uint8_t *>(pixels)));
}
void Context::texSubImage3DRobust(TextureType target,
@@ -3964,7 +3964,7 @@
Texture *texture = getTargetTexture(TextureTargetToType(target));
handleError(texture->setCompressedImage(this, mGLState.getUnpackState(), target, level,
internalformat, size, imageSize,
- reinterpret_cast<const uint8_t *>(data)));
+ static_cast<const uint8_t *>(data)));
}
void Context::compressedTexImage2DRobust(TextureTarget target,
@@ -3996,7 +3996,7 @@
Texture *texture = getTargetTexture(target);
handleError(texture->setCompressedImage(
this, mGLState.getUnpackState(), NonCubeTextureTypeToTarget(target), level, internalformat,
- size, imageSize, reinterpret_cast<const uint8_t *>(data)));
+ size, imageSize, static_cast<const uint8_t *>(data)));
}
void Context::compressedTexImage3DRobust(TextureType target,
@@ -4030,7 +4030,7 @@
Texture *texture = getTargetTexture(TextureTargetToType(target));
handleError(texture->setCompressedSubImage(this, mGLState.getUnpackState(), target, level, area,
format, imageSize,
- reinterpret_cast<const uint8_t *>(data)));
+ static_cast<const uint8_t *>(data)));
}
void Context::compressedTexSubImage2DRobust(TextureTarget target,
@@ -4072,7 +4072,7 @@
Texture *texture = getTargetTexture(target);
handleError(texture->setCompressedSubImage(
this, mGLState.getUnpackState(), NonCubeTextureTypeToTarget(target), level, area, format,
- imageSize, reinterpret_cast<const uint8_t *>(data)));
+ imageSize, static_cast<const uint8_t *>(data)));
}
void Context::compressedTexSubImage3DRobust(TextureType target,
@@ -6648,14 +6648,14 @@
void Context::eGLImageTargetTexture2D(TextureType target, GLeglImageOES image)
{
Texture *texture = getTargetTexture(target);
- egl::Image *imageObject = reinterpret_cast<egl::Image *>(image);
+ egl::Image *imageObject = static_cast<egl::Image *>(image);
handleError(texture->setEGLImageTarget(this, target, imageObject));
}
void Context::eGLImageTargetRenderbufferStorage(GLenum target, GLeglImageOES image)
{
Renderbuffer *renderbuffer = mGLState.getCurrentRenderbuffer();
- egl::Image *imageObject = reinterpret_cast<egl::Image *>(image);
+ egl::Image *imageObject = static_cast<egl::Image *>(image);
handleError(renderbuffer->setStorageEGLImageTarget(this, imageObject));
}
diff --git a/src/libANGLE/renderer/d3d/DeviceD3D.cpp b/src/libANGLE/renderer/d3d/DeviceD3D.cpp
index 7d3d004..cfc0dec 100644
--- a/src/libANGLE/renderer/d3d/DeviceD3D.cpp
+++ b/src/libANGLE/renderer/d3d/DeviceD3D.cpp
@@ -28,7 +28,7 @@
if (mIsInitialized && mDeviceType == EGL_D3D11_DEVICE_ANGLE)
{
// DeviceD3D holds a ref to an externally-sourced D3D11 device. We must release it.
- ID3D11Device *device = reinterpret_cast<ID3D11Device *>(mDevice);
+ ID3D11Device *device = static_cast<ID3D11Device *>(mDevice);
device->Release();
}
#endif
@@ -49,7 +49,7 @@
if (mDeviceType == EGL_D3D11_DEVICE_ANGLE)
{
// Validate the device
- IUnknown *iunknown = reinterpret_cast<IUnknown *>(mDevice);
+ IUnknown *iunknown = static_cast<IUnknown *>(mDevice);
ID3D11Device *d3dDevice = nullptr;
HRESULT hr =
diff --git a/src/libANGLE/renderer/d3d/FramebufferD3D.cpp b/src/libANGLE/renderer/d3d/FramebufferD3D.cpp
index 1aca71b..53274ae 100644
--- a/src/libANGLE/renderer/d3d/FramebufferD3D.cpp
+++ b/src/libANGLE/renderer/d3d/FramebufferD3D.cpp
@@ -270,7 +270,7 @@
(area.x - origArea.x) * sizedFormatInfo.pixelBytes + (area.y - origArea.y) * outputPitch;
return readPixelsImpl(context, area, format, type, outputPitch, packState,
- reinterpret_cast<uint8_t *>(pixels) + outputSkipBytes);
+ static_cast<uint8_t *>(pixels) + outputSkipBytes);
}
gl::Error FramebufferD3D::blit(const gl::Context *context,
diff --git a/src/libANGLE/renderer/d3d/HLSLCompiler.cpp b/src/libANGLE/renderer/d3d/HLSLCompiler.cpp
index b387650..db0bffb 100644
--- a/src/libANGLE/renderer/d3d/HLSLCompiler.cpp
+++ b/src/libANGLE/renderer/d3d/HLSLCompiler.cpp
@@ -217,7 +217,7 @@
if (errorMessage)
{
- std::string message = reinterpret_cast<const char*>(errorMessage->GetBufferPointer());
+ std::string message = static_cast<const char *>(errorMessage->GetBufferPointer());
SafeRelease(errorMessage);
infoLog.appendSanitized(message.c_str());
@@ -314,7 +314,7 @@
if (SUCCEEDED(result))
{
- *disassemblyOut = std::string(reinterpret_cast<const char*>(disassembly->GetBufferPointer()));
+ *disassemblyOut = std::string(static_cast<const char *>(disassembly->GetBufferPointer()));
}
else
{
diff --git a/src/libANGLE/renderer/d3d/d3d11/Blit11.cpp b/src/libANGLE/renderer/d3d/d3d11/Blit11.cpp
index bcc85e0..59b0e94 100644
--- a/src/libANGLE/renderer/d3d/d3d11/Blit11.cpp
+++ b/src/libANGLE/renderer/d3d/d3d11/Blit11.cpp
@@ -1134,7 +1134,7 @@
ANGLE_TRY(
mRenderer->mapResource(mSwizzleCB.get(), 0, D3D11_MAP_WRITE_DISCARD, 0, &mappedResource));
- unsigned int *swizzleIndices = reinterpret_cast<unsigned int *>(mappedResource.pData);
+ unsigned int *swizzleIndices = static_cast<unsigned int *>(mappedResource.pData);
swizzleIndices[0] = GetSwizzleIndex(swizzleTarget.swizzleRed);
swizzleIndices[1] = GetSwizzleIndex(swizzleTarget.swizzleGreen);
swizzleIndices[2] = GetSwizzleIndex(swizzleTarget.swizzleBlue);
diff --git a/src/libANGLE/renderer/d3d/d3d11/Clear11.cpp b/src/libANGLE/renderer/d3d/d3d11/Clear11.cpp
index a8a3407..80110c9 100644
--- a/src/libANGLE/renderer/d3d/d3d11/Clear11.cpp
+++ b/src/libANGLE/renderer/d3d/d3d11/Clear11.cpp
@@ -718,8 +718,7 @@
switch (clearParams.colorType)
{
case GL_FLOAT:
- dirtyCb = UpdateDataCache(reinterpret_cast<RtvDsvClearInfo<float> *>(&mShaderData),
- clearParams.colorF, zValue, numRtvs, colorMask);
+ dirtyCb = UpdateDataCache(&mShaderData, clearParams.colorF, zValue, numRtvs, colorMask);
break;
case GL_UNSIGNED_INT:
dirtyCb = UpdateDataCache(reinterpret_cast<RtvDsvClearInfo<uint32_t> *>(&mShaderData),
diff --git a/src/libANGLE/renderer/d3d/d3d11/Image11.cpp b/src/libANGLE/renderer/d3d/d3d11/Image11.cpp
index e3281eb..b2073f0 100644
--- a/src/libANGLE/renderer/d3d/d3d11/Image11.cpp
+++ b/src/libANGLE/renderer/d3d/d3d11/Image11.cpp
@@ -62,8 +62,8 @@
return error;
}
- const uint8_t *sourceData = reinterpret_cast<const uint8_t *>(srcMapped.pData);
- uint8_t *destData = reinterpret_cast<uint8_t *>(destMapped.pData);
+ const uint8_t *sourceData = static_cast<const uint8_t *>(srcMapped.pData);
+ uint8_t *destData = static_cast<uint8_t *>(destMapped.pData);
auto mipGenerationFunction =
d3d11::Format::Get(src->getInternalFormat(), rendererCaps).format().mipGenerationFunction;
@@ -112,10 +112,10 @@
gl::GetSizedInternalFormatInfo(destFormat.fboImplementationInternalFormat);
GLuint destPixelBytes = destFormatInfo.pixelBytes;
- const uint8_t *sourceData = reinterpret_cast<const uint8_t *>(srcMapped.pData) +
+ const uint8_t *sourceData = static_cast<const uint8_t *>(srcMapped.pData) +
sourceRect.x * sourcePixelBytes + sourceRect.y * srcMapped.RowPitch;
- uint8_t *destData = reinterpret_cast<uint8_t *>(destMapped.pData) +
- destOffset.x * destPixelBytes + destOffset.y * destMapped.RowPitch;
+ uint8_t *destData = static_cast<uint8_t *>(destMapped.pData) + destOffset.x * destPixelBytes +
+ destOffset.y * destMapped.RowPitch;
CopyImageCHROMIUM(sourceData, srcMapped.RowPitch, sourcePixelBytes,
sourceFormat.colorReadFunction, destData, destMapped.RowPitch, destPixelBytes,
@@ -304,11 +304,11 @@
D3D11_MAPPED_SUBRESOURCE mappedImage;
ANGLE_TRY(map(context, D3D11_MAP_WRITE, &mappedImage));
- uint8_t *offsetMappedData = (reinterpret_cast<uint8_t *>(mappedImage.pData) +
+ uint8_t *offsetMappedData = (static_cast<uint8_t *>(mappedImage.pData) +
(area.y * mappedImage.RowPitch + area.x * outputPixelSize +
area.z * mappedImage.DepthPitch));
loadFunction(area.width, area.height, area.depth,
- reinterpret_cast<const uint8_t *>(input) + inputSkipBytes, inputRowPitch,
+ static_cast<const uint8_t *>(input) + inputSkipBytes, inputRowPitch,
inputDepthPitch, offsetMappedData, mappedImage.RowPitch, mappedImage.DepthPitch);
unmap();
@@ -343,11 +343,11 @@
ANGLE_TRY(map(context, D3D11_MAP_WRITE, &mappedImage));
uint8_t *offsetMappedData =
- reinterpret_cast<uint8_t *>(mappedImage.pData) +
+ static_cast<uint8_t *>(mappedImage.pData) +
((area.y / outputBlockHeight) * mappedImage.RowPitch +
(area.x / outputBlockWidth) * outputPixelSize + area.z * mappedImage.DepthPitch);
- loadFunction(area.width, area.height, area.depth, reinterpret_cast<const uint8_t *>(input),
+ loadFunction(area.width, area.height, area.depth, static_cast<const uint8_t *>(input),
inputRowPitch, inputDepthPitch, offsetMappedData, mappedImage.RowPitch,
mappedImage.DepthPitch);
diff --git a/src/libANGLE/renderer/d3d/d3d11/IndexBuffer11.cpp b/src/libANGLE/renderer/d3d/d3d11/IndexBuffer11.cpp
index cde2b51..d520469 100644
--- a/src/libANGLE/renderer/d3d/d3d11/IndexBuffer11.cpp
+++ b/src/libANGLE/renderer/d3d/d3d11/IndexBuffer11.cpp
@@ -75,7 +75,7 @@
ANGLE_TRY(
mRenderer->mapResource(mBuffer.get(), 0, D3D11_MAP_WRITE_NO_OVERWRITE, 0, &mappedResource));
- *outMappedMemory = reinterpret_cast<char*>(mappedResource.pData) + offset;
+ *outMappedMemory = static_cast<char *>(mappedResource.pData) + offset;
return gl::NoError();
}
diff --git a/src/libANGLE/renderer/d3d/d3d11/Renderer11.cpp b/src/libANGLE/renderer/d3d/d3d11/Renderer11.cpp
index d4b7a9f..4a41a4f 100644
--- a/src/libANGLE/renderer/d3d/d3d11/Renderer11.cpp
+++ b/src/libANGLE/renderer/d3d/d3d11/Renderer11.cpp
@@ -807,7 +807,7 @@
void *device = nullptr;
ANGLE_TRY(deviceD3D->getDevice(&device));
- ID3D11Device *d3dDevice = reinterpret_cast<ID3D11Device *>(device);
+ ID3D11Device *d3dDevice = static_cast<ID3D11Device *>(device);
if (FAILED(d3dDevice->GetDeviceRemovedReason()))
{
return egl::EglNotInitialized() << "Inputted D3D11 device has been lost.";
@@ -1400,7 +1400,7 @@
void *Renderer11::getD3DDevice()
{
- return reinterpret_cast<void *>(mDevice);
+ return mDevice;
}
gl::Error Renderer11::drawWithGeometryShaderAndTransformFeedback(const gl::Context *context,
@@ -2792,7 +2792,7 @@
return gl::NoError();
}
- gl::Error error = loadExecutable(reinterpret_cast<const uint8_t *>(binary->GetBufferPointer()),
+ gl::Error error = loadExecutable(static_cast<const uint8_t *>(binary->GetBufferPointer()),
binary->GetBufferSize(), type, streamOutVaryings,
separatedOutputBuffers, outExectuable);
diff --git a/src/libANGLE/renderer/d3d/d3d11/StateManager11.cpp b/src/libANGLE/renderer/d3d/d3d11/StateManager11.cpp
index e9c3bea..ac9a1be 100644
--- a/src/libANGLE/renderer/d3d/d3d11/StateManager11.cpp
+++ b/src/libANGLE/renderer/d3d/d3d11/StateManager11.cpp
@@ -518,7 +518,7 @@
renderer->mapResource(driverConstantBuffer.get(), 0, D3D11_MAP_WRITE_DISCARD, 0, &mapping));
memcpy(mapping.pData, data, dataSize);
- memcpy(reinterpret_cast<uint8_t *>(mapping.pData) + dataSize, samplerData,
+ memcpy(static_cast<uint8_t *>(mapping.pData) + dataSize, samplerData,
sizeof(SamplerMetadata) * numSamplers);
renderer->getDeviceContext()->Unmap(driverConstantBuffer.get(), 0);
diff --git a/src/libANGLE/renderer/d3d/d3d11/VertexBuffer11.cpp b/src/libANGLE/renderer/d3d/d3d11/VertexBuffer11.cpp
index 3649cbe..441baa1 100644
--- a/src/libANGLE/renderer/d3d/d3d11/VertexBuffer11.cpp
+++ b/src/libANGLE/renderer/d3d/d3d11/VertexBuffer11.cpp
@@ -75,7 +75,7 @@
ANGLE_TRY(mRenderer->mapResource(mBuffer.get(), 0, D3D11_MAP_WRITE_NO_OVERWRITE, 0,
&mappedResource));
- mMappedResourceData = reinterpret_cast<uint8_t *>(mappedResource.pData);
+ mMappedResourceData = static_cast<uint8_t *>(mappedResource.pData);
}
return gl::NoError();
diff --git a/src/libANGLE/renderer/d3d/d3d9/Framebuffer9.cpp b/src/libANGLE/renderer/d3d/d3d9/Framebuffer9.cpp
index 3f7db02..28d29b6 100644
--- a/src/libANGLE/renderer/d3d/d3d9/Framebuffer9.cpp
+++ b/src/libANGLE/renderer/d3d/d3d9/Framebuffer9.cpp
@@ -184,7 +184,7 @@
return gl::OutOfMemory() << "Failed to lock internal render target.";
}
- uint8_t *source = reinterpret_cast<uint8_t *>(lock.pBits);
+ uint8_t *source = static_cast<uint8_t *>(lock.pBits);
int inputPitch = lock.Pitch;
const d3d9::D3DFormat &d3dFormatInfo = d3d9::GetD3DFormatInfo(desc.Format);
diff --git a/src/libANGLE/renderer/d3d/d3d9/Image9.cpp b/src/libANGLE/renderer/d3d/d3d9/Image9.cpp
index 817a40a..bf2cf72 100644
--- a/src/libANGLE/renderer/d3d/d3d9/Image9.cpp
+++ b/src/libANGLE/renderer/d3d/d3d9/Image9.cpp
@@ -87,8 +87,8 @@
<< gl::FmtHR(result);
}
- const uint8_t *sourceData = reinterpret_cast<const uint8_t*>(sourceLocked.pBits);
- uint8_t *destData = reinterpret_cast<uint8_t*>(destLocked.pBits);
+ const uint8_t *sourceData = static_cast<const uint8_t *>(sourceLocked.pBits);
+ uint8_t *destData = static_cast<uint8_t *>(destLocked.pBits);
ASSERT(sourceData && destData);
@@ -217,10 +217,10 @@
<< gl::FmtHR(result);
}
- const uint8_t *sourceData = reinterpret_cast<const uint8_t *>(sourceLocked.pBits) +
+ const uint8_t *sourceData = static_cast<const uint8_t *>(sourceLocked.pBits) +
sourceRect.x * sourceD3DFormatInfo.pixelBytes +
sourceRect.y * sourceLocked.Pitch;
- uint8_t *destData = reinterpret_cast<uint8_t *>(destLocked.pBits) +
+ uint8_t *destData = static_cast<uint8_t *>(destLocked.pBits) +
destOffset.x * destD3DFormatInfo.pixelBytes +
destOffset.y * destLocked.Pitch;
ASSERT(sourceData && destData);
@@ -325,8 +325,8 @@
return gl::OutOfMemory() << "Failed to lock image surface, " << gl::FmtHR(result);
}
- d3dFormatInfo.dataInitializerFunction(mWidth, mHeight, 1, reinterpret_cast<uint8_t*>(lockedRect.pBits),
- lockedRect.Pitch, 0);
+ d3dFormatInfo.dataInitializerFunction(
+ mWidth, mHeight, 1, static_cast<uint8_t *>(lockedRect.pBits), lockedRect.Pitch, 0);
result = newSurface->UnlockRect();
ASSERT(SUCCEEDED(result));
@@ -579,8 +579,8 @@
}
d3dFormatInfo.loadFunction(area.width, area.height, area.depth,
- reinterpret_cast<const uint8_t *>(input), inputRowPitch, 0,
- reinterpret_cast<uint8_t *>(locked.pBits), locked.Pitch, 0);
+ static_cast<const uint8_t *>(input), inputRowPitch, 0,
+ static_cast<uint8_t *>(locked.pBits), locked.Pitch, 0);
unlock();
@@ -622,8 +622,8 @@
}
d3d9FormatInfo.loadFunction(area.width, area.height, area.depth,
- reinterpret_cast<const uint8_t*>(input), inputRowPitch, inputDepthPitch,
- reinterpret_cast<uint8_t*>(locked.pBits), locked.Pitch, 0);
+ static_cast<const uint8_t *>(input), inputRowPitch, inputDepthPitch,
+ static_cast<uint8_t *>(locked.pBits), locked.Pitch, 0);
unlock();
diff --git a/src/libANGLE/renderer/d3d/d3d9/Renderer9.cpp b/src/libANGLE/renderer/d3d/d3d9/Renderer9.cpp
index e39e57f..1b72e26 100644
--- a/src/libANGLE/renderer/d3d/d3d9/Renderer9.cpp
+++ b/src/libANGLE/renderer/d3d/d3d9/Renderer9.cpp
@@ -837,7 +837,7 @@
void *Renderer9::getD3DDevice()
{
- return reinterpret_cast<void *>(mDevice);
+ return mDevice;
}
gl::Error Renderer9::allocateEventQuery(IDirect3DQuery9 **outQuery)
@@ -1506,7 +1506,7 @@
}
startIndex = static_cast<unsigned int>(offset) / 4;
- unsigned int *data = reinterpret_cast<unsigned int *>(mappedMemory);
+ unsigned int *data = static_cast<unsigned int *>(mappedMemory);
switch (type)
{
@@ -1589,7 +1589,7 @@
}
startIndex = static_cast<unsigned int>(offset) / 2;
- unsigned short *data = reinterpret_cast<unsigned short *>(mappedMemory);
+ unsigned short *data = static_cast<unsigned short *>(mappedMemory);
switch (type)
{
@@ -1716,7 +1716,7 @@
void *mappedMemory = nullptr;
ANGLE_TRY(mCountingIB->mapBuffer(spaceNeeded, &mappedMemory, nullptr));
- unsigned short *data = reinterpret_cast<unsigned short *>(mappedMemory);
+ unsigned short *data = static_cast<unsigned short *>(mappedMemory);
for (size_t i = 0; i < count; i++)
{
data[i] = static_cast<unsigned short>(i);
@@ -1738,7 +1738,7 @@
void *mappedMemory = nullptr;
ANGLE_TRY(mCountingIB->mapBuffer(spaceNeeded, &mappedMemory, nullptr));
- unsigned int *data = reinterpret_cast<unsigned int *>(mappedMemory);
+ unsigned int *data = static_cast<unsigned int *>(mappedMemory);
for (unsigned int i = 0; i < count; i++)
{
data[i] = i;
diff --git a/src/libANGLE/renderer/gl/FramebufferGL.cpp b/src/libANGLE/renderer/gl/FramebufferGL.cpp
index 417f9df..f42a405 100644
--- a/src/libANGLE/renderer/gl/FramebufferGL.cpp
+++ b/src/libANGLE/renderer/gl/FramebufferGL.cpp
@@ -455,7 +455,7 @@
packBuffer && packState.rowLength != 0 &&
packState.rowLength < area.width;
- GLubyte *pixels = reinterpret_cast<GLubyte *>(ptrOrOffset);
+ GLubyte *pixels = static_cast<GLubyte *>(ptrOrOffset);
int leftClip = area.x - origArea.x;
int topClip = area.y - origArea.y;
if (leftClip || topClip)
diff --git a/src/libANGLE/renderer/gl/VertexArrayGL.cpp b/src/libANGLE/renderer/gl/VertexArrayGL.cpp
index 2f617f2..9c4edac 100644
--- a/src/libANGLE/renderer/gl/VertexArrayGL.cpp
+++ b/src/libANGLE/renderer/gl/VertexArrayGL.cpp
@@ -357,7 +357,7 @@
// Attributes using client memory ignore the VERTEX_ATTRIB_BINDING state.
// https://www.opengl.org/registry/specs/ARB/vertex_attrib_binding.txt
- const uint8_t *inputPointer = reinterpret_cast<const uint8_t *>(attrib.pointer);
+ const uint8_t *inputPointer = static_cast<const uint8_t *>(attrib.pointer);
// Pack the data when copying it, user could have supplied a very large stride that
// would cause the buffer to be much larger than needed.
diff --git a/src/libANGLE/renderer/gl/renderergl_utils.cpp b/src/libANGLE/renderer/gl/renderergl_utils.cpp
index 1464033..0e1226f 100644
--- a/src/libANGLE/renderer/gl/renderergl_utils.cpp
+++ b/src/libANGLE/renderer/gl/renderergl_utils.cpp
@@ -1306,8 +1306,7 @@
{
if (functions->mapBufferRange != nullptr)
{
- return reinterpret_cast<uint8_t *>(
- functions->mapBufferRange(target, offset, length, access));
+ return static_cast<uint8_t *>(functions->mapBufferRange(target, offset, length, access));
}
else if (functions->mapBuffer != nullptr &&
(functions->standard == STANDARD_GL_DESKTOP || access == GL_MAP_WRITE_BIT))
@@ -1334,7 +1333,7 @@
return nullptr;
}
- return reinterpret_cast<uint8_t *>(functions->mapBuffer(target, accessEnum)) + offset;
+ return static_cast<uint8_t *>(functions->mapBuffer(target, accessEnum)) + offset;
}
else
{
diff --git a/src/libANGLE/renderer/vulkan/FramebufferVk.cpp b/src/libANGLE/renderer/vulkan/FramebufferVk.cpp
index c22b2f9..a86da49 100644
--- a/src/libANGLE/renderer/vulkan/FramebufferVk.cpp
+++ b/src/libANGLE/renderer/vulkan/FramebufferVk.cpp
@@ -315,7 +315,7 @@
params.pack = glState.getPackState();
ANGLE_TRY(readPixelsImpl(context, clippedArea, params,
- reinterpret_cast<uint8_t *>(pixels) + outputSkipBytes));
+ static_cast<uint8_t *>(pixels) + outputSkipBytes));
mReadPixelsBuffer.releaseRetainedBuffers(renderer);
return gl::NoError();
}
@@ -836,7 +836,7 @@
ANGLE_TRY(mReadPixelsBuffer.invalidate(renderer->getDevice()));
PackPixels(packPixelsParams, angleFormat, area.width * angleFormat.pixelBytes, readPixelBuffer,
- reinterpret_cast<uint8_t *>(pixels));
+ static_cast<uint8_t *>(pixels));
return vk::NoError();
}
diff --git a/src/libANGLE/renderer/vulkan/VertexArrayVk.cpp b/src/libANGLE/renderer/vulkan/VertexArrayVk.cpp
index 5cff70a..7c70fbb 100644
--- a/src/libANGLE/renderer/vulkan/VertexArrayVk.cpp
+++ b/src/libANGLE/renderer/vulkan/VertexArrayVk.cpp
@@ -522,7 +522,7 @@
void *srcDataMapping = nullptr;
ASSERT(!glBuffer->isMapped());
ANGLE_TRY(bufferVk->map(context, 0, &srcDataMapping));
- uint8_t *srcData = reinterpret_cast<uint8_t *>(srcDataMapping);
+ uint8_t *srcData = static_cast<uint8_t *>(srcDataMapping);
intptr_t offsetIntoSrcData = reinterpret_cast<intptr_t>(drawCallParams.indices());
srcData += offsetIntoSrcData;
diff --git a/src/libANGLE/validationEGL.cpp b/src/libANGLE/validationEGL.cpp
index dcd4edb..5c8a4eb 100644
--- a/src/libANGLE/validationEGL.cpp
+++ b/src/libANGLE/validationEGL.cpp
@@ -479,7 +479,7 @@
}
else if (platform == EGL_PLATFORM_DEVICE_EXT)
{
- Device *eglDevice = reinterpret_cast<Device *>(native_display);
+ Device *eglDevice = static_cast<Device *>(native_display);
if (eglDevice == nullptr || !Device::IsValidDevice(eglDevice))
{
return EglBadAttribute() << "native_display should be a valid EGL device if "
diff --git a/src/libANGLE/validationES.cpp b/src/libANGLE/validationES.cpp
index d3519fc..6a5894e 100644
--- a/src/libANGLE/validationES.cpp
+++ b/src/libANGLE/validationES.cpp
@@ -3591,7 +3591,7 @@
return false;
}
- egl::Image *imageObject = reinterpret_cast<egl::Image *>(image);
+ egl::Image *imageObject = static_cast<egl::Image *>(image);
ASSERT(context->getCurrentDisplay());
if (!context->getCurrentDisplay()->isValidImage(imageObject))
@@ -3639,7 +3639,7 @@
return false;
}
- egl::Image *imageObject = reinterpret_cast<egl::Image *>(image);
+ egl::Image *imageObject = static_cast<egl::Image *>(image);
ASSERT(context->getCurrentDisplay());
if (!context->getCurrentDisplay()->isValidImage(imageObject))
diff --git a/src/libGLESv2/entry_points_egl.cpp b/src/libGLESv2/entry_points_egl.cpp
index 8632985..addd6b8 100644
--- a/src/libGLESv2/entry_points_egl.cpp
+++ b/src/libGLESv2/entry_points_egl.cpp
@@ -1159,7 +1159,7 @@
}
else if (platform == EGL_PLATFORM_DEVICE_EXT)
{
- Device *eglDevice = reinterpret_cast<Device *>(native_display);
+ Device *eglDevice = static_cast<Device *>(native_display);
return Display::GetDisplayFromDevice(eglDevice, attribMap);
}
else
diff --git a/src/libGLESv2/entry_points_egl_ext.cpp b/src/libGLESv2/entry_points_egl_ext.cpp
index 2a1f1b1..9e309cd 100644
--- a/src/libGLESv2/entry_points_egl_ext.cpp
+++ b/src/libGLESv2/entry_points_egl_ext.cpp
@@ -182,7 +182,7 @@
}
else if (platform == EGL_PLATFORM_DEVICE_EXT)
{
- Device *eglDevice = reinterpret_cast<Device *>(native_display);
+ Device *eglDevice = static_cast<Device *>(native_display);
return Display::GetDisplayFromDevice(eglDevice, attribMap);
}
else
diff --git a/src/tests/gl_tests/D3D11EmulatedIndexedBufferTest.cpp b/src/tests/gl_tests/D3D11EmulatedIndexedBufferTest.cpp
index ad20579..6859ee8 100644
--- a/src/tests/gl_tests/D3D11EmulatedIndexedBufferTest.cpp
+++ b/src/tests/gl_tests/D3D11EmulatedIndexedBufferTest.cpp
@@ -31,7 +31,7 @@
ANGLETest::SetUp();
ASSERT_EQ(EGL_PLATFORM_ANGLE_TYPE_D3D11_ANGLE, GetParam().getRenderer());
- mContext = reinterpret_cast<gl::Context *>(getEGLWindow()->getContext());
+ mContext = static_cast<gl::Context *>(getEGLWindow()->getContext());
rx::Context11 *context11 = rx::GetImplAs<rx::Context11>(mContext);
mRenderer = context11->getRenderer();
diff --git a/src/tests/gl_tests/D3D11FormatTablesTest.cpp b/src/tests/gl_tests/D3D11FormatTablesTest.cpp
index 847bfaf..488371f 100644
--- a/src/tests/gl_tests/D3D11FormatTablesTest.cpp
+++ b/src/tests/gl_tests/D3D11FormatTablesTest.cpp
@@ -40,7 +40,7 @@
ASSERT_EQ(EGL_PLATFORM_ANGLE_TYPE_D3D11_ANGLE, GetParam().getRenderer());
// Hack the angle!
- gl::Context *context = reinterpret_cast<gl::Context *>(getEGLWindow()->getContext());
+ gl::Context *context = static_cast<gl::Context *>(getEGLWindow()->getContext());
rx::Context11 *context11 = rx::GetImplAs<rx::Context11>(context);
rx::Renderer11 *renderer = context11->getRenderer();
const auto &textureCaps = renderer->getNativeTextureCaps();
diff --git a/src/tests/gl_tests/D3D11InputLayoutCacheTest.cpp b/src/tests/gl_tests/D3D11InputLayoutCacheTest.cpp
index 118d106..e0def03 100644
--- a/src/tests/gl_tests/D3D11InputLayoutCacheTest.cpp
+++ b/src/tests/gl_tests/D3D11InputLayoutCacheTest.cpp
@@ -65,7 +65,7 @@
TEST_P(D3D11InputLayoutCacheTest, StressTest)
{
// Hack the ANGLE!
- gl::Context *context = reinterpret_cast<gl::Context *>(getEGLWindow()->getContext());
+ gl::Context *context = static_cast<gl::Context *>(getEGLWindow()->getContext());
rx::Context11 *context11 = rx::GetImplAs<rx::Context11>(context);
rx::Renderer11 *renderer11 = context11->getRenderer();
rx::InputLayoutCache *inputLayoutCache = renderer11->getStateManager()->getInputLayoutCache();
diff --git a/src/tests/gl_tests/VulkanFormatTablesTest.cpp b/src/tests/gl_tests/VulkanFormatTablesTest.cpp
index 27d2fbb..b7c635c 100644
--- a/src/tests/gl_tests/VulkanFormatTablesTest.cpp
+++ b/src/tests/gl_tests/VulkanFormatTablesTest.cpp
@@ -43,7 +43,7 @@
ASSERT_TRUE(IsVulkan());
// Hack the angle!
- const gl::Context *context = reinterpret_cast<gl::Context *>(getEGLWindow()->getContext());
+ const gl::Context *context = static_cast<gl::Context *>(getEGLWindow()->getContext());
auto *contextVk = rx::GetImplAs<rx::ContextVk>(context);
rx::RendererVk *renderer = contextVk->getRenderer();
diff --git a/src/tests/gl_tests/VulkanUniformUpdatesTest.cpp b/src/tests/gl_tests/VulkanUniformUpdatesTest.cpp
index a4e0003..9aba555 100644
--- a/src/tests/gl_tests/VulkanUniformUpdatesTest.cpp
+++ b/src/tests/gl_tests/VulkanUniformUpdatesTest.cpp
@@ -32,7 +32,7 @@
rx::ContextVk *hackANGLE()
{
// Hack the angle!
- const gl::Context *context = reinterpret_cast<gl::Context *>(getEGLWindow()->getContext());
+ const gl::Context *context = static_cast<gl::Context *>(getEGLWindow()->getContext());
return rx::GetImplAs<rx::ContextVk>(context);
}
};