Changeset View
Changeset View
Standalone View
Standalone View
source/blender/blenlib/intern/math_color_blend_inline.c
| Show First 20 Lines • Show All 376 Lines • ▼ Show 20 Lines | while (i--) { | ||||
| int temp; | int temp; | ||||
| if (src2[i] > 127) { | if (src2[i] > 127) { | ||||
| temp = max_ii(2 * (src2[i] - 127), src1[i]); | temp = max_ii(2 * (src2[i] - 127), src1[i]); | ||||
| } | } | ||||
| else { | else { | ||||
| temp = min_ii(2 * src2[i], src1[i]); | temp = min_ii(2 * src2[i], src1[i]); | ||||
| } | } | ||||
| dst[i] = (uchar)((temp * fac + src1[i] * mfac) / 255); | dst[i] = (uchar)((min_ii(temp, 255) * fac + src1[i] * mfac) / 255); | ||||
| } | } | ||||
| } | } | ||||
| else { | else { | ||||
| /* no op */ | /* no op */ | ||||
| copy_v4_v4_uchar(dst, src1); | copy_v4_v4_uchar(dst, src1); | ||||
| } | } | ||||
| } | } | ||||
| ▲ Show 20 Lines • Show All 74 Lines • ▼ Show 20 Lines | |||||
| MINLINE void blend_color_exclusion_byte(uchar dst[4], const uchar src1[4], const uchar src2[4]) | MINLINE void blend_color_exclusion_byte(uchar dst[4], const uchar src1[4], const uchar src2[4]) | ||||
| { | { | ||||
| const int fac = src2[3]; | const int fac = src2[3]; | ||||
| if (fac != 0) { | if (fac != 0) { | ||||
| const int mfac = 255 - fac; | const int mfac = 255 - fac; | ||||
| int i = 3; | int i = 3; | ||||
| while (i--) { | while (i--) { | ||||
| const int temp = 127 - ((2 * (src1[i] - 127) * (src2[i] - 127)) / 255); | const int temp = 127 - min_ii(((2 * (src1[i] - 127) * (src2[i] - 127)) / 255), 127); | ||||
| dst[i] = (uchar)((temp * fac + src1[i] * mfac) / 255); | dst[i] = (uchar)((temp * fac + src1[i] * mfac) / 255); | ||||
| } | } | ||||
| } | } | ||||
| else { | else { | ||||
| /* no op */ | /* no op */ | ||||
| copy_v4_v4_uchar(dst, src1); | copy_v4_v4_uchar(dst, src1); | ||||
| } | } | ||||
| } | } | ||||
| ▲ Show 20 Lines • Show All 406 Lines • ▼ Show 20 Lines | |||||
| MINLINE void blend_color_softlight_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]) | ||||
| { | { | ||||
| const float fac = src2[3]; | const float fac = src2[3]; | ||||
| if (fac != 0.0f) { | if (fac != 0.0f) { | ||||
| const float mfac = 1.0f - fac; | const float mfac = 1.0f - fac; | ||||
| int i = 3; | int i = 3; | ||||
| while (i--) { | while (i--) { | ||||
| float temp; | float screen = 1.0f - (1.0f - src1[i]) * (1.0f - src2[i]); | ||||
| float soft_light = ((1.0f - src1[i]) * src2[i] + screen) * src1[i]; | |||||
| if (src1[i] < 0.5f) { | dst[i] = src1[i] * mfac + soft_light * fac; | ||||
| temp = (src2[i] + 0.5f) * src1[i]; | |||||
| } | |||||
| else { | |||||
| temp = 1.0f - ((1.0f - (src2[i] + 0.5f)) * (1.0f - src1[i])); | |||||
| } | |||||
| dst[i] = (temp * fac + src1[i] * mfac); | |||||
| } | } | ||||
| } | } | ||||
| else { | else { | ||||
| /* no op */ | /* no op */ | ||||
| copy_v4_v4(dst, src1); | copy_v4_v4(dst, src1); | ||||
| } | } | ||||
| } | } | ||||
| ▲ Show 20 Lines • Show All 239 Lines • Show Last 20 Lines | |||||