From 9769fb0f585a34460f02c388f1515ee151ee909e Mon Sep 17 00:00:00 2001 From: JonasDichelle Date: Mon, 8 Jan 2024 02:21:02 +0100 Subject: [PATCH 1/9] Added color to the vector scope. Changed BG color. Added update hook to opacity --- .../blender/blenkernel/intern/colortools.cc | 11 +++ source/blender/draw/intern/draw_manager_c.cc | 2 + .../editors/interface/interface_draw.cc | 88 ++++++++++++++----- source/blender/makesdna/DNA_color_types.h | 1 + 4 files changed, 81 insertions(+), 21 deletions(-) diff --git a/source/blender/blenkernel/intern/colortools.cc b/source/blender/blenkernel/intern/colortools.cc index e78ab873cdc..4a495b9b279 100644 --- a/source/blender/blenkernel/intern/colortools.cc +++ b/source/blender/blenkernel/intern/colortools.cc @@ -1359,6 +1359,12 @@ static void save_sample_line( scopes->vecscope[idx + 0] = yuv[1]; scopes->vecscope[idx + 1] = yuv[2]; + int color_idx = (idx / 2) * 4; + scopes->vecscope_rgb[color_idx + 0] = rgb[0]; + scopes->vecscope_rgb[color_idx + 1] = rgb[1]; + scopes->vecscope_rgb[color_idx + 2] = rgb[2]; + scopes->vecscope_rgb[color_idx + 3] = scopes->vecscope_alpha; + /* Waveform. */ switch (scopes->wavefrm_mode) { case SCOPES_WAVEFRM_RGB: @@ -1707,6 +1713,7 @@ void BKE_scopes_update(Scopes *scopes, } if (scopes->vecscope) { MEM_freeN(scopes->vecscope); + MEM_freeN(scopes->vecscope_rgb); } scopes->waveform_1 = static_cast( @@ -1717,6 +1724,8 @@ void BKE_scopes_update(Scopes *scopes, MEM_callocN(scopes->waveform_tot * 2 * sizeof(float), "waveform point channel 3")); scopes->vecscope = static_cast( MEM_callocN(scopes->waveform_tot * 2 * sizeof(float), "vectorscope point channel")); + scopes->vecscope_rgb = static_cast( + MEM_callocN(scopes->waveform_tot * 4 * sizeof(float), "vectorscope color channel")); if (ibuf->float_buffer.data) { cm_processor = IMB_colormanagement_display_processor_new(view_settings, display_settings); @@ -1794,6 +1803,7 @@ void BKE_scopes_free(Scopes *scopes) MEM_SAFE_FREE(scopes->waveform_2); MEM_SAFE_FREE(scopes->waveform_3); MEM_SAFE_FREE(scopes->vecscope); + MEM_SAFE_FREE(scopes->vecscope_rgb); } void BKE_scopes_new(Scopes *scopes) @@ -1810,6 +1820,7 @@ void BKE_scopes_new(Scopes *scopes) scopes->waveform_2 = nullptr; scopes->waveform_3 = nullptr; scopes->vecscope = nullptr; + scopes->vecscope_rgb = nullptr; } void BKE_color_managed_display_settings_init(ColorManagedDisplaySettings *settings) diff --git a/source/blender/draw/intern/draw_manager_c.cc b/source/blender/draw/intern/draw_manager_c.cc index ce686da3399..301dd188adf 100644 --- a/source/blender/draw/intern/draw_manager_c.cc +++ b/source/blender/draw/intern/draw_manager_c.cc @@ -1761,6 +1761,8 @@ void DRW_draw_render_loop_ex(Depsgraph *depsgraph, drw_engines_draw_scene(); + // Clean up + /* Fix 3D view "lagging" on APPLE and WIN32+NVIDIA. (See #56996, #61474) */ if (GPU_type_matches_ex(GPU_DEVICE_ANY, GPU_OS_ANY, GPU_DRIVER_ANY, GPU_BACKEND_OPENGL)) { GPU_flush(); diff --git a/source/blender/editors/interface/interface_draw.cc b/source/blender/editors/interface/interface_draw.cc index aaffd708976..02557d6a5d8 100644 --- a/source/blender/editors/interface/interface_draw.cc +++ b/source/blender/editors/interface/interface_draw.cc @@ -610,6 +610,30 @@ static void waveform_draw_one(float *waveform, int waveform_num, const float col GPU_batch_discard(batch); } + +static void waveform_draw_rgb(float *waveform, int waveform_num, float *col) +{ + GPUVertFormat format = {0}; + const uint pos_id = GPU_vertformat_attr_add(&format, "pos", GPU_COMP_F32, 2, GPU_FETCH_FLOAT); + const uint col_id = GPU_vertformat_attr_add(&format, "color", GPU_COMP_F32, 4, GPU_FETCH_FLOAT); + + GPUVertBuf *vbo = GPU_vertbuf_create_with_format(&format); + GPU_vertbuf_data_alloc(vbo, waveform_num); + + GPU_vertbuf_attr_fill(vbo, pos_id, waveform); + + GPU_vertbuf_attr_fill(vbo, col_id, col); + + GPUBatch *batch = GPU_batch_create_ex(GPU_PRIM_POINTS, vbo, nullptr, GPU_BATCH_OWNS_VBO); + GPU_batch_program_set_builtin(batch, GPU_SHADER_3D_SMOOTH_COLOR); + + GPU_batch_draw(batch); + + GPU_batch_discard(batch); +} + + + void ui_draw_but_WAVEFORM(ARegion * /*region*/, uiBut *but, const uiWidgetColors * /*wcol*/, @@ -687,8 +711,6 @@ void ui_draw_but_WAVEFORM(ARegion * /*region*/, /* Flush text cache before drawing things on top. */ BLF_batch_draw_flush(); - GPU_blend(GPU_BLEND_ALPHA); - GPUVertFormat *format = immVertexFormat(); const uint pos = GPU_vertformat_attr_add(format, "pos", GPU_COMP_F32, 2, GPU_FETCH_FLOAT); @@ -907,7 +929,7 @@ static void vectorscope_draw_target( polar_to_y(centery, diam, tampli + dampli, tangle - dangle)); immEnd(); /* big target vary by 10 degree and 20% amplitude */ - immUniformColor4f(1.0f, 1.0f, 1.0f, 0.12f); + immUniformColor4f(1.0f, 1.0f, 1.0f, 0.25f); dangle = DEG2RADF(10.0f); dampli = 0.2f * tampli; dangle2 = DEG2RADF(5.0f); @@ -988,6 +1010,7 @@ void ui_draw_but_VECTORSCOPE(ARegion * /*region*/, const float diam = (w < h) ? w : h; const float alpha = scopes->vecscope_alpha * scopes->vecscope_alpha * scopes->vecscope_alpha; + const float vecsope_col[3] = {alpha, alpha, alpha}; GPU_blend(GPU_BLEND_ALPHA); @@ -1014,7 +1037,41 @@ void ui_draw_but_VECTORSCOPE(ARegion * /*region*/, immBindBuiltinProgram(GPU_SHADER_3D_UNIFORM_COLOR); - immUniformColor4f(1.0f, 1.0f, 1.0f, 0.08f); + /* circles */ + const int increment = 15; + const int num_points = int(360 / increment); + const float r = 0.5f; + + GPU_blend(GPU_BLEND_NONE); + immBegin(GPU_PRIM_TRI_FAN, num_points + 2); + immUniformColor3f(0.16f, 0.16f, 0.16f); + immVertex2f(pos, centerx, centery); + + for (int i = 0; i <= 360; i += increment) { + const float a = DEG2RADF(float(i)); + immVertex2f(pos, polar_to_x(centerx, diam, r, a), polar_to_y(centery, diam, r, a)); + } + + immEnd(); + + for (int j = 0; j < 5; j++) { + if (j == 4) + continue; + + GPU_blend(GPU_BLEND_ADDITIVE); + immUniformColor3f(0.2f, 0.2f, 0.2f); + immBegin(GPU_PRIM_LINE_LOOP, num_points); + + for (int i = 0; i < 360; i += increment) { + const float a = DEG2RADF(float(i)); + const float r = (j + 1) * 0.1f; + immVertex2f(pos, polar_to_x(centerx, diam, r, a), polar_to_y(centery, diam, r, a)); + } + + immEnd(); + } + + immUniformColor4f(1.0f, 1.0f, 1.0f, 0.1f); /* draw grid elements */ /* cross */ immBegin(GPU_PRIM_LINES, 4); @@ -1027,19 +1084,10 @@ void ui_draw_but_VECTORSCOPE(ARegion * /*region*/, immEnd(); - /* circles */ - for (int j = 0; j < 5; j++) { - const int increment = 15; - immBegin(GPU_PRIM_LINE_LOOP, int(360 / increment)); - for (int i = 0; i <= 360 - increment; i += increment) { - const float a = DEG2RADF(float(i)); - const float r = (j + 1) * 0.1f; - immVertex2f(pos, polar_to_x(centerx, diam, r, a), polar_to_y(centery, diam, r, a)); - } - immEnd(); - } + /* skin tone line */ - immUniformColor4f(1.0f, 0.4f, 0.0f, 0.2f); + GPU_blend(GPU_BLEND_ADDITIVE); + immUniformColor3f(0.5f, 0.5f, 0.5f); immBegin(GPU_PRIM_LINES, 2); immVertex2f( @@ -1055,16 +1103,14 @@ void ui_draw_but_VECTORSCOPE(ARegion * /*region*/, if (scopes->ok && scopes->vecscope != nullptr) { /* pixel point cloud */ - const float col[3] = {alpha, alpha, alpha}; - - GPU_blend(GPU_BLEND_ADDITIVE); - GPU_point_size(1.0); + GPU_blend(GPU_BLEND_ALPHA); + GPU_point_size(5.0); GPU_matrix_push(); GPU_matrix_translate_2f(centerx, centery); GPU_matrix_scale_1f(diam); - waveform_draw_one(scopes->vecscope, scopes->waveform_tot, col); + waveform_draw_rgb(scopes->vecscope, scopes->waveform_tot, scopes->vecscope_rgb); GPU_matrix_pop(); } diff --git a/source/blender/makesdna/DNA_color_types.h b/source/blender/makesdna/DNA_color_types.h index 7b17b91bbaf..caba7621611 100644 --- a/source/blender/makesdna/DNA_color_types.h +++ b/source/blender/makesdna/DNA_color_types.h @@ -163,6 +163,7 @@ typedef struct Scopes { float *waveform_2; float *waveform_3; float *vecscope; + float *vecscope_rgb; int waveform_tot; char _pad[4]; } Scopes; -- 2.30.2 From 5f58185acb2b0a5388c2acc9fc5b527184f39498 Mon Sep 17 00:00:00 2001 From: Jonas Dichelle Date: Tue, 9 Jan 2024 09:20:56 +0100 Subject: [PATCH 2/9] Made circle smoother, reduced point size --- source/blender/editors/interface/interface_draw.cc | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/source/blender/editors/interface/interface_draw.cc b/source/blender/editors/interface/interface_draw.cc index 02557d6a5d8..821b8e5528d 100644 --- a/source/blender/editors/interface/interface_draw.cc +++ b/source/blender/editors/interface/interface_draw.cc @@ -1038,7 +1038,7 @@ void ui_draw_but_VECTORSCOPE(ARegion * /*region*/, immBindBuiltinProgram(GPU_SHADER_3D_UNIFORM_COLOR); /* circles */ - const int increment = 15; + const int increment = 6; const int num_points = int(360 / increment); const float r = 0.5f; @@ -1104,7 +1104,7 @@ void ui_draw_but_VECTORSCOPE(ARegion * /*region*/, if (scopes->ok && scopes->vecscope != nullptr) { /* pixel point cloud */ GPU_blend(GPU_BLEND_ALPHA); - GPU_point_size(5.0); + GPU_point_size(1.0); GPU_matrix_push(); GPU_matrix_translate_2f(centerx, centery); -- 2.30.2 From ce816b75614ec28dbbf23d8de16a5d7ddff9716e Mon Sep 17 00:00:00 2001 From: JonasDichelle Date: Wed, 10 Jan 2024 02:41:30 +0100 Subject: [PATCH 3/9] removed big boxes, added letters, added outer color circle --- .../blender/blenkernel/intern/colortools.cc | 2 + .../editors/interface/interface_draw.cc | 144 ++++++++++-------- 2 files changed, 84 insertions(+), 62 deletions(-) diff --git a/source/blender/blenkernel/intern/colortools.cc b/source/blender/blenkernel/intern/colortools.cc index 4a495b9b279..13476ad3aab 100644 --- a/source/blender/blenkernel/intern/colortools.cc +++ b/source/blender/blenkernel/intern/colortools.cc @@ -1365,6 +1365,8 @@ static void save_sample_line( scopes->vecscope_rgb[color_idx + 2] = rgb[2]; scopes->vecscope_rgb[color_idx + 3] = scopes->vecscope_alpha; + + /* Waveform. */ switch (scopes->wavefrm_mode) { case SCOPES_WAVEFRM_RGB: diff --git a/source/blender/editors/interface/interface_draw.cc b/source/blender/editors/interface/interface_draw.cc index 821b8e5528d..dc961fef672 100644 --- a/source/blender/editors/interface/interface_draw.cc +++ b/source/blender/editors/interface/interface_draw.cc @@ -633,6 +633,27 @@ static void waveform_draw_rgb(float *waveform, int waveform_num, float *col) } +static void circle_draw_rgb(float *points, int tot_points, float *col) +{ + GPUVertFormat format = {0}; + const uint pos_id = GPU_vertformat_attr_add(&format, "pos", GPU_COMP_F32, 2, GPU_FETCH_FLOAT); + const uint col_id = GPU_vertformat_attr_add(&format, "color", GPU_COMP_F32, 4, GPU_FETCH_FLOAT); + + GPUVertBuf *vbo = GPU_vertbuf_create_with_format(&format); + GPU_vertbuf_data_alloc(vbo, tot_points); + + GPU_vertbuf_attr_fill(vbo, pos_id, points); + + GPU_vertbuf_attr_fill(vbo, col_id, col); + + GPUBatch *batch = GPU_batch_create_ex(GPU_PRIM_LINE_LOOP, vbo, nullptr, GPU_BATCH_OWNS_VBO); + GPU_batch_program_set_builtin(batch, GPU_SHADER_3D_SMOOTH_COLOR); + + GPU_batch_draw(batch); + + GPU_batch_discard(batch); +} + void ui_draw_but_WAVEFORM(ARegion * /*region*/, uiBut *but, @@ -885,7 +906,7 @@ static float polar_to_y(float center, float diam, float ampli, float angle) } static void vectorscope_draw_target( - uint pos, float centerx, float centery, float diam, const float colf[3]) + uint pos, float centerx, float centery, float diam, const float colf[3], const char *name) { float y, u, v; float tangle = 0.0f, tampli; @@ -927,56 +948,15 @@ static void vectorscope_draw_target( immVertex2f(pos, polar_to_x(centerx, diam, tampli + dampli, tangle - dangle), polar_to_y(centery, diam, tampli + dampli, tangle - dangle)); - immEnd(); - /* big target vary by 10 degree and 20% amplitude */ - immUniformColor4f(1.0f, 1.0f, 1.0f, 0.25f); - dangle = DEG2RADF(10.0f); - dampli = 0.2f * tampli; - dangle2 = DEG2RADF(5.0f); - dampli2 = 0.5f * dampli; - immBegin(GPU_PRIM_LINE_STRIP, 3); - immVertex2f(pos, - polar_to_x(centerx, diam, tampli + dampli - dampli2, tangle + dangle), - polar_to_y(centery, diam, tampli + dampli - dampli2, tangle + dangle)); - immVertex2f(pos, - polar_to_x(centerx, diam, tampli + dampli, tangle + dangle), - polar_to_y(centery, diam, tampli + dampli, tangle + dangle)); - immVertex2f(pos, - polar_to_x(centerx, diam, tampli + dampli, tangle + dangle - dangle2), - polar_to_y(centery, diam, tampli + dampli, tangle + dangle - dangle2)); - immEnd(); - immBegin(GPU_PRIM_LINE_STRIP, 3); - immVertex2f(pos, - polar_to_x(centerx, diam, tampli - dampli + dampli2, tangle + dangle), - polar_to_y(centery, diam, tampli - dampli + dampli2, tangle + dangle)); - immVertex2f(pos, - polar_to_x(centerx, diam, tampli - dampli, tangle + dangle), - polar_to_y(centery, diam, tampli - dampli, tangle + dangle)); - immVertex2f(pos, - polar_to_x(centerx, diam, tampli - dampli, tangle + dangle - dangle2), - polar_to_y(centery, diam, tampli - dampli, tangle + dangle - dangle2)); - immEnd(); - immBegin(GPU_PRIM_LINE_STRIP, 3); - immVertex2f(pos, - polar_to_x(centerx, diam, tampli - dampli + dampli2, tangle - dangle), - polar_to_y(centery, diam, tampli - dampli + dampli2, tangle - dangle)); - immVertex2f(pos, - polar_to_x(centerx, diam, tampli - dampli, tangle - dangle), - polar_to_y(centery, diam, tampli - dampli, tangle - dangle)); - immVertex2f(pos, - polar_to_x(centerx, diam, tampli - dampli, tangle - dangle + dangle2), - polar_to_y(centery, diam, tampli - dampli, tangle - dangle + dangle2)); - immEnd(); - immBegin(GPU_PRIM_LINE_STRIP, 3); - immVertex2f(pos, - polar_to_x(centerx, diam, tampli + dampli - dampli2, tangle - dangle), - polar_to_y(centery, diam, tampli + dampli - dampli2, tangle - dangle)); - immVertex2f(pos, - polar_to_x(centerx, diam, tampli + dampli, tangle - dangle), - polar_to_y(centery, diam, tampli + dampli, tangle - dangle)); - immVertex2f(pos, - polar_to_x(centerx, diam, tampli + dampli, tangle - dangle + dangle2), - polar_to_y(centery, diam, tampli + dampli, tangle - dangle + dangle2)); + + //draw text + BLF_color4f(BLF_default(), 1.0f, 1.0f, 1.0f, 0.3f); + BLF_draw_default(polar_to_x(centerx, diam, tampli, tangle) + 5, + polar_to_y(centery, diam, tampli, tangle), + 0, + name, + strlen(name)); + immEnd(); } @@ -989,14 +969,16 @@ void ui_draw_but_VECTORSCOPE(ARegion * /*region*/, Scopes *scopes = (Scopes *)but->poin; const float colors[6][3] = { - {0.75, 0.0, 0.0}, - {0.75, 0.75, 0.0}, - {0.0, 0.75, 0.0}, - {0.0, 0.75, 0.75}, - {0.0, 0.0, 0.75}, - {0.75, 0.0, 0.75}, + {0.75, 0.0, 0.0}, // Red + {0.75, 0.75, 0.0}, // Yellow + {0.0, 0.75, 0.0}, // Green + {0.0, 0.75, 0.75}, // Cyan + {0.0, 0.0, 0.75}, // Blue + {0.75, 0.0, 0.75}, // Magenta }; + const char color_names[6][4] = {"R", "Y", "G", "C", "B", "M"}; + rctf rect{}; rect.xmin = float(recti->xmin + 1); rect.xmax = float(recti->xmax - 1); @@ -1039,11 +1021,11 @@ void ui_draw_but_VECTORSCOPE(ARegion * /*region*/, /* circles */ const int increment = 6; - const int num_points = int(360 / increment); + const int tot_points = int(360 / increment); const float r = 0.5f; GPU_blend(GPU_BLEND_NONE); - immBegin(GPU_PRIM_TRI_FAN, num_points + 2); + immBegin(GPU_PRIM_TRI_FAN, tot_points + 2); immUniformColor3f(0.16f, 0.16f, 0.16f); immVertex2f(pos, centerx, centery); @@ -1054,13 +1036,51 @@ void ui_draw_but_VECTORSCOPE(ARegion * /*region*/, immEnd(); + float circle_points[(tot_points * 2)+3] = {}; + float circle_vertex_colors[(tot_points * 4)+5] = {}; + + float step = 360.0f / float(tot_points); + + for (int i = 0; i < tot_points; i++) { + // Calculate the angle in degrees for this point + float angle = step * i; + + // Convert angle to radians + const float a = DEG2RADF(angle); + + + // Calculate the position values + const float x = polar_to_x(centerx, diam, 0.5f, a); + const float y = polar_to_y(centery, diam, 0.5f, a); + + const float u = polar_to_x(0.0f, 1.0, 1.0f, a); + const float v = polar_to_y(0.0f, 1.0, 1.0f, a); + + circle_points[i * 2] = x; + circle_points[i * 2 + 1] = y; + + // Compute RGB values + float r = 0.0f, g = 0.0f, b = 0.0f; + yuv_to_rgb(0.5f, u, v, &r, &g, &b, BLI_YUV_ITU_BT709); + + // Set the color values + circle_vertex_colors[i * 4] = r; + circle_vertex_colors[i * 4 + 1] = g; + circle_vertex_colors[i * 4 + 2] = b; + circle_vertex_colors[i * 4 + 3] = 0.7f; + } + + GPU_blend(GPU_BLEND_ALPHA); + circle_draw_rgb(circle_points, tot_points, circle_vertex_colors); + + //inner circles for (int j = 0; j < 5; j++) { if (j == 4) continue; GPU_blend(GPU_BLEND_ADDITIVE); immUniformColor3f(0.2f, 0.2f, 0.2f); - immBegin(GPU_PRIM_LINE_LOOP, num_points); + immBegin(GPU_PRIM_LINE_LOOP, tot_points); for (int i = 0; i < 360; i += increment) { const float a = DEG2RADF(float(i)); @@ -1087,7 +1107,7 @@ void ui_draw_but_VECTORSCOPE(ARegion * /*region*/, /* skin tone line */ GPU_blend(GPU_BLEND_ADDITIVE); - immUniformColor3f(0.5f, 0.5f, 0.5f); + immUniformColor3f(0.25f, 0.25f, 0.25f); immBegin(GPU_PRIM_LINES, 2); immVertex2f( @@ -1098,7 +1118,7 @@ void ui_draw_but_VECTORSCOPE(ARegion * /*region*/, /* saturation points */ for (int i = 0; i < 6; i++) { - vectorscope_draw_target(pos, centerx, centery, diam, colors[i]); + vectorscope_draw_target(pos, centerx, centery, diam, colors[i], color_names[i]); } if (scopes->ok && scopes->vecscope != nullptr) { -- 2.30.2 From 6a02924793b5d64993efbd387045747b65d8c040 Mon Sep 17 00:00:00 2001 From: JonasDichelle Date: Wed, 10 Jan 2024 07:09:19 +0100 Subject: [PATCH 4/9] added vectorscope mode to pick between rgb and luma. --- scripts/startup/bl_ui/space_image.py | 5 ++++- .../blender/editors/interface/interface_draw.cc | 14 ++++++++++---- source/blender/makesdna/DNA_color_types.h | 17 ++++++++++++----- source/blender/makesrna/intern/rna_color.cc | 13 +++++++++++++ 4 files changed, 39 insertions(+), 10 deletions(-) diff --git a/scripts/startup/bl_ui/space_image.py b/scripts/startup/bl_ui/space_image.py index 4658fdd0857..b240b0361f7 100644 --- a/scripts/startup/bl_ui/space_image.py +++ b/scripts/startup/bl_ui/space_image.py @@ -1427,8 +1427,11 @@ class IMAGE_PT_view_vectorscope(ImageScopesPanel, Panel): layout = self.layout sima = context.space_data + layout.template_vectorscope(sima, "scopes") - layout.prop(sima.scopes, "vectorscope_alpha") + row = layout.split(factor=0.75) + row.prop(sima.scopes, "vectorscope_alpha") + row.prop(sima.scopes, "vectorscope_mode", text="") class IMAGE_PT_sample_line(ImageScopesPanel, Panel): diff --git a/source/blender/editors/interface/interface_draw.cc b/source/blender/editors/interface/interface_draw.cc index dc961fef672..76be4b7c312 100644 --- a/source/blender/editors/interface/interface_draw.cc +++ b/source/blender/editors/interface/interface_draw.cc @@ -991,8 +991,7 @@ void ui_draw_but_VECTORSCOPE(ARegion * /*region*/, const float centery = rect.ymin + h * 0.5f; const float diam = (w < h) ? w : h; - const float alpha = scopes->vecscope_alpha * scopes->vecscope_alpha * scopes->vecscope_alpha; - const float vecsope_col[3] = {alpha, alpha, alpha}; + const float alpha = scopes->vecscope_alpha; GPU_blend(GPU_BLEND_ALPHA); @@ -1123,14 +1122,21 @@ void ui_draw_but_VECTORSCOPE(ARegion * /*region*/, if (scopes->ok && scopes->vecscope != nullptr) { /* pixel point cloud */ - GPU_blend(GPU_BLEND_ALPHA); GPU_point_size(1.0); GPU_matrix_push(); GPU_matrix_translate_2f(centerx, centery); GPU_matrix_scale_1f(diam); - waveform_draw_rgb(scopes->vecscope, scopes->waveform_tot, scopes->vecscope_rgb); + const float col[3] = {alpha, alpha, alpha}; + if (scopes->vecscope_mode == SCOPES_VECSCOPE_RGB) { + GPU_blend(GPU_BLEND_ALPHA); + waveform_draw_rgb(scopes->vecscope, scopes->waveform_tot, scopes->vecscope_rgb); + } + else if (scopes->vecscope_mode == SCOPES_VECSCOPE_LUMA) { + GPU_blend(GPU_BLEND_ADDITIVE); + waveform_draw_one(scopes->vecscope, scopes->waveform_tot, col); + } GPU_matrix_pop(); } diff --git a/source/blender/makesdna/DNA_color_types.h b/source/blender/makesdna/DNA_color_types.h index caba7621611..b4c0aa73f51 100644 --- a/source/blender/makesdna/DNA_color_types.h +++ b/source/blender/makesdna/DNA_color_types.h @@ -150,13 +150,15 @@ typedef struct Scopes { int ok; int sample_full; int sample_lines; - float accuracy; int wavefrm_mode; + int vecscope_mode; + int wavefrm_height; + int vecscope_height; + int waveform_tot; + float accuracy; float wavefrm_alpha; float wavefrm_yfac; - int wavefrm_height; float vecscope_alpha; - int vecscope_height; float minmax[3][2]; struct Histogram hist; float *waveform_1; @@ -164,8 +166,7 @@ typedef struct Scopes { float *waveform_3; float *vecscope; float *vecscope_rgb; - int waveform_tot; - char _pad[4]; + char _pad[8]; // Adjusted for alignment } Scopes; /** #Scopes.wavefrm_mode */ @@ -178,6 +179,12 @@ enum { SCOPES_WAVEFRM_RGB = 5, }; +/** #Scopes.vecscope_mode */ +enum { + SCOPES_VECSCOPE_RGB = 0, + SCOPES_VECSCOPE_LUMA = 1, +}; + typedef struct ColorManagedViewSettings { int flag; char _pad[4]; diff --git a/source/blender/makesrna/intern/rna_color.cc b/source/blender/makesrna/intern/rna_color.cc index 820ab5aedf2..0544e92e086 100644 --- a/source/blender/makesrna/intern/rna_color.cc +++ b/source/blender/makesrna/intern/rna_color.cc @@ -1145,6 +1145,12 @@ static void rna_def_scopes(BlenderRNA *brna) {0, nullptr, 0, nullptr, nullptr}, }; + static const EnumPropertyItem prop_vecscope_mode_items[] = { + {SCOPES_VECSCOPE_LUMA, "LUMA", ICON_COLOR, "Luma", ""}, + {SCOPES_VECSCOPE_RGB, "RGB", ICON_COLOR, "Red Green Blue", ""}, + {0, nullptr, 0, nullptr, nullptr}, + }; + srna = RNA_def_struct(brna, "Scopes", nullptr); RNA_def_struct_ui_text(srna, "Scopes", "Scopes for statistical view of an image"); @@ -1177,10 +1183,17 @@ static void rna_def_scopes(BlenderRNA *brna) RNA_def_property_range(prop, 0, 1); RNA_def_property_ui_text(prop, "Waveform Opacity", "Opacity of the points"); + prop = RNA_def_property(srna, "vectorscope_mode", PROP_ENUM, PROP_NONE); + RNA_def_property_enum_sdna(prop, "Scopes", "vecscope_mode"); + RNA_def_property_enum_items(prop, prop_vecscope_mode_items); + RNA_def_property_ui_text(prop, "Vectorscope Mode", ""); + RNA_def_property_update(prop, 0, "rna_Scopes_update"); + prop = RNA_def_property(srna, "vectorscope_alpha", PROP_FLOAT, PROP_FACTOR); RNA_def_property_float_sdna(prop, "Scopes", "vecscope_alpha"); RNA_def_property_range(prop, 0, 1); RNA_def_property_ui_text(prop, "Vectorscope Opacity", "Opacity of the points"); + RNA_def_property_update(prop, 0, "rna_Scopes_update"); } static void rna_def_colormanage(BlenderRNA *brna) -- 2.30.2 From 968d784eb5d73e68975f04dde08fadd1aff52fda Mon Sep 17 00:00:00 2001 From: JonasDichelle Date: Wed, 10 Jan 2024 11:29:59 +0100 Subject: [PATCH 5/9] code style improvements - removed struct padding --- source/blender/draw/intern/draw_manager_c.cc | 2 - .../editors/interface/interface_draw.cc | 40 +++++++------------ source/blender/makesdna/DNA_color_types.h | 1 - 3 files changed, 14 insertions(+), 29 deletions(-) diff --git a/source/blender/draw/intern/draw_manager_c.cc b/source/blender/draw/intern/draw_manager_c.cc index eac94553448..5d540d77657 100644 --- a/source/blender/draw/intern/draw_manager_c.cc +++ b/source/blender/draw/intern/draw_manager_c.cc @@ -1763,8 +1763,6 @@ void DRW_draw_render_loop_ex(Depsgraph *depsgraph, drw_engines_draw_scene(); - // Clean up - /* Fix 3D view "lagging" on APPLE and WIN32+NVIDIA. (See #56996, #61474) */ if (GPU_type_matches_ex(GPU_DEVICE_ANY, GPU_OS_ANY, GPU_DRIVER_ANY, GPU_BACKEND_OPENGL)) { GPU_flush(); diff --git a/source/blender/editors/interface/interface_draw.cc b/source/blender/editors/interface/interface_draw.cc index 76be4b7c312..d3e68dba34a 100644 --- a/source/blender/editors/interface/interface_draw.cc +++ b/source/blender/editors/interface/interface_draw.cc @@ -618,17 +618,15 @@ static void waveform_draw_rgb(float *waveform, int waveform_num, float *col) const uint col_id = GPU_vertformat_attr_add(&format, "color", GPU_COMP_F32, 4, GPU_FETCH_FLOAT); GPUVertBuf *vbo = GPU_vertbuf_create_with_format(&format); + GPU_vertbuf_data_alloc(vbo, waveform_num); - GPU_vertbuf_attr_fill(vbo, pos_id, waveform); - GPU_vertbuf_attr_fill(vbo, col_id, col); GPUBatch *batch = GPU_batch_create_ex(GPU_PRIM_POINTS, vbo, nullptr, GPU_BATCH_OWNS_VBO); + GPU_batch_program_set_builtin(batch, GPU_SHADER_3D_SMOOTH_COLOR); - GPU_batch_draw(batch); - GPU_batch_discard(batch); } @@ -640,17 +638,15 @@ static void circle_draw_rgb(float *points, int tot_points, float *col) const uint col_id = GPU_vertformat_attr_add(&format, "color", GPU_COMP_F32, 4, GPU_FETCH_FLOAT); GPUVertBuf *vbo = GPU_vertbuf_create_with_format(&format); + GPU_vertbuf_data_alloc(vbo, tot_points); - GPU_vertbuf_attr_fill(vbo, pos_id, points); - GPU_vertbuf_attr_fill(vbo, col_id, col); GPUBatch *batch = GPU_batch_create_ex(GPU_PRIM_LINE_LOOP, vbo, nullptr, GPU_BATCH_OWNS_VBO); + GPU_batch_program_set_builtin(batch, GPU_SHADER_3D_SMOOTH_COLOR); - GPU_batch_draw(batch); - GPU_batch_discard(batch); } @@ -949,7 +945,7 @@ static void vectorscope_draw_target( polar_to_x(centerx, diam, tampli + dampli, tangle - dangle), polar_to_y(centery, diam, tampli + dampli, tangle - dangle)); - //draw text + /* draw color letter as text */ BLF_color4f(BLF_default(), 1.0f, 1.0f, 1.0f, 0.3f); BLF_draw_default(polar_to_x(centerx, diam, tampli, tangle) + 5, polar_to_y(centery, diam, tampli, tangle), @@ -969,12 +965,12 @@ void ui_draw_but_VECTORSCOPE(ARegion * /*region*/, Scopes *scopes = (Scopes *)but->poin; const float colors[6][3] = { - {0.75, 0.0, 0.0}, // Red - {0.75, 0.75, 0.0}, // Yellow - {0.0, 0.75, 0.0}, // Green - {0.0, 0.75, 0.75}, // Cyan - {0.0, 0.0, 0.75}, // Blue - {0.75, 0.0, 0.75}, // Magenta + {0.75, 0.0, 0.0}, /* Red */ + {0.75, 0.75, 0.0}, /* Yellow */ + {0.0, 0.75, 0.0}, /* Green */ + {0.0, 0.75, 0.75}, /* Cyan */ + {0.0, 0.0, 0.75}, /* Blue */ + {0.75, 0.0, 0.75}, /* Magenta */ }; const char color_names[6][4] = {"R", "Y", "G", "C", "B", "M"}; @@ -1032,23 +1028,18 @@ void ui_draw_but_VECTORSCOPE(ARegion * /*region*/, const float a = DEG2RADF(float(i)); immVertex2f(pos, polar_to_x(centerx, diam, r, a), polar_to_y(centery, diam, r, a)); } - immEnd(); + /* draw skin tone line */ float circle_points[(tot_points * 2)+3] = {}; float circle_vertex_colors[(tot_points * 4)+5] = {}; float step = 360.0f / float(tot_points); for (int i = 0; i < tot_points; i++) { - // Calculate the angle in degrees for this point float angle = step * i; - - // Convert angle to radians const float a = DEG2RADF(angle); - - // Calculate the position values const float x = polar_to_x(centerx, diam, 0.5f, a); const float y = polar_to_y(centery, diam, 0.5f, a); @@ -1058,11 +1049,9 @@ void ui_draw_but_VECTORSCOPE(ARegion * /*region*/, circle_points[i * 2] = x; circle_points[i * 2 + 1] = y; - // Compute RGB values float r = 0.0f, g = 0.0f, b = 0.0f; yuv_to_rgb(0.5f, u, v, &r, &g, &b, BLI_YUV_ITU_BT709); - // Set the color values circle_vertex_colors[i * 4] = r; circle_vertex_colors[i * 4 + 1] = g; circle_vertex_colors[i * 4 + 2] = b; @@ -1072,7 +1061,7 @@ void ui_draw_but_VECTORSCOPE(ARegion * /*region*/, GPU_blend(GPU_BLEND_ALPHA); circle_draw_rgb(circle_points, tot_points, circle_vertex_colors); - //inner circles + /* inner circles */ for (int j = 0; j < 5; j++) { if (j == 4) continue; @@ -1090,9 +1079,9 @@ void ui_draw_but_VECTORSCOPE(ARegion * /*region*/, immEnd(); } - immUniformColor4f(1.0f, 1.0f, 1.0f, 0.1f); /* draw grid elements */ /* cross */ + immUniformColor4f(1.0f, 1.0f, 1.0f, 0.1f); immBegin(GPU_PRIM_LINES, 4); immVertex2f(pos, centerx - (diam * 0.5f) - 5, centery); @@ -1103,7 +1092,6 @@ void ui_draw_but_VECTORSCOPE(ARegion * /*region*/, immEnd(); - /* skin tone line */ GPU_blend(GPU_BLEND_ADDITIVE); immUniformColor3f(0.25f, 0.25f, 0.25f); diff --git a/source/blender/makesdna/DNA_color_types.h b/source/blender/makesdna/DNA_color_types.h index b4c0aa73f51..5d32d22fae6 100644 --- a/source/blender/makesdna/DNA_color_types.h +++ b/source/blender/makesdna/DNA_color_types.h @@ -166,7 +166,6 @@ typedef struct Scopes { float *waveform_3; float *vecscope; float *vecscope_rgb; - char _pad[8]; // Adjusted for alignment } Scopes; /** #Scopes.wavefrm_mode */ -- 2.30.2 From 4be5c04f5f66945aca62f71626cc324dd94d6bcf Mon Sep 17 00:00:00 2001 From: JonasDichelle Date: Wed, 31 Jan 2024 21:44:58 +0100 Subject: [PATCH 6/9] Made circle look nicer -increased line width and opacity -made lines smooth --- source/blender/editors/interface/interface_draw.cc | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/source/blender/editors/interface/interface_draw.cc b/source/blender/editors/interface/interface_draw.cc index d3e68dba34a..e0f7f5ab178 100644 --- a/source/blender/editors/interface/interface_draw.cc +++ b/source/blender/editors/interface/interface_draw.cc @@ -989,6 +989,7 @@ void ui_draw_but_VECTORSCOPE(ARegion * /*region*/, const float alpha = scopes->vecscope_alpha; + GPU_line_smooth(true); GPU_blend(GPU_BLEND_ALPHA); float color[4]; @@ -1055,11 +1056,13 @@ void ui_draw_but_VECTORSCOPE(ARegion * /*region*/, circle_vertex_colors[i * 4] = r; circle_vertex_colors[i * 4 + 1] = g; circle_vertex_colors[i * 4 + 2] = b; - circle_vertex_colors[i * 4 + 3] = 0.7f; + circle_vertex_colors[i * 4 + 3] = 0.8f; } GPU_blend(GPU_BLEND_ALPHA); + GPU_line_width(2.5f); circle_draw_rgb(circle_points, tot_points, circle_vertex_colors); + GPU_line_width(1.0f); /* inner circles */ for (int j = 0; j < 5; j++) { -- 2.30.2 From 30e016c1f78c9524bc856d6ea15b843d11e0d88b Mon Sep 17 00:00:00 2001 From: JonasDichelle Date: Thu, 1 Feb 2024 12:40:33 +0100 Subject: [PATCH 7/9] Added colorwheel to background for luma version --- .../editors/interface/interface_draw.cc | 106 ++++++++++++------ 1 file changed, 69 insertions(+), 37 deletions(-) diff --git a/source/blender/editors/interface/interface_draw.cc b/source/blender/editors/interface/interface_draw.cc index e0f7f5ab178..0093a0ab4d8 100644 --- a/source/blender/editors/interface/interface_draw.cc +++ b/source/blender/editors/interface/interface_draw.cc @@ -630,8 +630,7 @@ static void waveform_draw_rgb(float *waveform, int waveform_num, float *col) GPU_batch_discard(batch); } - -static void circle_draw_rgb(float *points, int tot_points, float *col) +static void circle_draw_rgb(float *points, int tot_points, float *col, GPUPrimType prim) { GPUVertFormat format = {0}; const uint pos_id = GPU_vertformat_attr_add(&format, "pos", GPU_COMP_F32, 2, GPU_FETCH_FLOAT); @@ -643,7 +642,7 @@ static void circle_draw_rgb(float *points, int tot_points, float *col) GPU_vertbuf_attr_fill(vbo, pos_id, points); GPU_vertbuf_attr_fill(vbo, col_id, col); - GPUBatch *batch = GPU_batch_create_ex(GPU_PRIM_LINE_LOOP, vbo, nullptr, GPU_BATCH_OWNS_VBO); + GPUBatch *batch = GPU_batch_create_ex(prim, vbo, nullptr, GPU_BATCH_OWNS_VBO); GPU_batch_program_set_builtin(batch, GPU_SHADER_3D_SMOOTH_COLOR); GPU_batch_draw(batch); @@ -1014,63 +1013,96 @@ void ui_draw_but_VECTORSCOPE(ARegion * /*region*/, const uint pos = GPU_vertformat_attr_add(format, "pos", GPU_COMP_F32, 2, GPU_FETCH_FLOAT); immBindBuiltinProgram(GPU_SHADER_3D_UNIFORM_COLOR); - - /* circles */ const int increment = 6; const int tot_points = int(360 / increment); const float r = 0.5f; + float step = 360.0f / (tot_points - 1); - GPU_blend(GPU_BLEND_NONE); - immBegin(GPU_PRIM_TRI_FAN, tot_points + 2); - immUniformColor3f(0.16f, 0.16f, 0.16f); - immVertex2f(pos, centerx, centery); + float circle_fill_points[(tot_points * 2) + 2]; + float circle_fill_vertex_colors[(tot_points * 4) + 4]; - for (int i = 0; i <= 360; i += increment) { - const float a = DEG2RADF(float(i)); - immVertex2f(pos, polar_to_x(centerx, diam, r, a), polar_to_y(centery, diam, r, a)); - } - immEnd(); + /* draw filled RGB circle for background, only for LUMA mode */ + if (scopes->vecscope_mode == SCOPES_VECSCOPE_LUMA) { + /* Initialize center point and color */ + circle_fill_points[0] = centerx; + circle_fill_points[1] = centery; + circle_fill_vertex_colors[0] = 0.2f; + circle_fill_vertex_colors[1] = 0.2f; + circle_fill_vertex_colors[2] = 0.2f; + circle_fill_vertex_colors[3] = 0.8f; - /* draw skin tone line */ - float circle_points[(tot_points * 2)+3] = {}; - float circle_vertex_colors[(tot_points * 4)+5] = {}; - - float step = 360.0f / float(tot_points); - - for (int i = 0; i < tot_points; i++) { + for (int i = 0; i < tot_points; i++) { float angle = step * i; const float a = DEG2RADF(angle); - const float x = polar_to_x(centerx, diam, 0.5f, a); - const float y = polar_to_y(centery, diam, 0.5f, a); + const float x = polar_to_x(centerx, diam, r, a); + const float y = polar_to_y(centery, diam, r, a); const float u = polar_to_x(0.0f, 1.0, 1.0f, a); const float v = polar_to_y(0.0f, 1.0, 1.0f, a); - circle_points[i * 2] = x; - circle_points[i * 2 + 1] = y; + circle_fill_points[(i + 1) * 2] = x; + circle_fill_points[(i + 1) * 2 + 1] = y; - float r = 0.0f, g = 0.0f, b = 0.0f; + float r, g, b; yuv_to_rgb(0.5f, u, v, &r, &g, &b, BLI_YUV_ITU_BT709); - circle_vertex_colors[i * 4] = r; - circle_vertex_colors[i * 4 + 1] = g; - circle_vertex_colors[i * 4 + 2] = b; - circle_vertex_colors[i * 4 + 3] = 0.8f; + circle_fill_vertex_colors[(i + 1) * 4] = r * 0.2f; + circle_fill_vertex_colors[(i + 1) * 4 + 1] = g * 0.2f; + circle_fill_vertex_colors[(i + 1) * 4 + 2] = b * 0.2f; + circle_fill_vertex_colors[(i + 1) * 4 + 3] = 0.8f; } + GPU_blend(GPU_BLEND_ALPHA); + circle_draw_rgb(circle_fill_points, tot_points+2, circle_fill_vertex_colors, GPU_PRIM_TRI_FAN); + } + /* draw filled Gray circle for background, only for RGB mode */ + else if (scopes->vecscope_mode == SCOPES_VECSCOPE_RGB) { + GPU_blend(GPU_BLEND_NONE); + immBegin(GPU_PRIM_TRI_FAN, tot_points + 2); + immUniformColor3f(0.16f, 0.16f, 0.16f); + immVertex2f(pos, centerx, centery); + + for (int i = 0; i <= 360; i += increment) { + const float a = DEG2RADF(float(i)); + immVertex2f(pos, polar_to_x(centerx, diam, r, a), polar_to_y(centery, diam, r, a)); + } + immEnd(); + } + + /* draw RGB ring */ + float circle_points[(tot_points * 2) + 3] = {}; + float circle_vertex_colors[(tot_points * 4) + 5] = {}; + + for (int i = 0; i < tot_points; i++) { + float angle = step * i; + const float a = DEG2RADF(angle); + + const float x = polar_to_x(centerx, diam, 0.5f, a); + const float y = polar_to_y(centery, diam, 0.5f, a); + circle_points[i * 2] = x; + circle_points[i * 2 + 1] = y; + + const float u = polar_to_x(0.0f, 1.0, 1.0f, a); + const float v = polar_to_y(0.0f, 1.0, 1.0f, a); + float r, g, b; + yuv_to_rgb(0.5f, u, v, &r, &g, &b, BLI_YUV_ITU_BT709); + + circle_vertex_colors[i * 4] = r; + circle_vertex_colors[i * 4 + 1] = g; + circle_vertex_colors[i * 4 + 2] = b; + circle_vertex_colors[i * 4 + 3] = 0.8f; + } + GPU_blend(GPU_BLEND_ALPHA); GPU_line_width(2.5f); - circle_draw_rgb(circle_points, tot_points, circle_vertex_colors); - GPU_line_width(1.0f); + circle_draw_rgb(circle_points, tot_points, circle_vertex_colors, GPU_PRIM_LINE_LOOP); + GPU_line_width(1.5f); /* inner circles */ - for (int j = 0; j < 5; j++) { - if (j == 4) - continue; - + for (int j = 0; j < 4; j++) { GPU_blend(GPU_BLEND_ADDITIVE); - immUniformColor3f(0.2f, 0.2f, 0.2f); + immUniformColor3f(0.1f, 0.1f, 0.1f); immBegin(GPU_PRIM_LINE_LOOP, tot_points); for (int i = 0; i < 360; i += increment) { -- 2.30.2 From 2bebddf117ea1c0fcec0eb893f2cf06428e53bd4 Mon Sep 17 00:00:00 2001 From: JonasDichelle Date: Thu, 1 Feb 2024 16:34:55 +0100 Subject: [PATCH 8/9] minor code changes -changes color letters to chars -using circle_draw_rgb for all circles --- .../editors/interface/interface_draw.cc | 35 ++++++++++++------- 1 file changed, 22 insertions(+), 13 deletions(-) diff --git a/source/blender/editors/interface/interface_draw.cc b/source/blender/editors/interface/interface_draw.cc index 0093a0ab4d8..9567a849ddf 100644 --- a/source/blender/editors/interface/interface_draw.cc +++ b/source/blender/editors/interface/interface_draw.cc @@ -901,11 +901,12 @@ static float polar_to_y(float center, float diam, float ampli, float angle) } static void vectorscope_draw_target( - uint pos, float centerx, float centery, float diam, const float colf[3], const char *name) + uint pos, float centerx, float centery, float diam, const float colf[3], char label) { float y, u, v; float tangle = 0.0f, tampli; float dangle, dampli, dangle2, dampli2; + char labelstr[2] = {label, '\0'}; rgb_to_yuv(colf[0], colf[1], colf[2], &y, &u, &v, BLI_YUV_ITU_BT709); @@ -949,8 +950,8 @@ static void vectorscope_draw_target( BLF_draw_default(polar_to_x(centerx, diam, tampli, tangle) + 5, polar_to_y(centery, diam, tampli, tangle), 0, - name, - strlen(name)); + labelstr, + strlen(labelstr)); immEnd(); } @@ -972,7 +973,7 @@ void ui_draw_but_VECTORSCOPE(ARegion * /*region*/, {0.75, 0.0, 0.75}, /* Magenta */ }; - const char color_names[6][4] = {"R", "Y", "G", "C", "B", "M"}; + const char color_names[] = {'R', 'Y', 'G', 'C', 'B', 'M'}; rctf rect{}; rect.xmin = float(recti->xmin + 1); @@ -1100,20 +1101,28 @@ void ui_draw_but_VECTORSCOPE(ARegion * /*region*/, GPU_line_width(1.5f); /* inner circles */ + GPU_blend(GPU_BLEND_ADDITIVE); for (int j = 0; j < 4; j++) { - GPU_blend(GPU_BLEND_ADDITIVE); - immUniformColor3f(0.1f, 0.1f, 0.1f); - immBegin(GPU_PRIM_LINE_LOOP, tot_points); + float inner_circle_points[(tot_points * 2) + 3] = {}; + float inner_circle_colors[(tot_points * 4) + 5] = {}; + const float r = (j + 1) * 0.1f; - for (int i = 0; i < 360; i += increment) { - const float a = DEG2RADF(float(i)); - const float r = (j + 1) * 0.1f; - immVertex2f(pos, polar_to_x(centerx, diam, r, a), polar_to_y(centery, diam, r, a)); + for (int i = 0; i < tot_points; i++) { + float angle = step * i; + const float a = DEG2RADF(angle); + + inner_circle_points[i * 2] = polar_to_x(centerx, diam, r, a); + inner_circle_points[i * 2 + 1] = polar_to_y(centery, diam, r, a); + + inner_circle_colors[i * 4] = 0.1f; + inner_circle_colors[i * 4 + 1] = 0.1f; + inner_circle_colors[i * 4 + 2] = 0.1f; + inner_circle_colors[i * 4 + 3] = 0.8f; } - - immEnd(); + circle_draw_rgb(inner_circle_points, tot_points, inner_circle_colors, GPU_PRIM_LINE_LOOP); } + /* draw grid elements */ /* cross */ immUniformColor4f(1.0f, 1.0f, 1.0f, 0.1f); -- 2.30.2 From 24b7efa648103384229af64966da5e98f040f7f4 Mon Sep 17 00:00:00 2001 From: JonasDichelle Date: Tue, 6 Feb 2024 10:27:34 +0100 Subject: [PATCH 9/9] fixed formatting issues --- source/blender/blenkernel/intern/colortools.cc | 2 -- .../editors/interface/interface_draw.cc | 18 ++++++++---------- source/blender/makesdna/DNA_color_types.h | 4 ++-- source/blender/makesrna/intern/rna_color.cc | 8 ++++---- 4 files changed, 14 insertions(+), 18 deletions(-) diff --git a/source/blender/blenkernel/intern/colortools.cc b/source/blender/blenkernel/intern/colortools.cc index 7172cd335bb..b918d68dd77 100644 --- a/source/blender/blenkernel/intern/colortools.cc +++ b/source/blender/blenkernel/intern/colortools.cc @@ -1365,8 +1365,6 @@ static void save_sample_line( scopes->vecscope_rgb[color_idx + 2] = rgb[2]; scopes->vecscope_rgb[color_idx + 3] = scopes->vecscope_alpha; - - /* Waveform. */ switch (scopes->wavefrm_mode) { case SCOPES_WAVEFRM_RGB: diff --git a/source/blender/editors/interface/interface_draw.cc b/source/blender/editors/interface/interface_draw.cc index ef4e3a7be36..7e530476914 100644 --- a/source/blender/editors/interface/interface_draw.cc +++ b/source/blender/editors/interface/interface_draw.cc @@ -610,7 +610,6 @@ static void waveform_draw_one(float *waveform, int waveform_num, const float col GPU_batch_discard(batch); } - static void waveform_draw_rgb(float *waveform, int waveform_num, float *col) { GPUVertFormat format = {0}; @@ -649,7 +648,6 @@ static void circle_draw_rgb(float *points, int tot_points, float *col, GPUPrimTy GPU_batch_discard(batch); } - void ui_draw_but_WAVEFORM(ARegion * /*region*/, uiBut *but, const uiWidgetColors * /*wcol*/, @@ -965,12 +963,12 @@ void ui_draw_but_VECTORSCOPE(ARegion * /*region*/, Scopes *scopes = (Scopes *)but->poin; const float colors[6][3] = { - {0.75, 0.0, 0.0}, /* Red */ - {0.75, 0.75, 0.0}, /* Yellow */ - {0.0, 0.75, 0.0}, /* Green */ - {0.0, 0.75, 0.75}, /* Cyan */ - {0.0, 0.0, 0.75}, /* Blue */ - {0.75, 0.0, 0.75}, /* Magenta */ + {0.75, 0.0, 0.0}, /* Red */ + {0.75, 0.75, 0.0}, /* Yellow */ + {0.0, 0.75, 0.0}, /* Green */ + {0.0, 0.75, 0.75}, /* Cyan */ + {0.0, 0.0, 0.75}, /* Blue */ + {0.75, 0.0, 0.75}, /* Magenta */ }; const char color_names[] = {'R', 'Y', 'G', 'C', 'B', 'M'}; @@ -1055,7 +1053,8 @@ void ui_draw_but_VECTORSCOPE(ARegion * /*region*/, } GPU_blend(GPU_BLEND_ALPHA); - circle_draw_rgb(circle_fill_points, tot_points+2, circle_fill_vertex_colors, GPU_PRIM_TRI_FAN); + circle_draw_rgb( + circle_fill_points, tot_points + 2, circle_fill_vertex_colors, GPU_PRIM_TRI_FAN); } /* draw filled Gray circle for background, only for RGB mode */ else if (scopes->vecscope_mode == SCOPES_VECSCOPE_RGB) { @@ -1122,7 +1121,6 @@ void ui_draw_but_VECTORSCOPE(ARegion * /*region*/, circle_draw_rgb(inner_circle_points, tot_points, inner_circle_colors, GPU_PRIM_LINE_LOOP); } - /* draw grid elements */ /* cross */ immUniformColor4f(1.0f, 1.0f, 1.0f, 0.1f); diff --git a/source/blender/makesdna/DNA_color_types.h b/source/blender/makesdna/DNA_color_types.h index 5d32d22fae6..80d062446f3 100644 --- a/source/blender/makesdna/DNA_color_types.h +++ b/source/blender/makesdna/DNA_color_types.h @@ -180,8 +180,8 @@ enum { /** #Scopes.vecscope_mode */ enum { - SCOPES_VECSCOPE_RGB = 0, - SCOPES_VECSCOPE_LUMA = 1, + SCOPES_VECSCOPE_RGB = 0, + SCOPES_VECSCOPE_LUMA = 1, }; typedef struct ColorManagedViewSettings { diff --git a/source/blender/makesrna/intern/rna_color.cc b/source/blender/makesrna/intern/rna_color.cc index ab3bb194be3..197cf3c66d9 100644 --- a/source/blender/makesrna/intern/rna_color.cc +++ b/source/blender/makesrna/intern/rna_color.cc @@ -1145,11 +1145,11 @@ static void rna_def_scopes(BlenderRNA *brna) }; static const EnumPropertyItem prop_vecscope_mode_items[] = { - {SCOPES_VECSCOPE_LUMA, "LUMA", ICON_COLOR, "Luma", ""}, - {SCOPES_VECSCOPE_RGB, "RGB", ICON_COLOR, "Red Green Blue", ""}, - {0, nullptr, 0, nullptr, nullptr}, + {SCOPES_VECSCOPE_LUMA, "LUMA", ICON_COLOR, "Luma", ""}, + {SCOPES_VECSCOPE_RGB, "RGB", ICON_COLOR, "Red Green Blue", ""}, + {0, nullptr, 0, nullptr, nullptr}, }; - + srna = RNA_def_struct(brna, "Scopes", nullptr); RNA_def_struct_ui_text(srna, "Scopes", "Scopes for statistical view of an image"); -- 2.30.2