[Bf-blender-cvs] [9697d13] multiview: Removing the need of Scene for image packing operator

Dalai Felinto noreply at git.blender.org
Fri Mar 6 21:53:55 CET 2015


Commit: 9697d1375feffda2a8973526c16ce13765589a09
Author: Dalai Felinto
Date:   Fri Mar 6 17:40:09 2015 -0300
Branches: multiview
https://developer.blender.org/rB9697d1375feffda2a8973526c16ce13765589a09

Removing the need of Scene for image packing operator

The scene was originally used to determine the suffices of the packed
image. This was only used when the packed image was a Stereo3D image,
and packed as PNG.

We now resort to the default suggested _L, _R suffices for this case.

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

M	source/blender/blenkernel/BKE_image.h
M	source/blender/blenkernel/intern/image.c
M	source/blender/blenkernel/intern/scene.c
M	source/blender/blenloader/intern/versioning_270.c
M	source/blender/editors/space_image/image_ops.c
M	source/blender/makesdna/DNA_scene_types.h
M	source/blender/makesrna/intern/rna_image_api.c

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

diff --git a/source/blender/blenkernel/BKE_image.h b/source/blender/blenkernel/BKE_image.h
index 29ab6df..475f2a2 100644
--- a/source/blender/blenkernel/BKE_image.h
+++ b/source/blender/blenkernel/BKE_image.h
@@ -226,7 +226,7 @@ void    BKE_image_free_anim_ibufs(struct Image *ima, int except_frame);
 /* does all images with type MOVIE or SEQUENCE */
 void BKE_image_all_free_anim_ibufs(int except_frame);
 
-void BKE_image_memorypack(struct Scene *scene, struct Image *ima);
+void BKE_image_memorypack(struct Image *ima);
 void BKE_image_packfiles(struct ReportList *reports, struct Image *ima, const char *basepath);
 
 /* prints memory statistics for images */
diff --git a/source/blender/blenkernel/intern/image.c b/source/blender/blenkernel/intern/image.c
index c3b794e..501a4cf 100644
--- a/source/blender/blenkernel/intern/image.c
+++ b/source/blender/blenkernel/intern/image.c
@@ -902,11 +902,10 @@ Image *BKE_image_add_from_imbuf(ImBuf *ibuf)
 /* packs rects from memory as PNG
  * convert multiview images to R_IMF_VIEWS_INDIVIDUAL
  */
-static void image_memorypack_multiview(Scene *scene, Image *ima)
+static void image_memorypack_multiview(Image *ima)
 {
 	ImageView *iv;
 	size_t i;
-	const size_t totfiles = image_num_files(ima);
 
 	image_free_packedfiles(ima);
 
@@ -916,10 +915,11 @@ static void image_memorypack_multiview(Scene *scene, Image *ima)
 		ibuf->ftype = PNG;
 		ibuf->planes = R_IMF_PLANES_RGBA;
 
-		/* if the image was a R_IMF_VIEWS_STEREO_3D we need to create
-		 *  new names for the new individual views */
-		if (totfiles == 1)
-			BKE_scene_view_filepath_get(&scene->r, ima->name, iv->name, iv->filepath);
+		/* if the image was a R_IMF_VIEWS_STEREO_3D we force _L, _R suffices */
+		if (ima->stereo3d_format == R_IMF_VIEWS_STEREO_3D) {
+			const char *suffix[2] = {STEREO_LEFT_SUFFIX, STEREO_RIGHT_SUFFIX};
+			BLI_path_suffix(iv->filepath, FILE_MAX, suffix[i], "");
+		}
 
 		IMB_saveiff(ibuf, iv->filepath, IB_rect | IB_mem);
 
@@ -956,12 +956,12 @@ static void image_memorypack_multiview(Scene *scene, Image *ima)
 }
 
 /* packs rect from memory as PNG */
-void BKE_image_memorypack(Scene *scene, Image *ima)
+void BKE_image_memorypack(Image *ima)
 {
 	ImBuf *ibuf;
 
 	if ((ima->flag & IMA_IS_MULTIVIEW))
-		return image_memorypack_multiview(scene, ima);
+		return image_memorypack_multiview(ima);
 
 	ibuf = image_get_cached_ibuf_for_index_frame(ima, IMA_NO_INDEX, 0);
 
diff --git a/source/blender/blenkernel/intern/scene.c b/source/blender/blenkernel/intern/scene.c
index 690db39..1439c16 100644
--- a/source/blender/blenkernel/intern/scene.c
+++ b/source/blender/blenkernel/intern/scene.c
@@ -638,11 +638,11 @@ Scene *BKE_scene_add(Main *bmain, const char *name)
 	/* multiview - stereo */
 	BKE_scene_add_render_view(sce, STEREO_LEFT_NAME);
 	srv = (SceneRenderView *)sce->r.views.first;
-	BLI_strncpy(srv->suffix, "_L", sizeof(srv->suffix));
+	BLI_strncpy(srv->suffix, STEREO_LEFT_SUFFIX, sizeof(srv->suffix));
 
 	BKE_scene_add_render_view(sce, STEREO_RIGHT_NAME);
 	srv = (SceneRenderView *)sce->r.views.last;
-	BLI_strncpy(srv->suffix, "_R", sizeof(srv->suffix));
+	BLI_strncpy(srv->suffix, STEREO_RIGHT_SUFFIX, sizeof(srv->suffix));
 
 	/* game data */
 	sce->gm.stereoflag = STEREO_NOSTEREO;
diff --git a/source/blender/blenloader/intern/versioning_270.c b/source/blender/blenloader/intern/versioning_270.c
index e6a86c6..e497f7c 100644
--- a/source/blender/blenloader/intern/versioning_270.c
+++ b/source/blender/blenloader/intern/versioning_270.c
@@ -476,11 +476,11 @@ void blo_do_versions_270(FileData *fd, Library *UNUSED(lib), Main *main)
 			for (scene = main->scene.first; scene; scene = scene->id.next) {
 				BKE_scene_add_render_view(scene, STEREO_LEFT_NAME);
 				srv = (SceneRenderView *)scene->r.views.first;
-				BLI_strncpy(srv->suffix, "_L", sizeof(srv->suffix));
+				BLI_strncpy(srv->suffix, STEREO_LEFT_SUFFIX, sizeof(srv->suffix));
 
 				BKE_scene_add_render_view(scene, STEREO_RIGHT_NAME);
 				srv = (SceneRenderView *)scene->r.views.last;
-				BLI_strncpy(srv->suffix, "_R", sizeof(srv->suffix));
+				BLI_strncpy(srv->suffix, STEREO_RIGHT_SUFFIX, sizeof(srv->suffix));
 			}
 		}
 
diff --git a/source/blender/editors/space_image/image_ops.c b/source/blender/editors/space_image/image_ops.c
index 043c199..1a2e50b 100644
--- a/source/blender/editors/space_image/image_ops.c
+++ b/source/blender/editors/space_image/image_ops.c
@@ -2555,7 +2555,6 @@ static bool image_pack_test(bContext *C, wmOperator *op)
 static int image_pack_exec(bContext *C, wmOperator *op)
 {
 	struct Main *bmain = CTX_data_main(C);
-	Scene *scene = CTX_data_scene(C);
 	Image *ima = CTX_data_edit_image(C);
 	ImBuf *ibuf = BKE_image_acquire_ibuf(ima, NULL, NULL);
 	const bool as_png = RNA_boolean_get(op->ptr, "as_png");
@@ -2569,7 +2568,7 @@ static int image_pack_exec(bContext *C, wmOperator *op)
 	}
 
 	if (as_png)
-		BKE_image_memorypack(scene, ima);
+		BKE_image_memorypack(ima);
 	else
 		BKE_image_packfiles(op->reports, ima, ID_BLEND_PATH(bmain, &ima->id));
 
diff --git a/source/blender/makesdna/DNA_scene_types.h b/source/blender/makesdna/DNA_scene_types.h
index 79af5af..f75f4d0 100644
--- a/source/blender/makesdna/DNA_scene_types.h
+++ b/source/blender/makesdna/DNA_scene_types.h
@@ -880,6 +880,8 @@ enum {
 /* Stereo Flags */
 #define STEREO_RIGHT_NAME "right"
 #define STEREO_LEFT_NAME "left"
+#define STEREO_RIGHT_SUFFIX "_R"
+#define STEREO_LEFT_SUFFIX "_L"
 
 typedef enum StereoViews {
 	STEREO_LEFT_ID = 0,
diff --git a/source/blender/makesrna/intern/rna_image_api.c b/source/blender/makesrna/intern/rna_image_api.c
index 9b559c8..c3644c6 100644
--- a/source/blender/makesrna/intern/rna_image_api.c
+++ b/source/blender/makesrna/intern/rna_image_api.c
@@ -146,7 +146,6 @@ static void rna_Image_pack(
         Image *image, Main *bmain, bContext *C, ReportList *reports,
         int as_png, const char *data, int data_len)
 {
-	Scene *scene = CTX_data_scene(C);
 	ImBuf *ibuf = BKE_image_acquire_ibuf(image, NULL, NULL);
 
 	if (!as_png && (ibuf && (ibuf->userflags & IB_BITMAPDIRTY))) {
@@ -158,7 +157,7 @@ static void rna_Image_pack(
 			image->packedfile = NULL;
 		}
 		if (as_png) {
-			BKE_image_memorypack(scene, image);
+			BKE_image_memorypack(image);
 		}
 		else if (data) {
 			char *data_dup = MEM_mallocN(sizeof(*data_dup) * (size_t)data_len, __func__);




More information about the Bf-blender-cvs mailing list