From b3ba41ecd1e1ed1cbb28b9fe90efb3c4f4e596c8 Mon Sep 17 00:00:00 2001 From: Julian Eisel Date: Tue, 4 May 2021 18:17:16 +0200 Subject: Fix missing background of buttons after reports Reports would change the active emboss of the Block, to make some of its buttons appear without background. But it didn't reset it so that buttons added afterwards wouldn't use the correct embossing. --- source/blender/editors/interface/interface_templates.c | 3 +++ 1 file changed, 3 insertions(+) (limited to 'source') diff --git a/source/blender/editors/interface/interface_templates.c b/source/blender/editors/interface/interface_templates.c index caeb52ab7e9..0484565ee2e 100644 --- a/source/blender/editors/interface/interface_templates.c +++ b/source/blender/editors/interface/interface_templates.c @@ -6830,6 +6830,7 @@ void uiTemplateReportsBanner(uiLayout *layout, bContext *C) uiLayout *ui_abs = uiLayoutAbsolute(layout, false); uiBlock *block = uiLayoutGetBlock(ui_abs); + eUIEmbossType previous_emboss = UI_block_emboss_get(block); UI_fontstyle_set(&style->widgetlabel); int width = BLF_width(style->widgetlabel.uifont_id, report->message, report->len); @@ -6904,6 +6905,8 @@ void uiTemplateReportsBanner(uiLayout *layout, bContext *C) width + UI_UNIT_X, UI_UNIT_Y, "Show in Info Log"); + + UI_block_emboss_set(block, previous_emboss); } void uiTemplateInputStatus(uiLayout *layout, struct bContext *C) -- cgit v1.2.3 From d28c46183d8890114784692d0ebee27d4cc2cff9 Mon Sep 17 00:00:00 2001 From: Julian Eisel Date: Tue, 4 May 2021 20:20:15 +0200 Subject: Fix missing header & footer toggle chevrons in Spreadsheet The little chevron tab to open a hidden region wouldn't show up in the Spreadsheet editor. Cause was an incorrect GPU-scissor usage: While drawing regions, the scissors should be kept enabled, just the scissor rectangle should be updated - and afterwards reset to what it was before. --- .../editors/space_spreadsheet/spreadsheet_draw.cc | 18 ++++++++++++------ 1 file changed, 12 insertions(+), 6 deletions(-) (limited to 'source') diff --git a/source/blender/editors/space_spreadsheet/spreadsheet_draw.cc b/source/blender/editors/space_spreadsheet/spreadsheet_draw.cc index d6379c740e8..b911c80fa63 100644 --- a/source/blender/editors/space_spreadsheet/spreadsheet_draw.cc +++ b/source/blender/editors/space_spreadsheet/spreadsheet_draw.cc @@ -142,7 +142,9 @@ static void draw_left_column_content(const int scroll_offset_y, ARegion *region, const SpreadsheetDrawer &drawer) { - GPU_scissor_test(true); + int old_scissor[4]; + GPU_scissor_get(old_scissor); + GPU_scissor(0, 0, drawer.left_column_width, region->winy - drawer.top_row_height); uiBlock *left_column_block = UI_block_begin(C, region, __func__, UI_EMBOSS_NONE); @@ -165,7 +167,7 @@ static void draw_left_column_content(const int scroll_offset_y, UI_block_end(C, left_column_block); UI_block_draw(C, left_column_block); - GPU_scissor_test(false); + GPU_scissor(UNPACK4(old_scissor)); } static void draw_top_row_content(const bContext *C, @@ -173,7 +175,9 @@ static void draw_top_row_content(const bContext *C, const SpreadsheetDrawer &drawer, const int scroll_offset_x) { - GPU_scissor_test(true); + int old_scissor[4]; + GPU_scissor_get(old_scissor); + GPU_scissor(drawer.left_column_width + 1, region->winy - drawer.top_row_height, region->winx - drawer.left_column_width, @@ -200,7 +204,7 @@ static void draw_top_row_content(const bContext *C, UI_block_end(C, first_row_block); UI_block_draw(C, first_row_block); - GPU_scissor_test(false); + GPU_scissor(UNPACK4(old_scissor)); } static void draw_cell_contents(const bContext *C, @@ -209,7 +213,9 @@ static void draw_cell_contents(const bContext *C, const int scroll_offset_x, const int scroll_offset_y) { - GPU_scissor_test(true); + int old_scissor[4]; + GPU_scissor_get(old_scissor); + GPU_scissor(drawer.left_column_width + 1, 0, region->winx - drawer.left_column_width, @@ -248,7 +254,7 @@ static void draw_cell_contents(const bContext *C, UI_block_end(C, cells_block); UI_block_draw(C, cells_block); - GPU_scissor_test(false); + GPU_scissor(UNPACK4(old_scissor)); } static void update_view2d_tot_rect(const SpreadsheetDrawer &drawer, -- cgit v1.2.3 From 96abe5ebbc55323fc28ee4f6a852c912298c72d1 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Cl=C3=A9ment=20Foucault?= Date: Tue, 4 May 2021 22:30:10 +0200 Subject: DRW: Fix issue with batch reusing freed VBO indices. Some discard of vertbuf were not correctly followed by discards of the GPUBatches that were using them. This lead to a use-after-free situation where GPUBatches would reuse old VBO information. This did not crash immediatly because the VBO indices were cached by our VAO caching system. It kept working on some implementation because VBO reference in the VAO (probably) preventing the VBO from being freed by reference counting. This fixes T85977 NVidia: Random crashes in 'DrvPresentBuffers' --- source/blender/draw/intern/draw_cache_impl_mesh.c | 17 ++++++++++++++++- 1 file changed, 16 insertions(+), 1 deletion(-) (limited to 'source') diff --git a/source/blender/draw/intern/draw_cache_impl_mesh.c b/source/blender/draw/intern/draw_cache_impl_mesh.c index f11fd0f3906..af54b57b162 100644 --- a/source/blender/draw/intern/draw_cache_impl_mesh.c +++ b/source/blender/draw/intern/draw_cache_impl_mesh.c @@ -557,12 +557,18 @@ static void mesh_batch_cache_discard_surface_batches(MeshBatchCache *cache) static void mesh_batch_cache_discard_shaded_tri(MeshBatchCache *cache) { FOREACH_MESH_BUFFER_CACHE (cache, mbufcache) { - GPU_VERTBUF_DISCARD_SAFE(mbufcache->vbo.pos_nor); GPU_VERTBUF_DISCARD_SAFE(mbufcache->vbo.uv); GPU_VERTBUF_DISCARD_SAFE(mbufcache->vbo.tan); GPU_VERTBUF_DISCARD_SAFE(mbufcache->vbo.vcol); GPU_VERTBUF_DISCARD_SAFE(mbufcache->vbo.orco); } + /* Discard batches using vbo.uv. */ + GPU_BATCH_DISCARD_SAFE(cache->batch.edituv_faces); + GPU_BATCH_DISCARD_SAFE(cache->batch.edituv_faces_stretch_area); + GPU_BATCH_DISCARD_SAFE(cache->batch.edituv_faces_stretch_angle); + GPU_BATCH_DISCARD_SAFE(cache->batch.edituv_edges); + GPU_BATCH_DISCARD_SAFE(cache->batch.edituv_verts); + mesh_batch_cache_discard_surface_batches(cache); mesh_cd_layers_type_clear(&cache->cd_used); } @@ -659,8 +665,17 @@ void DRW_mesh_batch_cache_dirty_tag(Mesh *me, eMeshBatchDirtyMode mode) GPU_VERTBUF_DISCARD_SAFE(mbufcache->vbo.lnor); } GPU_BATCH_DISCARD_SAFE(cache->batch.surface); + /* Discard batches using vbo.pos_nor. */ GPU_BATCH_DISCARD_SAFE(cache->batch.wire_loops); GPU_BATCH_DISCARD_SAFE(cache->batch.wire_edges); + GPU_BATCH_DISCARD_SAFE(cache->batch.all_verts); + GPU_BATCH_DISCARD_SAFE(cache->batch.all_edges); + GPU_BATCH_DISCARD_SAFE(cache->batch.loose_edges); + GPU_BATCH_DISCARD_SAFE(cache->batch.edge_detection); + GPU_BATCH_DISCARD_SAFE(cache->batch.surface_weights); + GPU_BATCH_DISCARD_SAFE(cache->batch.edit_mesh_analysis); + /* Discard batches using vbo.lnor. */ + GPU_BATCH_DISCARD_SAFE(cache->batch.edit_lnor); mesh_batch_cache_discard_surface_batches(cache); cache->batch_ready &= ~(MBC_SURFACE | MBC_WIRE_EDGES | MBC_WIRE_LOOPS); break; -- cgit v1.2.3 From 9576612d45dc062c85ec66250e2c9824ea4026a5 Mon Sep 17 00:00:00 2001 From: Richard Antalik Date: Wed, 5 May 2021 07:19:30 +0200 Subject: VSE: Set view transform based on strip colorspace In some cases, users start video editing work from General template, where Filmic view transform is chosen by default. Currently, this causes issue when working with sRGB footage, which are not properly decoded into linear working space and final render looks miscolored. When adding first strip, check it's colorspace and if it corresponds to colorspace for byte images, ensure that view transform is set to default value, which is Standard. Reviewed By: brecht Differential Revision: https://developer.blender.org/D11151 --- .../editors/space_sequencer/sequencer_add.c | 46 +++++++++++++++++----- source/blender/sequencer/SEQ_add.h | 1 + source/blender/sequencer/intern/strip_add.c | 21 ++++++++++ 3 files changed, 59 insertions(+), 9 deletions(-) (limited to 'source') diff --git a/source/blender/editors/space_sequencer/sequencer_add.c b/source/blender/editors/space_sequencer/sequencer_add.c index 0b0c43d3417..ebd615e5f33 100644 --- a/source/blender/editors/space_sequencer/sequencer_add.c +++ b/source/blender/editors/space_sequencer/sequencer_add.c @@ -95,6 +95,7 @@ typedef struct SequencerAddData { #define SEQPROP_NOPATHS (1 << 2) #define SEQPROP_NOCHAN (1 << 3) #define SEQPROP_FIT_METHOD (1 << 4) +#define SEQPROP_VIEW_TRANSFORM (1 << 4) static const EnumPropertyItem scale_fit_methods[] = { {SEQ_SCALE_TO_FIT, "FIT", 0, "Scale to Fit", "Scale image to fit within the canvas"}, @@ -152,6 +153,14 @@ static void sequencer_generic_props__internal(wmOperatorType *ot, int flag) "Fit Method", "Scale fit method"); } + + if (flag & SEQPROP_VIEW_TRANSFORM) { + ot->prop = RNA_def_boolean(ot->srna, + "set_view_transform", + true, + "Set view transform", + "Set appropriate view transform based on media colorspace"); + } } static void sequencer_generic_invoke_path__internal(bContext *C, @@ -284,6 +293,11 @@ static void load_data_init_from_operator(SeqLoadData *load_data, bContext *C, wm load_data->flags |= SEQ_LOAD_MOVIE_SYNC_FPS; } + if ((prop = RNA_struct_find_property(op->ptr, "set_view_transform")) && + RNA_property_boolean_get(op->ptr, prop)) { + load_data->flags |= SEQ_LOAD_SET_VIEW_TRANSFORM; + } + if ((prop = RNA_struct_find_property(op->ptr, "use_multiview")) && RNA_property_boolean_get(op->ptr, prop)) { if (op->customdata) { @@ -368,8 +382,23 @@ static int sequencer_add_scene_strip_exec(bContext *C, wmOperator *op) return OPERATOR_FINISHED; } +static void sequencer_disable_one_time_properties(bContext *C, wmOperator *op) +{ + Editing *ed = SEQ_editing_get(CTX_data_scene(C), false); + /* Disable following properties if there are any existing strips, unless overridden by user. */ + if (ed && ed->seqbasep && ed->seqbasep->first) { + if (RNA_struct_find_property(op->ptr, "use_framerate")) { + RNA_boolean_set(op->ptr, "use_framerate", false); + } + if (RNA_struct_find_property(op->ptr, "set_view_transform")) { + RNA_boolean_set(op->ptr, "set_view_transform", false); + } + } +} + static int sequencer_add_scene_strip_invoke(bContext *C, wmOperator *op, const wmEvent *event) { + sequencer_disable_one_time_properties(C, op); if (!RNA_struct_property_is_set(op->ptr, "scene")) { return WM_enum_search_invoke(C, op, event); } @@ -702,13 +731,9 @@ static int sequencer_add_movie_strip_invoke(bContext *C, { PropertyRNA *prop; Scene *scene = CTX_data_scene(C); - Editing *ed = SEQ_editing_get(scene, false); - /* Only enable "use_framerate" if there aren't any existing strips, unless overridden by user. - */ - if (ed && ed->seqbasep && ed->seqbasep->first) { - RNA_boolean_set(op->ptr, "use_framerate", false); - } + sequencer_disable_one_time_properties(C, op); + RNA_enum_set(op->ptr, "fit_method", SEQ_tool_settings_fit_method_get(scene)); /* This is for drag and drop. */ @@ -777,7 +802,8 @@ void SEQUENCER_OT_movie_strip_add(struct wmOperatorType *ot) WM_FILESEL_SHOW_PROPS | WM_FILESEL_DIRECTORY, FILE_DEFAULTDISPLAY, FILE_SORT_DEFAULT); - sequencer_generic_props__internal(ot, SEQPROP_STARTFRAME | SEQPROP_FIT_METHOD); + sequencer_generic_props__internal( + ot, SEQPROP_STARTFRAME | SEQPROP_FIT_METHOD | SEQPROP_VIEW_TRANSFORM); RNA_def_boolean(ot->srna, "sound", true, "Sound", "Load sound with the movie"); RNA_def_boolean(ot->srna, "use_framerate", @@ -1055,6 +1081,8 @@ static int sequencer_add_image_strip_invoke(bContext *C, PropertyRNA *prop; Scene *scene = CTX_data_scene(C); + sequencer_disable_one_time_properties(C, op); + const SequencerToolSettings *tool_settings = scene->toolsettings->sequencer_tool_settings; RNA_enum_set(op->ptr, "fit_method", tool_settings->fit_method); @@ -1102,8 +1130,8 @@ void SEQUENCER_OT_image_strip_add(struct wmOperatorType *ot) WM_FILESEL_SHOW_PROPS | WM_FILESEL_DIRECTORY, FILE_DEFAULTDISPLAY, FILE_SORT_DEFAULT); - sequencer_generic_props__internal(ot, - SEQPROP_STARTFRAME | SEQPROP_ENDFRAME | SEQPROP_FIT_METHOD); + sequencer_generic_props__internal( + ot, SEQPROP_STARTFRAME | SEQPROP_ENDFRAME | SEQPROP_FIT_METHOD | SEQPROP_VIEW_TRANSFORM); RNA_def_boolean(ot->srna, "use_placeholders", diff --git a/source/blender/sequencer/SEQ_add.h b/source/blender/sequencer/SEQ_add.h index 9cb52145c04..2941eb6f4c0 100644 --- a/source/blender/sequencer/SEQ_add.h +++ b/source/blender/sequencer/SEQ_add.h @@ -36,6 +36,7 @@ typedef enum eSeqLoadFlags { SEQ_LOAD_SOUND_CACHE = (1 << 1), SEQ_LOAD_SOUND_MONO = (1 << 2), SEQ_LOAD_MOVIE_SYNC_FPS = (1 << 3), + SEQ_LOAD_SET_VIEW_TRANSFORM = (1 << 4), } eSeqLoadFlags; /* Api for adding new sequence strips. */ diff --git a/source/blender/sequencer/intern/strip_add.c b/source/blender/sequencer/intern/strip_add.c index 55d92c1eb10..1106f47c477 100644 --- a/source/blender/sequencer/intern/strip_add.c +++ b/source/blender/sequencer/intern/strip_add.c @@ -50,6 +50,7 @@ #include "DEG_depsgraph_query.h" +#include "IMB_colormanagement.h" #include "IMB_imbuf.h" #include "IMB_imbuf_types.h" #include "IMB_metadata.h" @@ -128,6 +129,24 @@ static void seq_add_set_name(Sequence *seq, SeqLoadData *load_data) } } +static void seq_add_set_view_transform(Scene *scene, Sequence *seq, SeqLoadData *load_data) +{ + const char *strip_colorspace = seq->strip->colorspace_settings.name; + + if (load_data->flags & SEQ_LOAD_SET_VIEW_TRANSFORM) { + const char *role_colorspace_byte; + role_colorspace_byte = IMB_colormanagement_role_colorspace_name_get(COLOR_ROLE_DEFAULT_BYTE); + + if (STREQ(strip_colorspace, role_colorspace_byte)) { + struct ColorManagedDisplay *display = IMB_colormanagement_display_get_named( + scene->display_settings.display_device); + const char *default_view_transform = + IMB_colormanagement_display_get_default_view_transform_name(display); + STRNCPY(scene->view_settings.view_transform, default_view_transform); + } + } +} + /** * Add scene strip. * @@ -344,6 +363,7 @@ Sequence *SEQ_add_image_strip(Main *bmain, Scene *scene, ListBase *seqbase, SeqL /* Set Last active directory. */ BLI_strncpy(scene->ed->act_imagedir, seq->strip->dir, sizeof(scene->ed->act_imagedir)); + seq_add_set_view_transform(scene, seq, load_data); seq_add_set_name(seq, load_data); seq_add_generic_update(scene, seqbase, seq); @@ -559,6 +579,7 @@ Sequence *SEQ_add_movie_strip(Main *bmain, Scene *scene, ListBase *seqbase, SeqL strip->stripdata->orig_height = orig_height; BLI_split_dirfile(load_data->path, strip->dir, se->name, sizeof(strip->dir), sizeof(se->name)); + seq_add_set_view_transform(scene, seq, load_data); seq_add_set_name(seq, load_data); seq_add_generic_update(scene, seqbase, seq); -- cgit v1.2.3