code cleanup: use bool for imbuf allocation functions.
This commit is contained in:
@@ -574,7 +574,7 @@ static void outliner_draw_restrictbuts(uiBlock *block, Scene *scene, ARegion *ar
|
||||
int but_flag = UI_BUT_DRAG_LOCK;
|
||||
gr = (Group *)tselem->id;
|
||||
|
||||
if(gr->id.lib)
|
||||
if (gr->id.lib)
|
||||
but_flag |= UI_BUT_DISABLED;
|
||||
|
||||
uiBlockSetEmboss(block, UI_EMBOSSN);
|
||||
|
||||
@@ -1671,7 +1671,8 @@ static bool snapObject(Scene *scene, short snap_mode, ARegion *ar, Object *ob, f
|
||||
}
|
||||
else if (ob->type == OB_EMPTY) {
|
||||
retval = snapEmpty(snap_mode, ar, ob, obmat, ray_start, ray_normal, mval, r_loc, r_no, r_dist_px, r_depth);
|
||||
} else if (ob->type == OB_CAMERA) {
|
||||
}
|
||||
else if (ob->type == OB_CAMERA) {
|
||||
retval = snapCamera(snap_mode, ar, scene, ob, obmat, ray_start, ray_normal, mval, r_loc, r_no, r_dist_px, r_depth);
|
||||
}
|
||||
|
||||
|
||||
@@ -51,9 +51,6 @@
|
||||
* - Endianness issues are dealt with internally.
|
||||
* - File I/O must be done externally. The module uses FILE*'s to
|
||||
* direct input/output.
|
||||
* - Platform dependency is limited. Some minor patches for
|
||||
* amiga and Irix are present. A 'posix-compliance-patch'
|
||||
* provides the interface to windows.
|
||||
*
|
||||
* \section dependencies Dependencies
|
||||
*
|
||||
@@ -72,6 +69,9 @@
|
||||
|
||||
#define IM_MAX_SPACE 64
|
||||
|
||||
/* for bool */
|
||||
#include "../blenlib/BLI_sys_types.h"
|
||||
|
||||
/**
|
||||
*
|
||||
* \attention defined in ???
|
||||
@@ -146,8 +146,8 @@ struct ImBuf *IMB_dupImBuf(struct ImBuf *ibuf1);
|
||||
*
|
||||
* \attention Defined in allocimbuf.c
|
||||
*/
|
||||
short addzbufImBuf(struct ImBuf *ibuf);
|
||||
short addzbuffloatImBuf(struct ImBuf *ibuf);
|
||||
bool addzbufImBuf(struct ImBuf *ibuf);
|
||||
bool addzbuffloatImBuf(struct ImBuf *ibuf);
|
||||
|
||||
/**
|
||||
*
|
||||
@@ -500,17 +500,17 @@ void buf_rectfill_area(unsigned char *rect, float *rectf, int width, int height,
|
||||
int x1, int y1, int x2, int y2);
|
||||
|
||||
/* defined in metadata.c */
|
||||
int IMB_metadata_change_field(struct ImBuf *img, const char *key, const char *field);
|
||||
bool IMB_metadata_change_field(struct ImBuf *img, const char *key, const char *field);
|
||||
|
||||
/* exported for image tools in blender, to quickly allocate 32 bits rect */
|
||||
short imb_addrectImBuf(struct ImBuf *ibuf);
|
||||
bool imb_addrectImBuf(struct ImBuf *ibuf);
|
||||
void imb_freerectImBuf(struct ImBuf *ibuf);
|
||||
|
||||
short imb_addrectfloatImBuf(struct ImBuf *ibuf);
|
||||
bool imb_addrectfloatImBuf(struct ImBuf *ibuf);
|
||||
void imb_freerectfloatImBuf(struct ImBuf *ibuf);
|
||||
void imb_freemipmapImBuf(struct ImBuf *ibuf);
|
||||
|
||||
short imb_addtilesImBuf(struct ImBuf *ibuf);
|
||||
bool imb_addtilesImBuf(struct ImBuf *ibuf);
|
||||
void imb_freetilesImBuf(struct ImBuf *ibuf);
|
||||
|
||||
/* threaded processors */
|
||||
|
||||
@@ -35,8 +35,8 @@
|
||||
|
||||
struct ImBuf;
|
||||
|
||||
short imb_addencodedbufferImBuf(struct ImBuf *ibuf);
|
||||
short imb_enlargeencodedbufferImBuf(struct ImBuf *ibuf);
|
||||
bool imb_addencodedbufferImBuf(struct ImBuf *ibuf);
|
||||
bool imb_enlargeencodedbufferImBuf(struct ImBuf *ibuf);
|
||||
|
||||
#endif
|
||||
|
||||
|
||||
@@ -94,7 +94,6 @@ int imb_savebmp(struct ImBuf *ibuf, const char *name, int flags);
|
||||
|
||||
/* cocoa */
|
||||
struct ImBuf *imb_cocoaLoadImage(unsigned char *mem, size_t size, int flags, char colorspace[IM_MAX_SPACE]);
|
||||
short imb_cocoaSaveImage(struct ImBuf *ibuf, const char *name, int flags);
|
||||
|
||||
/* cineon */
|
||||
int imb_save_cineon(struct ImBuf *buf, const char *name, int flags);
|
||||
|
||||
@@ -62,7 +62,7 @@ void IMB_metadata_free(struct ImBuf *img);
|
||||
* \param len - length of value buffer allocated by user.
|
||||
* \return - 1 (true) if ImageInfo present and value for the key found, 0 (false) otherwise
|
||||
*/
|
||||
int IMB_metadata_get_field(struct ImBuf *img, const char *key, char *value, const size_t len);
|
||||
bool IMB_metadata_get_field(struct ImBuf *img, const char *key, char *value, const size_t len);
|
||||
|
||||
/** set user data in the ImMetaData struct, which has to be allocated with IMB_metadata_create
|
||||
* before calling this function.
|
||||
@@ -71,13 +71,13 @@ int IMB_metadata_get_field(struct ImBuf *img, const char *key, char *value, cons
|
||||
* \param value - the data to be written to the field. zero terminated string
|
||||
* \return - 1 (true) if ImageInfo present, 0 (false) otherwise
|
||||
*/
|
||||
int IMB_metadata_add_field(struct ImBuf *img, const char *key, const char *value);
|
||||
bool IMB_metadata_add_field(struct ImBuf *img, const char *key, const char *value);
|
||||
|
||||
/** delete the key/field par in the ImMetaData struct.
|
||||
* \param img - the ImBuf that contains the image data
|
||||
* \param key - the key of the field
|
||||
* \return - 1 (true) if delete the key/field, 0 (false) otherwise
|
||||
*/
|
||||
int IMB_metadata_del_field(struct ImBuf *img, const char *key);
|
||||
bool IMB_metadata_del_field(struct ImBuf *img, const char *key);
|
||||
|
||||
#endif /* __IMB_METADATA_H__ */
|
||||
|
||||
@@ -191,11 +191,11 @@ ImBuf *IMB_makeSingleUser(ImBuf *ibuf)
|
||||
return rval;
|
||||
}
|
||||
|
||||
short addzbufImBuf(ImBuf *ibuf)
|
||||
bool addzbufImBuf(ImBuf *ibuf)
|
||||
{
|
||||
size_t size;
|
||||
|
||||
if (ibuf == NULL) return FALSE;
|
||||
if (ibuf == NULL) return false;
|
||||
|
||||
IMB_freezbufImBuf(ibuf);
|
||||
|
||||
@@ -204,17 +204,17 @@ short addzbufImBuf(ImBuf *ibuf)
|
||||
if ((ibuf->zbuf = MEM_mapallocN(size, __func__))) {
|
||||
ibuf->mall |= IB_zbuf;
|
||||
ibuf->flags |= IB_zbuf;
|
||||
return TRUE;
|
||||
return true;
|
||||
}
|
||||
|
||||
return FALSE;
|
||||
return false;
|
||||
}
|
||||
|
||||
short addzbuffloatImBuf(ImBuf *ibuf)
|
||||
bool addzbuffloatImBuf(ImBuf *ibuf)
|
||||
{
|
||||
size_t size;
|
||||
|
||||
if (ibuf == NULL) return FALSE;
|
||||
if (ibuf == NULL) return false;
|
||||
|
||||
IMB_freezbuffloatImBuf(ibuf);
|
||||
|
||||
@@ -223,16 +223,16 @@ short addzbuffloatImBuf(ImBuf *ibuf)
|
||||
if ((ibuf->zbuf_float = MEM_mapallocN(size, __func__))) {
|
||||
ibuf->mall |= IB_zbuffloat;
|
||||
ibuf->flags |= IB_zbuffloat;
|
||||
return TRUE;
|
||||
return true;
|
||||
}
|
||||
|
||||
return FALSE;
|
||||
return false;
|
||||
}
|
||||
|
||||
|
||||
short imb_addencodedbufferImBuf(ImBuf *ibuf)
|
||||
bool imb_addencodedbufferImBuf(ImBuf *ibuf)
|
||||
{
|
||||
if (ibuf == NULL) return FALSE;
|
||||
if (ibuf == NULL) return false;
|
||||
|
||||
freeencodedbufferImBuf(ibuf);
|
||||
|
||||
@@ -241,33 +241,33 @@ short imb_addencodedbufferImBuf(ImBuf *ibuf)
|
||||
|
||||
ibuf->encodedsize = 0;
|
||||
|
||||
if ((ibuf->encodedbuffer = MEM_mallocN(ibuf->encodedbuffersize, "addencodedbufferImBuf"))) {
|
||||
if ((ibuf->encodedbuffer = MEM_mallocN(ibuf->encodedbuffersize, __func__))) {
|
||||
ibuf->mall |= IB_mem;
|
||||
ibuf->flags |= IB_mem;
|
||||
return TRUE;
|
||||
return true;
|
||||
}
|
||||
|
||||
return FALSE;
|
||||
return false;
|
||||
}
|
||||
|
||||
|
||||
short imb_enlargeencodedbufferImBuf(ImBuf *ibuf)
|
||||
bool imb_enlargeencodedbufferImBuf(ImBuf *ibuf)
|
||||
{
|
||||
unsigned int newsize, encodedsize;
|
||||
void *newbuffer;
|
||||
|
||||
if (ibuf == NULL) return FALSE;
|
||||
if (ibuf == NULL) return false;
|
||||
|
||||
if (ibuf->encodedbuffersize < ibuf->encodedsize) {
|
||||
printf("imb_enlargeencodedbufferImBuf: error in parameters\n");
|
||||
return FALSE;
|
||||
printf("%s: error in parameters\n", __func__);
|
||||
return false;
|
||||
}
|
||||
|
||||
newsize = 2 * ibuf->encodedbuffersize;
|
||||
if (newsize < 10000) newsize = 10000;
|
||||
|
||||
newbuffer = MEM_mallocN(newsize, "enlargeencodedbufferImBuf");
|
||||
if (newbuffer == NULL) return FALSE;
|
||||
newbuffer = MEM_mallocN(newsize, __func__);
|
||||
if (newbuffer == NULL) return false;
|
||||
|
||||
if (ibuf->encodedbuffer) {
|
||||
memcpy(newbuffer, ibuf->encodedbuffer, ibuf->encodedsize);
|
||||
@@ -286,14 +286,14 @@ short imb_enlargeencodedbufferImBuf(ImBuf *ibuf)
|
||||
ibuf->mall |= IB_mem;
|
||||
ibuf->flags |= IB_mem;
|
||||
|
||||
return TRUE;
|
||||
return true;
|
||||
}
|
||||
|
||||
short imb_addrectfloatImBuf(ImBuf *ibuf)
|
||||
bool imb_addrectfloatImBuf(ImBuf *ibuf)
|
||||
{
|
||||
size_t size;
|
||||
|
||||
if (ibuf == NULL) return FALSE;
|
||||
if (ibuf == NULL) return false;
|
||||
|
||||
if (ibuf->rect_float)
|
||||
imb_freerectfloatImBuf(ibuf); /* frees mipmap too, hrm */
|
||||
@@ -304,18 +304,18 @@ short imb_addrectfloatImBuf(ImBuf *ibuf)
|
||||
if ((ibuf->rect_float = MEM_mapallocN(size, __func__))) {
|
||||
ibuf->mall |= IB_rectfloat;
|
||||
ibuf->flags |= IB_rectfloat;
|
||||
return TRUE;
|
||||
return true;
|
||||
}
|
||||
|
||||
return FALSE;
|
||||
return false;
|
||||
}
|
||||
|
||||
/* question; why also add zbuf? */
|
||||
short imb_addrectImBuf(ImBuf *ibuf)
|
||||
bool imb_addrectImBuf(ImBuf *ibuf)
|
||||
{
|
||||
size_t size;
|
||||
|
||||
if (ibuf == NULL) return FALSE;
|
||||
if (ibuf == NULL) return false;
|
||||
|
||||
/* don't call imb_freerectImBuf, it frees mipmaps, this call is used only too give float buffers display */
|
||||
if (ibuf->rect && (ibuf->mall & IB_rect))
|
||||
@@ -327,16 +327,20 @@ short imb_addrectImBuf(ImBuf *ibuf)
|
||||
if ((ibuf->rect = MEM_mapallocN(size, __func__))) {
|
||||
ibuf->mall |= IB_rect;
|
||||
ibuf->flags |= IB_rect;
|
||||
if (ibuf->planes > 32) return (addzbufImBuf(ibuf));
|
||||
else return TRUE;
|
||||
if (ibuf->planes > 32) {
|
||||
return (addzbufImBuf(ibuf));
|
||||
}
|
||||
else {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
return FALSE;
|
||||
return false;
|
||||
}
|
||||
|
||||
short imb_addtilesImBuf(ImBuf *ibuf)
|
||||
bool imb_addtilesImBuf(ImBuf *ibuf)
|
||||
{
|
||||
if (ibuf == NULL) return FALSE;
|
||||
if (ibuf == NULL) return false;
|
||||
|
||||
if (!ibuf->tiles)
|
||||
if ((ibuf->tiles = MEM_callocN(sizeof(unsigned int *) * ibuf->xtiles * ibuf->ytiles, "imb_tiles")))
|
||||
@@ -360,28 +364,28 @@ ImBuf *IMB_allocImBuf(unsigned int x, unsigned int y, uchar planes, unsigned int
|
||||
ibuf->ppm[0] = ibuf->ppm[1] = IMB_DPI_DEFAULT / 0.0254f; /* IMB_DPI_DEFAULT -> pixels-per-meter */
|
||||
|
||||
if (flags & IB_rect) {
|
||||
if (imb_addrectImBuf(ibuf) == FALSE) {
|
||||
if (imb_addrectImBuf(ibuf) == false) {
|
||||
IMB_freeImBuf(ibuf);
|
||||
return NULL;
|
||||
}
|
||||
}
|
||||
|
||||
if (flags & IB_rectfloat) {
|
||||
if (imb_addrectfloatImBuf(ibuf) == FALSE) {
|
||||
if (imb_addrectfloatImBuf(ibuf) == false) {
|
||||
IMB_freeImBuf(ibuf);
|
||||
return NULL;
|
||||
}
|
||||
}
|
||||
|
||||
if (flags & IB_zbuf) {
|
||||
if (addzbufImBuf(ibuf) == FALSE) {
|
||||
if (addzbufImBuf(ibuf) == false) {
|
||||
IMB_freeImBuf(ibuf);
|
||||
return NULL;
|
||||
}
|
||||
}
|
||||
|
||||
if (flags & IB_zbuffloat) {
|
||||
if (addzbuffloatImBuf(ibuf) == FALSE) {
|
||||
if (addzbuffloatImBuf(ibuf) == false) {
|
||||
IMB_freeImBuf(ibuf);
|
||||
return NULL;
|
||||
}
|
||||
@@ -420,7 +424,7 @@ ImBuf *IMB_dupImBuf(ImBuf *ibuf1)
|
||||
|
||||
if (ibuf1->encodedbuffer) {
|
||||
ibuf2->encodedbuffersize = ibuf1->encodedbuffersize;
|
||||
if (imb_addencodedbufferImBuf(ibuf2) == FALSE) {
|
||||
if (imb_addencodedbufferImBuf(ibuf2) == false) {
|
||||
IMB_freeImBuf(ibuf2);
|
||||
return NULL;
|
||||
}
|
||||
|
||||
@@ -63,21 +63,21 @@ void IMB_metadata_free(struct ImBuf *img)
|
||||
}
|
||||
}
|
||||
|
||||
int IMB_metadata_get_field(struct ImBuf *img, const char *key, char *field, const size_t len)
|
||||
bool IMB_metadata_get_field(struct ImBuf *img, const char *key, char *field, const size_t len)
|
||||
{
|
||||
ImMetaData *info;
|
||||
int retval = 0;
|
||||
bool retval = false;
|
||||
|
||||
if (!img)
|
||||
return 0;
|
||||
return false;
|
||||
if (!img->metadata) {
|
||||
return 0;
|
||||
return false;
|
||||
}
|
||||
info = img->metadata;
|
||||
while (info) {
|
||||
if (strcmp(key, info->key) == 0) {
|
||||
BLI_strncpy(field, info->value, len);
|
||||
retval = 1;
|
||||
retval = true;
|
||||
break;
|
||||
}
|
||||
info = info->next;
|
||||
@@ -85,13 +85,13 @@ int IMB_metadata_get_field(struct ImBuf *img, const char *key, char *field, cons
|
||||
return retval;
|
||||
}
|
||||
|
||||
int IMB_metadata_add_field(struct ImBuf *img, const char *key, const char *value)
|
||||
bool IMB_metadata_add_field(struct ImBuf *img, const char *key, const char *value)
|
||||
{
|
||||
ImMetaData *info;
|
||||
ImMetaData *last;
|
||||
|
||||
if (!img)
|
||||
return 0;
|
||||
return false;
|
||||
|
||||
if (!img->metadata) {
|
||||
img->metadata = MEM_callocN(sizeof(ImMetaData), "ImMetaData");
|
||||
@@ -109,15 +109,15 @@ int IMB_metadata_add_field(struct ImBuf *img, const char *key, const char *value
|
||||
}
|
||||
info->key = BLI_strdup(key);
|
||||
info->value = BLI_strdup(value);
|
||||
return 1;
|
||||
return true;
|
||||
}
|
||||
|
||||
int IMB_metadata_del_field(struct ImBuf *img, const char *key)
|
||||
bool IMB_metadata_del_field(struct ImBuf *img, const char *key)
|
||||
{
|
||||
ImMetaData *p, *p1;
|
||||
|
||||
if ((!img) || (!img->metadata))
|
||||
return (0);
|
||||
return false;
|
||||
|
||||
p = img->metadata;
|
||||
p1 = NULL;
|
||||
@@ -131,20 +131,20 @@ int IMB_metadata_del_field(struct ImBuf *img, const char *key)
|
||||
MEM_freeN(p->key);
|
||||
MEM_freeN(p->value);
|
||||
MEM_freeN(p);
|
||||
return (1);
|
||||
return true;
|
||||
}
|
||||
p1 = p;
|
||||
p = p->next;
|
||||
}
|
||||
return (0);
|
||||
return false;
|
||||
}
|
||||
|
||||
int IMB_metadata_change_field(struct ImBuf *img, const char *key, const char *field)
|
||||
bool IMB_metadata_change_field(struct ImBuf *img, const char *key, const char *field)
|
||||
{
|
||||
ImMetaData *p;
|
||||
|
||||
if (!img)
|
||||
return (0);
|
||||
return false;
|
||||
|
||||
if (!img->metadata)
|
||||
return (IMB_metadata_add_field(img, key, field));
|
||||
@@ -154,7 +154,7 @@ int IMB_metadata_change_field(struct ImBuf *img, const char *key, const char *fi
|
||||
if (!strcmp(key, p->key)) {
|
||||
MEM_freeN(p->value);
|
||||
p->value = BLI_strdup(field);
|
||||
return (1);
|
||||
return true;
|
||||
}
|
||||
p = p->next;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user