[Bf-blender-cvs] [6171314] master: Fix T42008: Dragging and packing issue about new blank image

Sergey Sharybin noreply at git.blender.org
Thu Oct 2 15:07:11 CEST 2014


Commit: 617131410c74bc0291ede50803e5d9badff2a0c9
Author: Sergey Sharybin
Date:   Thu Oct 2 19:04:38 2014 +0600
Branches: master
https://developer.blender.org/rB617131410c74bc0291ede50803e5d9badff2a0c9

Fix T42008: Dragging and packing issue about new blank image

The issue was caused by the fact that we never used to store the
generated image color in DNA, so image reload will loose this
information.

Now we store the color in DNA, making ti so re-loading the image
will preserve it's generated color.

It is now also possible to change generated image color using the
color swatch in image properties after the image was created.

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

M	source/blender/blenkernel/intern/image.c
M	source/blender/blenloader/intern/versioning_270.c
M	source/blender/editors/space_image/image_buttons.c
M	source/blender/makesdna/DNA_image_types.h
M	source/blender/makesrna/intern/rna_image.c

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

diff --git a/source/blender/blenkernel/intern/image.c b/source/blender/blenkernel/intern/image.c
index b57d014..5c673ee 100644
--- a/source/blender/blenkernel/intern/image.c
+++ b/source/blender/blenkernel/intern/image.c
@@ -62,6 +62,7 @@
 #include "DNA_meshdata_types.h"
 
 #include "BLI_blenlib.h"
+#include "BLI_math_vector.h"
 #include "BLI_threads.h"
 #include "BLI_timecode.h"  /* for stamp timecode format */
 #include "BLI_utildefines.h"
@@ -365,6 +366,7 @@ Image *BKE_image_copy(Main *bmain, Image *ima)
 	nima->gen_x = ima->gen_x;
 	nima->gen_y = ima->gen_y;
 	nima->gen_type = ima->gen_type;
+	copy_v4_v4(nima->gen_color, ima->gen_color);
 
 	nima->animspeed = ima->animspeed;
 
@@ -769,6 +771,7 @@ Image *BKE_image_add_generated(Main *bmain, unsigned int width, unsigned int hei
 		ima->gen_type = gen_type;
 		ima->gen_flag |= (floatbuf ? IMA_GEN_FLOAT : 0);
 		ima->gen_depth = depth;
+		copy_v4_v4(ima->gen_color, color);
 
 		ibuf = add_ibuf_size(width, height, ima->name, depth, floatbuf, gen_type, color, &ima->colorspace_settings);
 		image_assign_ibuf(ima, ibuf, IMA_NO_INDEX, 0);
@@ -2996,7 +2999,6 @@ BLI_INLINE bool image_quick_test(Image *ima, ImageUser *iuser)
 static ImBuf *image_acquire_ibuf(Image *ima, ImageUser *iuser, void **lock_r)
 {
 	ImBuf *ibuf = NULL;
-	float color[] = {0, 0, 0, 1};
 	int frame = 0, index = 0;
 
 	if (lock_r)
@@ -3041,7 +3043,7 @@ static ImBuf *image_acquire_ibuf(Image *ima, ImageUser *iuser, void **lock_r)
 			if (ima->gen_y == 0) ima->gen_y = 1024;
 			if (ima->gen_depth == 0) ima->gen_depth = 24;
 			ibuf = add_ibuf_size(ima->gen_x, ima->gen_y, ima->name, ima->gen_depth, (ima->gen_flag & IMA_GEN_FLOAT) != 0, ima->gen_type,
-			                     color, &ima->colorspace_settings);
+			                     ima->gen_color, &ima->colorspace_settings);
 			image_assign_ibuf(ima, ibuf, IMA_NO_INDEX, 0);
 			ima->ok = IMA_OK_LOADED;
 		}
diff --git a/source/blender/blenloader/intern/versioning_270.c b/source/blender/blenloader/intern/versioning_270.c
index b2a29e9..4fd033c 100644
--- a/source/blender/blenloader/intern/versioning_270.c
+++ b/source/blender/blenloader/intern/versioning_270.c
@@ -390,4 +390,11 @@ void blo_do_versions_270(FileData *fd, Library *UNUSED(lib), Main *main)
 			}
 		}
 	}
+
+	if (!DNA_struct_elem_find(fd->filesdna, "Image", "float", "gen_color")) {
+		Image *image;
+		for (image = main->image.first; image != NULL; image = image->id.next) {
+			image->gen_color[3] - 1.0f;
+		}
+	}
 }
diff --git a/source/blender/editors/space_image/image_buttons.c b/source/blender/editors/space_image/image_buttons.c
index 7e90008..ed6e6ba 100644
--- a/source/blender/editors/space_image/image_buttons.c
+++ b/source/blender/editors/space_image/image_buttons.c
@@ -809,6 +809,10 @@ void uiTemplateImage(uiLayout *layout, bContext *C, PointerRNA *ptr, const char
 				uiItemR(col, &imaptr, "use_generated_float", 0, NULL, ICON_NONE);
 
 				uiItemR(split, &imaptr, "generated_type", UI_ITEM_R_EXPAND, NULL, ICON_NONE);
+
+				if (ima->gen_type == IMA_GENTYPE_BLANK) {
+					uiItemR(layout, &imaptr, "generated_color", 0, NULL, ICON_NONE);
+				}
 			}
 
 		}
diff --git a/source/blender/makesdna/DNA_image_types.h b/source/blender/makesdna/DNA_image_types.h
index 0b9dddd..b66772f 100644
--- a/source/blender/makesdna/DNA_image_types.h
+++ b/source/blender/makesdna/DNA_image_types.h
@@ -109,6 +109,7 @@ typedef struct Image {
 	int gen_x, gen_y;
 	char gen_type, gen_flag;
 	short gen_depth;
+	float gen_color[4];
 	
 	/* display aspect - for UV editing images resized for faster openGL display */
 	float aspx, aspy;
diff --git a/source/blender/makesrna/intern/rna_image.c b/source/blender/makesrna/intern/rna_image.c
index 0b129ba..90c9cd1 100644
--- a/source/blender/makesrna/intern/rna_image.c
+++ b/source/blender/makesrna/intern/rna_image.c
@@ -589,6 +589,13 @@ static void rna_def_image(BlenderRNA *brna)
 	RNA_def_property_update(prop, NC_IMAGE | ND_DISPLAY, "rna_Image_generated_update");
 	RNA_def_property_clear_flag(prop, PROP_ANIMATABLE);
 
+	prop = RNA_def_property(srna, "generated_color", PROP_FLOAT, PROP_COLOR);
+	RNA_def_property_float_sdna(prop, NULL, "gen_color");
+	RNA_def_property_array(prop, 4);
+	RNA_def_property_ui_text(prop, "Color", "Fill color for the generated image");
+	RNA_def_property_update(prop, NC_IMAGE | ND_DISPLAY, "rna_Image_generated_update");
+	RNA_def_property_clear_flag(prop, PROP_ANIMATABLE);
+
 	/* realtime properties */
 	prop = RNA_def_property(srna, "mapping", PROP_ENUM, PROP_NONE);
 	RNA_def_property_enum_bitflag_sdna(prop, NULL, "flag");




More information about the Bf-blender-cvs mailing list