Changeset View
Changeset View
Standalone View
Standalone View
source/blender/imbuf/intern/rectop.c
| Context not available. | |||||
| #include "BLI_math_color_blend.h" | #include "BLI_math_color_blend.h" | ||||
| #include "BLI_math_vector.h" | #include "BLI_math_vector.h" | ||||
| #include "IMB_imbuf_types.h" | #include "DNA_image_types.h" /* for IMA_LAYER_LOCK_ALPHA - XXX? (kevin) */ | ||||
| #include "DNA_imbuf_types.h" | |||||
| #include "IMB_imbuf.h" | #include "IMB_imbuf.h" | ||||
| #include "IMB_colormanagement.h" | #include "IMB_colormanagement.h" | ||||
| Context not available. | |||||
| void IMB_rectcpy(ImBuf *dbuf, ImBuf *sbuf, int destx, | void IMB_rectcpy(ImBuf *dbuf, ImBuf *sbuf, int destx, | ||||
| int desty, int srcx, int srcy, int width, int height) | int desty, int srcx, int srcy, int width, int height) | ||||
| { | { | ||||
| IMB_rectblend(dbuf, dbuf, sbuf, NULL, NULL, NULL, 0, destx, desty, destx, desty, srcx, srcy, width, height, IMB_BLEND_COPY, false); | IMB_rectblend(dbuf, dbuf, sbuf, NULL, NULL, NULL, 0, destx, desty, destx, desty, srcx, srcy, width, height, IMB_BLEND_COPY, false, 2); | ||||
| } | } | ||||
| typedef void (*IMB_blend_func)(unsigned char *dst, const unsigned char *src1, const unsigned char *src2); | typedef void (*IMB_blend_func)(unsigned char *dst, const unsigned char *src1, const unsigned char *src2); | ||||
| Context not available. | |||||
| void IMB_rectblend(ImBuf *dbuf, ImBuf *obuf, ImBuf *sbuf, unsigned short *dmask, unsigned short *curvemask, | void IMB_rectblend(ImBuf *dbuf, ImBuf *obuf, ImBuf *sbuf, unsigned short *dmask, unsigned short *curvemask, | ||||
| unsigned short *texmask, float mask_max, | unsigned short *texmask, float mask_max, | ||||
| int destx, int desty, int origx, int origy, int srcx, int srcy, int width, int height, | int destx, int desty, int origx, int origy, int srcx, int srcy, int width, int height, | ||||
| IMB_BlendMode mode, bool accumulate) | IMB_BlendMode mode, bool accumulate, short lock_alpha) | ||||
| { | { | ||||
| unsigned int *drect = NULL, *orect, *srect = NULL, *dr, *or, *sr; | unsigned int *drect = NULL, *orect, *srect = NULL, *dr, *or, *sr; | ||||
| float *drectf = NULL, *orectf, *srectf = NULL, *drf, *orf, *srf; | float *drectf = NULL, *orectf, *srectf = NULL, *drf, *orf, *srf; | ||||
| Context not available. | |||||
| unsigned char *src = (unsigned char *)sr; | unsigned char *src = (unsigned char *)sr; | ||||
| float mask_lim = mask_max * (*cmr); | float mask_lim = mask_max * (*cmr); | ||||
| if (texmaskrect) | if (!((lock_alpha & IMA_LAYER_LOCK_ALPHA) && (pixel_is_transparent((unsigned char *)or)))) { | ||||
| mask_lim *= ((*tmr++) / 65535.0f); | if (texmaskrect) | ||||
| mask_lim *= ((*tmr++) / 65535.0f); | |||||
| if (src[3] && mask_lim) { | if (src[3] && mask_lim) { | ||||
| float mask; | float mask; | ||||
| if (accumulate) | if (accumulate) | ||||
| mask = *dmr + mask_lim; | mask = *dmr + mask_lim; | ||||
| else | else | ||||
| mask = *dmr + mask_lim - (*dmr * (*cmr / 65535.0f)); | mask = *dmr + mask_lim - (*dmr * (*cmr / 65535.0f)); | ||||
| mask = min_ff(mask, 65535.0); | mask = min_ff(mask, 65535.0); | ||||
| if (mask > *dmr) { | if (mask > *dmr) { | ||||
| unsigned char mask_src[4]; | unsigned char mask_src[4]; | ||||
| *dmr = mask; | *dmr = mask; | ||||
| mask_src[0] = src[0]; | mask_src[0] = src[0]; | ||||
| mask_src[1] = src[1]; | mask_src[1] = src[1]; | ||||
| mask_src[2] = src[2]; | mask_src[2] = src[2]; | ||||
| mask_src[3] = divide_round_i(src[3] * mask, 65535); | mask_src[3] = divide_round_i(src[3] * mask, 65535); | ||||
| func((unsigned char *)dr, (unsigned char *)or, mask_src); | func((unsigned char *)dr, (unsigned char *)or, mask_src); | ||||
| } | |||||
| } | } | ||||
| } | } | ||||
| } | } | ||||
| Context not available. | |||||
| unsigned char *src = (unsigned char *)sr; | unsigned char *src = (unsigned char *)sr; | ||||
| float mask = (float)mask_max * ((float)(*cmr)); | float mask = (float)mask_max * ((float)(*cmr)); | ||||
| if (texmaskrect) | if (!((lock_alpha & IMA_LAYER_LOCK_ALPHA) && (pixel_is_transparent((unsigned char *)or)))) { | ||||
| mask *= ((float)(*tmr++) / 65535.0f); | if (texmaskrect) | ||||
| mask *= ((float)(*tmr++) / 65535.0f); | |||||
| mask = min_ff(mask, 65535.0); | mask = min_ff(mask, 65535.0); | ||||
| if (src[3] && (mask > 0.0f)) { | if (src[3] && (mask > 0.0f)) { | ||||
| unsigned char mask_src[4]; | unsigned char mask_src[4]; | ||||
| mask_src[0] = src[0]; | mask_src[0] = src[0]; | ||||
| mask_src[1] = src[1]; | mask_src[1] = src[1]; | ||||
| mask_src[2] = src[2]; | mask_src[2] = src[2]; | ||||
| mask_src[3] = divide_round_i(src[3] * mask, 65535); | mask_src[3] = divide_round_i(src[3] * mask, 65535); | ||||
| func((unsigned char *)dr, (unsigned char *)or, mask_src); | func((unsigned char *)dr, (unsigned char *)or, mask_src); | ||||
| } | |||||
| } | } | ||||
| } | } | ||||
| } | } | ||||
| Context not available. | |||||