Commit: 2a3e7ee2641d4f33a707a69850e7ab456af67547 Author: Ines Almeida Date: Fri Apr 17 09:57:41 2015 +0100 Branches: ui-preview-buttons https://developer.blender.org/rB2a3e7ee2641d4f33a707a69850e7ab456af67547
ImagePreview: merging changed and user_edited into a single flag =================================================================== M source/blender/blenkernel/intern/icons.c M source/blender/editors/interface/interface_icons.c M source/blender/makesdna/DNA_ID.h M source/blender/makesrna/intern/rna_ID.c =================================================================== diff --git a/source/blender/blenkernel/intern/icons.c b/source/blender/blenkernel/intern/icons.c index dbf2935..dd85565 100644 --- a/source/blender/blenkernel/intern/icons.c +++ b/source/blender/blenkernel/intern/icons.c @@ -131,7 +131,7 @@ PreviewImage *BKE_previewimg_create(void) prv_img = MEM_callocN(sizeof(PreviewImage), "img_prv"); for (i = 0; i < NUM_ICON_SIZES; ++i) { - prv_img->changed[i] = 1; + prv_img->flag[i] |= CHANGED; prv_img->changed_timestamp[i] = 0; } return prv_img; @@ -151,7 +151,7 @@ PreviewImage *BKE_previewimg_thumbnail_create(const char *path, int source) prv->w[ICON_SIZE_PREVIEW] = thumb->x; prv->h[ICON_SIZE_PREVIEW] = thumb->y; prv->rect[ICON_SIZE_PREVIEW] = MEM_dupallocN(thumb->rect); - prv->changed[ICON_SIZE_PREVIEW] = 0; + prv->flag[ICON_SIZE_PREVIEW] &= ~CHANGED; if (thumb->x > thumb->y) { icon_w = ICON_RENDER_DEFAULT_HEIGHT; @@ -169,7 +169,7 @@ PreviewImage *BKE_previewimg_thumbnail_create(const char *path, int source) prv->w[ICON_SIZE_ICON] = icon_w; prv->h[ICON_SIZE_ICON] = icon_h; prv->rect[ICON_SIZE_ICON] = MEM_dupallocN(thumb->rect); - prv->changed[ICON_SIZE_ICON] = 0; + prv->flag[ICON_SIZE_ICON] &= ~CHANGED; IMB_freeImBuf(thumb); } @@ -213,7 +213,7 @@ void BKE_previewimg_clear(struct PreviewImage *prv, enum eIconSizes size) GPU_texture_free(prv->gputexture[size]); } prv->h[size] = prv->w[size] = 0; - prv->changed[size] = true; + prv->flag[size] |= CHANGED; prv->changed_timestamp[size] = 0; } @@ -318,7 +318,7 @@ void BKE_icon_changed(int id) if (prv) { int i; for (i = 0; i < NUM_ICON_SIZES; ++i) { - prv->changed[i] = 1; + prv->flag[i] |= CHANGED; prv->changed_timestamp[i]++; } } diff --git a/source/blender/editors/interface/interface_icons.c b/source/blender/editors/interface/interface_icons.c index 6a12031..d63df03 100644 --- a/source/blender/editors/interface/interface_icons.c +++ b/source/blender/editors/interface/interface_icons.c @@ -923,7 +923,7 @@ static void icon_create_rect(struct PreviewImage *prv_img, enum eIconSizes size) else if (!prv_img->rect[size]) { prv_img->w[size] = render_size; prv_img->h[size] = render_size; - prv_img->changed[size] = 1; + prv_img->flag[size] |= CHANGED; prv_img->changed_timestamp[size] = 0; prv_img->rect[size] = MEM_callocN(render_size * render_size * sizeof(unsigned int), "prv_rect"); } @@ -940,7 +940,7 @@ static void icon_set_image( return; } - if (prv_img->user_edited[size]) { + if (prv_img->flag[size] & USER_EDITED) { /* user-edited preview, do not auto-update! */ return; } @@ -1173,11 +1173,11 @@ static void icon_draw_size(float x, float y, int icon_id, float aspect, float al static void ui_id_preview_image_render_size( const bContext *C, Scene *scene, ID *id, PreviewImage *pi, int size, const bool use_job) { - if ((pi->changed[size] || !pi->rect[size])) { /* changed only ever set by dynamic icons */ + if ((pi->flag[size] & CHANGED || !pi->rect[size])) { /* changed only ever set by dynamic icons */ /* create the rect if necessary */ icon_set_image(C, scene, id, pi, size, use_job); - pi->changed[size] = 0; + pi->flag[size] &= ~CHANGED; } } @@ -1204,9 +1204,9 @@ static void ui_id_brush_render(const bContext *C, ID *id) for (i = 0; i < NUM_ICON_SIZES; i++) { /* check if rect needs to be created; changed * only set by dynamic icons */ - if ((pi->changed[i] || !pi->rect[i])) { + if ((pi->flag[i] & CHANGED || !pi->rect[i])) { icon_set_image(C, NULL, id, pi, i, true); - pi->changed[i] = 0; + pi->flag[i] &= ~CHANGED; } } } diff --git a/source/blender/makesdna/DNA_ID.h b/source/blender/makesdna/DNA_ID.h index d7fa961..666ebe8 100644 --- a/source/blender/makesdna/DNA_ID.h +++ b/source/blender/makesdna/DNA_ID.h @@ -159,14 +159,20 @@ enum eIconSizes { }; #define NUM_ICON_SIZES (ICON_SIZE_PREVIEW + 1) +/* for PreviewImage->flag */ +enum ePreviewImage_Flag { + CHANGED = (1 << 0), + USER_EDITED = (1 << 1), /* if user-edited, do not auto-update this anymore! */ +}; + typedef struct PreviewImage { /* All values of 2 are really NUM_ICON_SIZES */ unsigned int w[2]; unsigned int h[2]; - short changed[2]; + short flag[2]; short changed_timestamp[2]; - short user_edited[2]; /* if user-edited, do not auto-update this anymore! */ int icon_id; /* Used by previews outside of ID context. */ + int pad; unsigned int *rect[2]; struct GPUTexture *gputexture[2]; } PreviewImage; diff --git a/source/blender/makesrna/intern/rna_ID.c b/source/blender/makesrna/intern/rna_ID.c index c8a7796..a101a76 100644 --- a/source/blender/makesrna/intern/rna_ID.c +++ b/source/blender/makesrna/intern/rna_ID.c @@ -417,8 +417,12 @@ static void rna_Preview_is_custom_set(PointerRNA *ptr, int value, enum eIconSize BLI_assert(prv_img == BKE_previewimg_get(id)); UNUSED_VARS_NDEBUG(id); - prv_img->user_edited[size] = (short)value; - prv_img->changed[size] = true; + if(value) + prv_img->flag[size] |= USER_EDITED; + else + prv_img->flag[size] &= ~USER_EDITED; + + prv_img->flag[size] |= CHANGED; BKE_previewimg_clear(prv_img, size); } @@ -452,8 +456,7 @@ static void rna_Preview_size_set(PointerRNA *ptr, const int *values, enum eIconS prv_img->w[size] = values[0]; prv_img->h[size] = values[1]; - prv_img->user_edited[size] = true; - prv_img->changed[size] = true; + prv_img->flag[size] |= (CHANGED | USER_EDITED); } static int rna_Preview_pixels_get_length(PointerRNA *ptr, int length[RNA_MAX_ARRAY_DIMENSION], enum eIconSizes size) @@ -489,7 +492,7 @@ static void rna_Preview_pixels_set(PointerRNA *ptr, const int *values, enum eIco UNUSED_VARS_NDEBUG(id); memcpy(prv_img->rect[size], values, prv_img->w[size] * prv_img->h[size] * sizeof(unsigned int)); - prv_img->user_edited[size] = true; + prv_img->flag[size] |= USER_EDITED; } static void rna_Preview_image_is_custom_set(PointerRNA *ptr, int value) { @@ -679,9 +682,10 @@ static void rna_def_preview(BlenderRNA *brna) RNA_def_struct_ui_text(srna, "Preview", "Preview image and icon"); prop = RNA_def_property(srna, "image_is_custom", PROP_BOOLEAN, PROP_NONE); - RNA_def_property_boolean_sdna(prop, NULL, "user_edited[ICON_SIZE_PREVIEW]", 1); + RNA_def_property_boolean_sdna(prop, NULL, "flag[ICON_SIZE_PREVIEW]", USER_EDITED); RNA_def_property_boolean_funcs(prop, NULL, "rna_Preview_image_is_custom_set"); - RNA_def_property_ui_text(prop, "Custom Image", "True if this preview image has been modified by py script, and is no more auto-generated by Blender"); + RNA_def_property_ui_text(prop, "Custom Image", "True if this preview image has been modified by py script," + "and is no more auto-generated by Blender"); prop = RNA_def_int_vector(srna, "image_size", 2, NULL, 0, 0, "Image Size", "Width and height in pixels", 0, 0); @@ -697,9 +701,10 @@ static void rna_def_preview(BlenderRNA *brna) prop = RNA_def_property(srna, "icon_is_custom", PROP_BOOLEAN, PROP_NONE); - RNA_def_property_boolean_sdna(prop, NULL, "user_edited[ICON_SIZE_ICON]", 1); + RNA_def_property_boolean_sdna(prop, NULL, "flag[ICON_SIZE_ICON]", USER_EDITED); RNA_def_property_boolean_funcs(prop, NULL, "rna_Preview_icon_is_custom_set"); - RNA_def_property_ui_text(prop, "Custom Icon", "True if this preview icon has been modified by py script, and is no more auto-generated by Blender"); + RNA_def_property_ui_text(prop, "Custom Icon", "True if this preview icon has been modified by py script," + "and is no more auto-generated by Blender"); prop = RNA_def_int_vector(srna, "icon_size", 2, NULL, 0, 0, "Icon Size", "Width and height in pixels", 0, 0); _______________________________________________ Bf-blender-cvs mailing list Bf-blender-cvs@blender.org http://lists.blender.org/mailman/listinfo/bf-blender-cvs