2023-05-31 16:19:06 +02:00
|
|
|
/* SPDX-FileCopyrightText: 2001-2002 NaN Holding BV. All rights reserved.
|
|
|
|
*
|
|
|
|
* SPDX-License-Identifier: GPL-2.0-or-later */
|
2013-04-27 14:51:23 +02:00
|
|
|
|
|
|
|
#pragma once
|
|
|
|
|
2019-02-17 22:08:12 +01:00
|
|
|
/** \file
|
|
|
|
* \ingroup bli
|
2013-04-27 14:51:23 +02:00
|
|
|
*/
|
|
|
|
|
2020-05-08 18:16:39 +02:00
|
|
|
#include "BLI_math_inline.h"
|
Cleanup: reduce amount of math-related includes
Using ClangBuildAnalyzer on the whole Blender build, it was pointing
out that BLI_math.h is the heaviest "header hub" (i.e. non tiny file
that is included a lot).
However, there's very little (actually zero) source files in Blender
that need "all the math" (base, colors, vectors, matrices,
quaternions, intersection, interpolation, statistics, solvers and
time). A common use case is source files needing just vectors, or
just vectors & matrices, or just colors etc. Actually, 181 files
were including the whole math thing without needing it at all.
This change removes BLI_math.h completely, and instead in all the
places that need it, includes BLI_math_vector.h or BLI_math_color.h
and so on.
Change from that:
- BLI_math_color.h was included 1399 times -> now 408 (took 114.0sec
to parse -> now 36.3sec)
- BLI_simd.h 1403 -> 418 (109.7sec -> 34.9sec).
Full rebuild of Blender (Apple M1, Xcode, RelWithDebInfo) is not
affected much (342sec -> 334sec). Most of benefit would be when
someone's changing BLI_simd.h or BLI_math_color.h or similar files,
that now there's 3x fewer files result in a recompile.
Pull Request #110944
2023-08-09 10:39:20 +02:00
|
|
|
#include "BLI_sys_types.h"
|
|
|
|
#include "BLI_utildefines.h"
|
2020-05-08 18:16:39 +02:00
|
|
|
|
2013-04-27 14:51:23 +02:00
|
|
|
#ifdef __cplusplus
|
|
|
|
extern "C" {
|
|
|
|
#endif
|
|
|
|
|
|
|
|
/******************** Blending Modes **********************
|
|
|
|
* - byte function assume straight alpha
|
|
|
|
* - float functions assume premultiplied alpha
|
|
|
|
*/
|
|
|
|
|
|
|
|
MINLINE void blend_color_mix_byte(unsigned char dst[4],
|
|
|
|
const unsigned char src1[4],
|
|
|
|
const unsigned char src2[4]);
|
|
|
|
MINLINE void blend_color_add_byte(unsigned char dst[4],
|
|
|
|
const unsigned char src1[4],
|
|
|
|
const unsigned char src2[4]);
|
|
|
|
MINLINE void blend_color_sub_byte(unsigned char dst[4],
|
|
|
|
const unsigned char src1[4],
|
|
|
|
const unsigned char src2[4]);
|
|
|
|
MINLINE void blend_color_mul_byte(unsigned char dst[4],
|
|
|
|
const unsigned char src1[4],
|
|
|
|
const unsigned char src2[4]);
|
|
|
|
MINLINE void blend_color_lighten_byte(unsigned char dst[4],
|
|
|
|
const unsigned char src1[4],
|
|
|
|
const unsigned char src2[4]);
|
|
|
|
MINLINE void blend_color_darken_byte(unsigned char dst[4],
|
|
|
|
const unsigned char src1[4],
|
|
|
|
const unsigned char src2[4]);
|
|
|
|
MINLINE void blend_color_erase_alpha_byte(unsigned char dst[4],
|
|
|
|
const unsigned char src1[4],
|
|
|
|
const unsigned char src2[4]);
|
|
|
|
MINLINE void blend_color_add_alpha_byte(unsigned char dst[4],
|
|
|
|
const unsigned char src1[4],
|
|
|
|
const unsigned char src2[4]);
|
2014-07-21 12:02:05 +02:00
|
|
|
|
|
|
|
MINLINE void blend_color_overlay_byte(unsigned char dst[4],
|
2020-02-07 15:02:18 +01:00
|
|
|
const uchar src1[4],
|
|
|
|
const uchar src2[4]);
|
2014-07-21 12:02:05 +02:00
|
|
|
MINLINE void blend_color_hardlight_byte(unsigned char dst[4],
|
2020-02-07 15:02:18 +01:00
|
|
|
const uchar src1[4],
|
|
|
|
const uchar src2[4]);
|
2020-02-07 15:26:35 +01:00
|
|
|
MINLINE void blend_color_burn_byte(unsigned char dst[4], const uchar src1[4], const uchar src2[4]);
|
2014-07-21 12:02:05 +02:00
|
|
|
MINLINE void blend_color_linearburn_byte(unsigned char dst[4],
|
2020-02-07 15:02:18 +01:00
|
|
|
const uchar src1[4],
|
|
|
|
const uchar src2[4]);
|
2014-07-21 12:02:05 +02:00
|
|
|
MINLINE void blend_color_dodge_byte(unsigned char dst[4],
|
2020-02-07 15:02:18 +01:00
|
|
|
const uchar src1[4],
|
|
|
|
const uchar src2[4]);
|
2014-07-21 12:02:05 +02:00
|
|
|
MINLINE void blend_color_screen_byte(unsigned char dst[4],
|
2020-02-07 15:02:18 +01:00
|
|
|
const uchar src1[4],
|
|
|
|
const uchar src2[4]);
|
2014-07-21 12:02:05 +02:00
|
|
|
MINLINE void blend_color_softlight_byte(unsigned char dst[4],
|
2020-02-07 15:02:18 +01:00
|
|
|
const uchar src1[4],
|
|
|
|
const uchar src2[4]);
|
2014-07-21 12:02:05 +02:00
|
|
|
MINLINE void blend_color_pinlight_byte(unsigned char dst[4],
|
2020-02-07 15:02:18 +01:00
|
|
|
const uchar src1[4],
|
|
|
|
const uchar src2[4]);
|
2014-07-21 12:02:05 +02:00
|
|
|
MINLINE void blend_color_linearlight_byte(unsigned char dst[4],
|
2020-02-07 15:02:18 +01:00
|
|
|
const uchar src1[4],
|
|
|
|
const uchar src2[4]);
|
2014-07-21 12:02:05 +02:00
|
|
|
MINLINE void blend_color_vividlight_byte(unsigned char dst[4],
|
2020-02-07 15:02:18 +01:00
|
|
|
const uchar src1[4],
|
|
|
|
const uchar src2[4]);
|
2014-07-21 12:02:05 +02:00
|
|
|
MINLINE void blend_color_difference_byte(unsigned char dst[4],
|
2020-02-07 15:02:18 +01:00
|
|
|
const uchar src1[4],
|
|
|
|
const uchar src2[4]);
|
2014-07-21 12:02:05 +02:00
|
|
|
MINLINE void blend_color_exclusion_byte(unsigned char dst[4],
|
2020-02-07 15:02:18 +01:00
|
|
|
const uchar src1[4],
|
|
|
|
const uchar src2[4]);
|
2014-07-21 12:02:05 +02:00
|
|
|
MINLINE void blend_color_color_byte(unsigned char dst[4],
|
2020-02-07 15:02:18 +01:00
|
|
|
const uchar src1[4],
|
|
|
|
const uchar src2[4]);
|
2020-02-07 15:26:35 +01:00
|
|
|
MINLINE void blend_color_hue_byte(unsigned char dst[4], const uchar src1[4], const uchar src2[4]);
|
2014-07-21 12:02:05 +02:00
|
|
|
MINLINE void blend_color_saturation_byte(unsigned char dst[4],
|
2020-02-07 15:02:18 +01:00
|
|
|
const uchar src1[4],
|
|
|
|
const uchar src2[4]);
|
2014-07-21 12:02:05 +02:00
|
|
|
MINLINE void blend_color_luminosity_byte(unsigned char dst[4],
|
2020-02-07 15:02:18 +01:00
|
|
|
const uchar src1[4],
|
|
|
|
const uchar src2[4]);
|
2014-07-21 12:02:05 +02:00
|
|
|
|
2013-04-30 18:07:52 +02:00
|
|
|
MINLINE void blend_color_interpolate_byte(unsigned char dst[4],
|
|
|
|
const unsigned char src1[4],
|
|
|
|
const unsigned char src2[4],
|
|
|
|
float t);
|
2013-04-27 14:51:23 +02:00
|
|
|
|
|
|
|
MINLINE void blend_color_mix_float(float dst[4], const float src1[4], const float src2[4]);
|
|
|
|
MINLINE void blend_color_add_float(float dst[4], const float src1[4], const float src2[4]);
|
|
|
|
MINLINE void blend_color_sub_float(float dst[4], const float src1[4], const float src2[4]);
|
|
|
|
MINLINE void blend_color_mul_float(float dst[4], const float src1[4], const float src2[4]);
|
|
|
|
MINLINE void blend_color_lighten_float(float dst[4], const float src1[4], const float src2[4]);
|
|
|
|
MINLINE void blend_color_darken_float(float dst[4], const float src1[4], const float src2[4]);
|
|
|
|
MINLINE void blend_color_erase_alpha_float(float dst[4], const float src1[4], const float src2[4]);
|
|
|
|
MINLINE void blend_color_add_alpha_float(float dst[4], const float src1[4], const float src2[4]);
|
2014-07-21 12:02:05 +02:00
|
|
|
|
2014-09-30 10:47:19 +02:00
|
|
|
MINLINE void blend_color_overlay_float(float dst[4], const float src1[4], const float src2[4]);
|
|
|
|
MINLINE void blend_color_hardlight_float(float dst[4], const float src1[4], const float src2[4]);
|
|
|
|
MINLINE void blend_color_burn_float(float dst[4], const float src1[4], const float src2[4]);
|
|
|
|
MINLINE void blend_color_linearburn_float(float dst[4], const float src1[4], const float src2[4]);
|
|
|
|
MINLINE void blend_color_dodge_float(float dst[4], const float src1[4], const float src2[4]);
|
|
|
|
MINLINE void blend_color_screen_float(float dst[4], const float src1[4], const float src2[4]);
|
|
|
|
MINLINE void blend_color_softlight_float(float dst[4], const float src1[4], const float src2[4]);
|
|
|
|
MINLINE void blend_color_pinlight_float(float dst[4], const float src1[4], const float src2[4]);
|
|
|
|
MINLINE void blend_color_linearlight_float(float dst[4], const float src1[4], const float src2[4]);
|
|
|
|
MINLINE void blend_color_vividlight_float(float dst[4], const float src1[4], const float src2[4]);
|
|
|
|
MINLINE void blend_color_difference_float(float dst[4], const float src1[4], const float src2[4]);
|
|
|
|
MINLINE void blend_color_exclusion_float(float dst[4], const float src1[4], const float src2[4]);
|
|
|
|
MINLINE void blend_color_color_float(float dst[4], const float src1[4], const float src2[4]);
|
|
|
|
MINLINE void blend_color_hue_float(float dst[4], const float src1[4], const float src2[4]);
|
|
|
|
MINLINE void blend_color_saturation_float(float dst[4], const float src1[4], const float src2[4]);
|
|
|
|
MINLINE void blend_color_luminosity_float(float dst[4], const float src1[4], const float src2[4]);
|
2014-07-21 12:02:05 +02:00
|
|
|
|
2013-04-30 18:07:52 +02:00
|
|
|
MINLINE void blend_color_interpolate_float(float dst[4],
|
|
|
|
const float src1[4],
|
|
|
|
const float src2[4],
|
|
|
|
float t);
|
2013-04-27 14:51:23 +02:00
|
|
|
|
|
|
|
#if BLI_MATH_DO_INLINE
|
|
|
|
# include "intern/math_color_blend_inline.c"
|
|
|
|
#endif
|
|
|
|
|
|
|
|
#ifdef __cplusplus
|
|
|
|
}
|
|
|
|
#endif
|