From b29b35cee5ae13c1f3e972dd175b263d63174459 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?R=C3=A9mi=20Verschelde?= Date: Tue, 3 Apr 2018 12:32:03 +0200 Subject: [PATCH] Fix more -Wc++11-narrowing errors with clang Follow-up to and fixes #17725 (again). --- core/image.cpp | 12 ++++++------ drivers/gles2/rasterizer_gles2.cpp | 14 +++++++------- servers/audio/audio_mixer_sw.cpp | 8 ++++---- servers/spatial_sound/spatial_sound_server_sw.cpp | 4 ++-- .../spatial_sound_2d_server_sw.cpp | 4 ++-- 5 files changed, 21 insertions(+), 21 deletions(-) diff --git a/core/image.cpp b/core/image.cpp index 8f0a16e506d..c86925b77a0 100644 --- a/core/image.cpp +++ b/core/image.cpp @@ -1518,8 +1518,8 @@ Error Image::_decompress_bc() { col_b |= src[2]; uint8_t table[4][4] = { - { (col_a >> 11) << 3, ((col_a >> 5) & 0x3f) << 2, ((col_a)&0x1f) << 3, 255 }, - { (col_b >> 11) << 3, ((col_b >> 5) & 0x3f) << 2, ((col_b)&0x1f) << 3, 255 }, + { (uint8_t)((col_a >> 11) << 3), (uint8_t)(((col_a >> 5) & 0x3f) << 2), (uint8_t)(((col_a)&0x1f) << 3), 255 }, + { (uint8_t)((col_b >> 11) << 3), (uint8_t)(((col_b >> 5) & 0x3f) << 2), (uint8_t)(((col_b)&0x1f) << 3), 255 }, { 0, 0, 0, 255 }, { 0, 0, 0, 255 } }; @@ -1611,8 +1611,8 @@ Error Image::_decompress_bc() { col_b |= src[8 + 2]; uint8_t table[4][4] = { - { (col_a >> 11) << 3, ((col_a >> 5) & 0x3f) << 2, ((col_a)&0x1f) << 3, 255 }, - { (col_b >> 11) << 3, ((col_b >> 5) & 0x3f) << 2, ((col_b)&0x1f) << 3, 255 }, + { (uint8_t)((col_a >> 11) << 3), (uint8_t)(((col_a >> 5) & 0x3f) << 2), (uint8_t)(((col_a)&0x1f) << 3), 255 }, + { (uint8_t)((col_b >> 11) << 3), (uint8_t)(((col_b >> 5) & 0x3f) << 2), (uint8_t)(((col_b)&0x1f) << 3), 255 }, { 0, 0, 0, 255 }, { 0, 0, 0, 255 } }; @@ -1722,8 +1722,8 @@ Error Image::_decompress_bc() { col_b |= src[8 + 2]; uint8_t table[4][4] = { - { (col_a >> 11) << 3, ((col_a >> 5) & 0x3f) << 2, ((col_a)&0x1f) << 3, 255 }, - { (col_b >> 11) << 3, ((col_b >> 5) & 0x3f) << 2, ((col_b)&0x1f) << 3, 255 }, + { (uint8_t)((col_a >> 11) << 3), (uint8_t)(((col_a >> 5) & 0x3f) << 2), (uint8_t)(((col_a)&0x1f) << 3), 255 }, + { (uint8_t)((col_b >> 11) << 3), (uint8_t)(((col_b >> 5) & 0x3f) << 2), (uint8_t)(((col_b)&0x1f) << 3), 255 }, { 0, 0, 0, 255 }, { 0, 0, 0, 255 } }; diff --git a/drivers/gles2/rasterizer_gles2.cpp b/drivers/gles2/rasterizer_gles2.cpp index 3986a8b8d56..90ee94cce1b 100644 --- a/drivers/gles2/rasterizer_gles2.cpp +++ b/drivers/gles2/rasterizer_gles2.cpp @@ -2135,9 +2135,9 @@ Error RasterizerGLES2::_surface_set_arrays(Surface *p_surface, uint8_t *p_mem, u for (int i = 0; i < p_surface->array_len; i++) { GLbyte vector[4] = { - CLAMP(src[i].x * 127, -128, 127), - CLAMP(src[i].y * 127, -128, 127), - CLAMP(src[i].z * 127, -128, 127), + (GLbyte)CLAMP(src[i].x * 127, -128, 127), + (GLbyte)CLAMP(src[i].y * 127, -128, 127), + (GLbyte)CLAMP(src[i].z * 127, -128, 127), 0, }; @@ -2169,10 +2169,10 @@ Error RasterizerGLES2::_surface_set_arrays(Surface *p_surface, uint8_t *p_mem, u for (int i = 0; i < p_surface->array_len; i++) { GLbyte xyzw[4] = { - CLAMP(src[i * 4 + 0] * 127, -128, 127), - CLAMP(src[i * 4 + 1] * 127, -128, 127), - CLAMP(src[i * 4 + 2] * 127, -128, 127), - CLAMP(src[i * 4 + 3] * 127, -128, 127) + (GLbyte)CLAMP(src[i * 4 + 0] * 127, -128, 127), + (GLbyte)CLAMP(src[i * 4 + 1] * 127, -128, 127), + (GLbyte)CLAMP(src[i * 4 + 2] * 127, -128, 127), + (GLbyte)CLAMP(src[i * 4 + 3] * 127, -128, 127) }; copymem(&p_mem[a.ofs + i * stride], xyzw, a.size); diff --git a/servers/audio/audio_mixer_sw.cpp b/servers/audio/audio_mixer_sw.cpp index 642377d7708..dcab2834e5d 100644 --- a/servers/audio/audio_mixer_sw.cpp +++ b/servers/audio/audio_mixer_sw.cpp @@ -280,7 +280,7 @@ void AudioMixerSW::mix_channel(Channel &c) { //stereo pan float pan = c.pan * 0.5 + 0.5; float panv[2] = { - (1.0 - pan) * (1 << MIX_VOL_FRAC_BITS), + (1.0f - pan) * (1 << MIX_VOL_FRAC_BITS), (pan) * (1 << MIX_VOL_FRAC_BITS) }; @@ -297,9 +297,9 @@ void AudioMixerSW::mix_channel(Channel &c) { float pany = c.depth * 0.5 + 0.5; // with this model every speaker plays at 0.25 energy at the center.. i'm not sure if it's correct but it seems to be balanced float panv[4] = { - (1.0 - pany) * (1.0 - panx) * (1 << MIX_VOL_FRAC_BITS), - (1.0 - pany) * (panx) * (1 << MIX_VOL_FRAC_BITS), - (pany) * (1.0 - panx) * (1 << MIX_VOL_FRAC_BITS), + (1.0f - pany) * (1.0f - panx) * (1 << MIX_VOL_FRAC_BITS), + (1.0f - pany) * (panx) * (1 << MIX_VOL_FRAC_BITS), + (pany) * (1.0f - panx) * (1 << MIX_VOL_FRAC_BITS), (pany) * (panx) * (1 << MIX_VOL_FRAC_BITS) }; diff --git a/servers/spatial_sound/spatial_sound_server_sw.cpp b/servers/spatial_sound/spatial_sound_server_sw.cpp index 67d83e695e7..e75ff15fa8a 100644 --- a/servers/spatial_sound/spatial_sound_server_sw.cpp +++ b/servers/spatial_sound/spatial_sound_server_sw.cpp @@ -689,7 +689,7 @@ bool SpatialSoundServerSW::internal_buffer_mix(int32_t *p_buffer, int p_frames) case 2: { float p = sd.panning.x * 0.5 + 0.5; - float panf[2] = { (1.0 - p), p }; + float panf[2] = { (1.0f - p), p }; panf[0] *= sd.volume; panf[1] *= sd.volume; @@ -740,7 +740,7 @@ bool SpatialSoundServerSW::internal_buffer_mix(int32_t *p_buffer, int p_frames) float xp = sd.panning.x * 0.5 + 0.5; float yp = sd.panning.y * 0.5 + 0.5; - float panf[4] = { (1.0 - xp) * (1.0 - yp), (xp) * (1.0 - yp), (1.0 - xp) * (yp), (xp) * (yp) }; + float panf[4] = { (1.0f - xp) * (1.0f - yp), (xp) * (1.0f - yp), (1.0f - xp) * (yp), (xp) * (yp) }; panf[0] *= sd.volume; panf[1] *= sd.volume; panf[2] *= sd.volume; diff --git a/servers/spatial_sound_2d/spatial_sound_2d_server_sw.cpp b/servers/spatial_sound_2d/spatial_sound_2d_server_sw.cpp index 34d543a70e2..482a0f50ff2 100644 --- a/servers/spatial_sound_2d/spatial_sound_2d_server_sw.cpp +++ b/servers/spatial_sound_2d/spatial_sound_2d_server_sw.cpp @@ -675,7 +675,7 @@ bool SpatialSound2DServerSW::internal_buffer_mix(int32_t *p_buffer, int p_frames case 2: { float p = sd.panning.x * 0.5 + 0.5; - float panf[2] = { (1.0 - p), p }; + float panf[2] = { (1.0f - p), p }; panf[0] *= sd.volume; panf[1] *= sd.volume; @@ -726,7 +726,7 @@ bool SpatialSound2DServerSW::internal_buffer_mix(int32_t *p_buffer, int p_frames float xp = sd.panning.x * 0.5 + 0.5; float yp = sd.panning.y * 0.5 + 0.5; - float panf[4] = { (1.0 - xp) * (1.0 - yp), (xp) * (1.0 - yp), (1.0 - xp) * (yp), (xp) * (yp) }; + float panf[4] = { (1.0f - xp) * (1.0f - yp), (xp) * (1.0f - yp), (1.0f - xp) * (yp), (xp) * (yp) }; panf[0] *= sd.volume; panf[1] *= sd.volume; panf[2] *= sd.volume;