Commit: 3d6fd2906be0adac2f42528f55a53e0cac1d5896 Author: Hans Goudey Date: Sat Jan 21 15:30:16 2023 -0600 Branches: master https://developer.blender.org/rB3d6fd2906be0adac2f42528f55a53e0cac1d5896
Cleanup: Move versioning_290.c to C++ Ref T103343 =================================================================== M source/blender/blenloader/CMakeLists.txt R090 source/blender/blenloader/intern/versioning_290.c source/blender/blenloader/intern/versioning_290.cc M source/blender/blenloader/intern/versioning_common.cc =================================================================== diff --git a/source/blender/blenloader/CMakeLists.txt b/source/blender/blenloader/CMakeLists.txt index a7e99e7df2e..c660360bde7 100644 --- a/source/blender/blenloader/CMakeLists.txt +++ b/source/blender/blenloader/CMakeLists.txt @@ -43,7 +43,7 @@ set(SRC intern/versioning_260.c intern/versioning_270.c intern/versioning_280.c - intern/versioning_290.c + intern/versioning_290.cc intern/versioning_300.cc intern/versioning_400.cc intern/versioning_common.cc diff --git a/source/blender/blenloader/intern/versioning_290.c b/source/blender/blenloader/intern/versioning_290.cc similarity index 90% rename from source/blender/blenloader/intern/versioning_290.c rename to source/blender/blenloader/intern/versioning_290.cc index 10f72f22b8e..9c968e905cf 100644 --- a/source/blender/blenloader/intern/versioning_290.c +++ b/source/blender/blenloader/intern/versioning_290.cc @@ -6,7 +6,6 @@ /* allow readfile to use deprecated functionality */ #define DNA_DEPRECATED_ALLOW -#include "BLI_alloca.h" #include "BLI_listbase.h" #include "BLI_math.h" #include "BLI_string.h" @@ -73,16 +72,16 @@ static eSpaceSeq_Proxy_RenderSize get_sequencer_render_size(Main *bmain) { - eSpaceSeq_Proxy_RenderSize render_size = 100; + eSpaceSeq_Proxy_RenderSize render_size = eSpaceSeq_Proxy_RenderSize(100); - for (bScreen *screen = bmain->screens.first; screen; screen = screen->id.next) { + LISTBASE_FOREACH (bScreen *, screen, &bmain->screens) { LISTBASE_FOREACH (ScrArea *, area, &screen->areabase) { LISTBASE_FOREACH (SpaceLink *, sl, &area->spacedata) { switch (sl->spacetype) { case SPACE_SEQ: { SpaceSeq *sseq = (SpaceSeq *)sl; if (sseq->mainb == SEQ_DRAW_IMG_IMBUF) { - render_size = sseq->render_size; + render_size = eSpaceSeq_Proxy_RenderSize(sseq->render_size); break; } } @@ -96,7 +95,7 @@ static eSpaceSeq_Proxy_RenderSize get_sequencer_render_size(Main *bmain) static bool can_use_proxy(const Sequence *seq, int psize) { - if (seq->strip->proxy == NULL) { + if (seq->strip->proxy == nullptr) { return false; } short size_flags = seq->strip->proxy->build_size_flags; @@ -110,7 +109,7 @@ static void seq_convert_transform_animation(const Sequence *seq, const int image_size, const int scene_size) { - if (scene->adt == NULL || scene->adt->action == NULL) { + if (scene->adt == nullptr || scene->adt->action == nullptr) { return; } @@ -121,7 +120,7 @@ static void seq_convert_transform_animation(const Sequence *seq, /* Convert offset animation, but only if crop is not used. */ if ((seq->flag & use_transform_flag) != 0 && (seq->flag & use_crop_flag) == 0) { FCurve *fcu = BKE_fcurve_find(&scene->adt->action->curves, path, 0); - if (fcu != NULL && !BKE_fcurve_is_empty(fcu)) { + if (fcu != nullptr && !BKE_fcurve_is_empty(fcu)) { BezTriple *bezt = fcu->bezt; for (int i = 0; i < fcu->totvert; i++, bezt++) { /* Same math as with old_image_center_*, but simplified. */ @@ -142,11 +141,11 @@ static void seq_convert_transform_crop(const Scene *scene, Sequence *seq, const eSpaceSeq_Proxy_RenderSize render_size) { - if (seq->strip->transform == NULL) { - seq->strip->transform = MEM_callocN(sizeof(struct StripTransform), "StripTransform"); + if (seq->strip->transform == nullptr) { + seq->strip->transform = MEM_cnew<StripTransform>(__func__); } - if (seq->strip->crop == NULL) { - seq->strip->crop = MEM_callocN(sizeof(struct StripCrop), "StripCrop"); + if (seq->strip->crop == nullptr) { + seq->strip->crop = MEM_cnew<StripCrop>(__func__); } StripCrop *c = seq->strip->crop; @@ -161,7 +160,7 @@ static void seq_convert_transform_crop(const Scene *scene, const uint32_t use_crop_flag = (1 << 17); const StripElem *s_elem = seq->strip->stripdata; - if (s_elem != NULL) { + if (s_elem != nullptr) { image_size_x = s_elem->orig_width; image_size_y = s_elem->orig_height; @@ -186,8 +185,8 @@ static void seq_convert_transform_crop(const Scene *scene, t->xofs = t->yofs = 0; /* Reverse scale to fit for strips not using offset. */ - float project_aspect = (float)scene->r.xsch / (float)scene->r.ysch; - float image_aspect = (float)image_size_x / (float)image_size_y; + float project_aspect = float(scene->r.xsch) / float(scene->r.ysch); + float image_aspect = float(image_size_x) / float(image_size_y); if (project_aspect > image_aspect) { t->scale_x = project_aspect / image_aspect; } @@ -207,8 +206,8 @@ static void seq_convert_transform_crop(const Scene *scene, int cropped_image_size_x = image_size_x - c->right - c->left; int cropped_image_size_y = image_size_y - c->top - c->bottom; c->bottom = c->top = c->left = c->right = 0; - t->scale_x *= (float)image_size_x / (float)cropped_image_size_x; - t->scale_y *= (float)image_size_y / (float)cropped_image_size_y; + t->scale_x *= float(image_size_x) / float(cropped_image_size_x); + t->scale_y *= float(image_size_y) / float(cropped_image_size_y); } if ((seq->flag & use_transform_flag) != 0) { @@ -217,8 +216,8 @@ static void seq_convert_transform_crop(const Scene *scene, old_image_center_y = image_size_y / 2 - c->bottom + t->yofs; /* Preserve original image size. */ - t->scale_x = t->scale_y = MAX2((float)image_size_x / (float)scene->r.xsch, - (float)image_size_y / (float)scene->r.ysch); + t->scale_x = t->scale_y = MAX2(float(image_size_x) / float(scene->r.xsch), + float(image_size_y) / float(scene->r.ysch)); /* Convert crop. */ if ((seq->flag & use_crop_flag) != 0) { @@ -265,12 +264,12 @@ static void seq_convert_transform_animation_2(const Scene *scene, const char *path, const float scale_to_fit_factor) { - if (scene->adt == NULL || scene->adt->action == NULL) { + if (scene->adt == nullptr || scene->adt->action == nullptr) { return; } FCurve *fcu = BKE_fcurve_find(&scene->adt->action->curves, path, 0); - if (fcu != NULL && !BKE_fcurve_is_empty(fcu)) { + if (fcu != nullptr && !BKE_fcurve_is_empty(fcu)) { BezTriple *bezt = fcu->bezt; for (int i = 0; i < fcu->totvert; i++, bezt++) { /* Same math as with old_image_center_*, but simplified. */ @@ -286,7 +285,7 @@ static void seq_convert_transform_crop_2(const Scene *scene, const eSpaceSeq_Proxy_RenderSize render_size) { const StripElem *s_elem = seq->strip->stripdata; - if (s_elem == NULL) { + if (s_elem == nullptr) { return; } @@ -301,8 +300,8 @@ static void seq_convert_transform_crop_2(const Scene *scene, } /* Calculate scale factor, so image fits in preview area with original aspect ratio. */ - const float scale_to_fit_factor = MIN2((float)scene->r.xsch / (float)image_size_x, - (float)scene->r.ysch / (float)image_size_y); + const float scale_to_fit_factor = MIN2(float(scene->r.xsch) / float(image_size_x), + float(scene->r.ysch) / float(image_size_y)); t->scale_x *= scale_to_fit_factor; t->scale_y *= scale_to_fit_factor; c->top /= scale_to_fit_factor; @@ -351,7 +350,7 @@ static void seq_update_meta_disp_range(Scene *scene) { Editing *ed = SEQ_editing_get(scene); - if (ed == NULL) { + if (ed == nullptr) { return; } @@ -411,7 +410,7 @@ static void version_node_socket_duplicate(bNodeTree *ntree, } } -void do_versions_after_linking_290(Main *bmain, ReportList *UNUSED(reports)) +void do_versions_after_linking_290(Main *bmain, ReportList * /*reports*/) { if (!MAIN_VERSION_ATLEAST(bmain, 290, 1)) { /* Patch old grease pencil modifiers material filter. */ @@ -421,8 +420,8 @@ void do_versions_after_linking_290(Main *bmain, ReportList *UNUSED(reports)) case eGpencilModifierType_Array: { ArrayGpencilModifierData *gpmd = (ArrayGpencilModifierData *)md; if (gpmd->materialname[0] != '\0') { - gpmd->material = BLI_findstring( - &bmain->materials, gpmd->materialname, offsetof(ID, name) + 2); + gpmd->material = static_cast<Material *>( + BLI_findstring(&bmain->materials, gpmd->materialname, offsetof(ID, name) + 2)); gpmd->materialname[0] = '\0'; } break; @@ -430,8 +429,8 @@ void do_versions_after_linking_290(Main *bmain, ReportList *UNUSED(reports)) case eGpencilModifierType_Color: { ColorGpencilModifierData *gpmd = (ColorGpencilModifierData *)md; if (gpmd->materialname[0] != '\0') { - gpmd->material = BLI_findstring( - &bmain->materials, gpmd->materialname, offsetof(ID, name) + 2); + gpmd->material = static_cast<Material *>( + BLI_findstring(&bmain->materials, gpmd->materialname, offsetof(ID, name) + 2)); gpmd->materialname[0] = '\0'; } break; @@ -439,8 +438,8 @@ void do_versions_after_linking_290(Main *bmain, ReportList *UNUSED(reports)) case eGpencilModifierType_Hook: { HookGpencilModifierData *gpmd = (HookGpencilModifierData *)md; if (gpmd->materialname[0] != '\0') { - gpmd->material = BLI_findstring( - &bmain->materials, gpmd->materialname, offsetof(ID, name) + 2); + gpmd->material = static_cast<Material *>( + BLI_findstring(&bmain->materials, gpmd->materialname, offsetof(ID, name) + 2)); gpmd->materialname[0] = '\0'; } break; @@ -448,8 +447,8 @@ void do_versions_after_linking_290(Main *bmain, ReportList *UNUSED(reports)) case eGpencilModifierType_Lattice: { LatticeGpencilModifierData *gpmd = (LatticeGpe @@ Diff output truncated at 10240 characters. @@ _______________________________________________ Bf-blender-cvs mailing list Bf-blender-cvs@blender.org List details, subscription details or unsubscribe: https://lists.blender.org/mailman/listinfo/bf-blender-cvs