[Bf-blender-cvs] [67fcf52] master: Move allocation of imbuf from array to allocimbuf. Skip allocation of temporary imbuf

Antony Riakiotakis noreply at git.blender.org
Mon Feb 23 17:24:41 CET 2015


Commit: 67fcf5256d81ce7e80ab1f4c75fb81b43e634301
Author: Antony Riakiotakis
Date:   Mon Feb 23 17:19:06 2015 +0100
Branches: master
https://developer.blender.org/rB67fcf5256d81ce7e80ab1f4c75fb81b43e634301

Move allocation of imbuf from array to allocimbuf.
Skip allocation of temporary imbuf

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

M	source/blender/imbuf/IMB_imbuf.h
M	source/blender/imbuf/intern/allocimbuf.c
M	source/blender/imbuf/intern/scaling.c

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

diff --git a/source/blender/imbuf/IMB_imbuf.h b/source/blender/imbuf/IMB_imbuf.h
index 299918a..447a14b 100644
--- a/source/blender/imbuf/IMB_imbuf.h
+++ b/source/blender/imbuf/IMB_imbuf.h
@@ -126,6 +126,13 @@ struct ImBuf *IMB_allocImBuf(unsigned int x, unsigned int y,
                              unsigned char d, unsigned int flags);
 
 /**
+ * Create a copy of a pixel buffer and wrap it to a new ImBuf
+ * \attention Defined in allocimbuf.c
+ */
+struct ImBuf *IMB_allocFromBuffer(const unsigned int *rect, const float *rectf,
+                                  unsigned int w, unsigned int h);
+
+/**
  *
  * Increase reference count to imbuf
  * (to delete an imbuf you have to call freeImBuf as many times as it
@@ -353,13 +360,6 @@ struct ImBuf *IMB_onehalf(struct ImBuf *ibuf1);
 struct ImBuf *IMB_scaleImBuf(struct ImBuf *ibuf, unsigned int newx, unsigned int newy);
 
 /**
- * Create a copy of a pixel buffer and wrap it to a new ImBuf
- * \attention Defined in scaling.c
- */
-struct ImBuf *IMB_allocFromBuffer(const unsigned int *rect, const float *frect,
-                                  unsigned int w, unsigned int h);
-
-/**
  *
  * \attention Defined in scaling.c
  */
diff --git a/source/blender/imbuf/intern/allocimbuf.c b/source/blender/imbuf/intern/allocimbuf.c
index 556c4be..b28d19e 100644
--- a/source/blender/imbuf/intern/allocimbuf.c
+++ b/source/blender/imbuf/intern/allocimbuf.c
@@ -362,6 +362,30 @@ bool imb_addrectImBuf(ImBuf *ibuf)
 	return false;
 }
 
+struct ImBuf *IMB_allocFromBuffer(const unsigned int *rect, const float *rectf,
+                                  unsigned int w, unsigned int h)
+{
+	ImBuf *ibuf = NULL;
+
+	if (!(rect || rectf))
+		return NULL;
+
+	ibuf = IMB_allocImBuf(w, h, 32, 0);
+
+	if (rectf) {
+		ibuf->rect_float = MEM_dupallocN(rectf);
+		ibuf->flags |= IB_rectfloat;
+		ibuf->mall |= IB_rectfloat;
+	}
+	if (rect) {
+		ibuf->rect = MEM_dupallocN(rect);
+		ibuf->flags |= IB_rect;
+		ibuf->mall |= IB_rect;
+	}
+
+	return ibuf;
+}
+
 bool imb_addtilesImBuf(ImBuf *ibuf)
 {
 	if (ibuf == NULL) return false;
diff --git a/source/blender/imbuf/intern/scaling.c b/source/blender/imbuf/intern/scaling.c
index f750421..2601fe6 100644
--- a/source/blender/imbuf/intern/scaling.c
+++ b/source/blender/imbuf/intern/scaling.c
@@ -1545,34 +1545,6 @@ struct ImBuf *IMB_scaleImBuf(struct ImBuf *ibuf, unsigned int newx, unsigned int
 	return(ibuf);
 }
 
-struct ImBuf *IMB_allocFromBuffer(const unsigned int *rect, const float *frect,
-                                  unsigned int w, unsigned int h)
-{
-	ImBuf *ibuf = NULL;
-	ImBuf *tmpibuf = IMB_allocImBuf(w, h, 32, 0);
-
-	if (frect) {
-		/* allocate new image buffer and set the temporary buffer float buffer correctly */
-		ibuf = IMB_allocImBuf(w, h, 32, IB_rectfloat);
-		tmpibuf->rect_float = (float *)frect;
-
-		IMB_rectcpy(ibuf, tmpibuf, 0, 0, 0, 0, w, h);
-	}
-	else if (rect) {
-		ibuf = IMB_allocImBuf(w, h, 32, IB_rect);
-		tmpibuf->rect = (unsigned int *)rect;
-
-		IMB_rectcpy(ibuf, tmpibuf, 0, 0, 0, 0, w, h);
-	}
-
-	/* important, else we clean the source image imbufs! */
-	tmpibuf->rect_float = NULL;
-	tmpibuf->rect = NULL;
-	IMB_freeImBuf(tmpibuf);
-
-	return ibuf;
-}
-
 struct imbufRGBA {
 	float r, g, b, a;
 };




More information about the Bf-blender-cvs mailing list