[Bf-blender-cvs] SVN commit: /data/svn/bf-blender [59979] trunk/blender/source/blender: code cleanup: use bool for imbuf allocation functions.
Campbell Barton
ideasman42 at gmail.com
Tue Sep 10 03:00:05 CEST 2013
Revision: 59979
http://projects.blender.org/scm/viewvc.php?view=rev&root=bf-blender&revision=59979
Author: campbellbarton
Date: 2013-09-10 01:00:03 +0000 (Tue, 10 Sep 2013)
Log Message:
-----------
code cleanup: use bool for imbuf allocation functions.
Modified Paths:
--------------
trunk/blender/source/blender/editors/space_outliner/outliner_draw.c
trunk/blender/source/blender/editors/transform/transform_snap.c
trunk/blender/source/blender/imbuf/IMB_imbuf.h
trunk/blender/source/blender/imbuf/intern/IMB_allocimbuf.h
trunk/blender/source/blender/imbuf/intern/IMB_filetype.h
trunk/blender/source/blender/imbuf/intern/IMB_metadata.h
trunk/blender/source/blender/imbuf/intern/allocimbuf.c
trunk/blender/source/blender/imbuf/intern/metadata.c
Modified: trunk/blender/source/blender/editors/space_outliner/outliner_draw.c
===================================================================
--- trunk/blender/source/blender/editors/space_outliner/outliner_draw.c 2013-09-10 00:53:39 UTC (rev 59978)
+++ trunk/blender/source/blender/editors/space_outliner/outliner_draw.c 2013-09-10 01:00:03 UTC (rev 59979)
@@ -574,7 +574,7 @@
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);
Modified: trunk/blender/source/blender/editors/transform/transform_snap.c
===================================================================
--- trunk/blender/source/blender/editors/transform/transform_snap.c 2013-09-10 00:53:39 UTC (rev 59978)
+++ trunk/blender/source/blender/editors/transform/transform_snap.c 2013-09-10 01:00:03 UTC (rev 59979)
@@ -1671,7 +1671,8 @@
}
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);
}
Modified: trunk/blender/source/blender/imbuf/IMB_imbuf.h
===================================================================
--- trunk/blender/source/blender/imbuf/IMB_imbuf.h 2013-09-10 00:53:39 UTC (rev 59978)
+++ trunk/blender/source/blender/imbuf/IMB_imbuf.h 2013-09-10 01:00:03 UTC (rev 59979)
@@ -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 @@
*
* \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 @@
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 */
Modified: trunk/blender/source/blender/imbuf/intern/IMB_allocimbuf.h
===================================================================
--- trunk/blender/source/blender/imbuf/intern/IMB_allocimbuf.h 2013-09-10 00:53:39 UTC (rev 59978)
+++ trunk/blender/source/blender/imbuf/intern/IMB_allocimbuf.h 2013-09-10 01:00:03 UTC (rev 59979)
@@ -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
Modified: trunk/blender/source/blender/imbuf/intern/IMB_filetype.h
===================================================================
--- trunk/blender/source/blender/imbuf/intern/IMB_filetype.h 2013-09-10 00:53:39 UTC (rev 59978)
+++ trunk/blender/source/blender/imbuf/intern/IMB_filetype.h 2013-09-10 01:00:03 UTC (rev 59979)
@@ -94,7 +94,6 @@
/* 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);
Modified: trunk/blender/source/blender/imbuf/intern/IMB_metadata.h
===================================================================
--- trunk/blender/source/blender/imbuf/intern/IMB_metadata.h 2013-09-10 00:53:39 UTC (rev 59978)
+++ trunk/blender/source/blender/imbuf/intern/IMB_metadata.h 2013-09-10 01:00:03 UTC (rev 59979)
@@ -62,7 +62,7 @@
* \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 @@
* \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__ */
Modified: trunk/blender/source/blender/imbuf/intern/allocimbuf.c
===================================================================
--- trunk/blender/source/blender/imbuf/intern/allocimbuf.c 2013-09-10 00:53:39 UTC (rev 59978)
+++ trunk/blender/source/blender/imbuf/intern/allocimbuf.c 2013-09-10 01:00:03 UTC (rev 59979)
@@ -191,11 +191,11 @@
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 @@
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 @@
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 @@
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 @@
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 @@
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 @@
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 @@
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) {
@@ Diff output truncated at 10240 characters. @@
More information about the Bf-blender-cvs
mailing list