diff options
author | Ton Roosendaal <ton@blender.org> | 2009-06-25 19:41:27 +0400 |
---|---|---|
committer | Ton Roosendaal <ton@blender.org> | 2009-06-25 19:41:27 +0400 |
commit | 47ca543b32e74b67e5f8eb6265cc08f93018b002 (patch) | |
tree | 4091e83691f48b26743dfe6f054e5c24e7edd0c5 /source/blender/editors/interface/interface_icons.c | |
parent | d428ba1de8074e8b0ca2b7c0b060c18ebf7d6b0c (diff) |
2.5
Rendering preview icons is back!
Note for Andrea: the render code has been decoupled from
drawing, it needs Scene context to be able to run...
At the moment only the search menu calls the new render
code (which is the ID browse menu default anyway)
Diffstat (limited to 'source/blender/editors/interface/interface_icons.c')
-rw-r--r-- | source/blender/editors/interface/interface_icons.c | 63 |
1 files changed, 32 insertions, 31 deletions
diff --git a/source/blender/editors/interface/interface_icons.c b/source/blender/editors/interface/interface_icons.c index df069069a33..6b566012525 100644 --- a/source/blender/editors/interface/interface_icons.c +++ b/source/blender/editors/interface/interface_icons.c @@ -41,28 +41,30 @@ #include "BLI_blenlib.h" #include "BLI_storage_types.h" +#include "DNA_material_types.h" #include "DNA_screen_types.h" +#include "DNA_scene_types.h" #include "DNA_userdef_types.h" - -#include "BKE_utildefines.h" #include "BKE_image.h" #include "BKE_icons.h" +#include "BKE_utildefines.h" #include "IMB_imbuf.h" #include "IMB_imbuf_types.h" #include "BIF_gl.h" #include "BIF_glutil.h" -#include "UI_interface.h" -#include "UI_interface_icons.h" -// XXX #include "BIF_previewrender.h" -// XXX #include "BIF_screen.h" +#include "ED_datafiles.h" +#include "ED_previewrender.h" +#include "UI_interface.h" +#include "UI_interface_icons.h" #include "UI_resources.h" /* elubie: should be removed once the enum for the ICONS is in BIF_preview_icons.h */ + #include "interface_intern.h" -#include "ED_datafiles.h" + #define ICON_IMAGE_W 600 #define ICON_IMAGE_H 640 @@ -650,7 +652,6 @@ void UI_icons_init(int first_dyn_id) init_internal_icons(); } -#if 0 static void icon_copy_rect(ImBuf *ibuf, unsigned int w, unsigned int h, unsigned int *rect) { struct ImBuf *ima; @@ -771,18 +772,14 @@ static void set_alpha(char* cp, int sizex, int sizey, char alpha) } } } -#endif /* only called when icon has changed */ /* only call with valid pointer from UI_icon_draw */ -static void icon_set_image(ID *id, DrawInfo *di, PreviewImage* prv_img, int miplevel) +static void icon_set_image(Scene *scene, ID *id, PreviewImage* prv_img, int miplevel) { -#if 0 // XXX - preview renders have to be redesigned - possibly low level op (elubie) RenderInfo ri; unsigned int pr_size = 0; - if (!di) return; - if (!prv_img) { printf("No preview image for this ID: %s\n", id->name); return; @@ -798,13 +795,12 @@ static void icon_set_image(ID *id, DrawInfo *di, PreviewImage* prv_img, int mipl ri.curtile= 0; ri.tottile= 0; - ri.rect = NULL; ri.pr_rectx = prv_img->w[miplevel]; ri.pr_recty = prv_img->h[miplevel]; - pr_size = ri.pr_rectx*ri.pr_recty*sizeof(unsigned int); + ri.rect = MEM_callocN(pr_size, "pr icon rect"); - BIF_previewrender(id, &ri, NULL, PR_ICON_RENDER); + ED_preview_iconrender(scene, id, ri.rect, ri.pr_rectx, ri.pr_recty); /* world is rendered with alpha=0, so it wasn't displayed this could be render option for sky to, for later */ @@ -818,15 +814,11 @@ static void icon_set_image(ID *id, DrawInfo *di, PreviewImage* prv_img, int mipl } } - if (ri.rect) { - memcpy(prv_img->rect[miplevel], ri.rect, pr_size); + memcpy(prv_img->rect[miplevel], ri.rect, pr_size); - /* and clean up */ - MEM_freeN(ri.rect); - ri.rect = 0; - } + /* and clean up */ + MEM_freeN(ri.rect); } -#endif } static void icon_draw_rect(float x, float y, int w, int h, float aspect, int rw, int rh, unsigned int *rect) @@ -912,14 +904,7 @@ static void icon_draw_size(float x, float y, int icon_id, float aspect, int mipl PreviewImage* pi = BKE_previewimg_get((ID*)icon->obj); if (pi) { - if (!nocreate && (pi->changed[miplevel] ||!pi->rect[miplevel])) /* changed only ever set by dynamic icons */ - { - // XXX waitcursor(1); - /* create the preview rect if necessary */ - icon_set_image((ID*)icon->obj, icon->drawinfo, pi, miplevel); - pi->changed[miplevel] = 0; - // XXX waitcursor(0); - } + /* no create icon on this level in code */ if (!pi->rect[miplevel]) return; /* something has gone wrong! */ @@ -928,6 +913,22 @@ static void icon_draw_size(float x, float y, int icon_id, float aspect, int mipl } } +void ui_id_icon_render(Scene *scene, ID *id) +{ + PreviewImage *pi = BKE_previewimg_get(id); + + if (pi) { + if ((pi->changed[0] ||!pi->rect[0])) /* changed only ever set by dynamic icons */ + { + /* create the preview rect if necessary */ + icon_set_image(scene, id, pi, 0); + pi->changed[0] = 0; + } + } +} + + + static void icon_draw_mipmap(float x, float y, int icon_id, float aspect, int miplevel, int nocreate) { int draw_size = preview_size(miplevel); |