diff --git a/source/blender/blenfont/intern/blf.cc b/source/blender/blenfont/intern/blf.cc index f6e6da4afa0..81911b5765a 100644 --- a/source/blender/blenfont/intern/blf.cc +++ b/source/blender/blenfont/intern/blf.cc @@ -59,7 +59,7 @@ static FontBLF *blf_get(int fontid) return nullptr; } -int BLF_init(void) +int BLF_init() { for (int i = 0; i < BLF_MAX_FONT; i++) { global_font[i] = nullptr; @@ -68,7 +68,7 @@ int BLF_init(void) return blf_font_init(); } -void BLF_exit(void) +void BLF_exit() { for (int i = 0; i < BLF_MAX_FONT; i++) { FontBLF *font = global_font[i]; @@ -81,7 +81,7 @@ void BLF_exit(void) blf_font_exit(); } -void BLF_cache_clear(void) +void BLF_cache_clear() { for (int i = 0; i < BLF_MAX_FONT; i++) { FontBLF *font = global_font[i]; @@ -123,7 +123,7 @@ static int blf_search_by_filepath(const char *filepath) return -1; } -static int blf_search_available(void) +static int blf_search_available() { for (int i = 0; i < BLF_MAX_FONT; i++) { if (!global_font[i]) { @@ -277,7 +277,7 @@ void BLF_unload_id(int fontid) } } -void BLF_unload_all(void) +void BLF_unload_all() { for (int i = 0; i < BLF_MAX_FONT; i++) { FontBLF *font = global_font[i]; @@ -486,20 +486,20 @@ void BLF_color3f(int fontid, float r, float g, float b) BLF_color4fv(fontid, rgba); } -void BLF_batch_draw_begin(void) +void BLF_batch_draw_begin() { BLI_assert(g_batch.enabled == false); g_batch.enabled = true; } -void BLF_batch_draw_flush(void) +void BLF_batch_draw_flush() { if (g_batch.enabled) { blf_batch_draw(); } } -void BLF_batch_draw_end(void) +void BLF_batch_draw_end() { BLI_assert(g_batch.enabled == true); blf_batch_draw(); /* Draw remaining glyphs */ @@ -541,7 +541,7 @@ static void blf_draw_gl__end(const FontBLF *font) } } -void BLF_draw_ex(int fontid, const char *str, const size_t str_len, struct ResultBLF *r_info) +void BLF_draw_ex(int fontid, const char *str, const size_t str_len, ResultBLF *r_info) { FontBLF *font = blf_get(fontid); @@ -640,7 +640,7 @@ size_t BLF_width_to_strlen( int width_result; ret = blf_font_width_to_strlen(font, str, str_len, width / xa, &width_result); if (r_width) { - *r_width = (float)width_result * xa; + *r_width = float(width_result) * xa; } return ret; } @@ -662,7 +662,7 @@ size_t BLF_width_to_rstrlen( int width_result; ret = blf_font_width_to_rstrlen(font, str, str_len, width / xa, &width_result); if (r_width) { - *r_width = (float)width_result * xa; + *r_width = float(width_result) * xa; } return ret; } @@ -674,7 +674,7 @@ size_t BLF_width_to_rstrlen( } void BLF_boundbox_ex( - int fontid, const char *str, const size_t str_len, rcti *r_box, struct ResultBLF *r_info) + int fontid, const char *str, const size_t str_len, rcti *r_box, ResultBLF *r_info) { FontBLF *font = blf_get(fontid); @@ -708,7 +708,7 @@ void BLF_width_and_height( } } -float BLF_width_ex(int fontid, const char *str, const size_t str_len, struct ResultBLF *r_info) +float BLF_width_ex(int fontid, const char *str, const size_t str_len, ResultBLF *r_info) { FontBLF *font = blf_get(fontid); @@ -737,7 +737,7 @@ float BLF_fixed_width(int fontid) return 0.0f; } -float BLF_height_ex(int fontid, const char *str, const size_t str_len, struct ResultBLF *r_info) +float BLF_height_ex(int fontid, const char *str, const size_t str_len, ResultBLF *r_info) { FontBLF *font = blf_get(fontid); @@ -887,12 +887,9 @@ void blf_draw_buffer__start(FontBLF *font) srgb_to_linearrgb_v4(buf_info->col_float, buf_info->col_init); } } -void blf_draw_buffer__end(void) {} +void blf_draw_buffer__end() {} -void BLF_draw_buffer_ex(int fontid, - const char *str, - const size_t str_len, - struct ResultBLF *r_info) +void BLF_draw_buffer_ex(int fontid, const char *str, const size_t str_len, ResultBLF *r_info) { FontBLF *font = blf_get(fontid); diff --git a/source/blender/blenfont/intern/blf_default.cc b/source/blender/blenfont/intern/blf_default.cc index da04f13bf98..c76ba1e4be1 100644 --- a/source/blender/blenfont/intern/blf_default.cc +++ b/source/blender/blenfont/intern/blf_default.cc @@ -36,13 +36,13 @@ void BLF_default_set(int fontid) } } -int BLF_default(void) +int BLF_default() { ASSERT_DEFAULT_SET; return global_font_default; } -int BLF_set_default(void) +int BLF_set_default() { ASSERT_DEFAULT_SET; diff --git a/source/blender/blenfont/intern/blf_font.cc b/source/blender/blenfont/intern/blf_font.cc index 1696795c5a4..e06b027ae6b 100644 --- a/source/blender/blenfont/intern/blf_font.cc +++ b/source/blender/blenfont/intern/blf_font.cc @@ -177,7 +177,7 @@ static ft_pix blf_unscaled_F26Dot6_to_pixels(FontBLF *font, FT_Pos value) * group some strings together and render them in one draw-call. This behavior * is on demand only, between #BLF_batch_draw_begin() and #BLF_batch_draw_end(). */ -static void blf_batch_draw_init(void) +static void blf_batch_draw_init() { GPUVertFormat format = {0}; g_batch.pos_loc = GPU_vertformat_attr_add(&format, "pos", GPU_COMP_F32, 4, GPU_FETCH_FLOAT); @@ -205,7 +205,7 @@ static void blf_batch_draw_init(void) GPU_batch_instbuf_set(g_batch.batch, g_batch.verts, true); } -static void blf_batch_draw_exit(void) +static void blf_batch_draw_exit() { GPU_BATCH_DISCARD_SAFE(g_batch.batch); } @@ -270,7 +270,7 @@ void blf_batch_draw_begin(FontBLF *font) } } -static GPUTexture *blf_batch_cache_texture_load(void) +static GPUTexture *blf_batch_cache_texture_load() { GlyphCacheBLF *gc = g_batch.glyph_cache; BLI_assert(gc); @@ -310,7 +310,7 @@ static GPUTexture *blf_batch_cache_texture_load(void) return gc->texture; } -void blf_batch_draw(void) +void blf_batch_draw() { if (g_batch.glyph_len == 0) { return; @@ -343,7 +343,7 @@ void blf_batch_draw(void) g_batch.glyph_len = 0; } -static void blf_batch_draw_end(void) +static void blf_batch_draw_end() { if (!g_batch.active) { blf_batch_draw(); @@ -394,7 +394,7 @@ BLI_INLINE ft_pix blf_kerning(FontBLF *font, const GlyphBLF *g_prev, const Glyph /* If ASCII we save this value to our cache for quicker access next time. */ if ((g_prev->c < KERNING_CACHE_TABLE_SIZE) && (g->c < KERNING_CACHE_TABLE_SIZE)) { - font->kerning_cache->ascii_table[g->c][g_prev->c] = (int)delta.x; + font->kerning_cache->ascii_table[g->c][g_prev->c] = int(delta.x); } if (delta.x != 0) { @@ -416,7 +416,7 @@ static void blf_font_draw_ex(FontBLF *font, GlyphCacheBLF *gc, const char *str, const size_t str_len, - struct ResultBLF *r_info, + ResultBLF *r_info, const ft_pix pen_y) { GlyphBLF *g, *g_prev = nullptr; @@ -452,7 +452,7 @@ static void blf_font_draw_ex(FontBLF *font, r_info->width = ft_pix_to_int(pen_x); } } -void blf_font_draw(FontBLF *font, const char *str, const size_t str_len, struct ResultBLF *r_info) +void blf_font_draw(FontBLF *font, const char *str, const size_t str_len, ResultBLF *r_info) { GlyphCacheBLF *gc = blf_glyph_cache_acquire(font); blf_font_draw_ex(font, gc, str, str_len, r_info, 0); @@ -481,7 +481,7 @@ int blf_font_draw_mono(FontBLF *font, const char *str, const size_t str_len, int /* do not return this loop if clipped, we want every character tested */ blf_glyph_draw(font, gc, g, ft_pix_to_int_floor(pen_x), ft_pix_to_int_floor(pen_y)); - col = BLI_wcwidth((char32_t)g->c); + col = BLI_wcwidth(char32_t(g->c)); if (col < 0) { col = 1; } @@ -557,9 +557,9 @@ static void blf_glyph_draw_buffer(FontBufInfoBLF *buf_info, const char a_byte = *(g->bitmap + x + (yb * g->pitch)); if (a_byte) { const float a = (a_byte / 255.0f) * b_col_float[3]; - const size_t buf_ofs = (((size_t)(chx + x) + - ((size_t)(pen_y_px + y) * (size_t)buf_info->dims[0])) * - (size_t)buf_info->ch); + const size_t buf_ofs = ((size_t(chx + x) + + (size_t(pen_y_px + y) * size_t(buf_info->dims[0]))) * + size_t(buf_info->ch)); float *fbuf = buf_info->fbuf + buf_ofs; float font_pixel[4]; @@ -588,9 +588,9 @@ static void blf_glyph_draw_buffer(FontBufInfoBLF *buf_info, if (a_byte) { const float a = (a_byte / 255.0f) * b_col_float[3]; - const size_t buf_ofs = (((size_t)(chx + x) + - ((size_t)(pen_y_px + y) * (size_t)buf_info->dims[0])) * - (size_t)buf_info->ch); + const size_t buf_ofs = ((size_t(chx + x) + + (size_t(pen_y_px + y) * size_t(buf_info->dims[0]))) * + size_t(buf_info->ch)); uchar *cbuf = buf_info->cbuf + buf_ofs; uchar font_pixel[4]; @@ -617,7 +617,7 @@ static void blf_font_draw_buffer_ex(FontBLF *font, GlyphCacheBLF *gc, const char *str, const size_t str_len, - struct ResultBLF *r_info, + ResultBLF *r_info, ft_pix pen_y) { GlyphBLF *g, *g_prev = nullptr; @@ -650,10 +650,7 @@ static void blf_font_draw_buffer_ex(FontBLF *font, } } -void blf_font_draw_buffer(FontBLF *font, - const char *str, - const size_t str_len, - struct ResultBLF *r_info) +void blf_font_draw_buffer(FontBLF *font, const char *str, const size_t str_len, ResultBLF *r_info) { GlyphCacheBLF *gc = blf_glyph_cache_acquire(font); blf_font_draw_buffer_ex(font, gc, str, str_len, r_info, 0); @@ -692,7 +689,7 @@ size_t blf_font_width_to_strlen( size_t i, i_prev; GlyphCacheBLF *gc = blf_glyph_cache_acquire(font); - const int width_i = (int)width; + const int width_i = int(width); for (i_prev = i = 0, width_new = pen_x = 0, g_prev = nullptr; (i < str_len) && str[i]; i_prev = i, width_new = pen_x, g_prev = g) @@ -724,9 +721,9 @@ size_t blf_font_width_to_rstrlen( i = BLI_strnlen(str, str_len); s = BLI_str_find_prev_char_utf8(&str[i], str); - i = (size_t)(s - str); + i = size_t(s - str); s_prev = BLI_str_find_prev_char_utf8(s, str); - i_prev = (size_t)(s_prev - str); + i_prev = size_t(s_prev - str); i_tmp = i; g = blf_glyph_from_utf8_and_step(font, gc, str, str_len, &i_tmp); @@ -734,7 +731,7 @@ size_t blf_font_width_to_rstrlen( i = i_prev, s = s_prev, g = g_prev, g_prev = nullptr, width_new = pen_x) { s_prev = BLI_str_find_prev_char_utf8(s, str); - i_prev = (size_t)(s_prev - str); + i_prev = size_t(s_prev - str); if (s_prev != nullptr) { i_tmp = i_prev; @@ -766,7 +763,7 @@ static void blf_font_boundbox_ex(FontBLF *font, const char *str, const size_t str_len, rcti *box, - struct ResultBLF *r_info, + ResultBLF *r_info, ft_pix pen_y) { GlyphBLF *g, *g_prev = nullptr; @@ -828,7 +825,7 @@ static void blf_font_boundbox_ex(FontBLF *font, } } void blf_font_boundbox( - FontBLF *font, const char *str, const size_t str_len, rcti *r_box, struct ResultBLF *r_info) + FontBLF *font, const char *str, const size_t str_len, rcti *r_box, ResultBLF *r_info) { GlyphCacheBLF *gc = blf_glyph_cache_acquire(font); blf_font_boundbox_ex(font, gc, str, str_len, r_box, r_info, 0); @@ -840,7 +837,7 @@ void blf_font_width_and_height(FontBLF *font, const size_t str_len, float *r_width, float *r_height, - struct ResultBLF *r_info) + ResultBLF *r_info) { float xa, ya; rcti box; @@ -860,14 +857,11 @@ void blf_font_width_and_height(FontBLF *font, else { blf_font_boundbox(font, str, str_len, &box, r_info); } - *r_width = ((float)BLI_rcti_size_x(&box) * xa); - *r_height = ((float)BLI_rcti_size_y(&box) * ya); + *r_width = (float(BLI_rcti_size_x(&box)) * xa); + *r_height = (float(BLI_rcti_size_y(&box)) * ya); } -float blf_font_width(FontBLF *font, - const char *str, - const size_t str_len, - struct ResultBLF *r_info) +float blf_font_width(FontBLF *font, const char *str, const size_t str_len, ResultBLF *r_info) { float xa; rcti box; @@ -885,13 +879,10 @@ float blf_font_width(FontBLF *font, else { blf_font_boundbox(font, str, str_len, &box, r_info); } - return (float)BLI_rcti_size_x(&box) * xa; + return float(BLI_rcti_size_x(&box)) * xa; } -float blf_font_height(FontBLF *font, - const char *str, - const size_t str_len, - struct ResultBLF *r_info) +float blf_font_height(FontBLF *font, const char *str, const size_t str_len, ResultBLF *r_info) { float ya; rcti box; @@ -909,13 +900,13 @@ float blf_font_height(FontBLF *font, else { blf_font_boundbox(font, str, str_len, &box, r_info); } - return (float)BLI_rcti_size_y(&box) * ya; + return float(BLI_rcti_size_y(&box)) * ya; } float blf_font_fixed_width(FontBLF *font) { GlyphCacheBLF *gc = blf_glyph_cache_acquire(font); - float width = (gc) ? (float)gc->fixed_width : font->size / 2.0f; + float width = (gc) ? float(gc->fixed_width) : font->size / 2.0f; blf_glyph_cache_release(font); return width; } @@ -990,11 +981,11 @@ size_t blf_str_offset_from_cursor_position(FontBLF *font, { CursorPositionForeachGlyph_Data data{}; data.location_x = location_x; - data.r_offset = (size_t)-1; + data.r_offset = size_t(-1); blf_font_boundbox_foreach_glyph(font, str, str_len, blf_cursor_position_foreach_glyph, &data); - if (data.r_offset == (size_t)-1) { + if (data.r_offset == size_t(-1)) { /* We are to the right of the string, so return position of null terminator. */ data.r_offset = BLI_strnlen(str, str_len); } @@ -1055,7 +1046,7 @@ void blf_str_offset_to_glyph_bounds(FontBLF *font, static void blf_font_wrap_apply(FontBLF *font, const char *str, const size_t str_len, - struct ResultBLF *r_info, + ResultBLF *r_info, void (*callback)(FontBLF *font, GlyphCacheBLF *gc, const char *str, @@ -1161,10 +1152,7 @@ static void blf_font_draw__wrap_cb(FontBLF *font, { blf_font_draw_ex(font, gc, str, str_len, nullptr, pen_y); } -void blf_font_draw__wrap(FontBLF *font, - const char *str, - const size_t str_len, - struct ResultBLF *r_info) +void blf_font_draw__wrap(FontBLF *font, const char *str, const size_t str_len, ResultBLF *r_info) { blf_font_wrap_apply(font, str, str_len, r_info, blf_font_draw__wrap_cb, nullptr); } @@ -1184,7 +1172,7 @@ static void blf_font_boundbox_wrap_cb(FontBLF *font, BLI_rcti_union(box, &box_single); } void blf_font_boundbox__wrap( - FontBLF *font, const char *str, const size_t str_len, rcti *box, struct ResultBLF *r_info) + FontBLF *font, const char *str, const size_t str_len, rcti *box, ResultBLF *r_info) { box->xmin = 32000; box->xmax = -32000; @@ -1207,7 +1195,7 @@ static void blf_font_draw_buffer__wrap_cb(FontBLF *font, void blf_font_draw_buffer__wrap(FontBLF *font, const char *str, const size_t str_len, - struct ResultBLF *r_info) + ResultBLF *r_info) { blf_font_wrap_apply(font, str, str_len, r_info, blf_font_draw_buffer__wrap_cb, nullptr); } @@ -1268,7 +1256,7 @@ char *blf_display_name(FontBLF *font) /** \name Font Subsystem Init/Exit * \{ */ -int blf_font_init(void) +int blf_font_init() { memset(&g_batch, 0, sizeof(g_batch)); BLI_mutex_init(&ft_lib_mutex); @@ -1290,7 +1278,7 @@ int blf_font_init(void) return err; } -void blf_font_exit(void) +void blf_font_exit() { BLI_mutex_end(&ft_lib_mutex); if (ftc_manager) { @@ -1426,7 +1414,7 @@ bool blf_ensure_face(FontBLF *font) fprintf(stderr, "FT_Attach_File failed to load '%s' with error %d\n", font->filepath, - (int)err); + int(err)); } MEM_freeN(mfile); } @@ -1456,10 +1444,10 @@ bool blf_ensure_face(FontBLF *font) /* Save TrueType table with bits to quickly test most unicode block coverage. */ TT_OS2 *os2_table = (TT_OS2 *)FT_Get_Sfnt_Table(font->face, FT_SFNT_OS2); if (os2_table) { - font->unicode_ranges[0] = (uint)os2_table->ulUnicodeRange1; - font->unicode_ranges[1] = (uint)os2_table->ulUnicodeRange2; - font->unicode_ranges[2] = (uint)os2_table->ulUnicodeRange3; - font->unicode_ranges[3] = (uint)os2_table->ulUnicodeRange4; + font->unicode_ranges[0] = uint(os2_table->ulUnicodeRange1); + font->unicode_ranges[1] = uint(os2_table->ulUnicodeRange2); + font->unicode_ranges[2] = uint(os2_table->ulUnicodeRange3); + font->unicode_ranges[3] = uint(os2_table->ulUnicodeRange4); } if (FT_IS_FIXED_WIDTH(font)) { @@ -1489,13 +1477,13 @@ struct FaceDetails { }; /* Details about the fallback fonts we ship, so that we can load only when needed. */ -static const struct FaceDetails static_face_details[] = { +static const FaceDetails static_face_details[] = { {"lastresort.woff2", UINT32_MAX, UINT32_MAX, UINT32_MAX, UINT32_MAX}, {"Noto Sans CJK Regular.woff2", 0x30000083L, 0x29DF3C10L, 0x16L, 0}, {"NotoEmoji-VariableFont_wght.woff2", 0x80000003L, 0x241E4ACL, 0x14000000L, 0x4000000L}, {"NotoSansArabic-VariableFont_wdth,wght.woff2", TT_UCR_ARABIC, - (uint)TT_UCR_ARABIC_PRESENTATION_FORMS_A, + uint(TT_UCR_ARABIC_PRESENTATION_FORMS_A), TT_UCR_ARABIC_PRESENTATION_FORMS_B, 0}, {"NotoSansArmenian-VariableFont_wdth,wght.woff2", TT_UCR_ARMENIAN, 0, 0, 0}, @@ -1556,9 +1544,9 @@ static FontBLF *blf_font_new_impl(const char *filepath, if (font->filepath) { const char *filename = BLI_path_basename(font->filepath); - for (int i = 0; i < (int)ARRAY_SIZE(static_face_details); i++) { + for (int i = 0; i < int(ARRAY_SIZE(static_face_details)); i++) { if (BLI_path_cmp(static_face_details[i].filename, filename) == 0) { - const struct FaceDetails *static_details = &static_face_details[i]; + const FaceDetails *static_details = &static_face_details[i]; font->unicode_ranges[0] = static_details->coverage1; font->unicode_ranges[1] = static_details->coverage2; font->unicode_ranges[2] = static_details->coverage3; @@ -1680,7 +1668,7 @@ bool blf_font_size(FontBLF *font, float size) /* FreeType uses fixed-point integers in 64ths. */ FT_UInt ft_size = round_fl_to_uint(size * 64.0f); /* Adjust our new size to be on even 64ths. */ - size = (float)ft_size / 64.0f; + size = float(ft_size) / 64.0f; if (font->size != size) { if (font->flags & BLF_CACHED) { diff --git a/source/blender/blenfont/intern/blf_font_default.cc b/source/blender/blenfont/intern/blf_font_default.cc index a46a142477f..613075b352b 100644 --- a/source/blender/blenfont/intern/blf_font_default.cc +++ b/source/blender/blenfont/intern/blf_font_default.cc @@ -52,7 +52,7 @@ int BLF_load_mono_default(const bool unique) return font_id; } -static void blf_load_datafiles_dir(void) +static void blf_load_datafiles_dir() { const char *datafiles_fonts_dir = BLF_DATAFILES_FONTS_DIR SEP_STR; const char *path = BKE_appdir_folder_id(BLENDER_DATAFILES, datafiles_fonts_dir); @@ -65,7 +65,7 @@ static void blf_load_datafiles_dir(void) return; } - struct direntry *file_list; + direntry *file_list; uint file_list_num = BLI_filelist_dir_contents(path, &file_list); for (int i = 0; i < file_list_num; i++) { if (S_ISDIR(file_list[i].s.st_mode)) { @@ -94,7 +94,7 @@ static void blf_load_datafiles_dir(void) BLI_filelist_free(file_list, file_list_num); } -void BLF_load_font_stack(void) +void BLF_load_font_stack() { /* Load these if not already, might have been replaced by user custom. */ BLF_load_default(false); diff --git a/source/blender/blenfont/intern/blf_glyph.cc b/source/blender/blenfont/intern/blf_glyph.cc index bedb8dc257d..1a469d0d19b 100644 --- a/source/blender/blenfont/intern/blf_glyph.cc +++ b/source/blender/blenfont/intern/blf_glyph.cc @@ -105,11 +105,11 @@ static GlyphCacheBLF *blf_glyph_cache_new(FontBLF *font) FT_Fixed advance = 0; FT_Get_Advance(font->face, gindex, FT_LOAD_NO_HINTING, &advance); /* Use CSS 'ch unit' width, advance of zero character. */ - gc->fixed_width = (int)(advance >> 16); + gc->fixed_width = int(advance >> 16); } else { /* Font does not have a face or does not contain "0" so use CSS fallback of 1/2 of em. */ - gc->fixed_width = (int)((font->ft_size->metrics.height / 2) >> 6); + gc->fixed_width = int((font->ft_size->metrics.height / 2) >> 6); } if (gc->fixed_width < 1) { gc->fixed_width = 1; @@ -237,8 +237,8 @@ static GlyphBLF *blf_glyph_cache_add_glyph( g->advance_x = (ft_pix)glyph->advance.x; g->pos[0] = glyph->bitmap_left; g->pos[1] = glyph->bitmap_top; - g->dims[0] = (int)glyph->bitmap.width; - g->dims[1] = (int)glyph->bitmap.rows; + g->dims[0] = int(glyph->bitmap.width); + g->dims[1] = int(glyph->bitmap.rows); g->pitch = glyph->bitmap.pitch; FT_BBox bbox; @@ -252,7 +252,7 @@ static GlyphBLF *blf_glyph_cache_add_glyph( g->lsb_delta = (ft_pix)glyph->lsb_delta; g->rsb_delta = (ft_pix)glyph->rsb_delta; - const int buffer_size = (int)(glyph->bitmap.width * glyph->bitmap.rows); + const int buffer_size = int(glyph->bitmap.width * glyph->bitmap.rows); if (buffer_size != 0) { if (font->flags & BLF_MONOCHROME) { /* Font buffer uses only 0 or 1 values, Blender expects full 0..255 range. */ @@ -268,8 +268,8 @@ static GlyphBLF *blf_glyph_cache_add_glyph( } #endif /* BLF_GAMMA_CORRECT_GLYPHS */ } - g->bitmap = static_cast(MEM_mallocN((size_t)buffer_size, "glyph bitmap")); - memcpy(g->bitmap, glyph->bitmap.buffer, (size_t)buffer_size); + g->bitmap = static_cast(MEM_mallocN(size_t(buffer_size), "glyph bitmap")); + memcpy(g->bitmap, glyph->bitmap.buffer, size_t(buffer_size)); } const uint key = blf_hash(g->c); @@ -298,7 +298,7 @@ struct UnicodeBlock { * https://en.wikipedia.org/wiki/Unicode_block */ }; -static const struct UnicodeBlock unicode_blocks[] = { +static const UnicodeBlock unicode_blocks[] = { /* Must be in ascending order by start of range. */ {0x0, 0x7F, 0}, /* Basic Latin. */ {0x80, 0xFF, 1}, /* Latin-1 Supplement. */ @@ -560,7 +560,7 @@ static const struct UnicodeBlock unicode_blocks[] = { /** * Find a unicode block that a `charcode` belongs to. */ -static const struct UnicodeBlock *blf_charcode_to_unicode_block(const uint charcode) +static const UnicodeBlock *blf_charcode_to_unicode_block(const uint charcode) { if (charcode < 0x80) { /* Shortcut to Basic Latin. */ @@ -595,7 +595,7 @@ static const struct UnicodeBlock *blf_charcode_to_unicode_block(const uint charc static int blf_charcode_to_coverage_bit(uint charcode) { int coverage_bit = -1; - const struct UnicodeBlock *block = blf_charcode_to_unicode_block(charcode); + const UnicodeBlock *block = blf_charcode_to_unicode_block(charcode); if (block) { coverage_bit = block->coverage_bit; } @@ -614,7 +614,7 @@ static bool blf_font_has_coverage_bit(const FontBLF *font, int coverage_bit) if (coverage_bit < 0) { return false; } - return (font->unicode_ranges[(uint)coverage_bit >> 5] & (1u << ((uint)coverage_bit % 32))); + return (font->unicode_ranges[uint(coverage_bit) >> 5] & (1u << (uint(coverage_bit) % 32))); } /** @@ -807,7 +807,7 @@ static const FT_Var_Axis *blf_var_axis_by_tag(const FT_MM_Var *variations, if (!variations) { return nullptr; } - for (int i = 0; i < (int)variations->num_axis; i++) { + for (int i = 0; i < int(variations->num_axis); i++) { if (variations->axis[i].tag == tag) { *r_axis_index = i; return &(variations->axis)[i]; @@ -828,11 +828,11 @@ static FT_Fixed blf_factor_to_coordinate(const FT_Var_Axis *axis, const float fa FT_Fixed value = axis->def; if (factor > 0) { /* Map 0-1 to axis->def - axis->maximum */ - value += (FT_Fixed)((double)(axis->maximum - axis->def) * factor); + value += (FT_Fixed)(double(axis->maximum - axis->def) * factor); } else if (factor < 0) { /* Map -1-0 to axis->minimum - axis->def */ - value += (FT_Fixed)((double)(axis->def - axis->minimum) * factor); + value += (FT_Fixed)(double(axis->def - axis->minimum) * factor); } return value; } @@ -895,7 +895,7 @@ static bool blf_glyph_transform_weight(FT_GlyphSlot glyph, float factor, bool mo /* Fake bold if the font does not have this variable axis. */ const FontBLF *font = (FontBLF *)glyph->face->generic.data; const FT_Pos average_width = font->ft_size->metrics.height; - FT_Pos change = (FT_Pos)((float)average_width * factor * 0.1f); + FT_Pos change = (FT_Pos)(float(average_width) * factor * 0.1f); FT_Outline_EmboldenXY(&glyph->outline, change, change / 2); if (monospaced) { /* Widened fixed-pitch font needs a nudge left. */ @@ -939,7 +939,7 @@ static bool blf_glyph_transform_width(FT_GlyphSlot glyph, float factor) float scale = (factor * 0.4f) + 1.0f; /* 0.6f - 1.4f */ FT_Matrix matrix = {to_16dot16(scale), 0, 0, to_16dot16(1)}; FT_Outline_Transform(&glyph->outline, &matrix); - glyph->advance.x = (FT_Pos)((double)glyph->advance.x * scale); + glyph->advance.x = (FT_Pos)(double(glyph->advance.x) * scale); return true; } return false; @@ -955,7 +955,7 @@ static bool blf_glyph_transform_spacing(FT_GlyphSlot glyph, float factor) if (glyph->advance.x > 0) { const FontBLF *font = (FontBLF *)glyph->face->generic.data; const long int size = font->ft_size->metrics.height; - glyph->advance.x += (FT_Pos)(factor * (float)size / 6.0f); + glyph->advance.x += (FT_Pos)(factor * float(size) / 6.0f); return true; } return false; @@ -973,7 +973,7 @@ static bool blf_glyph_transform_monospace(FT_GlyphSlot glyph, int width) const FT_Pos embolden = (FT_Pos)((current - target) >> 13); /* Horizontally widen strokes to counteract narrowing. */ FT_Outline_EmboldenXY(&glyph->outline, embolden, 0); - const float scale = (float)(target - (embolden << 9)) / (float)current; + const float scale = float(target - (embolden << 9)) / float(current); FT_Matrix matrix = {to_16dot16(scale), 0, 0, to_16dot16(1)}; FT_Outline_Transform(&glyph->outline, &matrix); } @@ -1056,7 +1056,7 @@ static FT_GlyphSlot blf_glyph_render(FontBLF *settings_font, } if ((settings_font->flags & BLF_MONOSPACED) && (settings_font != glyph_font)) { - blf_glyph_transform_monospace(glyph, BLI_wcwidth((char32_t)charcode) * fixed_width); + blf_glyph_transform_monospace(glyph, BLI_wcwidth(char32_t(charcode)) * fixed_width); } /* Fallback glyph transforms, but only if required and not yet done. */ @@ -1162,11 +1162,11 @@ static void blf_texture_draw(const uchar color[4], /* Only one vertex per glyph, geometry shader expand it into a quad. */ /* TODO: Get rid of Geom Shader because it's not optimal AT ALL for the GPU. */ copy_v4_fl4(static_cast(GPU_vertbuf_raw_step(&g_batch.pos_step)), - (float)(x1 + g_batch.ofs[0]), - (float)(y1 + g_batch.ofs[1]), - (float)(x2 + g_batch.ofs[0]), - (float)(y2 + g_batch.ofs[1])); - copy_v4_v4_uchar(static_cast(GPU_vertbuf_raw_step(&g_batch.col_step)), color); + float(x1 + g_batch.ofs[0]), + float(y1 + g_batch.ofs[1]), + float(x2 + g_batch.ofs[0]), + float(y2 + g_batch.ofs[1])); + copy_v4_v4_uchar(static_cast(GPU_vertbuf_raw_step(&g_batch.col_step)), color); copy_v2_v2_int(static_cast(GPU_vertbuf_raw_step(&g_batch.glyph_size_step)), glyph_size); *((int *)GPU_vertbuf_raw_step(&g_batch.offset_step)) = offset; @@ -1231,7 +1231,7 @@ void blf_glyph_draw(FontBLF *font, GlyphCacheBLF *gc, GlyphBLF *g, const int x, gc->bitmap_len_alloc = w * h; gc->bitmap_result = static_cast( - MEM_reallocN(gc->bitmap_result, (size_t)gc->bitmap_len_alloc)); + MEM_reallocN(gc->bitmap_result, size_t(gc->bitmap_len_alloc))); /* Keep in sync with the texture. */ if (gc->texture) { @@ -1243,7 +1243,7 @@ void blf_glyph_draw(FontBLF *font, GlyphCacheBLF *gc, GlyphBLF *g, const int x, gc->bitmap_len_landed = 0; } - memcpy(&gc->bitmap_result[gc->bitmap_len], g->bitmap, (size_t)buff_size); + memcpy(&gc->bitmap_result[gc->bitmap_len], g->bitmap, size_t(buff_size)); gc->bitmap_len = bitmap_len; g->glyph_cache = gc; @@ -1262,7 +1262,7 @@ void blf_glyph_draw(FontBLF *font, GlyphCacheBLF *gc, GlyphBLF *g, const int x, } rcti rect_test; - blf_glyph_calc_rect_test(&rect_test, g, (int)((float)x * xa), (int)((float)y * ya)); + blf_glyph_calc_rect_test(&rect_test, g, int(float(x) * xa), int(float(y) * ya)); BLI_rcti_translate(&rect_test, font->pos[0], font->pos[1]); if (!BLI_rcti_inside_rcti(&font->clip_rec, &rect_test)) { return; diff --git a/source/blender/blenfont/intern/blf_thumbs.cc b/source/blender/blenfont/intern/blf_thumbs.cc index 0c601de80d6..66f0c8ffa07 100644 --- a/source/blender/blenfont/intern/blf_thumbs.cc +++ b/source/blender/blenfont/intern/blf_thumbs.cc @@ -255,10 +255,10 @@ static const char32_t *blf_get_sample_text(FT_Face face) return U"\xE000\xFFFF"; } - int language_count = count_bits_i((uint)os2_table->ulUnicodeRange1) + - count_bits_i((uint)os2_table->ulUnicodeRange2) + - count_bits_i((uint)os2_table->ulUnicodeRange3) + - count_bits_i((uint)os2_table->ulUnicodeRange4); + int language_count = count_bits_i(uint(os2_table->ulUnicodeRange1)) + + count_bits_i(uint(os2_table->ulUnicodeRange2)) + + count_bits_i(uint(os2_table->ulUnicodeRange3)) + + count_bits_i(uint(os2_table->ulUnicodeRange4)); /* Use OS/2 Table code page range bits to differentiate between (combined) CJK fonts. * See https://learn.microsoft.com/en-us/typography/opentype/spec/os2#cpr */ @@ -354,13 +354,13 @@ bool BLF_thumb_preview(const char *filename, uchar *buf, int w, int h, int /*cha glyph_ids[i] = FT_Get_Char_Index(face, codepoints[i]); /* If sample glyph is not found, use another. */ if (!glyph_ids[i]) { - glyph_ids[i] = (uint)(face->num_glyphs / (BLF_SAMPLE_LEN + 1)) * (i + 1); + glyph_ids[i] = uint(face->num_glyphs / (BLF_SAMPLE_LEN + 1)) * (i + 1); } /* Get advance without loading the glyph. */ FT_Fixed advance; FT_Get_Advance(face, glyph_ids[i], FT_LOAD_NO_HINTING, &advance); /* Advance is returned in 16.16 format, so divide by 65536 for pixels. */ - width += (int)(advance >> 16); + width += int(advance >> 16); } int height = ft_pix_to_int((ft_pix)face->size->metrics.ascender - @@ -368,11 +368,11 @@ bool BLF_thumb_preview(const char *filename, uchar *buf, int w, int h, int /*cha width = MAX2(width, height); /* Fill up to 96% horizontally or vertically. */ - float font_size = MIN3((float)w, - ((float)w * 0.96f / (float)width * (float)w), - (float)h * 0.96f / (float)height * (float)h); + float font_size = MIN3(float(w), + (float(w) * 0.96f / float(width) * float(w)), + float(h) * 0.96f / float(height) * float(h)); - if (font_size < 1 || FT_Set_Char_Size(face, (int)(font_size * 64.0f), 0, 72, 72) != FT_Err_Ok) { + if (font_size < 1 || FT_Set_Char_Size(face, int(font_size * 64.0f), 0, 72, 72) != FT_Err_Ok) { /* Sizing can fail, but very rarely. */ FT_Done_Face(face); FT_Done_FreeType(ft_lib); @@ -380,8 +380,8 @@ bool BLF_thumb_preview(const char *filename, uchar *buf, int w, int h, int /*cha } /* Horizontally center, line up baselines vertically. */ - int left = (int)(((float)w - ((float)width * (font_size / (float)w))) / 2.0f); - int top = (int)((float)h * 0.7f); + int left = int((float(w) - (float(width) * (font_size / float(w)))) / 2.0f); + int top = int(float(h) * 0.7f); /* Print out to buffer. */ @@ -402,15 +402,15 @@ bool BLF_thumb_preview(const char *filename, uchar *buf, int w, int h, int /*cha glyph_count++; - for (int y = 0; y < (int)face->glyph->bitmap.rows; y++) { - int dest_row = (h - y - 1 + (int)face->glyph->bitmap_top - top); + for (int y = 0; y < int(face->glyph->bitmap.rows); y++) { + int dest_row = (h - y - 1 + int(face->glyph->bitmap_top) - top); if (dest_row >= 0 && dest_row < h) { - for (int x = 0; x < (int)face->glyph->bitmap.width; x++) { + for (int x = 0; x < int(face->glyph->bitmap.width); x++) { int dest_col = (x + ft_pix_to_int((ft_pix)advance_x) + face->glyph->bitmap_left + left); if (dest_col >= 0 && dest_col < w) { - uchar *source = &face->glyph->bitmap.buffer[y * (int)face->glyph->bitmap.width + x]; + uchar *source = &face->glyph->bitmap.buffer[y * int(face->glyph->bitmap.width) + x]; uchar *dest = &buf[dest_row * w * 4 + (dest_col * 4 + 3)]; - *dest = (uchar)MIN2(((uint)*dest + (uint)*source), 255u); + *dest = uchar(MIN2((uint(*dest) + uint(*source)), 255u)); } } } diff --git a/source/blender/blentranslation/intern/blt_lang.cc b/source/blender/blentranslation/intern/blt_lang.cc index 77bfc3f6b6a..f6ca4c13f55 100644 --- a/source/blender/blentranslation/intern/blt_lang.cc +++ b/source/blender/blentranslation/intern/blt_lang.cc @@ -46,7 +46,7 @@ static int num_locales = 0; static EnumPropertyItem *locales_menu = nullptr; static int num_locales_menu = 0; -static void free_locales(void) +static void free_locales() { if (locales) { int idx = num_locales_menu - 1; /* Last item does not need to be freed! */ @@ -63,7 +63,7 @@ static void free_locales(void) num_locales = num_locales_menu = 0; } -static void fill_locales(void) +static void fill_locales() { const char *const languages_path = BKE_appdir_folder_id(BLENDER_DATAFILES, "locale"); char languages[FILE_MAX]; @@ -169,7 +169,7 @@ static void fill_locales(void) } #endif /* WITH_INTERNATIONAL */ -EnumPropertyItem *BLT_lang_RNA_enum_properties(void) +EnumPropertyItem *BLT_lang_RNA_enum_properties() { #ifdef WITH_INTERNATIONAL return locales_menu; @@ -178,7 +178,7 @@ EnumPropertyItem *BLT_lang_RNA_enum_properties(void) #endif } -void BLT_lang_init(void) +void BLT_lang_init() { #ifdef WITH_INTERNATIONAL const char *const messagepath = BKE_appdir_folder_id(BLENDER_DATAFILES, "locale"); @@ -223,7 +223,7 @@ void BLT_lang_init(void) #endif } -void BLT_lang_free(void) +void BLT_lang_free() { #ifdef WITH_INTERNATIONAL free_locales(); @@ -267,7 +267,7 @@ void BLT_lang_set(const char *str) #endif } -const char *BLT_lang_get(void) +const char *BLT_lang_get() { #ifdef WITH_INTERNATIONAL if (BLT_translate()) { diff --git a/source/blender/blentranslation/intern/blt_translation.cc b/source/blender/blentranslation/intern/blt_translation.cc index 42c00340b24..ee8b665ac6f 100644 --- a/source/blender/blentranslation/intern/blt_translation.cc +++ b/source/blender/blentranslation/intern/blt_translation.cc @@ -63,7 +63,7 @@ const char *BLT_pgettext(const char *msgctxt, const char *msgid) #endif } -bool BLT_translate(void) +bool BLT_translate() { #ifdef WITH_INTERNATIONAL return BLI_thread_is_main(); @@ -72,7 +72,7 @@ bool BLT_translate(void) #endif } -bool BLT_translate_iface(void) +bool BLT_translate_iface() { #ifdef WITH_INTERNATIONAL return BLT_translate() && (U.transopts & USER_TR_IFACE); @@ -81,7 +81,7 @@ bool BLT_translate_iface(void) #endif } -bool BLT_translate_tooltips(void) +bool BLT_translate_tooltips() { #ifdef WITH_INTERNATIONAL return BLT_translate() && (U.transopts & USER_TR_TOOLTIPS); @@ -90,7 +90,7 @@ bool BLT_translate_tooltips(void) #endif } -bool BLT_translate_new_dataname(void) +bool BLT_translate_new_dataname() { #ifdef WITH_INTERNATIONAL return BLT_translate() && (U.transopts & USER_TR_NEWDATANAME); diff --git a/source/blender/blentranslation/msgfmt/msgfmt.cc b/source/blender/blentranslation/msgfmt/msgfmt.cc index 46e3757e9b5..7495580401d 100644 --- a/source/blender/blentranslation/msgfmt/msgfmt.cc +++ b/source/blender/blentranslation/msgfmt/msgfmt.cc @@ -148,7 +148,7 @@ BLI_INLINE size_t uint32_to_bytes(const int value, char *bytes) { size_t i; for (i = 0; i < sizeof(value); i++) { - bytes[i] = (char)((value >> ((int)i * 8)) & 0xff); + bytes[i] = char((value >> (int(i) * 8)) & 0xff); } return i; } @@ -188,11 +188,11 @@ static char *generate(GHash *messages, size_t *r_output_size) /* For each string, we need size and file offset. * Each string is nullptr terminated; the nullptr does not count into the size. */ off->key_offset = tot_keys_len; - off->key_len = (uint32_t)strlen(keys[i]); + off->key_len = uint32_t(strlen(keys[i])); tot_keys_len += off->key_len + 1; off->val_offset = tot_vals_len; - off->val_len = (uint32_t)strlen(vals[i]); + off->val_len = uint32_t(strlen(vals[i])); tot_vals_len += off->val_len + 1; } @@ -252,9 +252,9 @@ static char *generate(GHash *messages, size_t *r_output_size) /* Add a non-fuzzy translation to the dictionary. */ static void add(GHash *messages, MemArena *memarena, const Message *msg) { - const size_t msgctxt_len = (size_t)BLI_dynstr_get_len(msg->ctxt); - const size_t msgid_len = (size_t)BLI_dynstr_get_len(msg->id); - const size_t msgstr_len = (size_t)BLI_dynstr_get_len(msg->str); + const size_t msgctxt_len = size_t(BLI_dynstr_get_len(msg->ctxt)); + const size_t msgid_len = size_t(BLI_dynstr_get_len(msg->id)); + const size_t msgstr_len = size_t(BLI_dynstr_get_len(msg->str)); const size_t msgkey_len = msgid_len + ((msgctxt_len == 0) ? 0 : msgctxt_len + 1); if (!msg->is_fuzzy && msgstr_len != 0) { diff --git a/source/blender/ikplugin/intern/ikplugin_api.cc b/source/blender/ikplugin/intern/ikplugin_api.cc index 3fffa8a7cdf..4e00a7c5ce4 100644 --- a/source/blender/ikplugin/intern/ikplugin_api.cc +++ b/source/blender/ikplugin/intern/ikplugin_api.cc @@ -63,7 +63,7 @@ static IKPlugin *get_plugin(bPose *pose) /*----------------------------------------*/ /* Plugin API */ -void BIK_init_tree(struct Depsgraph *depsgraph, Scene *scene, Object *ob, float ctime) +void BIK_init_tree(Depsgraph *depsgraph, Scene *scene, Object *ob, float ctime) { IKPlugin *plugin = get_plugin(ob->pose); @@ -73,7 +73,7 @@ void BIK_init_tree(struct Depsgraph *depsgraph, Scene *scene, Object *ob, float } void BIK_execute_tree( - struct Depsgraph *depsgraph, Scene *scene, Object *ob, bPoseChannel *pchan, float ctime) + Depsgraph *depsgraph, Scene *scene, Object *ob, bPoseChannel *pchan, float ctime) { IKPlugin *plugin = get_plugin(ob->pose); @@ -118,7 +118,7 @@ void BIK_update_param(bPose *pose) } } -void BIK_test_constraint(Object *ob, struct bConstraint *cons) +void BIK_test_constraint(Object *ob, bConstraint *cons) { IKPlugin *plugin = get_plugin(ob->pose); diff --git a/source/blender/ikplugin/intern/iksolver_plugin.cc b/source/blender/ikplugin/intern/iksolver_plugin.cc index b22c898e66e..96099880bcc 100644 --- a/source/blender/ikplugin/intern/iksolver_plugin.cc +++ b/source/blender/ikplugin/intern/iksolver_plugin.cc @@ -262,10 +262,7 @@ static void where_is_ik_bone(bPoseChannel *pchan, * Called from within the core #BKE_pose_where_is loop, all animation-systems and constraints * were executed & assigned. Now as last we do an IK pass. */ -static void execute_posetree(struct Depsgraph *depsgraph, - struct Scene *scene, - Object *ob, - PoseTree *tree) +static void execute_posetree(Depsgraph *depsgraph, Scene *scene, Object *ob, PoseTree *tree) { float R_parmat[3][3], identity[3][3]; float iR_parmat[3][3]; @@ -575,8 +572,8 @@ static void free_posetree(PoseTree *tree) /* ------------------------------ * Plugin API for legacy iksolver */ -void iksolver_initialize_tree(struct Depsgraph * /*depsgraph*/, - struct Scene * /*scene*/, +void iksolver_initialize_tree(Depsgraph * /*depsgraph*/, + Scene * /*scene*/, Object *ob, float /*ctime*/) { @@ -590,11 +587,8 @@ void iksolver_initialize_tree(struct Depsgraph * /*depsgraph*/, ob->pose->flag &= ~POSE_WAS_REBUILT; } -void iksolver_execute_tree(struct Depsgraph *depsgraph, - struct Scene *scene, - Object *ob, - bPoseChannel *pchan_root, - float ctime) +void iksolver_execute_tree( + Depsgraph *depsgraph, Scene *scene, Object *ob, bPoseChannel *pchan_root, float ctime) { while (pchan_root->iktree.first) { PoseTree *tree = static_cast(pchan_root->iktree.first); @@ -635,7 +629,7 @@ void iksolver_execute_tree(struct Depsgraph *depsgraph, } } -void iksolver_release_tree(struct Scene * /*scene*/, Object *ob, float /*ctime*/) +void iksolver_release_tree(Scene * /*scene*/, Object *ob, float /*ctime*/) { iksolver_clear_data(ob->pose); } diff --git a/source/blender/sequencer/intern/clipboard.cc b/source/blender/sequencer/intern/clipboard.cc index 3df501c2868..149a007420a 100644 --- a/source/blender/sequencer/intern/clipboard.cc +++ b/source/blender/sequencer/intern/clipboard.cc @@ -51,7 +51,7 @@ static char seq_clipboard_active_seq_name[SEQ_NAME_MAXSTR]; void seq_clipboard_pointers_free(ListBase *seqbase); -void SEQ_clipboard_free(void) +void SEQ_clipboard_free() { seq_clipboard_pointers_free(&seqbase_clipboard); diff --git a/source/blender/sequencer/intern/disk_cache.cc b/source/blender/sequencer/intern/disk_cache.cc index 010fca6b21b..0693b88cf4b 100644 --- a/source/blender/sequencer/intern/disk_cache.cc +++ b/source/blender/sequencer/intern/disk_cache.cc @@ -91,7 +91,7 @@ struct SeqDiskCache { }; struct DiskCacheFile { - struct DiskCacheFile *next, *prev; + DiskCacheFile *next, *prev; char filepath[FILE_MAX]; char dir[FILE_MAXDIR]; char file[FILE_MAX]; @@ -106,12 +106,12 @@ struct DiskCacheFile { static ThreadMutex cache_create_lock = BLI_MUTEX_INITIALIZER; -static char *seq_disk_cache_base_dir(void) +static char *seq_disk_cache_base_dir() { return U.sequencer_disk_cache_dir; } -static int seq_disk_cache_compression_level(void) +static int seq_disk_cache_compression_level() { switch (U.sequencer_disk_cache_compression) { case USER_SEQ_DISK_CACHE_COMPRESSION_NONE: @@ -125,9 +125,9 @@ static int seq_disk_cache_compression_level(void) return U.sequencer_disk_cache_compression; } -static size_t seq_disk_cache_size_limit(void) +static size_t seq_disk_cache_size_limit() { - return (size_t)U.sequencer_disk_cache_size_limit * (1024 * 1024 * 1024); + return size_t(U.sequencer_disk_cache_size_limit) * (1024 * 1024 * 1024); } bool seq_disk_cache_is_enabled(Main *bmain) @@ -163,7 +163,7 @@ static DiskCacheFile *seq_disk_cache_add_file_to_list(SeqDiskCache *disk_cache, static void seq_disk_cache_get_files(SeqDiskCache *disk_cache, char *dirpath) { - struct direntry *filelist, *fl; + direntry *filelist, *fl; uint i; disk_cache->size_total = 0; @@ -324,7 +324,7 @@ static void seq_disk_cache_get_file_path(SeqDiskCache *disk_cache, size_t filepath_maxncpy) { seq_disk_cache_get_dir(disk_cache, key->context.scene, key->seq, filepath, filepath_maxncpy); - int frameno = (int)key->frame_index / DCACHE_IMAGES_PER_FILE; + int frameno = int(key->frame_index) / DCACHE_IMAGES_PER_FILE; char cache_filename[FILE_MAXFILE]; SNPRINTF(cache_filename, DCACHE_FNAME_FORMAT, @@ -635,8 +635,8 @@ ImBuf *seq_disk_cache_read_file(SeqDiskCache *disk_cache, SeqCacheKey *key) } ImBuf *ibuf; - uint64_t size_char = (uint64_t)key->context.rectx * key->context.recty * 4; - uint64_t size_float = (uint64_t)key->context.rectx * key->context.recty * 16; + uint64_t size_char = uint64_t(key->context.rectx) * key->context.recty * 4; + uint64_t size_float = uint64_t(key->context.rectx) * key->context.recty * 16; size_t expected_size; if (header.entry[entry_index].size_raw == size_char) { diff --git a/source/blender/sequencer/intern/effects.cc b/source/blender/sequencer/intern/effects.cc index b8e0e205391..423f5023e68 100644 --- a/source/blender/sequencer/intern/effects.cc +++ b/source/blender/sequencer/intern/effects.cc @@ -60,7 +60,7 @@ #include "strip_time.h" #include "utils.h" -static struct SeqEffectHandle get_sequence_effect_impl(int seq_type); +static SeqEffectHandle get_sequence_effect_impl(int seq_type); /* -------------------------------------------------------------------- */ /** \name Internal Utilities @@ -438,7 +438,7 @@ static void do_cross_effect_byte(float fac, int x, int y, uchar *rect1, uchar *r uchar *rt2 = rect2; uchar *rt = out; - int temp_fac = (int)(256.0f * fac); + int temp_fac = int(256.0f * fac); int temp_mfac = 256 - temp_fac; for (int i = 0; i < y; i++) { @@ -536,7 +536,7 @@ static void makeGammaTables(float gamma) valid_gamma = gamma; valid_inv_gamma = 1.0f / gamma; color_step = 1.0f / RE_GAMMA_TABLE_SIZE; - inv_color_step = (float)RE_GAMMA_TABLE_SIZE; + inv_color_step = float(RE_GAMMA_TABLE_SIZE); /* We could squeeze out the two range tables to gain some memory */ for (i = 0; i < RE_GAMMA_TABLE_SIZE; i++) { @@ -644,7 +644,7 @@ static void gamtabs(float gamma) } } -static void build_gammatabs(void) +static void build_gammatabs() { if (gamma_tabs_init == false) { gamtabs(2.0f); @@ -762,11 +762,11 @@ static void do_add_effect_byte(float fac, int x, int y, uchar *rect1, uchar *rec uchar *cp2 = rect2; uchar *rt = out; - int temp_fac = (int)(256.0f * fac); + int temp_fac = int(256.0f * fac); for (int i = 0; i < y; i++) { for (int j = 0; j < x; j++) { - const int temp_fac2 = temp_fac * (int)cp2[3]; + const int temp_fac2 = temp_fac * int(cp2[3]); rt[0] = min_ii(cp1[0] + ((temp_fac2 * cp2[0]) >> 16), 255); rt[1] = min_ii(cp1[1] + ((temp_fac2 * cp2[1]) >> 16), 255); rt[2] = min_ii(cp1[2] + ((temp_fac2 * cp2[2]) >> 16), 255); @@ -841,11 +841,11 @@ static void do_sub_effect_byte(float fac, int x, int y, uchar *rect1, uchar *rec uchar *cp2 = rect2; uchar *rt = out; - int temp_fac = (int)(256.0f * fac); + int temp_fac = int(256.0f * fac); for (int i = 0; i < y; i++) { for (int j = 0; j < x; j++) { - const int temp_fac2 = temp_fac * (int)cp2[3]; + const int temp_fac2 = temp_fac * int(cp2[3]); rt[0] = max_ii(cp1[0] - ((temp_fac2 * cp2[0]) >> 16), 0); rt[1] = max_ii(cp1[1] - ((temp_fac2 * cp2[1]) >> 16), 0); rt[2] = max_ii(cp1[2] - ((temp_fac2 * cp2[2]) >> 16), 0); @@ -925,7 +925,7 @@ static void do_drop_effect_byte(float fac, int x, int y, uchar *rect2i, uchar *r const int xoff = min_ii(XOFF, x); const int yoff = min_ii(YOFF, y); - int temp_fac = (int)(70.0f * fac); + int temp_fac = int(70.0f * fac); uchar *rt2 = rect2i + yoff * 4 * x; uchar *rt1 = rect1i; @@ -999,7 +999,7 @@ static void do_mul_effect_byte(float fac, int x, int y, uchar *rect1, uchar *rec uchar *rt2 = rect2; uchar *rt = out; - int temp_fac = (int)(256.0f * fac); + int temp_fac = int(256.0f * fac); /* Formula: * `fac * (a * b) + (1 - fac) * a => fac * a * (b - 1) + axaux = c * px + py * s;` // + centx @@ -1095,7 +1095,7 @@ BLI_INLINE void apply_blend_function_byte(float fac, for (int i = 0; i < y; i++) { for (int j = 0; j < x; j++) { uint achannel = rt2[3]; - rt2[3] = (uint)achannel * fac; + rt2[3] = uint(achannel) * fac; blend_function(rt, rt1, rt2); rt2[3] = achannel; rt[3] = rt1[3]; @@ -1374,7 +1374,7 @@ static void precalc_wipe_zone(WipeZone *wipezone, WipeVars *wipe, int xo, int yo wipezone->angle = tanf(fabsf(wipe->angle)); wipezone->xo = xo; wipezone->yo = yo; - wipezone->width = (int)(wipe->edgeWidth * ((xo + yo) / 2.0f)); + wipezone->width = int(wipe->edgeWidth * ((xo + yo) / 2.0f)); wipezone->pythangle = 1.0f / sqrtf(wipezone->angle * wipezone->angle + 1.0f); } @@ -1386,11 +1386,11 @@ static float in_band(float width, float dist, int side, int dir) float alpha; if (width == 0) { - return (float)side; + return float(side); } if (width < dist) { - return (float)side; + return float(side); } if (side == 1) { @@ -1531,11 +1531,11 @@ static float check_zone(WipeZone *wipezone, int x, int y, Sequence *seq, float f * temp4: angle of high side of blur */ output = 1.0f - fac; - widthf = wipe->edgeWidth * 2.0f * (float)M_PI; - temp1 = 2.0f * (float)M_PI * fac; + widthf = wipe->edgeWidth * 2.0f * float(M_PI); + temp1 = 2.0f * float(M_PI) * fac; if (wipe->forward) { - temp1 = 2.0f * (float)M_PI - temp1; + temp1 = 2.0f * float(M_PI) - temp1; } x = x - halfx; @@ -1543,13 +1543,13 @@ static float check_zone(WipeZone *wipezone, int x, int y, Sequence *seq, float f temp2 = asin(abs(y) / hypot(x, y)); if (x <= 0 && y >= 0) { - temp2 = (float)M_PI - temp2; + temp2 = float(M_PI) - temp2; } else if (x <= 0 && y <= 0) { - temp2 += (float)M_PI; + temp2 += float(M_PI); } else if (x >= 0 && y <= 0) { - temp2 = 2.0f * (float)M_PI - temp2; + temp2 = 2.0f * float(M_PI) - temp2; } if (wipe->forward) { @@ -1563,8 +1563,8 @@ static float check_zone(WipeZone *wipezone, int x, int y, Sequence *seq, float f if (temp3 < 0) { temp3 = 0; } - if (temp4 > 2.0f * (float)M_PI) { - temp4 = 2.0f * (float)M_PI; + if (temp4 > 2.0f * float(M_PI)) { + temp4 = 2.0f * float(M_PI); } if (temp2 < temp3) { @@ -1636,7 +1636,7 @@ static void init_wipe_effect(Sequence *seq) seq->effectdata = MEM_callocN(sizeof(WipeVars), "wipevars"); } -static int num_inputs_wipe(void) +static int num_inputs_wipe() { return 2; } @@ -1829,7 +1829,7 @@ static void init_transform_effect(Sequence *seq) transform->uniform_scale = 0; } -static int num_inputs_transform(void) +static int num_inputs_transform() { return 1; } @@ -1999,10 +1999,10 @@ static void RVBlurBitmap2_float(float *map, int width, int height, float blur, i * Blancmange */ - k = -1.0f / (2.0f * (float)M_PI * blur * blur); + k = -1.0f / (2.0f * float(M_PI) * blur * blur); for (ix = 0; ix < halfWidth; ix++) { - weight = (float)exp(k * (ix * ix)); + weight = float(exp(k * (ix * ix))); filter[halfWidth - ix] = weight; filter[halfWidth + ix] = weight; } @@ -2173,7 +2173,7 @@ static void init_glow_effect(Sequence *seq) glow->bNoComp = 0; } -static int num_inputs_glow(void) +static int num_inputs_glow() { return 1; } @@ -2298,7 +2298,7 @@ static void init_solid_color(Sequence *seq) cv->col[0] = cv->col[1] = cv->col[2] = 0.5; } -static int num_inputs_color(void) +static int num_inputs_color() { return 0; } @@ -2384,7 +2384,7 @@ static ImBuf *do_solid_color(const SeqRenderData *context, * \{ */ /** No effect inputs for multi-camera, we use #give_ibuf_seq. */ -static int num_inputs_multicam(void) +static int num_inputs_multicam() { return 0; } @@ -2432,7 +2432,7 @@ static ImBuf *do_multicam(const SeqRenderData *context, * \{ */ /** No effect inputs for adjustment, we use #give_ibuf_seq. */ -static int num_inputs_adjustment(void) +static int num_inputs_adjustment() { return 0; } @@ -2532,7 +2532,7 @@ static void load_speed_effect(Sequence *seq) v->frameMap = nullptr; } -static int num_inputs_speed(void) +static int num_inputs_speed() { return 1; } @@ -2681,7 +2681,7 @@ static ImBuf *do_speed_effect(const SeqRenderData *context, ImBuf *ibuf3) { SpeedControlVars *s = (SpeedControlVars *)seq->effectdata; - struct SeqEffectHandle cross_effect = get_sequence_effect_impl(SEQ_TYPE_CROSS); + SeqEffectHandle cross_effect = get_sequence_effect_impl(SEQ_TYPE_CROSS); ImBuf *out; if (s->flags & SEQ_SPEED_USE_INTERPOLATION) { @@ -2759,7 +2759,7 @@ static void init_gaussian_blur_effect(Sequence *seq) seq->effectdata = MEM_callocN(sizeof(WipeVars), "wipevars"); } -static int num_inputs_gaussian_blur(void) +static int num_inputs_gaussian_blur() { return 1; } @@ -2797,7 +2797,7 @@ static float *make_gaussian_blur_kernel(float rad, int size) sum = 0.0f; fac = (rad > 0.0f ? 1.0f / rad : 0.0f); for (i = -size; i <= size; i++) { - val = RE_filter_value(R_FILTER_GAUSS, (float)i * fac); + val = RE_filter_value(R_FILTER_GAUSS, float(i) * fac); sum += val; gausstab[i + size] = val; } @@ -2821,7 +2821,7 @@ static void do_gaussian_blur_effect_byte_x(Sequence *seq, { #define INDEX(_x, _y) (((_y) * (x) + (_x)) * 4) GaussianBlurVars *data = static_cast(seq->effectdata); - const int size_x = (int)(data->size_x + 0.5f); + const int size_x = int(data->size_x + 0.5f); int i, j; /* Make gaussian weight table. */ @@ -2871,7 +2871,7 @@ static void do_gaussian_blur_effect_byte_y(Sequence *seq, { #define INDEX(_x, _y) (((_y) * (x) + (_x)) * 4) GaussianBlurVars *data = static_cast(seq->effectdata); - const int size_y = (int)(data->size_y + 0.5f); + const int size_y = int(data->size_y + 0.5f); int i, j; /* Make gaussian weight table. */ @@ -2919,7 +2919,7 @@ static void do_gaussian_blur_effect_float_x(Sequence *seq, { #define INDEX(_x, _y) (((_y) * (x) + (_x)) * 4) GaussianBlurVars *data = static_cast(seq->effectdata); - const int size_x = (int)(data->size_x + 0.5f); + const int size_x = int(data->size_x + 0.5f); int i, j; /* Make gaussian weight table. */ @@ -2960,7 +2960,7 @@ static void do_gaussian_blur_effect_float_y(Sequence *seq, { #define INDEX(_x, _y) (((_y) * (x) + (_x)) * 4) GaussianBlurVars *data = static_cast(seq->effectdata); - const int size_y = (int)(data->size_y + 0.5f); + const int size_y = int(data->size_y + 0.5f); int i, j; /* Make gaussian weight table. */ @@ -3240,7 +3240,7 @@ void SEQ_effect_text_font_load(TextVars *data, const bool do_id_user) char name[MAX_ID_FULL_NAME]; BKE_id_full_name_get(name, &vfont->id, 0); - data->text_blf_id = BLF_load_mem(name, static_cast(pf->data), pf->size); + data->text_blf_id = BLF_load_mem(name, static_cast(pf->data), pf->size); } else { char filepath[FILE_MAX]; @@ -3278,7 +3278,7 @@ static void copy_text_effect(Sequence *dst, Sequence *src, const int flag) SEQ_effect_text_font_load(data, (flag & LIB_ID_CREATE_NO_USER_REFCOUNT) == 0); } -static int num_inputs_text(void) +static int num_inputs_text() { return 0; } @@ -3356,7 +3356,7 @@ static ImBuf *do_text_effect(const SeqRenderData *context, /* vars for calculating wordwrap and optional box */ struct { - struct ResultBLF info; + ResultBLF info; rcti rect; } wrap; @@ -3427,7 +3427,7 @@ static void load_noop(Sequence * /*seq*/) {} static void free_noop(Sequence * /*seq*/, const bool /*do_id_user*/) {} -static int num_inputs_default(void) +static int num_inputs_default() { return 2; } @@ -3487,7 +3487,7 @@ static void get_default_fac_fade(const Scene *scene, float timeline_frame, float *fac) { - *fac = (float)(timeline_frame - SEQ_time_left_handle_frame_get(scene, seq)); + *fac = float(timeline_frame - SEQ_time_left_handle_frame_get(scene, seq)); *fac /= SEQ_time_strip_length_get(scene, seq); } @@ -3501,9 +3501,9 @@ static ImBuf *init_execution(const SeqRenderData *context, return out; } -static struct SeqEffectHandle get_sequence_effect_impl(int seq_type) +static SeqEffectHandle get_sequence_effect_impl(int seq_type) { - struct SeqEffectHandle rval; + SeqEffectHandle rval; int sequence_type = seq_type; rval.multithreaded = false; @@ -3676,9 +3676,9 @@ static struct SeqEffectHandle get_sequence_effect_impl(int seq_type) /** \name Public Sequencer Effect API * \{ */ -struct SeqEffectHandle SEQ_effect_handle_get(Sequence *seq) +SeqEffectHandle SEQ_effect_handle_get(Sequence *seq) { - struct SeqEffectHandle rval = {false, false, nullptr}; + SeqEffectHandle rval = {false, false, nullptr}; if (seq->type & SEQ_TYPE_EFFECT) { rval = get_sequence_effect_impl(seq->type); @@ -3691,9 +3691,9 @@ struct SeqEffectHandle SEQ_effect_handle_get(Sequence *seq) return rval; } -struct SeqEffectHandle seq_effect_get_sequence_blend(Sequence *seq) +SeqEffectHandle seq_effect_get_sequence_blend(Sequence *seq) { - struct SeqEffectHandle rval = {false, false, nullptr}; + SeqEffectHandle rval = {false, false, nullptr}; if (seq->blend_mode != 0) { if ((seq->flag & SEQ_EFFECT_NOT_LOADED) != 0) { @@ -3715,7 +3715,7 @@ struct SeqEffectHandle seq_effect_get_sequence_blend(Sequence *seq) int SEQ_effect_get_num_inputs(int seq_type) { - struct SeqEffectHandle rval = get_sequence_effect_impl(seq_type); + SeqEffectHandle rval = get_sequence_effect_impl(seq_type); int count = rval.num_inputs(); if (rval.execute || (rval.execute_slice && rval.init_execution)) { diff --git a/source/blender/sequencer/intern/image_cache.cc b/source/blender/sequencer/intern/image_cache.cc index 97bcca6ab48..8edd9b51a61 100644 --- a/source/blender/sequencer/intern/image_cache.cc +++ b/source/blender/sequencer/intern/image_cache.cc @@ -79,7 +79,7 @@ struct SeqCache { BLI_mempool *keys_pool; BLI_mempool *items_pool; SeqCacheKey *last_key; - struct SeqDiskCache *disk_cache; + SeqDiskCache *disk_cache; int thumbnail_count; }; @@ -104,9 +104,9 @@ static uint seq_hash_render_data(const SeqRenderData *a) uint rval = a->rectx + a->recty; rval ^= a->preview_render_size; - rval ^= ((intptr_t)a->bmain) << 6; - rval ^= ((intptr_t)a->scene) << 6; - rval ^= (int)(a->motion_blur_shutter * 100.0f) << 10; + rval ^= intptr_t(a->bmain) << 6; + rval ^= intptr_t(a->scene) << 6; + rval ^= int(a->motion_blur_shutter * 100.0f) << 10; rval ^= a->motion_blur_samples << 16; rval ^= ((a->scene->r.views_format * 2) + a->view_id) << 24; @@ -120,7 +120,7 @@ static uint seq_cache_hashhash(const void *key_) rval ^= *(const uint *)&key->frame_index; rval += key->type; - rval ^= ((intptr_t)key->seq) << 6; + rval ^= intptr_t(key->seq) << 6; return rval; } @@ -181,9 +181,9 @@ static void seq_cache_unlock(Scene *scene) } } -static size_t seq_cache_get_mem_total(void) +static size_t seq_cache_get_mem_total() { - return ((size_t)U.memcachelimit) * 1024 * 1024; + return (size_t(U.memcachelimit)) * 1024 * 1024; } static void seq_cache_keyfree(void *val) @@ -718,7 +718,7 @@ void seq_cache_thumbnail_cleanup(Scene *scene, rctf *view_area_safe) const int frame_index = key->timeline_frame - SEQ_time_left_handle_frame_get(scene, key->seq); const int frame_step = SEQ_render_thumbnails_guaranteed_set_frame_step_get(scene, key->seq); - const int relative_base_frame = round_fl_to_int(frame_index / (float)frame_step) * frame_step; + const int relative_base_frame = round_fl_to_int(frame_index / float(frame_step)) * frame_step; const int nearest_guaranted_absolute_frame = relative_base_frame + SEQ_time_left_handle_frame_get(scene, key->seq); @@ -933,7 +933,7 @@ void SEQ_cache_iterate( seq_cache_unlock(scene); } -bool seq_cache_is_full(void) +bool seq_cache_is_full() { return seq_cache_get_mem_total() < MEM_get_memory_in_use(); } diff --git a/source/blender/sequencer/intern/modifier.cc b/source/blender/sequencer/intern/modifier.cc index 62c340ed830..28498cff5e4 100644 --- a/source/blender/sequencer/intern/modifier.cc +++ b/source/blender/sequencer/intern/modifier.cc @@ -330,7 +330,7 @@ MINLINE float color_balance_fl_sop(float in, static void make_cb_table_float_lgg(float lift, float gain, float gamma, float *table, float mul) { for (int y = 0; y < 256; y++) { - float v = color_balance_fl_lgg((float)y * (1.0f / 255.0f), lift, gain, gamma, mul); + float v = color_balance_fl_lgg(float(y) * (1.0f / 255.0f), lift, gain, gamma, mul); table[y] = v; } @@ -340,7 +340,7 @@ static void make_cb_table_float_sop( float slope, float offset, float power, float pivot, float *table, float mul) { for (int y = 0; y < 256; y++) { - float v = color_balance_fl_sop((float)y * (1.0f / 255.0f), slope, offset, power, pivot, mul); + float v = color_balance_fl_sop(float(y) * (1.0f / 255.0f), slope, offset, power, pivot, mul); table[y] = v; } @@ -372,7 +372,7 @@ static void color_balance_byte_byte( } if (m) { - float m_normal = (float)m[c] / 255.0f; + float m_normal = float(m[c]) / 255.0f; p[c] = p[c] * (1.0f - m_normal) + t * m_normal; } @@ -420,7 +420,7 @@ static void color_balance_byte_float(StripColorBalance *cb_, } for (i = 0; i < 256; i++) { - cb_tab[3][i] = ((float)i) * (1.0f / 255.0f); + cb_tab[3][i] = float(i) * (1.0f / 255.0f); } while (p < e) { @@ -1026,14 +1026,14 @@ static void brightcontrast_apply_threaded(int width, uchar *pixel = rect + pixel_index; for (c = 0; c < 3; c++) { - i = (float)pixel[c] / 255.0f; + i = float(pixel[c]) / 255.0f; v = a * i + b; if (mask_rect) { uchar *m = mask_rect + pixel_index; - float t = (float)m[c] / 255.0f; + float t = float(m[c]) / 255.0f; - v = (float)pixel[c] / 255.0f * (1.0f - t) + v * t; + v = float(pixel[c]) / 255.0f * (1.0f - t) + v * t; } pixel[c] = unit_float_to_uchar_clamp(v); @@ -1118,7 +1118,7 @@ static void maskmodifier_apply_threaded(int width, * this is the only way to alpha-over byte strip after * applying mask modifier. */ - pixel[3] = (float)(pixel[3] * mask) / 255.0f; + pixel[3] = float(pixel[3] * mask) / 255.0f; } else if (rect_float) { int c; @@ -1378,7 +1378,7 @@ static SequenceModifierTypeInfo seqModifier_Tonemap = { /** \name Public Modifier Functions * \{ */ -static void sequence_modifier_type_info_init(void) +static void sequence_modifier_type_info_init() { #define INIT_TYPE(typeName) (modifiersTypes[seqModifierType_##typeName] = &seqModifier_##typeName) diff --git a/source/blender/sequencer/intern/multiview.cc b/source/blender/sequencer/intern/multiview.cc index 30fbca4eca9..4474149908a 100644 --- a/source/blender/sequencer/intern/multiview.cc +++ b/source/blender/sequencer/intern/multiview.cc @@ -18,7 +18,7 @@ #include "multiview.h" -void seq_anim_add_suffix(Scene *scene, struct anim *anim, const int view_id) +void seq_anim_add_suffix(Scene *scene, anim *anim, const int view_id) { const char *suffix = BKE_scene_multiview_view_id_suffix_get(&scene->r, view_id); IMB_suffix_anim(anim, suffix); diff --git a/source/blender/sequencer/intern/prefetch.cc b/source/blender/sequencer/intern/prefetch.cc index 893708bcd26..91fcfa49282 100644 --- a/source/blender/sequencer/intern/prefetch.cc +++ b/source/blender/sequencer/intern/prefetch.cc @@ -50,7 +50,7 @@ #include "render.h" struct PrefetchJob { - struct PrefetchJob *next, *prev; + PrefetchJob *next, *prev; Main *bmain; Main *bmain_eval; @@ -248,7 +248,7 @@ static void seq_prefetch_update_area(PrefetchJob *pfjob) } } -void SEQ_prefetch_stop_all(void) +void SEQ_prefetch_stop_all() { /* TODO(Richard): Use wm_jobs for prefetch, or pass main. */ for (Scene *scene = static_cast(G.main->scenes.first); scene; @@ -572,7 +572,7 @@ void seq_prefetch_start(const SeqRenderData *context, float timeline_frame) { Scene *scene = context->scene; Editing *ed = scene->ed; - bool has_strips = (bool)ed->seqbasep->first; + bool has_strips = bool(ed->seqbasep->first); if (!context->is_prefetch_render && !context->is_proxy_render) { bool playing = seq_prefetch_is_playing(context->bmain); diff --git a/source/blender/sequencer/intern/proxy.cc b/source/blender/sequencer/intern/proxy.cc index 530281b972e..5853656a6a8 100644 --- a/source/blender/sequencer/intern/proxy.cc +++ b/source/blender/sequencer/intern/proxy.cc @@ -54,7 +54,7 @@ #include "utils.h" struct SeqIndexBuildContext { - struct IndexBuildContext *index_context; + IndexBuildContext *index_context; int tc_flags; int size_flags; @@ -213,7 +213,7 @@ ImBuf *seq_proxy_fetch(const SeqRenderData *context, Sequence *seq, int timeline } if (proxy->storage & SEQ_STORAGE_PROXY_CUSTOM_FILE) { - int frameno = (int)SEQ_give_frame_index(context->scene, seq, timeline_frame) + + int frameno = int(SEQ_give_frame_index(context->scene, seq, timeline_frame)) + seq->anim_startofs; if (proxy->anim == nullptr) { if (seq_proxy_get_filepath( @@ -292,7 +292,7 @@ static void seq_proxy_build_frame(const SeqRenderData *context, ibuf = IMB_dupImBuf(ibuf_tmp); IMB_metadata_copy(ibuf, ibuf_tmp); IMB_freeImBuf(ibuf_tmp); - IMB_scalefastImBuf(ibuf, (short)rectx, (short)recty); + IMB_scalefastImBuf(ibuf, short(rectx), short(recty)); } else { ibuf = ibuf_tmp; @@ -411,7 +411,7 @@ static int seq_proxy_context_count(Sequence *seq, Scene *scene) return num_views; } -static bool seq_proxy_need_rebuild(Sequence *seq, struct anim *anim) +static bool seq_proxy_need_rebuild(Sequence *seq, anim *anim) { if ((seq->strip->proxy->build_flags & SEQ_PROXY_SKIP_EXISTING) == 0) { return true; @@ -565,7 +565,7 @@ void SEQ_proxy_rebuild(SeqIndexBuildContext *context, bool *stop, bool *do_updat seq_proxy_build_frame(&render_context, &state, seq, timeline_frame, 100, overwrite); } - *progress = (float)(timeline_frame - SEQ_time_left_handle_frame_get(scene, seq)) / + *progress = float(timeline_frame - SEQ_time_left_handle_frame_get(scene, seq)) / (SEQ_time_right_handle_frame_get(scene, seq) - SEQ_time_left_handle_frame_get(scene, seq)); *do_update = true; @@ -606,7 +606,7 @@ void SEQ_proxy_set(Sequence *seq, bool value) } } -void seq_proxy_index_dir_set(struct anim *anim, const char *base_dir) +void seq_proxy_index_dir_set(anim *anim, const char *base_dir) { char dirname[FILE_MAX]; char filename[FILE_MAXFILE]; diff --git a/source/blender/sequencer/intern/proxy_job.cc b/source/blender/sequencer/intern/proxy_job.cc index 6e64317f20d..053dd996e13 100644 --- a/source/blender/sequencer/intern/proxy_job.cc +++ b/source/blender/sequencer/intern/proxy_job.cc @@ -48,7 +48,7 @@ static void proxy_startjob(void *pjv, bool *stop, bool *do_update, float *progre LinkData *link; for (link = static_cast(pj->queue.first); link; link = link->next) { - struct SeqIndexBuildContext *context = static_cast(link->data); + SeqIndexBuildContext *context = static_cast(link->data); SEQ_proxy_rebuild(context, stop, do_update, progress); @@ -78,7 +78,7 @@ static void proxy_endjob(void *pjv) ProxyJob *ED_seq_proxy_job_get(const bContext *C, wmJob *wm_job) { Scene *scene = CTX_data_scene(C); - struct Depsgraph *depsgraph = CTX_data_depsgraph_pointer(C); + Depsgraph *depsgraph = CTX_data_depsgraph_pointer(C); ProxyJob *pj = static_cast(WM_jobs_customdata_get(wm_job)); if (!pj) { pj = static_cast(MEM_callocN(sizeof(ProxyJob), "proxy rebuild job")); diff --git a/source/blender/sequencer/intern/render.cc b/source/blender/sequencer/intern/render.cc index 4298ac21f22..2b657395578 100644 --- a/source/blender/sequencer/intern/render.cc +++ b/source/blender/sequencer/intern/render.cc @@ -254,7 +254,7 @@ StripElem *SEQ_render_give_stripelem(const Scene *scene, Sequence *seq, int time * all other strips don't use this... */ - int frame_index = (int)SEQ_give_frame_index(scene, seq, timeline_frame); + int frame_index = int(SEQ_give_frame_index(scene, seq, timeline_frame)); if (frame_index == -1 || se == nullptr) { return nullptr; @@ -447,7 +447,7 @@ static void sequencer_image_crop_init(const Sequence *seq, static void sequencer_thumbnail_transform(ImBuf *in, ImBuf *out) { - float image_scale_factor = (float)out->x / in->x; + float image_scale_factor = float(out->x) / in->x; float transform_matrix[4][4]; /* Set to keep same loc,scale,rot but change scale to thumb size limit. */ @@ -519,7 +519,7 @@ static void sequencer_preprocess_transform_crop( { const Scene *scene = context->scene; const float preview_scale_factor = context->preview_render_size == SEQ_RENDER_SIZE_SCENE ? - (float)scene->r.size / 100 : + float(scene->r.size) / 100 : SEQ_rendersize_to_scale_factor( context->preview_render_size); const bool do_scale_to_render_size = seq_need_scale_to_render_size(seq, is_proxy_image); @@ -580,7 +580,7 @@ static void multibuf(ImBuf *ibuf, const float fmul) rt_float = ibuf->float_buffer.data; if (rt) { - const int imul = (int)(256.0f * fmul); + const int imul = int(256.0f * fmul); a = ibuf->x * ibuf->y; while (a--) { rt[0] = min_ii((imul * rt[0]) >> 8, 255); @@ -715,7 +715,7 @@ static ImBuf *seq_render_preprocess_ibuf(const SeqRenderData *context, } struct RenderEffectInitData { - struct SeqEffectHandle *sh; + SeqEffectHandle *sh; const SeqRenderData *context; Sequence *seq; float timeline_frame, fac; @@ -725,7 +725,7 @@ struct RenderEffectInitData { }; struct RenderEffectThread { - struct SeqEffectHandle *sh; + SeqEffectHandle *sh; const SeqRenderData *context; Sequence *seq; float timeline_frame, fac; @@ -775,7 +775,7 @@ static void *render_effect_execute_do_thread(void *thread_data_v) return nullptr; } -ImBuf *seq_render_effect_execute_threaded(struct SeqEffectHandle *sh, +ImBuf *seq_render_effect_execute_threaded(SeqEffectHandle *sh, const SeqRenderData *context, Sequence *seq, float timeline_frame, @@ -815,7 +815,7 @@ static ImBuf *seq_render_effect_strip_impl(const SeqRenderData *context, float fac; int early_out; int i; - struct SeqEffectHandle sh = SEQ_effect_handle_get(seq); + SeqEffectHandle sh = SEQ_effect_handle_get(seq); FCurve *fcu = nullptr; ImBuf *ibuf[3]; Sequence *input[3]; @@ -1065,7 +1065,7 @@ static ImBuf *seq_render_movie_strip_custom_file_proxy(const SeqRenderData *cont } } - int frameno = (int)SEQ_give_frame_index(context->scene, seq, timeline_frame) + + int frameno = int(SEQ_give_frame_index(context->scene, seq, timeline_frame)) + seq->anim_startofs; return IMB_anim_absolute(proxy->anim, frameno, IMB_TC_NONE, IMB_PROXY_NONE); } @@ -1361,7 +1361,7 @@ ImBuf *seq_render_mask(const SeqRenderData *context, ub_dst = ibuf->byte_buffer.data; i = context->rectx * context->recty; while (--i) { - ub_dst[0] = ub_dst[1] = ub_dst[2] = (uchar)(*fp_src * 255.0f); /* already clamped */ + ub_dst[0] = ub_dst[1] = ub_dst[2] = uchar(*fp_src * 255.0f); /* already clamped */ ub_dst[3] = 255; fp_src += 1; @@ -1452,7 +1452,7 @@ static ImBuf *seq_render_scene_strip(const SeqRenderData *context, } scene = seq->scene; - frame = (double)scene->r.sfra + (double)frame_index + (double)seq->anim_startofs; + frame = double(scene->r.sfra) + double(frame_index) + double(seq->anim_startofs); #if 0 /* UNUSED */ have_seq = (scene->r.scemode & R_DOSEQ) && scene->ed && scene->ed->seqbase.first; @@ -1824,7 +1824,7 @@ static bool seq_must_swap_input_in_blend_mode(Sequence *seq) static int seq_get_early_out_for_blend_mode(Sequence *seq) { - struct SeqEffectHandle sh = seq_effect_get_sequence_blend(seq); + SeqEffectHandle sh = seq_effect_get_sequence_blend(seq); float fac = seq->blend_opacity / 100.0f; int early_out = sh.early_out(seq, fac); @@ -1847,7 +1847,7 @@ static ImBuf *seq_render_strip_stack_apply_effect( const SeqRenderData *context, Sequence *seq, float timeline_frame, ImBuf *ibuf1, ImBuf *ibuf2) { ImBuf *out; - struct SeqEffectHandle sh = seq_effect_get_sequence_blend(seq); + SeqEffectHandle sh = seq_effect_get_sequence_blend(seq); float fac = seq->blend_opacity / 100.0f; int swap_input = seq_must_swap_input_in_blend_mode(seq); @@ -2065,8 +2065,7 @@ float SEQ_render_thumbnail_first_frame_get(const Scene *scene, return SEQ_time_left_handle_frame_get(scene, seq); } - float aligned_frame_offset = (int)((first_drawable_frame - seq->start) / frame_step) * - frame_step; + float aligned_frame_offset = int((first_drawable_frame - seq->start) / frame_step) * frame_step; return seq->start + aligned_frame_offset; } @@ -2079,7 +2078,7 @@ float SEQ_render_thumbnail_next_frame_get(const Scene *scene, /* If handle position was displayed, align next frame with `seq->start`. */ if (last_frame == SEQ_time_left_handle_frame_get(scene, seq)) { - next_frame = seq->start + ((int)((last_frame - seq->start) / frame_step) + 1) * frame_step; + next_frame = seq->start + (int((last_frame - seq->start) / frame_step) + 1) * frame_step; } return next_frame; @@ -2098,7 +2097,7 @@ static ImBuf *seq_get_uncached_thumbnail(const SeqRenderData *context, return nullptr; } - float aspect_ratio = (float)ibuf->x / ibuf->y; + float aspect_ratio = float(ibuf->x) / ibuf->y; int rectx, recty; /* Calculate new dimensions - THUMB_SIZE (256) for x or y. */ if (ibuf->x > ibuf->y) { diff --git a/source/blender/sequencer/intern/sequence_lookup.cc b/source/blender/sequencer/intern/sequence_lookup.cc index 521571f25c7..b10087e9aed 100644 --- a/source/blender/sequencer/intern/sequence_lookup.cc +++ b/source/blender/sequencer/intern/sequence_lookup.cc @@ -91,7 +91,7 @@ static void seq_sequence_lookup_build(const Scene *scene, SequenceLookup *lookup lookup->tag &= ~SEQ_LOOKUP_TAG_INVALID; } -static SequenceLookup *seq_sequence_lookup_new(void) +static SequenceLookup *seq_sequence_lookup_new() { SequenceLookup *lookup = static_cast( MEM_callocN(sizeof(SequenceLookup), __func__)); diff --git a/source/blender/sequencer/intern/sequencer.cc b/source/blender/sequencer/intern/sequencer.cc index 96edd542fcd..c90c77435b2 100644 --- a/source/blender/sequencer/intern/sequencer.cc +++ b/source/blender/sequencer/intern/sequencer.cc @@ -54,7 +54,7 @@ /** \name Allocate / Free Functions * \{ */ -StripProxy *seq_strip_proxy_alloc(void) +StripProxy *seq_strip_proxy_alloc() { StripProxy *strip_proxy = static_cast( MEM_callocN(sizeof(StripProxy), "StripProxy")); @@ -172,7 +172,7 @@ static void seq_sequence_free_ex(Scene *scene, SEQ_relations_sequence_free_anim(seq); if (seq->type & SEQ_TYPE_EFFECT) { - struct SeqEffectHandle sh = SEQ_effect_handle_get(seq); + SeqEffectHandle sh = SEQ_effect_handle_get(seq); sh.free(seq, do_id_user); } @@ -325,7 +325,7 @@ static void seq_new_fix_links_recursive(Sequence *seq) } } -SequencerToolSettings *SEQ_tool_settings_init(void) +SequencerToolSettings *SEQ_tool_settings_init() { SequencerToolSettings *tool_settings = static_cast( MEM_callocN(sizeof(SequencerToolSettings), "Sequencer tool settings")); @@ -559,7 +559,7 @@ static Sequence *seq_dupli(const Scene *scene_src, seqn->strip->stripdata = static_cast(MEM_dupallocN(seq->strip->stripdata)); } else if (seq->type & SEQ_TYPE_EFFECT) { - struct SeqEffectHandle sh; + SeqEffectHandle sh; sh = SEQ_effect_handle_get(seq); if (sh.copy) { sh.copy(seqn, seq, flag); diff --git a/source/blender/sequencer/intern/sound.cc b/source/blender/sequencer/intern/sound.cc index 0c423c409c3..44702379f62 100644 --- a/source/blender/sequencer/intern/sound.cc +++ b/source/blender/sequencer/intern/sound.cc @@ -51,7 +51,7 @@ static bool sequencer_refresh_sound_length_recursive(Main *bmain, Scene *scene, float fac; seq->len = MAX2(1, round((info.length - seq->sound->offset_time) * FPS)); - fac = (float)seq->len / (float)old; + fac = float(seq->len) / float(old); old = seq->startofs; seq->startofs *= fac; seq->endofs *= fac; diff --git a/source/blender/sequencer/intern/strip_add.cc b/source/blender/sequencer/intern/strip_add.cc index 2719f5db943..f9ea7d8e8aa 100644 --- a/source/blender/sequencer/intern/strip_add.cc +++ b/source/blender/sequencer/intern/strip_add.cc @@ -165,7 +165,7 @@ Sequence *SEQ_add_effect_strip(Scene *scene, ListBase *seqbase, SeqLoadData *loa seqbase, load_data->start_frame, load_data->channel, load_data->effect.type); seq->flag |= SEQ_USE_EFFECT_DEFAULT_FADE; - struct SeqEffectHandle sh = SEQ_effect_handle_get(seq); + SeqEffectHandle sh = SEQ_effect_handle_get(seq); sh.init(seq); seq->seq1 = load_data->effect.seq1; seq->seq2 = load_data->effect.seq2; @@ -293,7 +293,7 @@ static void seq_add_sound_av_sync(Main *bmain, Scene *scene, Sequence *seq, SeqL const double av_stream_offset = sound_stream.start - load_data->r_video_stream_start; const int frame_offset = av_stream_offset * FPS; /* Set sub-frame offset. */ - seq->sound->offset_time = ((double)frame_offset / FPS) - av_stream_offset; + seq->sound->offset_time = (double(frame_offset) / FPS) - av_stream_offset; SEQ_transform_translate_sequence(scene, seq, frame_offset); } @@ -391,8 +391,7 @@ Sequence *SEQ_add_movie_strip(Main *bmain, Scene *scene, ListBase *seqbase, SeqL char colorspace[64] = "\0"; /* MAX_COLORSPACE_NAME */ bool is_multiview_loaded = false; const int totfiles = seq_num_files(scene, load_data->views_format, load_data->use_multiview); - struct anim **anim_arr = static_cast( - MEM_callocN(sizeof(struct anim *) * totfiles, "Video files")); + anim **anim_arr = static_cast(MEM_callocN(sizeof(anim *) * totfiles, "Video files")); int i; int orig_width = 0; int orig_height = 0; @@ -487,7 +486,7 @@ Sequence *SEQ_add_movie_strip(Main *bmain, Scene *scene, ListBase *seqbase, SeqL short frs_sec; float frs_sec_base; if (IMB_anim_get_fps(anim_arr[0], &frs_sec, &frs_sec_base, true)) { - seq->media_playback_rate = (float)frs_sec / frs_sec_base; + seq->media_playback_rate = float(frs_sec) / frs_sec_base; } } @@ -575,7 +574,7 @@ void SEQ_add_reload_new_file(Main *bmain, Scene *scene, Sequence *seq, const boo if (prefix[0] != '\0') { for (i = 0; i < totfiles; i++) { - struct anim *anim; + anim *anim; char filepath_view[FILE_MAX]; seq_multiview_name(scene, i, prefix, ext, filepath_view, sizeof(filepath_view)); @@ -596,7 +595,7 @@ void SEQ_add_reload_new_file(Main *bmain, Scene *scene, Sequence *seq, const boo } if (is_multiview_loaded == false) { - struct anim *anim; + anim *anim; anim = openanim(filepath, IB_rect | ((seq->flag & SEQ_FILTERY) ? IB_animdeinterlace : 0), seq->streamindex, @@ -658,7 +657,7 @@ void SEQ_add_reload_new_file(Main *bmain, Scene *scene, Sequence *seq, const boo if (!seq->sound) { return; } - seq->len = ceil((double)BKE_sound_get_length(bmain, seq->sound) * FPS); + seq->len = ceil(double(BKE_sound_get_length(bmain, seq->sound)) * FPS); seq->len -= seq->anim_startofs; seq->len -= seq->anim_endofs; if (seq->len < 0) { diff --git a/source/blender/sequencer/intern/strip_time.cc b/source/blender/sequencer/intern/strip_time.cc index 1a0667368e4..200e1f2bc6e 100644 --- a/source/blender/sequencer/intern/strip_time.cc +++ b/source/blender/sequencer/intern/strip_time.cc @@ -50,7 +50,7 @@ float seq_time_media_playback_rate_factor_get(const Scene *scene, const Sequence return 1.0f; } - float scene_playback_rate = (float)scene->r.frs_sec / scene->r.frs_sec_base; + float scene_playback_rate = float(scene->r.frs_sec) / scene->r.frs_sec_base; return seq->media_playback_rate / scene_playback_rate; } @@ -105,7 +105,7 @@ float SEQ_give_frame_index(const Scene *scene, Sequence *seq, float timeline_fra } if (seq->strobe > 1.0f) { - frame_index -= fmodf((double)frame_index, (double)seq->strobe); + frame_index -= fmodf(double(frame_index), double(seq->strobe)); } return frame_index; @@ -349,7 +349,7 @@ float SEQ_time_sequence_get_fps(Scene *scene, Sequence *seq) short frs_sec; float frs_sec_base; if (IMB_anim_get_fps(strip_anim->anim, &frs_sec, &frs_sec_base, true)) { - return (float)frs_sec / frs_sec_base; + return float(frs_sec) / frs_sec_base; } break; } @@ -360,7 +360,7 @@ float SEQ_time_sequence_get_fps(Scene *scene, Sequence *seq) break; case SEQ_TYPE_SCENE: if (seq->scene != nullptr) { - return (float)seq->scene->r.frs_sec / seq->scene->r.frs_sec_base; + return float(seq->scene->r.frs_sec) / seq->scene->r.frs_sec_base; } break; } @@ -421,8 +421,8 @@ void seq_time_gap_info_get(const Scene *scene, rctf rectf; /* Get first and last frame. */ SEQ_timeline_boundbox(scene, seqbase, &rectf); - const int sfra = (int)rectf.xmin; - const int efra = (int)rectf.xmax; + const int sfra = int(rectf.xmin); + const int efra = int(rectf.xmax); int timeline_frame = initial_frame; r_gap_info->gap_exists = false; diff --git a/source/blender/sequencer/intern/utils.cc b/source/blender/sequencer/intern/utils.cc index 32b619baec3..2215175183a 100644 --- a/source/blender/sequencer/intern/utils.cc +++ b/source/blender/sequencer/intern/utils.cc @@ -502,18 +502,18 @@ void SEQ_set_scale_to_fit(const Sequence *seq, switch (fit_method) { case SEQ_SCALE_TO_FIT: - transform->scale_x = transform->scale_y = MIN2((float)preview_width / (float)image_width, - (float)preview_height / (float)image_height); + transform->scale_x = transform->scale_y = MIN2(float(preview_width) / float(image_width), + float(preview_height) / float(image_height)); break; case SEQ_SCALE_TO_FILL: - transform->scale_x = transform->scale_y = MAX2((float)preview_width / (float)image_width, - (float)preview_height / (float)image_height); + transform->scale_x = transform->scale_y = MAX2(float(preview_width) / float(image_width), + float(preview_height) / float(image_height)); break; case SEQ_STRETCH_TO_FILL: - transform->scale_x = (float)preview_width / (float)image_width; - transform->scale_y = (float)preview_height / (float)image_height; + transform->scale_x = float(preview_width) / float(image_width); + transform->scale_y = float(preview_height) / float(image_height); break; case SEQ_USE_ORIGINAL_SIZE: transform->scale_x = 1.0f; diff --git a/source/blender/simulation/intern/implicit_blender.cc b/source/blender/simulation/intern/implicit_blender.cc index 3c61baa4102..1d7468bc96d 100644 --- a/source/blender/simulation/intern/implicit_blender.cc +++ b/source/blender/simulation/intern/implicit_blender.cc @@ -179,7 +179,7 @@ DO_INLINE float dot_lfvector(float (*fLongVectorA)[3], float (*fLongVectorB)[3], * different results each time you run it! * schedule(guided, 2) */ //#pragma omp parallel for reduction(+: temp) if (verts > CLOTH_OPENMP_LIMIT) - for (i = 0; i < (long)verts; i++) { + for (i = 0; i < long(verts); i++) { temp += dot_v3v3(fLongVectorA[i], fLongVectorB[i]); } return temp; @@ -1590,7 +1590,7 @@ static void edge_wind_vertex(const float dir[3], /* angle of wind direction to edge */ cos_alpha = dot_v3v3(wind, dir) / windlen; sin_alpha = sqrtf(1.0f - cos_alpha * cos_alpha); - cross_section = radius * ((float)M_PI * radius * sin_alpha + length * cos_alpha); + cross_section = radius * (float(M_PI) * radius * sin_alpha + length * cos_alpha); mul_v3_v3fl(f, wind, density * cross_section); } @@ -1851,7 +1851,7 @@ bool SIM_mass_spring_force_spring_bending( BLI_INLINE void poly_avg(lfVector *data, const int *inds, int len, float r_avg[3]) { - float fact = 1.0f / (float)len; + float fact = 1.0f / float(len); zero_v3(r_avg);