Welcome to mirror list, hosted at ThFree Co, Russian Federation.

git.blender.org/blender.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorCampbell Barton <ideasman42@gmail.com>2013-09-10 05:00:03 +0400
committerCampbell Barton <ideasman42@gmail.com>2013-09-10 05:00:03 +0400
commitfc6c283271f0193e5626b2439b311114022b284a (patch)
treee3d537d275b8b952fdccf3a79cbb83dd783b8d90
parentec388a2a15346bace87cccc7e4da0eff89014ebb (diff)
code cleanup: use bool for imbuf allocation functions.
-rw-r--r--source/blender/editors/space_outliner/outliner_draw.c2
-rw-r--r--source/blender/editors/transform/transform_snap.c3
-rw-r--r--source/blender/imbuf/IMB_imbuf.h18
-rw-r--r--source/blender/imbuf/intern/IMB_allocimbuf.h4
-rw-r--r--source/blender/imbuf/intern/IMB_filetype.h1
-rw-r--r--source/blender/imbuf/intern/IMB_metadata.h6
-rw-r--r--source/blender/imbuf/intern/allocimbuf.c76
-rw-r--r--source/blender/imbuf/intern/metadata.c30
8 files changed, 72 insertions, 68 deletions
diff --git a/source/blender/editors/space_outliner/outliner_draw.c b/source/blender/editors/space_outliner/outliner_draw.c
index 349d644310b..e9a3c48d8dc 100644
--- a/source/blender/editors/space_outliner/outliner_draw.c
+++ b/source/blender/editors/space_outliner/outliner_draw.c
@@ -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);
diff --git a/source/blender/editors/transform/transform_snap.c b/source/blender/editors/transform/transform_snap.c
index e2b81d794c7..4a208f6eee1 100644
--- a/source/blender/editors/transform/transform_snap.c
+++ b/source/blender/editors/transform/transform_snap.c
@@ -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);
}
diff --git a/source/blender/imbuf/IMB_imbuf.h b/source/blender/imbuf/IMB_imbuf.h
index 819026facc6..8c2e79ab7d8 100644
--- a/source/blender/imbuf/IMB_imbuf.h
+++ b/source/blender/imbuf/IMB_imbuf.h
@@ -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 */
diff --git a/source/blender/imbuf/intern/IMB_allocimbuf.h b/source/blender/imbuf/intern/IMB_allocimbuf.h
index 047228926ee..02b738cc2cd 100644
--- a/source/blender/imbuf/intern/IMB_allocimbuf.h
+++ b/source/blender/imbuf/intern/IMB_allocimbuf.h
@@ -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
diff --git a/source/blender/imbuf/intern/IMB_filetype.h b/source/blender/imbuf/intern/IMB_filetype.h
index 154941c5c09..3c8b29cf68a 100644
--- a/source/blender/imbuf/intern/IMB_filetype.h
+++ b/source/blender/imbuf/intern/IMB_filetype.h
@@ -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);
diff --git a/source/blender/imbuf/intern/IMB_metadata.h b/source/blender/imbuf/intern/IMB_metadata.h
index f731fd69620..a717764b44f 100644
--- a/source/blender/imbuf/intern/IMB_metadata.h
+++ b/source/blender/imbuf/intern/IMB_metadata.h
@@ -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__ */
diff --git a/source/blender/imbuf/intern/allocimbuf.c b/source/blender/imbuf/intern/allocimbuf.c
index 8593b785096..4dfeef5c502 100644
--- a/source/blender/imbuf/intern/allocimbuf.c
+++ b/source/blender/imbuf/intern/allocimbuf.c
@@ -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;
}
diff --git a/source/blender/imbuf/intern/metadata.c b/source/blender/imbuf/intern/metadata.c
index fed55c05eea..2b4367528dd 100644
--- a/source/blender/imbuf/intern/metadata.c
+++ b/source/blender/imbuf/intern/metadata.c
@@ -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;
}