Cleanup: use const for image blending functions

This commit is contained in:
2019-09-25 17:11:00 +10:00
parent 3142ae19d2
commit d0279f7d36
5 changed files with 52 additions and 38 deletions

View File

@@ -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);

View File

@@ -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,

View File

@@ -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);

View File

@@ -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,

View File

@@ -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;