mirror of
https://github.com/encounter/dawn-cmake.git
synced 2025-12-17 00:47:13 +00:00
Improve usage of static_casts over reinterpret_casts
Static_casts are prefered over reinterpret_casts for better type safety Change-Id: I190cbee293591ebf8ab8035e900c081848eb1f30 Reviewed-on: https://dawn-review.googlesource.com/c/dawn/+/6921 Commit-Queue: Kai Ninomiya <kainino@chromium.org> Reviewed-by: Kai Ninomiya <kainino@chromium.org>
This commit is contained in:
committed by
Commit Bot service account
parent
e99e2408e9
commit
f54bb68f47
@@ -34,12 +34,12 @@ uint32_t Align(uint32_t value, size_t alignment);
|
||||
|
||||
template <typename T>
|
||||
T* AlignPtr(T* ptr, size_t alignment) {
|
||||
return reinterpret_cast<T*>(AlignVoidPtr(ptr, alignment));
|
||||
return static_cast<T*>(AlignVoidPtr(ptr, alignment));
|
||||
}
|
||||
|
||||
template <typename T>
|
||||
const T* AlignPtr(const T* ptr, size_t alignment) {
|
||||
return reinterpret_cast<const T*>(AlignVoidPtr(const_cast<T*>(ptr), alignment));
|
||||
return static_cast<const T*>(AlignVoidPtr(const_cast<T*>(ptr), alignment));
|
||||
}
|
||||
|
||||
template <typename destType, typename sourceType>
|
||||
|
||||
@@ -22,18 +22,18 @@ DawnSwapChainImplementation CreateSwapChainImplementation(T* swapChain) {
|
||||
DawnSwapChainImplementation impl = {};
|
||||
impl.userData = swapChain;
|
||||
impl.Init = [](void* userData, void* wsiContext) {
|
||||
auto* ctx = reinterpret_cast<typename T::WSIContext*>(wsiContext);
|
||||
auto* ctx = static_cast<typename T::WSIContext*>(wsiContext);
|
||||
reinterpret_cast<T*>(userData)->Init(ctx);
|
||||
};
|
||||
impl.Destroy = [](void* userData) { delete reinterpret_cast<T*>(userData); };
|
||||
impl.Configure = [](void* userData, DawnTextureFormat format, DawnTextureUsageBit allowedUsage,
|
||||
uint32_t width, uint32_t height) {
|
||||
return reinterpret_cast<T*>(userData)->Configure(format, allowedUsage, width, height);
|
||||
return static_cast<T*>(userData)->Configure(format, allowedUsage, width, height);
|
||||
};
|
||||
impl.GetNextTexture = [](void* userData, DawnSwapChainNextTexture* nextTexture) {
|
||||
return reinterpret_cast<T*>(userData)->GetNextTexture(nextTexture);
|
||||
return static_cast<T*>(userData)->GetNextTexture(nextTexture);
|
||||
};
|
||||
impl.Present = [](void* userData) { return reinterpret_cast<T*>(userData)->Present(); };
|
||||
impl.Present = [](void* userData) { return static_cast<T*>(userData)->Present(); };
|
||||
return impl;
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user