|
Blender V5.0
|
#include "BLI_math_color.h"#include "BLI_math_color.hh"#include "BLI_math_matrix.hh"#include "BLI_math_vector.hh"#include "BLI_simd.hh"#include "BLI_utildefines.h"#include <algorithm>#include <cstring>#include "BLI_strict_flags.h"Go to the source code of this file.
Classes | |
| struct | blender::math::locus_entry_t |
Namespaces | |
| namespace | blender |
| namespace | blender::math |
Variables | |
| float | BLI_color_from_srgb_table [256] |
| ushort | BLI_color_to_srgb_table [0x10000] |
| static const std::array< locus_entry_t, 31 > | blender::math::planck_locus |
| MALWAYS_INLINE float _bli_math_fastpow | ( | const int | exp, |
| const int | e2coeff, | ||
| const float | arg ) |
Definition at line 592 of file math_color.cc.
References exp, float, float_as_int(), int_as_float(), MALWAYS_INLINE, and ret.
Referenced by _bli_math_fastpow24(), and _bli_math_fastpow512().
| MALWAYS_INLINE float _bli_math_fastpow24 | ( | const float | arg | ) |
Definition at line 610 of file math_color.cc.
References _bli_math_fastpow(), _bli_math_improve_5throot_solution(), MALWAYS_INLINE, and x.
Referenced by srgb_to_linearrgb_approx().
| MALWAYS_INLINE float _bli_math_fastpow512 | ( | const float | arg | ) |
Definition at line 626 of file math_color.cc.
References _bli_math_fastpow(), _bli_math_rsqrt(), and MALWAYS_INLINE.
Referenced by linearrgb_to_srgb_approx().
| MALWAYS_INLINE float _bli_math_improve_5throot_solution | ( | const float | old_result, |
| const float | x ) |
Definition at line 601 of file math_color.cc.
References MALWAYS_INLINE, and x.
Referenced by _bli_math_fastpow24().
| MALWAYS_INLINE float _bli_math_rsqrt | ( | float | in | ) |
Definition at line 621 of file math_color.cc.
References in, MALWAYS_INLINE, and sqrtf.
Referenced by _bli_math_fastpow512().
| void BLI_init_srgb_conversion | ( | void | ) |
Definition at line 749 of file math_color.cc.
References b, BLI_color_from_srgb_table, BLI_color_to_srgb_table, hipart(), i, index_to_float(), initialized, linearrgb_to_srgb(), and srgb_to_linearrgb().
Referenced by colormanagement_init(), blender::gpu::GPUTest::SetUpTestSuite(), blender::tests::TEST(), blender::tests::TEST(), blender::tests::TEST(), blender::tests::TEST(), and blender::tests::TEST().
Definition at line 408 of file math_color.cc.
Referenced by BKE_palette_from_hash().
| MALWAYS_INLINE int32_t float_as_int | ( | float | v | ) |
Definition at line 585 of file math_color.cc.
References i, MALWAYS_INLINE, MINLINE, and v.
Referenced by _bli_math_fastpow(), and isect_ray_tri_watertight_v3().
Definition at line 185 of file math_color.cc.
References hex_to_rgba().
Referenced by BKE_gpencil_palette_ensure().
Definition at line 190 of file math_color.cc.
Referenced by hex_to_rgb(), and ui_colorpicker_hex_rna_cb().
Definition at line 709 of file math_color.cc.
Referenced by BLI_init_srgb_conversion().
Definition at line 38 of file math_color.cc.
References CLAMP, fabsf, and l.
Referenced by BKE_icon_geom_invert_lightness(), blender::nodes::node_fn_combine_color_cc::get_multi_function(), hsl_to_rgb_v(), blender::nodes::node_composite_combine_color_cc::node_build_multi_function(), and svm_combine_color().
Definition at line 62 of file math_color.cc.
References hsl_to_rgb().
Referenced by BKE_colorband_evaluate(), color_mul_hsl_v3(), colorfn(), TEST(), ui_color_picker_hsv_to_rgb(), and ui_color_picker_to_rgb_HSVCUBE_v().
Clamp hsv to usable values.
Definition at line 368 of file math_color.cc.
We define a 'cpack' here as a (3 byte color code) number that can be expressed like 0xFFAA66 or so. For that reason it is sensitive for endianness... with this function it works correctly.
Definition at line 377 of file math_color.cc.
References b, col, hsv_to_rgb(), and v.
Definition at line 21 of file math_color.cc.
References CLAMP, fabsf, and v.
Referenced by blender::seq::HueCorrectApplyOp::apply(), BKE_paint_face_set_overlay_color_get(), blend_color_color_byte(), blend_color_color_float(), blend_color_hue_byte(), blend_color_hue_float(), blend_color_luminosity_byte(), blend_color_luminosity_float(), blend_color_saturation_byte(), blend_color_saturation_float(), do_hue_sat_fac(), blender::nodes::node_fn_combine_color_cc::get_multi_function(), hsv_to_cpack(), hsv_to_rgb_v(), IMB_saturation(), blender::color::mix_color(), blender::color::mix_hue(), blender::color::mix_luminosity(), blender::color::mix_saturation(), blender::nodes::node_composite_combine_color_cc::node_build_multi_function(), node_mix_color(), node_mix_hue(), node_mix_sat(), node_mix_val(), ramp_blend(), rgb_float_set_hue_float_offset(), svm_combine_color(), svm_mix_color(), svm_mix_hue(), svm_mix_sat(), svm_mix_val(), svm_node_hsv(), and ui_draw_gradient_hsv_to_rgb().
Definition at line 57 of file math_color.cc.
References hsv_to_rgb().
Referenced by blender::apply_color_factor(), BKE_colorband_evaluate(), BKE_paint_randomize_color(), checker_board_color_fill(), Color_channel_hsv_set(), blender::ed::sculpt_paint::color::color_filter_task(), Color_hsv_set(), colorfn(), ED_scene_draw_fps(), blender::nodes::node_composite_glare_cc::GlareOperation::execute_highlights_cpu(), getcolor_fcurve_rainbow(), blender::ed::greasepencil::grease_pencil_vertex_paint_hsv_exec(), blender::nodes::node_composite_huecorrect_cc::hue_correct(), image_buf_fill_checker_slice(), blender::draw::gpencil::list_sort_do(), blender::workbench::Material::Material(), blender::nodes::node_composite_hue_sat_val_cc::node_build_multi_function(), TEST(), ui_color_picker_hsv_to_rgb(), ui_color_picker_to_rgb_HSVCUBE_v(), ui_do_but_COLOR(), ui_do_but_HSVCIRCLE(), vertex_color_hsv_exec(), and blender::nodes::node_composite_glare_cc::GlareOperation::write_glare_output_cpu().
Definition at line 722 of file math_color.cc.
Referenced by BLI_init_srgb_conversion().
| MALWAYS_INLINE float int_as_float | ( | int32_t | v | ) |
Definition at line 578 of file math_color.cc.
References i, MALWAYS_INLINE, MINLINE, and v.
Referenced by _bli_math_fastpow(), blender::eevee::ShadowPunctual::end_sync(), and render_result_from_bake().
Definition at line 426 of file math_color.cc.
References powf.
Referenced by BLI_init_srgb_conversion(), ibuftoimage(), studiolight_irradiance_preview(), studiolight_matcap_preview(), studiolight_radiance_preview(), TEST(), TEST(), and TEST().
| MALWAYS_INLINE float linearrgb_to_srgb_approx | ( | float | c | ) |
Definition at line 648 of file math_color.cc.
References _bli_math_fastpow512(), and MALWAYS_INLINE.
Referenced by linearrgb_to_srgb_v3_v3().
Definition at line 664 of file math_color.cc.
References linearrgb_to_srgb_approx().
Referenced by BKE_brush_color_sync_legacy(), BKE_brush_color_sync_legacy(), BKE_palette_color_sync_legacy(), blender::ed::sculpt_paint::color::from_float(), IMB_buffer_byte_from_float(), IMB_buffer_float_from_float(), IMB_colormanagement_scene_linear_to_srgb_v3(), linearrgb_to_srgb_predivide_v4(), linearrgb_to_srgb_uchar3(), linearrgb_to_srgb_v4(), blender::ed::sculpt_paint::load_tex_task_cb_ex(), paint_brush_color_get(), TEST(), ui_but_paste_color(), ui_draw_but_CURVE(), blender::io::grease_pencil::write_fill_color_attribute(), blender::io::grease_pencil::write_stroke_color_attribute(), blender::io::grease_pencil::PDFExporter::write_stroke_to_polyline(), and blender::io::obj::OBJWriter::write_vertex_coords().
Applies an HUE offset to a byte RGB color.
Definition at line 692 of file math_color.cc.
References rgb_float_set_hue_float_offset(), rgb_float_to_uchar(), and rgb_uchar_to_float().
Referenced by blender::ed::vse::color3ubv_from_seq().
Applies an HUE offset to a float RGB color.
Definition at line 675 of file math_color.cc.
References hsv_to_rgb(), and rgb_to_hsv().
Referenced by rgb_byte_set_hue_float_offset().
Definition at line 393 of file math_color.cc.
References b, floorf, and max_ff().
Referenced by palette_extract_img_exec(), studiolight_irradiance_preview(), studiolight_matcap_preview(), and studiolight_radiance_preview().
Definition at line 263 of file math_color.cc.
References b, l, max_fff(), min_ff(), and min_fff().
Referenced by blender::nodes::node_fn_separate_color_cc::SeparateHSLAFunction::call(), blender::nodes::node_composite_separate_color_cc::node_build_multi_function(), rgb_to_hsl_compat(), rgb_to_hsl_v(), and svm_separate_color().
Definition at line 292 of file math_color.cc.
References b, fabsf, and rgb_to_hsl().
Referenced by rgb_to_hsl_compat_v().
Definition at line 323 of file math_color.cc.
References rgb_to_hsl_compat().
Referenced by ui_color_picker_rgb_to_hsv_compat(), and ui_rgb_to_color_picker_HSVCUBE_compat_v().
Definition at line 328 of file math_color.cc.
References rgb_to_hsl().
Referenced by apply_color_space(), BKE_colorband_evaluate(), BKE_icon_geom_invert_lightness(), color_mul_hsl_v3(), TEST(), ui_color_picker_rgb_to_hsv(), ui_draw_but_HSV_v(), and ui_rgb_to_color_picker_HSVCUBE_v().
Definition at line 234 of file math_color.cc.
References b, fabsf, min_ff(), and SWAP.
Referenced by blender::seq::HueCorrectApplyOp::apply(), BKE_palette_from_hash(), blend_color_color_byte(), blend_color_color_float(), blend_color_hue_byte(), blend_color_hue_float(), blend_color_luminosity_byte(), blend_color_luminosity_float(), blend_color_saturation_byte(), blend_color_saturation_float(), blender::nodes::node_fn_separate_color_cc::SeparateHSVAFunction::call(), Color_channel_hsv_get(), Color_hsv_get(), do_hue_sat_fac(), ED_image_draw_info(), blender::color::mix_color(), blender::color::mix_hue(), blender::color::mix_luminosity(), blender::color::mix_saturation(), blender::nodes::node_composite_separate_color_cc::node_build_multi_function(), node_mix_color(), node_mix_hue(), node_mix_sat(), node_mix_val(), palette_sort_exec(), ramp_blend(), rgb_float_set_hue_float_offset(), rgb_to_hsv_compat(), rgb_to_hsv_v(), svm_mix_color(), svm_mix_hue(), svm_mix_sat(), svm_mix_val(), svm_node_hsv(), and svm_separate_color().
Definition at line 333 of file math_color.cc.
References b, fabsf, and rgb_to_hsv().
Referenced by rgb_to_hsv_compat_v().
Definition at line 363 of file math_color.cc.
References rgb_to_hsv_compat().
Referenced by ui_color_picker_rgb_to_hsv_compat(), ui_do_but_COLOR(), ui_draw_but_HSVCUBE(), and ui_rgb_to_color_picker_HSVCUBE_compat_v().
Definition at line 258 of file math_color.cc.
References rgb_to_hsv().
Referenced by blender::apply_color_factor(), apply_color_space(), BKE_colorband_evaluate(), BKE_paint_randomize_color(), Color_channel_hsv_set(), blender::ed::sculpt_paint::color::color_filter_task(), blender::nodes::node_composite_color_matte_cc::color_matte(), blender::nodes::node_composite_channel_matte_cc::compute_channels(), ED_scene_draw_fps(), blender::nodes::node_composite_glare_cc::GlareOperation::execute_highlights_cpu(), blender::ed::greasepencil::grease_pencil_vertex_paint_hsv_exec(), blender::nodes::node_composite_huecorrect_cc::hue_correct(), IMB_saturation(), blender::nodes::node_composite_hue_sat_val_cc::node_build_multi_function(), TEST(), ui_color_picker_rgb_to_hsv(), ui_draw_but_CURVE(), ui_draw_but_HSV_v(), ui_rgb_to_color_picker_HSVCUBE_v(), UI_tooltip_color_field_add(), vertex_color_hsv_exec(), weightvg_do_mask(), and blender::nodes::node_composite_glare_cc::GlareOperation::write_glare_output_cpu().
| void rgb_to_ycc | ( | float | r, |
| float | g, | ||
| float | b, | ||
| float * | r_y, | ||
| float * | r_cb, | ||
| float * | r_cr, | ||
| int | colorspace ) |
The RGB inputs are supposed gamma corrected and in the range 0 - 1.0f
Output YCC have a range of 16-235 and 16-240 except with JFIF_0_255 where the range is 0-255.
Definition at line 115 of file math_color.cc.
References b, BLI_assert_msg, BLI_YCC_ITU_BT601, BLI_YCC_ITU_BT709, BLI_YCC_JFIF_0_255, and y.
Referenced by blender::nodes::node_composite_chroma_matte_cc::chroma_matte(), blender::nodes::node_composite_channel_matte_cc::compute_channels(), blender::nodes::node_composite_distance_matte_cc::distance_key(), blender::nodes::node_composite_separate_color_cc::node_build_multi_function(), scopes_update_cb(), and TEST().
| void rgb_to_yuv | ( | float | r, |
| float | g, | ||
| float | b, | ||
| float * | r_y, | ||
| float * | r_u, | ||
| float * | r_v, | ||
| int | colorspace ) |
Definition at line 67 of file math_color.cc.
References b, BLI_assert, BLI_YUV_ITU_BT601, BLI_YUV_ITU_BT709, v, and y.
Referenced by blender::nodes::node_composite_channel_matte_cc::compute_channels(), ED_image_draw_info(), blender::nodes::node_composite_separate_color_cc::node_build_multi_function(), blender::ed::vse::rgb_to_uv_scaled(), save_sample_line(), TEST(), and vectorscope_draw_target().
Definition at line 417 of file math_color.cc.
References powf.
Referenced by BLI_init_srgb_conversion(), image_buf_fill_checker_slice(), imb_save_openexr_half(), and TEST().
| MALWAYS_INLINE float srgb_to_linearrgb_approx | ( | float | c | ) |
Definition at line 639 of file math_color.cc.
References _bli_math_fastpow24(), and MALWAYS_INLINE.
Referenced by srgb_to_linearrgb_v3_v3().
Definition at line 657 of file math_color.cc.
References srgb_to_linearrgb_approx().
Referenced by blo_do_versions_250(), blo_do_versions_280(), drop_color_invoke(), blender::io::obj::geom_add_vertex(), IMB_buffer_byte_from_float(), IMB_buffer_float_from_float(), IMB_colormanagement_imbuf_to_float_texture(), IMB_colormanagement_srgb_to_scene_linear_v3(), paint_brush_color_get(), srgb_to_linearrgb_predivide_v4(), srgb_to_linearrgb_v4(), TEST(), blender::ed::sculpt_paint::color::to_float(), and ui_but_copy_color().
| void ycc_to_rgb | ( | float | y, |
| float | cb, | ||
| float | cr, | ||
| float * | r_r, | ||
| float * | r_g, | ||
| float * | r_b, | ||
| int | colorspace ) |
Definition at line 150 of file math_color.cc.
References b, BLI_assert_unreachable, BLI_YCC_ITU_BT601, BLI_YCC_ITU_BT709, BLI_YCC_JFIF_0_255, and y.
Referenced by imb_load_openexr(), blender::nodes::node_composite_combine_color_cc::node_build_multi_function(), and TEST().
| void yuv_to_rgb | ( | float | y, |
| float | u, | ||
| float | v, | ||
| float * | r_r, | ||
| float * | r_g, | ||
| float * | r_b, | ||
| int | colorspace ) |
Definition at line 91 of file math_color.cc.
References b, BLI_assert, BLI_YUV_ITU_BT601, BLI_YUV_ITU_BT709, v, and y.
Referenced by blender::ed::vse::draw_vectorscope_graticule(), blender::nodes::node_composite_combine_color_cc::node_build_multi_function(), TEST(), and ui_draw_but_VECTORSCOPE().
| float BLI_color_from_srgb_table[256] |
Definition at line 706 of file math_color.cc.
Referenced by BLI_init_srgb_conversion(), blender::draw::AttributeConverter< ColorGeometry4b >::convert(), blender::draw::particle_mcol_convert(), blender::draw::particle_pack_mcol(), and srgb_to_linearrgb_uchar4().
| ushort BLI_color_to_srgb_table[0x10000] |
Definition at line 707 of file math_color.cc.
Referenced by BLI_init_srgb_conversion(), and to_srgb_table_lookup().