[Bf-blender-cvs] [72ede30d0f9] master: Cleanup: pass const image data to IMB_ibImageFromMemory

Campbell Barton noreply at git.blender.org
Sun Mar 24 23:13:31 CET 2019


Commit: 72ede30d0f970fe7d6774ce0851e3aacc82e23d8
Author: Campbell Barton
Date:   Mon Mar 25 09:08:29 2019 +1100
Branches: master
https://developer.blender.org/rB72ede30d0f970fe7d6774ce0851e3aacc82e23d8

Cleanup: pass const image data to IMB_ibImageFromMemory

===================================================================

M	source/blender/editors/interface/interface_icons.c
M	source/blender/editors/space_file/filelist.c
M	source/blender/imbuf/IMB_imbuf.h
M	source/blender/imbuf/intern/anim_movie.c
M	source/blender/imbuf/intern/readimage.c
M	source/blender/windowmanager/intern/wm_operators.c
M	source/blender/windowmanager/intern/wm_playanim.c

===================================================================

diff --git a/source/blender/editors/interface/interface_icons.c b/source/blender/editors/interface/interface_icons.c
index ae9ee152d0f..8606779d5fd 100644
--- a/source/blender/editors/interface/interface_icons.c
+++ b/source/blender/editors/interface/interface_icons.c
@@ -92,7 +92,7 @@ typedef struct IconImage {
 	int w;
 	int h;
 	uint *rect;
-	uchar *datatoc_rect;
+	const uchar *datatoc_rect;
 	int datatoc_size;
 } IconImage;
 
@@ -719,13 +719,13 @@ static void init_internal_icons(void)
 	}
 #endif
 	if (b16buf == NULL)
-		b16buf = IMB_ibImageFromMemory((uchar *)datatoc_blender_icons16_png,
+		b16buf = IMB_ibImageFromMemory((const uchar *)datatoc_blender_icons16_png,
 		                               datatoc_blender_icons16_png_size, IB_rect, NULL, "<blender icons>");
 	if (b16buf)
 		IMB_premultiply_alpha(b16buf);
 
 	if (b32buf == NULL)
-		b32buf = IMB_ibImageFromMemory((uchar *)datatoc_blender_icons32_png,
+		b32buf = IMB_ibImageFromMemory((const uchar *)datatoc_blender_icons32_png,
 		                               datatoc_blender_icons32_png_size, IB_rect, NULL, "<blender icons>");
 	if (b32buf)
 		IMB_premultiply_alpha(b32buf);
diff --git a/source/blender/editors/space_file/filelist.c b/source/blender/editors/space_file/filelist.c
index eec30adff10..623442b753a 100644
--- a/source/blender/editors/space_file/filelist.c
+++ b/source/blender/editors/space_file/filelist.c
@@ -787,7 +787,7 @@ void filelist_init_icons(void)
 #ifdef WITH_HEADLESS
 	bbuf = NULL;
 #else
-	bbuf = IMB_ibImageFromMemory((unsigned char *)datatoc_prvicons_png, datatoc_prvicons_png_size, IB_rect, NULL, "<splash>");
+	bbuf = IMB_ibImageFromMemory((const uchar *)datatoc_prvicons_png, datatoc_prvicons_png_size, IB_rect, NULL, "<splash>");
 #endif
 	if (bbuf) {
 		for (y = 0; y < SPECIAL_IMG_ROWS; y++) {
diff --git a/source/blender/imbuf/IMB_imbuf.h b/source/blender/imbuf/IMB_imbuf.h
index 81050841550..03d07844ec8 100644
--- a/source/blender/imbuf/IMB_imbuf.h
+++ b/source/blender/imbuf/IMB_imbuf.h
@@ -95,7 +95,9 @@ void IMB_exit(void);
  *
  * \attention Defined in readimage.c
  */
-struct ImBuf *IMB_ibImageFromMemory(unsigned char *mem, size_t size, int flags, char colorspace[IM_MAX_SPACE], const char *descr);
+struct ImBuf *IMB_ibImageFromMemory(
+        const unsigned char *mem, size_t size, int flags,
+        char colorspace[IM_MAX_SPACE], const char *descr);
 
 /**
  *
diff --git a/source/blender/imbuf/intern/anim_movie.c b/source/blender/imbuf/intern/anim_movie.c
index f5b3cab2024..43d91dc0d8e 100644
--- a/source/blender/imbuf/intern/anim_movie.c
+++ b/source/blender/imbuf/intern/anim_movie.c
@@ -425,7 +425,7 @@ static ImBuf *avi_fetchibuf(struct anim *anim, int position)
 		if (anim->pgf) {
 			lpbi = AVIStreamGetFrame(anim->pgf, position + AVIStreamStart(anim->pavi[anim->firstvideo]));
 			if (lpbi) {
-				ibuf = IMB_ibImageFromMemory((unsigned char *) lpbi, 100, IB_rect, anim->colorspace, "<avi_fetchibuf>");
+				ibuf = IMB_ibImageFromMemory((const unsigned char *) lpbi, 100, IB_rect, anim->colorspace, "<avi_fetchibuf>");
 //Oh brother...
 			}
 		}
diff --git a/source/blender/imbuf/intern/readimage.c b/source/blender/imbuf/intern/readimage.c
index feb75bed831..ad4e07030d1 100644
--- a/source/blender/imbuf/intern/readimage.c
+++ b/source/blender/imbuf/intern/readimage.c
@@ -92,7 +92,9 @@ static void imb_handle_alpha(ImBuf *ibuf, int flags, char colorspace[IM_MAX_SPAC
 	colormanage_imbuf_make_linear(ibuf, effective_colorspace);
 }
 
-ImBuf *IMB_ibImageFromMemory(unsigned char *mem, size_t size, int flags, char colorspace[IM_MAX_SPACE], const char *descr)
+ImBuf *IMB_ibImageFromMemory(
+        const unsigned char *mem, size_t size, int flags,
+        char colorspace[IM_MAX_SPACE], const char *descr)
 {
 	ImBuf *ibuf;
 	const ImFileType *type;
diff --git a/source/blender/windowmanager/intern/wm_operators.c b/source/blender/windowmanager/intern/wm_operators.c
index 8221dfdbaae..6f33bd62bcd 100644
--- a/source/blender/windowmanager/intern/wm_operators.c
+++ b/source/blender/windowmanager/intern/wm_operators.c
@@ -1426,11 +1426,11 @@ static uiBlock *wm_block_create_splash(bContext *C, ARegion *ar, void *UNUSED(ar
 
 #ifndef WITH_HEADLESS
 	if (U.dpi_fac > 1.0) {
-		ibuf = IMB_ibImageFromMemory((unsigned char *)datatoc_splash_2x_png,
+		ibuf = IMB_ibImageFromMemory((const uchar *)datatoc_splash_2x_png,
 		                             datatoc_splash_2x_png_size, IB_rect, NULL, "<splash screen>");
 	}
 	else {
-		ibuf = IMB_ibImageFromMemory((unsigned char *)datatoc_splash_png,
+		ibuf = IMB_ibImageFromMemory((const uchar *)datatoc_splash_png,
 		                             datatoc_splash_png_size, IB_rect, NULL, "<splash screen>");
 	}
 
diff --git a/source/blender/windowmanager/intern/wm_playanim.c b/source/blender/windowmanager/intern/wm_playanim.c
index a8d75ac8fdb..e6c73bf3bf7 100644
--- a/source/blender/windowmanager/intern/wm_playanim.c
+++ b/source/blender/windowmanager/intern/wm_playanim.c
@@ -228,7 +228,7 @@ static void playanim_event_qual_update(void)
 
 typedef struct PlayAnimPict {
 	struct PlayAnimPict *next, *prev;
-	char *mem;
+	uchar *mem;
 	int size;
 	const char *name;
 	struct ImBuf *ibuf;
@@ -380,7 +380,8 @@ static void playanim_toscreen(PlayState *ps, PlayAnimPict *picture, struct ImBuf
 
 static void build_pict_list_ex(PlayState *ps, const char *first, int totframes, int fstep, int fontid)
 {
-	char *mem, filepath[FILE_MAX];
+	char filepath[FILE_MAX];
+	uchar *mem;
 //	short val;
 	PlayAnimPict *picture = NULL;
 	struct ImBuf *ibuf = NULL;
@@ -465,7 +466,7 @@ static void build_pict_list_ex(PlayState *ps, const char *first, int totframes,
 			picture->IB_flags = IB_rect;
 
 			if (fromdisk == false) {
-				mem = (char *)MEM_mallocN(size, "build pic list");
+				mem = MEM_mallocN(size, "build pic list");
 				if (mem == NULL) {
 					printf("Couldn't get memory\n");
 					close(file);
@@ -497,7 +498,7 @@ static void build_pict_list_ex(PlayState *ps, const char *first, int totframes,
 			if (ptottime > 1.0) {
 				/* OCIO_TODO: support different input color space */
 				if (picture->mem) {
-					ibuf = IMB_ibImageFromMemory((unsigned char *)picture->mem, picture->size,
+					ibuf = IMB_ibImageFromMemory(picture->mem, picture->size,
 					                             picture->IB_flags, NULL, picture->name);
 				}
 				else {
@@ -1377,7 +1378,7 @@ static char *wm_main_playanim_intern(int argc, const char **argv)
 			}
 			else if (ps.picture->mem) {
 				/* use correct colorspace here */
-				ibuf = IMB_ibImageFromMemory((unsigned char *) ps.picture->mem, ps.picture->size,
+				ibuf = IMB_ibImageFromMemory(ps.picture->mem, ps.picture->size,
 				                             ps.picture->IB_flags, NULL, ps.picture->name);
 			}
 			else {



More information about the Bf-blender-cvs mailing list