From d0279f7d36a6cba8bf91b9c6a982da5185a51ac4 Mon Sep 17 00:00:00 2001 From: Campbell Barton Date: Wed, 25 Sep 2019 17:11:00 +1000 Subject: Cleanup: use const for image blending functions --- source/blender/imbuf/IMB_imbuf.h | 31 ++++++++++-------- source/blender/imbuf/intern/IMB_filetype.h | 2 +- source/blender/imbuf/intern/filetype.c | 4 +-- source/blender/imbuf/intern/rectop.c | 51 ++++++++++++++++++------------ source/blender/imbuf/intern/util.c | 2 +- 5 files changed, 52 insertions(+), 38 deletions(-) (limited to 'source/blender/imbuf') diff --git a/source/blender/imbuf/IMB_imbuf.h b/source/blender/imbuf/IMB_imbuf.h index 7e7e489a6c3..6e49630dc46 100644 --- a/source/blender/imbuf/IMB_imbuf.h +++ b/source/blender/imbuf/IMB_imbuf.h @@ -218,15 +218,18 @@ typedef enum IMB_BlendMode { } IMB_BlendMode; void IMB_blend_color_byte(unsigned char dst[4], - unsigned char src1[4], - unsigned char src2[4], + const unsigned char src1[4], + const unsigned char src2[4], IMB_BlendMode mode); -void IMB_blend_color_float(float dst[4], float src1[4], float src2[4], IMB_BlendMode mode); +void IMB_blend_color_float(float dst[4], + const float src1[4], + const float src2[4], + IMB_BlendMode mode); void IMB_rect_crop(struct ImBuf *ibuf, const struct rcti *crop); void IMB_rectclip(struct ImBuf *dbuf, - struct ImBuf *sbuf, + const struct ImBuf *sbuf, int *destx, int *desty, int *srcx, @@ -234,7 +237,7 @@ void IMB_rectclip(struct ImBuf *dbuf, int *width, int *height); void IMB_rectcpy(struct ImBuf *drect, - struct ImBuf *srect, + const struct ImBuf *srect, int destx, int desty, int srcx, @@ -242,11 +245,11 @@ void IMB_rectcpy(struct ImBuf *drect, int width, int height); void IMB_rectblend(struct ImBuf *dbuf, - struct ImBuf *obuf, - struct ImBuf *sbuf, + const struct ImBuf *obuf, + const struct ImBuf *sbuf, unsigned short *dmask, - unsigned short *curvemask, - unsigned short *mmask, + const unsigned short *curvemask, + const unsigned short *mmask, float mask_max, int destx, int desty, @@ -259,11 +262,11 @@ void IMB_rectblend(struct ImBuf *dbuf, IMB_BlendMode mode, bool accumulate); void IMB_rectblend_threaded(struct ImBuf *dbuf, - struct ImBuf *obuf, - struct ImBuf *sbuf, + const struct ImBuf *obuf, + const struct ImBuf *sbuf, unsigned short *dmask, - unsigned short *curvemask, - unsigned short *mmask, + const unsigned short *curvemask, + const unsigned short *mmask, float mask_max, int destx, int desty, @@ -477,7 +480,7 @@ int imb_get_anim_type(const char *name); * * \attention Defined in util.c */ -bool IMB_isfloat(struct ImBuf *ibuf); +bool IMB_isfloat(const struct ImBuf *ibuf); /* Do byte/float and colorspace conversions need to take alpha into account? */ bool IMB_alpha_affects_rgb(const struct ImBuf *ibuf); diff --git a/source/blender/imbuf/intern/IMB_filetype.h b/source/blender/imbuf/intern/IMB_filetype.h index 5048414ac65..52db0b80441 100644 --- a/source/blender/imbuf/intern/IMB_filetype.h +++ b/source/blender/imbuf/intern/IMB_filetype.h @@ -33,7 +33,7 @@ typedef struct ImFileType { int (*is_a)(const unsigned char *buf); int (*is_a_filepath)(const char *name); - int (*ftype)(const struct ImFileType *type, struct ImBuf *ibuf); + int (*ftype)(const struct ImFileType *type, const struct ImBuf *ibuf); struct ImBuf *(*load)(const unsigned char *mem, size_t size, int flags, diff --git a/source/blender/imbuf/intern/filetype.c b/source/blender/imbuf/intern/filetype.c index d1b3bf21e23..c6f8bab325b 100644 --- a/source/blender/imbuf/intern/filetype.c +++ b/source/blender/imbuf/intern/filetype.c @@ -40,11 +40,11 @@ # include "dds/dds_api.h" #endif -static int imb_ftype_default(const ImFileType *type, ImBuf *ibuf) +static int imb_ftype_default(const ImFileType *type, const ImBuf *ibuf) { return (ibuf->ftype == type->filetype); } -static int imb_ftype_iris(const ImFileType *type, ImBuf *ibuf) +static int imb_ftype_iris(const ImFileType *type, const ImBuf *ibuf) { (void)type; return (ibuf->ftype == IMB_FTYPE_IMAGIC); diff --git a/source/blender/imbuf/intern/rectop.c b/source/blender/imbuf/intern/rectop.c index 76918c216f7..b8ea6c2ea03 100644 --- a/source/blender/imbuf/intern/rectop.c +++ b/source/blender/imbuf/intern/rectop.c @@ -39,8 +39,8 @@ #include "MEM_guardedalloc.h" void IMB_blend_color_byte(unsigned char dst[4], - unsigned char src1[4], - unsigned char src2[4], + const unsigned char src1[4], + const unsigned char src2[4], IMB_BlendMode mode) { switch (mode) { @@ -126,7 +126,10 @@ void IMB_blend_color_byte(unsigned char dst[4], } } -void IMB_blend_color_float(float dst[4], float src1[4], float src2[4], IMB_BlendMode mode) +void IMB_blend_color_float(float dst[4], + const float src1[4], + const float src2[4], + IMB_BlendMode mode) { switch (mode) { case IMB_BLEND_MIX: @@ -279,7 +282,7 @@ void IMB_rect_crop(ImBuf *ibuf, const rcti *crop) /* clipping */ void IMB_rectclip(ImBuf *dbuf, - ImBuf *sbuf, + const ImBuf *sbuf, int *destx, int *desty, int *srcx, @@ -341,8 +344,8 @@ void IMB_rectclip(ImBuf *dbuf, } static void imb_rectclip3(ImBuf *dbuf, - ImBuf *obuf, - ImBuf *sbuf, + const ImBuf *obuf, + const ImBuf *sbuf, int *destx, int *desty, int *origx, @@ -435,8 +438,14 @@ static void imb_rectclip3(ImBuf *dbuf, /* copy and blend */ -void IMB_rectcpy( - ImBuf *dbuf, ImBuf *sbuf, int destx, int desty, int srcx, int srcy, int width, int height) +void IMB_rectcpy(ImBuf *dbuf, + const ImBuf *sbuf, + int destx, + int desty, + int srcx, + int srcy, + int width, + int height) { IMB_rectblend(dbuf, dbuf, @@ -463,11 +472,11 @@ typedef void (*IMB_blend_func)(unsigned char *dst, typedef void (*IMB_blend_func_float)(float *dst, const float *src1, const float *src2); void IMB_rectblend(ImBuf *dbuf, - ImBuf *obuf, - ImBuf *sbuf, + const ImBuf *obuf, + const ImBuf *sbuf, unsigned short *dmask, - unsigned short *curvemask, - unsigned short *texmask, + const unsigned short *curvemask, + const unsigned short *texmask, float mask_max, int destx, int desty, @@ -482,9 +491,9 @@ void IMB_rectblend(ImBuf *dbuf, { unsigned int *drect = NULL, *orect = NULL, *srect = NULL, *dr, * or, *sr; float *drectf = NULL, *orectf = NULL, *srectf = NULL, *drf, *orf, *srf; - unsigned short *cmaskrect = curvemask, *cmr; + const unsigned short *cmaskrect = curvemask, *cmr; unsigned short *dmaskrect = dmask, *dmr; - unsigned short *texmaskrect = texmask, *tmr; + const unsigned short *texmaskrect = texmask, *tmr; int do_float, do_char, srcskip, destskip, origskip, x; IMB_blend_func func = NULL; IMB_blend_func_float func_float = NULL; @@ -924,8 +933,10 @@ void IMB_rectblend(ImBuf *dbuf, } typedef struct RectBlendThreadData { - ImBuf *dbuf, *obuf, *sbuf; - unsigned short *dmask, *curvemask, *texmask; + ImBuf *dbuf; + const ImBuf *obuf, *sbuf; + unsigned short *dmask; + const unsigned short *curvemask, *texmask; float mask_max; int destx, desty, origx, origy; int srcx, srcy, width; @@ -956,11 +967,11 @@ static void rectblend_thread_do(void *data_v, int start_scanline, int num_scanli } void IMB_rectblend_threaded(ImBuf *dbuf, - ImBuf *obuf, - ImBuf *sbuf, + const ImBuf *obuf, + const ImBuf *sbuf, unsigned short *dmask, - unsigned short *curvemask, - unsigned short *texmask, + const unsigned short *curvemask, + const unsigned short *texmask, float mask_max, int destx, int desty, diff --git a/source/blender/imbuf/intern/util.c b/source/blender/imbuf/intern/util.c index ff7cb87960e..c5bae4ddbad 100644 --- a/source/blender/imbuf/intern/util.c +++ b/source/blender/imbuf/intern/util.c @@ -389,7 +389,7 @@ bool IMB_isanim(const char *filename) return (type && type != ANIM_SEQUENCE); } -bool IMB_isfloat(ImBuf *ibuf) +bool IMB_isfloat(const ImBuf *ibuf) { const ImFileType *type; -- cgit v1.2.3