From f34e03d34d79785bdb4710b668b4cf803704c9a4 Mon Sep 17 00:00:00 2001 From: Bastien Montagne Date: Mon, 20 Nov 2017 10:12:21 +0100 Subject: Fix (unreported) Crash: broken RNA accessors to tesselated MCol data. Regression from rB823bcf1689a3 (VPaint 2017 GSoC, this is not in 2.79 release). Also cleanup, using fake-array-ification to access struct members is generally not a great idea, but when we already have a totally confusing broken struct layout, this is pure evil, as demonstrated here! Found while investigating T53341. --- source/blender/makesrna/intern/rna_mesh.c | 83 ++++++++++++++++--------------- 1 file changed, 42 insertions(+), 41 deletions(-) (limited to 'source/blender') diff --git a/source/blender/makesrna/intern/rna_mesh.c b/source/blender/makesrna/intern/rna_mesh.c index 41758758178..18fd4c64242 100644 --- a/source/blender/makesrna/intern/rna_mesh.c +++ b/source/blender/makesrna/intern/rna_mesh.c @@ -577,99 +577,100 @@ static void rna_MeshColor_color1_get(PointerRNA *ptr, float *values) { MCol *mcol = (MCol *)ptr->data; - values[2] = (&mcol[0].r)[0] / 255.0f; - values[1] = (&mcol[0].r)[1] / 255.0f; - values[0] = (&mcol[0].r)[2] / 255.0f; + values[3] = mcol[0].a / 255.0f; + values[2] = mcol[0].r / 255.0f; + values[1] = mcol[0].g / 255.0f; + values[0] = mcol[0].b / 255.0f; } static void rna_MeshColor_color1_set(PointerRNA *ptr, const float *values) { MCol *mcol = (MCol *)ptr->data; - (&mcol[0].r)[2] = round_fl_to_uchar_clamp(values[0] * 255.0f); - (&mcol[0].r)[1] = round_fl_to_uchar_clamp(values[1] * 255.0f); - (&mcol[0].r)[0] = round_fl_to_uchar_clamp(values[2] * 255.0f); - (&mcol[0].r)[3] = round_fl_to_uchar_clamp(values[3] * 255.0f); + mcol[0].a = round_fl_to_uchar_clamp(values[3] * 255.0f); + mcol[0].r = round_fl_to_uchar_clamp(values[2] * 255.0f); + mcol[0].g = round_fl_to_uchar_clamp(values[1] * 255.0f); + mcol[0].b = round_fl_to_uchar_clamp(values[0] * 255.0f); } static void rna_MeshColor_color2_get(PointerRNA *ptr, float *values) { MCol *mcol = (MCol *)ptr->data; - values[3] = (&mcol[1].r)[3] / 255.0f; - values[2] = (&mcol[1].r)[0] / 255.0f; - values[1] = (&mcol[1].r)[1] / 255.0f; - values[0] = (&mcol[1].r)[2] / 255.0f; + values[3] = mcol[1].a / 255.0f; + values[2] = mcol[1].r / 255.0f; + values[1] = mcol[1].g / 255.0f; + values[0] = mcol[1].b / 255.0f; } static void rna_MeshColor_color2_set(PointerRNA *ptr, const float *values) { MCol *mcol = (MCol *)ptr->data; - (&mcol[1].r)[2] = round_fl_to_uchar_clamp(values[0] * 255.0f); - (&mcol[1].r)[1] = round_fl_to_uchar_clamp(values[1] * 255.0f); - (&mcol[1].r)[0] = round_fl_to_uchar_clamp(values[2] * 255.0f); - (&mcol[1].r)[3] = round_fl_to_uchar_clamp(values[3] * 255.0f); + mcol[1].a = round_fl_to_uchar_clamp(values[3] * 255.0f); + mcol[1].r = round_fl_to_uchar_clamp(values[2] * 255.0f); + mcol[1].g = round_fl_to_uchar_clamp(values[1] * 255.0f); + mcol[1].b = round_fl_to_uchar_clamp(values[0] * 255.0f); } static void rna_MeshColor_color3_get(PointerRNA *ptr, float *values) { MCol *mcol = (MCol *)ptr->data; - values[3] = (&mcol[2].r)[3] / 255.0f; - values[2] = (&mcol[2].r)[0] / 255.0f; - values[1] = (&mcol[2].r)[1] / 255.0f; - values[0] = (&mcol[2].r)[2] / 255.0f; + values[3] = mcol[2].a / 255.0f; + values[2] = mcol[2].r / 255.0f; + values[1] = mcol[2].g / 255.0f; + values[0] = mcol[2].b / 255.0f; } static void rna_MeshColor_color3_set(PointerRNA *ptr, const float *values) { MCol *mcol = (MCol *)ptr->data; - (&mcol[2].r)[2] = round_fl_to_uchar_clamp(values[0] * 255.0f); - (&mcol[2].r)[1] = round_fl_to_uchar_clamp(values[1] * 255.0f); - (&mcol[2].r)[0] = round_fl_to_uchar_clamp(values[2] * 255.0f); - (&mcol[2].r)[3] = round_fl_to_uchar_clamp(values[3] * 255.0f); + mcol[2].a = round_fl_to_uchar_clamp(values[3] * 255.0f); + mcol[2].r = round_fl_to_uchar_clamp(values[2] * 255.0f); + mcol[2].g = round_fl_to_uchar_clamp(values[1] * 255.0f); + mcol[2].b = round_fl_to_uchar_clamp(values[0] * 255.0f); } static void rna_MeshColor_color4_get(PointerRNA *ptr, float *values) { MCol *mcol = (MCol *)ptr->data; - values[2] = (&mcol[3].r)[0] / 255.0f; - values[1] = (&mcol[3].r)[1] / 255.0f; - values[0] = (&mcol[3].r)[2] / 255.0f; - values[3] = (&mcol[3].r)[3] / 255.0f; + values[3] = mcol[3].a / 255.0f; + values[2] = mcol[3].r / 255.0f; + values[1] = mcol[3].g / 255.0f; + values[0] = mcol[3].b / 255.0f; } static void rna_MeshColor_color4_set(PointerRNA *ptr, const float *values) { MCol *mcol = (MCol *)ptr->data; - (&mcol[3].r)[2] = round_fl_to_uchar_clamp(values[0] * 255.0f); - (&mcol[3].r)[1] = round_fl_to_uchar_clamp(values[1] * 255.0f); - (&mcol[3].r)[0] = round_fl_to_uchar_clamp(values[2] * 255.0f); - (&mcol[3].r)[3] = round_fl_to_uchar_clamp(values[3] * 255.0f); + mcol[3].a = round_fl_to_uchar_clamp(values[3] * 255.0f); + mcol[3].r = round_fl_to_uchar_clamp(values[2] * 255.0f); + mcol[3].g = round_fl_to_uchar_clamp(values[1] * 255.0f); + mcol[3].b = round_fl_to_uchar_clamp(values[0] * 255.0f); } static void rna_MeshLoopColor_color_get(PointerRNA *ptr, float *values) { - MLoopCol *mcol = (MLoopCol *)ptr->data; + MLoopCol *mlcol = (MLoopCol *)ptr->data; - values[0] = (&mcol->r)[0] / 255.0f; - values[1] = (&mcol->r)[1] / 255.0f; - values[2] = (&mcol->r)[2] / 255.0f; - values[3] = (&mcol->r)[3] / 255.0f; + values[0] = mlcol->r / 255.0f; + values[1] = mlcol->g / 255.0f; + values[2] = mlcol->b / 255.0f; + values[3] = mlcol->a / 255.0f; } static void rna_MeshLoopColor_color_set(PointerRNA *ptr, const float *values) { - MLoopCol *mcol = (MLoopCol *)ptr->data; + MLoopCol *mlcol = (MLoopCol *)ptr->data; - (&mcol->r)[0] = round_fl_to_uchar_clamp(values[0] * 255.0f); - (&mcol->r)[1] = round_fl_to_uchar_clamp(values[1] * 255.0f); - (&mcol->r)[2] = round_fl_to_uchar_clamp(values[2] * 255.0f); - (&mcol->r)[3] = round_fl_to_uchar_clamp(values[3] * 255.0f); + mlcol->r = round_fl_to_uchar_clamp(values[0] * 255.0f); + mlcol->g = round_fl_to_uchar_clamp(values[1] * 255.0f); + mlcol->b = round_fl_to_uchar_clamp(values[2] * 255.0f); + mlcol->a = round_fl_to_uchar_clamp(values[3] * 255.0f); } static int rna_Mesh_texspace_editable(PointerRNA *ptr, const char **UNUSED(r_info)) -- cgit v1.2.3 From 96415cb52a95be5cecec343496021e067b87d6ad Mon Sep 17 00:00:00 2001 From: Brecht Van Lommel Date: Mon, 20 Nov 2017 23:32:06 +0100 Subject: Code cleanup: fix harmless compiler warning. --- source/blender/blenlib/intern/threads.c | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) (limited to 'source/blender') diff --git a/source/blender/blenlib/intern/threads.c b/source/blender/blenlib/intern/threads.c index fbb64f3ece2..2f961701801 100644 --- a/source/blender/blenlib/intern/threads.c +++ b/source/blender/blenlib/intern/threads.c @@ -508,14 +508,16 @@ void BLI_spin_unlock(SpinLock *spin) #endif } -void BLI_spin_end(SpinLock *spin) +#if defined(__APPLE__) || defined(_MSC_VER) +void BLI_spin_end(SpinLock *UNUSED(spin)) { -#if defined(__APPLE__) -#elif defined(_MSC_VER) +} #else +void BLI_spin_end(SpinLock *spin) +{ pthread_spin_destroy(spin); -#endif } +#endif /* Read/Write Mutex Lock */ -- cgit v1.2.3 From a591bd203ead1af9483b66417aedd0bf70bb7ebf Mon Sep 17 00:00:00 2001 From: Campbell Barton Date: Tue, 21 Nov 2017 16:14:31 +1100 Subject: Cleanup: redundant ELEM use --- source/blender/blenkernel/intern/fcurve.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'source/blender') diff --git a/source/blender/blenkernel/intern/fcurve.c b/source/blender/blenkernel/intern/fcurve.c index 382b26abbc6..9c85a26b58a 100644 --- a/source/blender/blenkernel/intern/fcurve.c +++ b/source/blender/blenkernel/intern/fcurve.c @@ -1775,7 +1775,7 @@ void driver_variable_name_validate(DriverVar *dvar) /* 1) Must start with a letter */ /* XXX: We assume that valid unicode letters in other languages are ok too, hence the blacklisting */ - if (ELEM(dvar->name[0], '0', '1', '2', '3', '4', '5', '6', '7', '8', '9')) { + if (IN_RANGE_INCL(dvar->name[0], '0', '9')) { dvar->flag |= DVAR_FLAG_INVALID_START_NUM; } else if (dvar->name[0] == '_') { -- cgit v1.2.3 From 175e8fdc1e2e76bd1287f1aa93db4aa4cc44d3f9 Mon Sep 17 00:00:00 2001 From: Campbell Barton Date: Tue, 21 Nov 2017 16:33:36 +1100 Subject: Disable adding scene sequence strips into themselves D2923 by @spockTheGray w/ edits, see T52586 for details --- .../editors/space_sequencer/sequencer_add.c | 2 +- source/blender/makesrna/RNA_enum_types.h | 1 + source/blender/windowmanager/intern/wm_operators.c | 47 ++++++++++++++++------ 3 files changed, 36 insertions(+), 14 deletions(-) (limited to 'source/blender') diff --git a/source/blender/editors/space_sequencer/sequencer_add.c b/source/blender/editors/space_sequencer/sequencer_add.c index 46f212e3679..258cbdfaffd 100644 --- a/source/blender/editors/space_sequencer/sequencer_add.c +++ b/source/blender/editors/space_sequencer/sequencer_add.c @@ -361,7 +361,7 @@ void SEQUENCER_OT_scene_strip_add(struct wmOperatorType *ot) sequencer_generic_props__internal(ot, SEQPROP_STARTFRAME); prop = RNA_def_enum(ot->srna, "scene", DummyRNA_NULL_items, 0, "Scene", ""); - RNA_def_enum_funcs(prop, RNA_scene_itemf); + RNA_def_enum_funcs(prop, RNA_scene_without_active_itemf); RNA_def_property_flag(prop, PROP_ENUM_NO_TRANSLATE); ot->prop = prop; } diff --git a/source/blender/makesrna/RNA_enum_types.h b/source/blender/makesrna/RNA_enum_types.h index b4b8dd7806e..0f4e20a02ab 100644 --- a/source/blender/makesrna/RNA_enum_types.h +++ b/source/blender/makesrna/RNA_enum_types.h @@ -237,6 +237,7 @@ const EnumPropertyItem *RNA_group_local_itemf(struct bContext *C, struct Pointer const EnumPropertyItem *RNA_image_itemf(struct bContext *C, struct PointerRNA *ptr, struct PropertyRNA *prop, bool *r_free); const EnumPropertyItem *RNA_image_local_itemf(struct bContext *C, struct PointerRNA *ptr, struct PropertyRNA *prop, bool *r_free); const EnumPropertyItem *RNA_scene_itemf(struct bContext *C, struct PointerRNA *ptr, struct PropertyRNA *prop, bool *r_free); +const EnumPropertyItem *RNA_scene_without_active_itemf(struct bContext *C, struct PointerRNA *ptr, struct PropertyRNA *prop, bool *r_free); const EnumPropertyItem *RNA_scene_local_itemf(struct bContext *C, struct PointerRNA *ptr, struct PropertyRNA *prop, bool *r_free); const EnumPropertyItem *RNA_movieclip_itemf(struct bContext *C, struct PointerRNA *ptr, struct PropertyRNA *prop, bool *r_free); const EnumPropertyItem *RNA_movieclip_local_itemf(struct bContext *C, struct PointerRNA *ptr, struct PropertyRNA *prop, bool *r_free); diff --git a/source/blender/windowmanager/intern/wm_operators.c b/source/blender/windowmanager/intern/wm_operators.c index fbd6d89e7bc..4674df9983b 100644 --- a/source/blender/windowmanager/intern/wm_operators.c +++ b/source/blender/windowmanager/intern/wm_operators.c @@ -3852,14 +3852,29 @@ void wm_window_keymap(wmKeyConfig *keyconf) gesture_straightline_modal_keymap(keyconf); } +/** + * Filter functions that can be used with rna_id_itemf() below. + * Should return false if 'id' should be excluded. + */ +static bool rna_id_enum_filter_single(ID *id, void *user_data) +{ + return (id != user_data); +} + /* Generic itemf's for operators that take library args */ -static const EnumPropertyItem *rna_id_itemf(bContext *UNUSED(C), PointerRNA *UNUSED(ptr), bool *r_free, ID *id, bool local) +static const EnumPropertyItem *rna_id_itemf( + bContext *UNUSED(C), PointerRNA *UNUSED(ptr), + bool *r_free, ID *id, bool local, + bool (*filter_ids)(ID *id, void *user_data), void *user_data) { EnumPropertyItem item_tmp = {0}, *item = NULL; int totitem = 0; int i = 0; for (; id; id = id->next) { + if ((filter_ids != NULL) && filter_ids(user_data, id) == false) { + continue; + } if (local == false || !ID_IS_LINKED(id)) { item_tmp.identifier = item_tmp.name = id->name + 2; item_tmp.value = i++; @@ -3876,7 +3891,7 @@ static const EnumPropertyItem *rna_id_itemf(bContext *UNUSED(C), PointerRNA *UNU /* can add more as needed */ const EnumPropertyItem *RNA_action_itemf(bContext *C, PointerRNA *ptr, PropertyRNA *UNUSED(prop), bool *r_free) { - return rna_id_itemf(C, ptr, r_free, C ? (ID *)CTX_data_main(C)->action.first : NULL, false); + return rna_id_itemf(C, ptr, r_free, C ? (ID *)CTX_data_main(C)->action.first : NULL, false, NULL, NULL); } #if 0 /* UNUSED */ const EnumPropertyItem *RNA_action_local_itemf(bContext *C, PointerRNA *ptr, PropertyRNA *UNUSED(prop), bool *r_free) @@ -3887,45 +3902,51 @@ const EnumPropertyItem *RNA_action_local_itemf(bContext *C, PointerRNA *ptr, Pro const EnumPropertyItem *RNA_group_itemf(bContext *C, PointerRNA *ptr, PropertyRNA *UNUSED(prop), bool *r_free) { - return rna_id_itemf(C, ptr, r_free, C ? (ID *)CTX_data_main(C)->group.first : NULL, false); + return rna_id_itemf(C, ptr, r_free, C ? (ID *)CTX_data_main(C)->group.first : NULL, false, NULL, NULL); } const EnumPropertyItem *RNA_group_local_itemf(bContext *C, PointerRNA *ptr, PropertyRNA *UNUSED(prop), bool *r_free) { - return rna_id_itemf(C, ptr, r_free, C ? (ID *)CTX_data_main(C)->group.first : NULL, true); + return rna_id_itemf(C, ptr, r_free, C ? (ID *)CTX_data_main(C)->group.first : NULL, true, NULL, NULL); } const EnumPropertyItem *RNA_image_itemf(bContext *C, PointerRNA *ptr, PropertyRNA *UNUSED(prop), bool *r_free) { - return rna_id_itemf(C, ptr, r_free, C ? (ID *)CTX_data_main(C)->image.first : NULL, false); + return rna_id_itemf(C, ptr, r_free, C ? (ID *)CTX_data_main(C)->image.first : NULL, false, NULL, NULL); } const EnumPropertyItem *RNA_image_local_itemf(bContext *C, PointerRNA *ptr, PropertyRNA *UNUSED(prop), bool *r_free) { - return rna_id_itemf(C, ptr, r_free, C ? (ID *)CTX_data_main(C)->image.first : NULL, true); + return rna_id_itemf(C, ptr, r_free, C ? (ID *)CTX_data_main(C)->image.first : NULL, true, NULL, NULL); } const EnumPropertyItem *RNA_scene_itemf(bContext *C, PointerRNA *ptr, PropertyRNA *UNUSED(prop), bool *r_free) { - return rna_id_itemf(C, ptr, r_free, C ? (ID *)CTX_data_main(C)->scene.first : NULL, false); + return rna_id_itemf(C, ptr, r_free, C ? (ID *)CTX_data_main(C)->scene.first : NULL, false, NULL, NULL); } const EnumPropertyItem *RNA_scene_local_itemf(bContext *C, PointerRNA *ptr, PropertyRNA *UNUSED(prop), bool *r_free) { - return rna_id_itemf(C, ptr, r_free, C ? (ID *)CTX_data_main(C)->scene.first : NULL, true); + return rna_id_itemf(C, ptr, r_free, C ? (ID *)CTX_data_main(C)->scene.first : NULL, true, NULL, NULL); +} +const EnumPropertyItem *RNA_scene_without_active_itemf(bContext *C, PointerRNA *ptr, PropertyRNA *UNUSED(prop), bool *r_free) +{ + Scene *scene_active = C ? CTX_data_scene(C) : NULL; + return rna_id_itemf( + C, ptr, r_free, C ? (ID *)CTX_data_main(C)->scene.first : NULL, true, + rna_id_enum_filter_single, scene_active); } - const EnumPropertyItem *RNA_movieclip_itemf(bContext *C, PointerRNA *ptr, PropertyRNA *UNUSED(prop), bool *r_free) { - return rna_id_itemf(C, ptr, r_free, C ? (ID *)CTX_data_main(C)->movieclip.first : NULL, false); + return rna_id_itemf(C, ptr, r_free, C ? (ID *)CTX_data_main(C)->movieclip.first : NULL, false, NULL, NULL); } const EnumPropertyItem *RNA_movieclip_local_itemf(bContext *C, PointerRNA *ptr, PropertyRNA *UNUSED(prop), bool *r_free) { - return rna_id_itemf(C, ptr, r_free, C ? (ID *)CTX_data_main(C)->movieclip.first : NULL, true); + return rna_id_itemf(C, ptr, r_free, C ? (ID *)CTX_data_main(C)->movieclip.first : NULL, true, NULL, NULL); } const EnumPropertyItem *RNA_mask_itemf(bContext *C, PointerRNA *ptr, PropertyRNA *UNUSED(prop), bool *r_free) { - return rna_id_itemf(C, ptr, r_free, C ? (ID *)CTX_data_main(C)->mask.first : NULL, false); + return rna_id_itemf(C, ptr, r_free, C ? (ID *)CTX_data_main(C)->mask.first : NULL, false, NULL, NULL); } const EnumPropertyItem *RNA_mask_local_itemf(bContext *C, PointerRNA *ptr, PropertyRNA *UNUSED(prop), bool *r_free) { - return rna_id_itemf(C, ptr, r_free, C ? (ID *)CTX_data_main(C)->mask.first : NULL, true); + return rna_id_itemf(C, ptr, r_free, C ? (ID *)CTX_data_main(C)->mask.first : NULL, true, NULL, NULL); } -- cgit v1.2.3 From 6785a2bd66f7f1c55098e4c71baa68ce3cc2bbf9 Mon Sep 17 00:00:00 2001 From: Sergey Sharybin Date: Tue, 21 Nov 2017 17:31:45 +0100 Subject: Fix T53371: Keying Node fails with values above 1 This was expected behavior for over-exposured lamps when the mode was originally created for Tears of Steel. Turns out, there could be really bad green screen in real production which will only have green (or rather screen) channel over exposured. Tweaked condition now so we use least bright channel to see if the area has proper exposure or not. Seems to work fine in tests, but further tweaks are possible. --- source/blender/compositor/operations/COM_KeyingOperation.cpp | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) (limited to 'source/blender') diff --git a/source/blender/compositor/operations/COM_KeyingOperation.cpp b/source/blender/compositor/operations/COM_KeyingOperation.cpp index e2566d2f4f0..873a537efe3 100644 --- a/source/blender/compositor/operations/COM_KeyingOperation.cpp +++ b/source/blender/compositor/operations/COM_KeyingOperation.cpp @@ -74,8 +74,9 @@ void KeyingOperation::executePixelSampled(float output[4], float x, float y, Pix this->m_screenReader->readSampled(screenColor, x, y, sampler); const int primary_channel = max_axis_v3(screenColor); + const float min_pixel_color = min_fff(pixelColor[0], pixelColor[1], pixelColor[2]); - if (pixelColor[primary_channel] > 1.0f) { + if (min_pixel_color > 1.0f) { /* overexposure doesn't happen on screen itself and usually happens * on light sources in the shot, this need to be checked separately * because saturation and falloff calculation is based on the fact -- cgit v1.2.3 From 6c372530b43931d1159e5ae82beaf36859ce08ca Mon Sep 17 00:00:00 2001 From: Sergey Sharybin Date: Tue, 21 Nov 2017 17:34:44 +0100 Subject: Cleanup: We do not use camel case in Blender code At least not for variables. --- .../compositor/operations/COM_KeyingOperation.cpp | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) (limited to 'source/blender') diff --git a/source/blender/compositor/operations/COM_KeyingOperation.cpp b/source/blender/compositor/operations/COM_KeyingOperation.cpp index 873a537efe3..fa0ef70fca6 100644 --- a/source/blender/compositor/operations/COM_KeyingOperation.cpp +++ b/source/blender/compositor/operations/COM_KeyingOperation.cpp @@ -67,14 +67,14 @@ void KeyingOperation::deinitExecution() void KeyingOperation::executePixelSampled(float output[4], float x, float y, PixelSampler sampler) { - float pixelColor[4]; - float screenColor[4]; + float pixel_color[4]; + float screen_color[4]; - this->m_pixelReader->readSampled(pixelColor, x, y, sampler); - this->m_screenReader->readSampled(screenColor, x, y, sampler); + this->m_pixelReader->readSampled(pixel_color, x, y, sampler); + this->m_screenReader->readSampled(screen_color, x, y, sampler); - const int primary_channel = max_axis_v3(screenColor); - const float min_pixel_color = min_fff(pixelColor[0], pixelColor[1], pixelColor[2]); + const int primary_channel = max_axis_v3(screen_color); + const float min_pixel_color = min_fff(pixel_color[0], pixel_color[1], pixel_color[2]); if (min_pixel_color > 1.0f) { /* overexposure doesn't happen on screen itself and usually happens @@ -85,8 +85,8 @@ void KeyingOperation::executePixelSampled(float output[4], float x, float y, Pix output[0] = 1.0f; } else { - float saturation = get_pixel_saturation(pixelColor, this->m_screenBalance, primary_channel); - float screen_saturation = get_pixel_saturation(screenColor, this->m_screenBalance, primary_channel); + float saturation = get_pixel_saturation(pixel_color, this->m_screenBalance, primary_channel); + float screen_saturation = get_pixel_saturation(screen_color, this->m_screenBalance, primary_channel); if (saturation < 0) { /* means main channel of pixel is different from screen, -- cgit v1.2.3 From 7770c2ef8712ce0f3761fef305978c3275384834 Mon Sep 17 00:00:00 2001 From: Bastien Montagne Date: Tue, 21 Nov 2017 17:52:25 +0100 Subject: Removing OMP: get rid of last bit in /editors/ area. Just removing it, such cases are not bottlenecks and not worth the complication of doing real threading with own BLI_task. --- source/blender/editors/mesh/editmesh_utils.c | 1 - 1 file changed, 1 deletion(-) (limited to 'source/blender') diff --git a/source/blender/editors/mesh/editmesh_utils.c b/source/blender/editors/mesh/editmesh_utils.c index fc568a8b8ee..8baf5d05fe9 100644 --- a/source/blender/editors/mesh/editmesh_utils.c +++ b/source/blender/editors/mesh/editmesh_utils.c @@ -1240,7 +1240,6 @@ void EDBM_mesh_reveal(BMEditMesh *em, bool select) /* Use tag flag to remember what was hidden before all is revealed. * BM_ELEM_HIDDEN --> BM_ELEM_TAG */ -#pragma omp parallel for schedule(static) if (em->bm->totvert + em->bm->totedge + em->bm->totface >= BM_OMP_LIMIT) for (i = 0; i < 3; i++) { BMIter iter; BMElem *ele; -- cgit v1.2.3 From 5f4058ddbcc2e5250e3f9e2d5e16960f3b611b4c Mon Sep 17 00:00:00 2001 From: Bastien Montagne Date: Tue, 21 Nov 2017 17:55:07 +0100 Subject: Removing OMP: get rid of usages in /bmesh/ area. Just removing it, such cases are not bottlenecks and not worth the complication of doing real threading with own BLI_task. Other (remaining) usages may be relevant, need case-by-case check. --- source/blender/bmesh/intern/bmesh_marking.c | 108 ++++++++------------ source/blender/bmesh/intern/bmesh_operators.c | 141 +++++++++++--------------- 2 files changed, 102 insertions(+), 147 deletions(-) (limited to 'source/blender') diff --git a/source/blender/bmesh/intern/bmesh_marking.c b/source/blender/bmesh/intern/bmesh_marking.c index 7f2032d5f53..432c82afe4a 100644 --- a/source/blender/bmesh/intern/bmesh_marking.c +++ b/source/blender/bmesh/intern/bmesh_marking.c @@ -57,7 +57,6 @@ static void recount_totsels(BMesh *bm) tots[1] = &bm->totedgesel; tots[2] = &bm->totfacesel; -#pragma omp parallel for schedule(static) if (bm->totvert + bm->totedge + bm->totface >= BM_OMP_LIMIT) for (i = 0; i < 3; i++) { BMIter iter; BMElem *ele; @@ -253,44 +252,34 @@ void BM_mesh_select_mode_flush_ex(BMesh *bm, const short selectmode) if (selectmode & SCE_SELECT_VERTEX) { /* both loops only set edge/face flags and read off verts */ -#pragma omp parallel sections if (bm->totedge + bm->totface >= BM_OMP_LIMIT) - { -#pragma omp section + BM_ITER_MESH (e, &eiter, bm, BM_EDGES_OF_MESH) { + if (BM_elem_flag_test(e->v1, BM_ELEM_SELECT) && + BM_elem_flag_test(e->v2, BM_ELEM_SELECT) && + !BM_elem_flag_test(e, BM_ELEM_HIDDEN)) { - BM_ITER_MESH (e, &eiter, bm, BM_EDGES_OF_MESH) { - if (BM_elem_flag_test(e->v1, BM_ELEM_SELECT) && - BM_elem_flag_test(e->v2, BM_ELEM_SELECT) && - !BM_elem_flag_test(e, BM_ELEM_HIDDEN)) - { - BM_elem_flag_enable(e, BM_ELEM_SELECT); - } - else { - BM_elem_flag_disable(e, BM_ELEM_SELECT); - } - } + BM_elem_flag_enable(e, BM_ELEM_SELECT); } -#pragma omp section - { - BM_ITER_MESH (f, &fiter, bm, BM_FACES_OF_MESH) { - bool ok = true; - if (!BM_elem_flag_test(f, BM_ELEM_HIDDEN)) { - l_iter = l_first = BM_FACE_FIRST_LOOP(f); - do { - if (!BM_elem_flag_test(l_iter->v, BM_ELEM_SELECT)) { - ok = false; - break; - } - } while ((l_iter = l_iter->next) != l_first); - } - else { + else { + BM_elem_flag_disable(e, BM_ELEM_SELECT); + } + } + BM_ITER_MESH (f, &fiter, bm, BM_FACES_OF_MESH) { + bool ok = true; + if (!BM_elem_flag_test(f, BM_ELEM_HIDDEN)) { + l_iter = l_first = BM_FACE_FIRST_LOOP(f); + do { + if (!BM_elem_flag_test(l_iter->v, BM_ELEM_SELECT)) { ok = false; + break; } - - BM_elem_flag_set(f, BM_ELEM_SELECT, ok); - } + } while ((l_iter = l_iter->next) != l_first); } + else { + ok = false; + } + + BM_elem_flag_set(f, BM_ELEM_SELECT, ok); } - /* end sections */ } else if (selectmode & SCE_SELECT_EDGE) { BM_ITER_MESH (f, &fiter, bm, BM_FACES_OF_MESH) { @@ -375,42 +364,31 @@ void BM_mesh_select_flush(BMesh *bm) bool ok; - /* we can use 2 sections here because the second loop isnt checking edge selection */ -#pragma omp parallel sections if (bm->totedge + bm->totface >= BM_OMP_LIMIT) - { -#pragma omp section + BM_ITER_MESH (e, &eiter, bm, BM_EDGES_OF_MESH) { + if (BM_elem_flag_test(e->v1, BM_ELEM_SELECT) && + BM_elem_flag_test(e->v2, BM_ELEM_SELECT) && + !BM_elem_flag_test(e, BM_ELEM_HIDDEN)) { - BM_ITER_MESH (e, &eiter, bm, BM_EDGES_OF_MESH) { - if (BM_elem_flag_test(e->v1, BM_ELEM_SELECT) && - BM_elem_flag_test(e->v2, BM_ELEM_SELECT) && - !BM_elem_flag_test(e, BM_ELEM_HIDDEN)) - { - BM_elem_flag_enable(e, BM_ELEM_SELECT); - } - } + BM_elem_flag_enable(e, BM_ELEM_SELECT); } - -#pragma omp section - { - BM_ITER_MESH (f, &fiter, bm, BM_FACES_OF_MESH) { - ok = true; - if (!BM_elem_flag_test(f, BM_ELEM_HIDDEN)) { - l_iter = l_first = BM_FACE_FIRST_LOOP(f); - do { - if (!BM_elem_flag_test(l_iter->v, BM_ELEM_SELECT)) { - ok = false; - break; - } - } while ((l_iter = l_iter->next) != l_first); - } - else { + } + BM_ITER_MESH (f, &fiter, bm, BM_FACES_OF_MESH) { + ok = true; + if (!BM_elem_flag_test(f, BM_ELEM_HIDDEN)) { + l_iter = l_first = BM_FACE_FIRST_LOOP(f); + do { + if (!BM_elem_flag_test(l_iter->v, BM_ELEM_SELECT)) { ok = false; + break; } + } while ((l_iter = l_iter->next) != l_first); + } + else { + ok = false; + } - if (ok) { - BM_elem_flag_enable(f, BM_ELEM_SELECT); - } - } + if (ok) { + BM_elem_flag_enable(f, BM_ELEM_SELECT); } } @@ -1107,8 +1085,6 @@ void BM_mesh_elem_hflag_disable_test( { /* fast path for deselect all, avoid topology loops * since we know all will be de-selected anyway. */ - -#pragma omp parallel for schedule(static) if (bm->totvert + bm->totedge + bm->totface >= BM_OMP_LIMIT) for (i = 0; i < 3; i++) { BMIter iter; BMElem *ele; diff --git a/source/blender/bmesh/intern/bmesh_operators.c b/source/blender/bmesh/intern/bmesh_operators.c index 44445aae25a..3e12a43e457 100644 --- a/source/blender/bmesh/intern/bmesh_operators.c +++ b/source/blender/bmesh/intern/bmesh_operators.c @@ -550,37 +550,30 @@ static int bmo_mesh_flag_count( { int count_vert = 0, count_edge = 0, count_face = 0; -#pragma omp parallel sections if ((bm->totvert + bm->totedge + bm->totface >= BM_OMP_LIMIT) && \ - (ELEM(htype, BM_VERT, BM_EDGE, BM_FACE) == 0)) - { -#pragma omp section - if (htype & BM_VERT) { - BMIter iter; - BMVert *ele; - BM_ITER_MESH (ele, &iter, bm, BM_VERTS_OF_MESH) { - if (BMO_vert_flag_test_bool(bm, ele, oflag) == test_for_enabled) { - count_vert++; - } + if (htype & BM_VERT) { + BMIter iter; + BMVert *ele; + BM_ITER_MESH (ele, &iter, bm, BM_VERTS_OF_MESH) { + if (BMO_vert_flag_test_bool(bm, ele, oflag) == test_for_enabled) { + count_vert++; } } -#pragma omp section - if (htype & BM_EDGE) { - BMIter iter; - BMEdge *ele; - BM_ITER_MESH (ele, &iter, bm, BM_EDGES_OF_MESH) { - if (BMO_edge_flag_test_bool(bm, ele, oflag) == test_for_enabled) { - count_edge++; - } + } + if (htype & BM_EDGE) { + BMIter iter; + BMEdge *ele; + BM_ITER_MESH (ele, &iter, bm, BM_EDGES_OF_MESH) { + if (BMO_edge_flag_test_bool(bm, ele, oflag) == test_for_enabled) { + count_edge++; } } -#pragma omp section - if (htype & BM_FACE) { - BMIter iter; - BMFace *ele; - BM_ITER_MESH (ele, &iter, bm, BM_FACES_OF_MESH) { - if (BMO_face_flag_test_bool(bm, ele, oflag) == test_for_enabled) { - count_face++; - } + } + if (htype & BM_FACE) { + BMIter iter; + BMFace *ele; + BM_ITER_MESH (ele, &iter, bm, BM_FACES_OF_MESH) { + if (BMO_face_flag_test_bool(bm, ele, oflag) == test_for_enabled) { + count_face++; } } } @@ -601,33 +594,25 @@ int BMO_mesh_disabled_flag_count(BMesh *bm, const char htype, const short oflag) void BMO_mesh_flag_disable_all(BMesh *bm, BMOperator *UNUSED(op), const char htype, const short oflag) { - -#pragma omp parallel sections if ((bm->totvert + bm->totedge + bm->totface >= BM_OMP_LIMIT) && \ - (ELEM(htype, BM_VERT, BM_EDGE, BM_FACE) == 0)) - { -#pragma omp section - if (htype & BM_VERT) { - BMIter iter; - BMVert *ele; - BM_ITER_MESH (ele, &iter, bm, BM_VERTS_OF_MESH) { - BMO_vert_flag_disable(bm, ele, oflag); - } + if (htype & BM_VERT) { + BMIter iter; + BMVert *ele; + BM_ITER_MESH (ele, &iter, bm, BM_VERTS_OF_MESH) { + BMO_vert_flag_disable(bm, ele, oflag); } -#pragma omp section - if (htype & BM_EDGE) { - BMIter iter; - BMEdge *ele; - BM_ITER_MESH (ele, &iter, bm, BM_EDGES_OF_MESH) { - BMO_edge_flag_disable(bm, ele, oflag); - } + } + if (htype & BM_EDGE) { + BMIter iter; + BMEdge *ele; + BM_ITER_MESH (ele, &iter, bm, BM_EDGES_OF_MESH) { + BMO_edge_flag_disable(bm, ele, oflag); } -#pragma omp section - if (htype & BM_FACE) { - BMIter iter; - BMFace *ele; - BM_ITER_MESH (ele, &iter, bm, BM_FACES_OF_MESH) { - BMO_face_flag_disable(bm, ele, oflag); - } + } + if (htype & BM_FACE) { + BMIter iter; + BMFace *ele; + BM_ITER_MESH (ele, &iter, bm, BM_FACES_OF_MESH) { + BMO_face_flag_disable(bm, ele, oflag); } } } @@ -1383,38 +1368,32 @@ static void bmo_flag_layer_clear(BMesh *bm) const int totflags_offset = bm->totflags - 1; -#pragma omp parallel sections if (bm->totvert + bm->totedge + bm->totface >= BM_OMP_LIMIT) + /* now go through and memcpy all the flag */ { - /* now go through and memcpy all the flag */ -#pragma omp section - { - BMIter iter; - BMVert_OFlag *ele; - int i; - BM_ITER_MESH_INDEX (ele, &iter, bm, BM_VERTS_OF_MESH, i) { - ele->oflags[totflags_offset] = zero_flag; - BM_elem_index_set(&ele->base, i); /* set_inline */ - } + BMIter iter; + BMVert_OFlag *ele; + int i; + BM_ITER_MESH_INDEX (ele, &iter, bm, BM_VERTS_OF_MESH, i) { + ele->oflags[totflags_offset] = zero_flag; + BM_elem_index_set(&ele->base, i); /* set_inline */ } -#pragma omp section - { - BMIter iter; - BMEdge_OFlag *ele; - int i; - BM_ITER_MESH_INDEX (ele, &iter, bm, BM_EDGES_OF_MESH, i) { - ele->oflags[totflags_offset] = zero_flag; - BM_elem_index_set(&ele->base, i); /* set_inline */ - } + } + { + BMIter iter; + BMEdge_OFlag *ele; + int i; + BM_ITER_MESH_INDEX (ele, &iter, bm, BM_EDGES_OF_MESH, i) { + ele->oflags[totflags_offset] = zero_flag; + BM_elem_index_set(&ele->base, i); /* set_inline */ } -#pragma omp section - { - BMIter iter; - BMFace_OFlag *ele; - int i; - BM_ITER_MESH_INDEX (ele, &iter, bm, BM_FACES_OF_MESH, i) { - ele->oflags[totflags_offset] = zero_flag; - BM_elem_index_set(&ele->base, i); /* set_inline */ - } + } + { + BMIter iter; + BMFace_OFlag *ele; + int i; + BM_ITER_MESH_INDEX (ele, &iter, bm, BM_FACES_OF_MESH, i) { + ele->oflags[totflags_offset] = zero_flag; + BM_elem_index_set(&ele->base, i); /* set_inline */ } } -- cgit v1.2.3 From 69b5165902d3e433af5b3ece633903162cbc292a Mon Sep 17 00:00:00 2001 From: Campbell Barton Date: Wed, 22 Nov 2017 17:11:03 +1100 Subject: WM: minor correction to user-pref writing When saving templates had wrong return value. --- source/blender/blenkernel/BKE_blendfile.h | 3 +-- source/blender/blenkernel/intern/blendfile.c | 13 +++++++----- source/blender/windowmanager/intern/wm_files.c | 29 ++++++++++++++------------ 3 files changed, 25 insertions(+), 20 deletions(-) (limited to 'source/blender') diff --git a/source/blender/blenkernel/BKE_blendfile.h b/source/blender/blenkernel/BKE_blendfile.h index ac58451e412..1cf8a78fef3 100644 --- a/source/blender/blenkernel/BKE_blendfile.h +++ b/source/blender/blenkernel/BKE_blendfile.h @@ -58,8 +58,7 @@ struct UserDef *BKE_blendfile_userdef_read_from_memory( const void *filebuf, int filelength, struct ReportList *reports); -int BKE_blendfile_userdef_write(const char *filepath, struct ReportList *reports); - +bool BKE_blendfile_userdef_write(const char *filepath, struct ReportList *reports); /* partial blend file writing */ void BKE_blendfile_write_partial_tag_ID(struct ID *id, bool set); diff --git a/source/blender/blenkernel/intern/blendfile.c b/source/blender/blenkernel/intern/blendfile.c index 980df05aca2..99e3769572a 100644 --- a/source/blender/blenkernel/intern/blendfile.c +++ b/source/blender/blenkernel/intern/blendfile.c @@ -497,19 +497,22 @@ UserDef *BKE_blendfile_userdef_read_from_memory( } -/* only write the userdef in a .blend */ -int BKE_blendfile_userdef_write(const char *filepath, ReportList *reports) +/** + * Only write the userdef in a .blend + * \return success + */ +bool BKE_blendfile_userdef_write(const char *filepath, ReportList *reports) { Main *mainb = MEM_callocN(sizeof(Main), "empty main"); - int retval = 0; + bool ok = false; if (BLO_write_file(mainb, filepath, G_FILE_USERPREFS, reports, NULL)) { - retval = 1; + ok = true; } MEM_freeN(mainb); - return retval; + return ok; } /** \} */ diff --git a/source/blender/windowmanager/intern/wm_files.c b/source/blender/windowmanager/intern/wm_files.c index e991e901bb1..97aa64a8dee 100644 --- a/source/blender/windowmanager/intern/wm_files.c +++ b/source/blender/windowmanager/intern/wm_files.c @@ -1472,7 +1472,7 @@ static int wm_userpref_write_exec(bContext *C, wmOperator *op) wmWindowManager *wm = CTX_wm_manager(C); char filepath[FILE_MAX]; const char *cfgdir; - bool ok = false; + bool ok = true; /* update keymaps in user preferences */ WM_keyconfig_update(wm); @@ -1482,31 +1482,34 @@ static int wm_userpref_write_exec(bContext *C, wmOperator *op) printf("trying to save userpref at %s ", filepath); if (BKE_blendfile_userdef_write(filepath, op->reports) != 0) { printf("ok\n"); - ok = true; } else { printf("fail\n"); + ok = false; } } else { BKE_report(op->reports, RPT_ERROR, "Unable to create userpref path"); } - if (U.app_template[0] && (cfgdir = BKE_appdir_folder_id_create(BLENDER_USER_CONFIG, U.app_template))) { - /* Also save app-template prefs */ - BLI_path_join(filepath, sizeof(filepath), cfgdir, BLENDER_USERPREF_FILE, NULL); - printf("trying to save app-template userpref at %s ", filepath); - if (BKE_blendfile_userdef_write(filepath, op->reports) == 0) { - printf("fail\n"); - ok = true; + if (U.app_template[0]) { + if ((cfgdir = BKE_appdir_folder_id_create(BLENDER_USER_CONFIG, U.app_template))) { + /* Also save app-template prefs */ + BLI_path_join(filepath, sizeof(filepath), cfgdir, BLENDER_USERPREF_FILE, NULL); + printf("trying to save app-template userpref at %s ", filepath); + if (BKE_blendfile_userdef_write(filepath, op->reports) != 0) { + printf("ok\n"); + } + else { + printf("fail\n"); + ok = false; + } } else { - printf("ok\n"); + BKE_report(op->reports, RPT_ERROR, "Unable to create app-template userpref path"); + ok = false; } } - else if (U.app_template[0]) { - BKE_report(op->reports, RPT_ERROR, "Unable to create app-template userpref path"); - } return ok ? OPERATOR_FINISHED : OPERATOR_CANCELLED; } -- cgit v1.2.3