2.5
authorTon Roosendaal <ton@blender.org>
Fri, 10 Jul 2009 16:55:49 +0000 (16:55 +0000)
committerTon Roosendaal <ton@blender.org>
Fri, 10 Jul 2009 16:55:49 +0000 (16:55 +0000)
Render usability:

- Option back to render to imagewindow, or fullscreen.
  The latter is default. Setting is stored in Scene.
- Added button in output panel, the option "to new window" will follow!
- F11 again toggles render view
  (moved MS Windows "full screen" to shift+F11 for now)

source/blender/blenkernel/intern/image.c
source/blender/blenloader/intern/readfile.c
source/blender/blenloader/intern/writefile.c
source/blender/editors/screen/screen_ops.c
source/blender/editors/space_image/image_draw.c
source/blender/makesdna/DNA_image_types.h
source/blender/makesdna/DNA_scene_types.h
source/blender/makesrna/intern/rna_scene.c
source/blender/windowmanager/intern/wm_operators.c

index ef0984bf93dbb3242eff27ee5bfa6c7248e7657c..754ec06f23f942f83db92f5b3ba12544f810f5b9 100644 (file)
@@ -253,6 +253,10 @@ void free_image(Image *ima)
        if (ima->preview) {
                BKE_previewimg_free(&ima->preview);
        }
+       if (ima->render_text) {
+               MEM_freeN(ima->render_text);
+               ima->render_text= NULL;
+       }
 }
 
 /* only image block itself */
index c36a287b9811d6dc970e35a825a6fb3a7db2128d..460a1dcb2f58fcc9871aacf15f167b9516be7b23 100644 (file)
@@ -2641,6 +2641,7 @@ static void direct_link_image(FileData *fd, Image *ima)
        ima->anim= NULL;
        ima->rr= NULL;
        ima->repbind= NULL;
+       ima->render_text= newdataadr(fd, ima->render_text);
        
        ima->packedfile = direct_link_packedfile(fd, ima->packedfile);
        ima->preview = direct_link_preview_image(fd, ima->preview);
index c433232d084b7115f53e4257b3e35835aedc08bd..9d35967c95d4bbd5399d3599b5de98d1287d0dca 100644 (file)
@@ -1439,7 +1439,10 @@ static void write_images(WriteData *wd, ListBase *idbase)
 
                        write_previews(wd, ima->preview);
 
-                       }
+                       /* exception: render text only saved in undo files (wd->current) */
+                       if (ima->render_text && wd->current)
+                               writedata(wd, DATA, IMA_RW_MAXTEXT, ima->render_text);
+               }
                ima= ima->id.next;
        }
        /* flush helps the compression for undo-save */
index 631ab3cf8cb865cf0e2b67689333c48e7a4fe80e..01cb4427944137002fbaea9396dc385ebd226f56 100644 (file)
@@ -2286,46 +2286,54 @@ static ScrArea *find_area_showing_r_result(bContext *C)
 
 static void screen_set_image_output(bContext *C)
 {
+       Scene *scene= CTX_data_scene(C);
        ScrArea *sa;
        SpaceImage *sima;
        
-       sa= find_area_showing_r_result(C);
+       if(scene->r.displaymode==R_OUTPUT_SCREEN) {
+               /* this function returns with changed context */
+               ED_screen_full_newspace(C, CTX_wm_area(C), SPACE_IMAGE);
+               sa= CTX_wm_area(C);
+       }
+       else {
        
-       if(sa==NULL) {
-               /* find largest open non-image area */
-               sa= biggest_non_image_area(C);
-               if(sa) {
-                       ED_area_newspace(C, sa, SPACE_IMAGE);
-                       sima= sa->spacedata.first;
-                       
-                       /* makes ESC go back to prev space */
-                       sima->flag |= SI_PREVSPACE;
-               }
-               else {
-                       /* use any area of decent size */
-                       sa= biggest_area(C);
-                       if(sa->spacetype!=SPACE_IMAGE) {
-                               // XXX newspace(sa, SPACE_IMAGE);
+               sa= find_area_showing_r_result(C);
+               
+               if(sa==NULL) {
+                       /* find largest open non-image area */
+                       sa= biggest_non_image_area(C);
+                       if(sa) {
+                               ED_area_newspace(C, sa, SPACE_IMAGE);
                                sima= sa->spacedata.first;
                                
                                /* makes ESC go back to prev space */
                                sima->flag |= SI_PREVSPACE;
                        }
+                       else {
+                               /* use any area of decent size */
+                               sa= biggest_area(C);
+                               if(sa->spacetype!=SPACE_IMAGE) {
+                                       // XXX newspace(sa, SPACE_IMAGE);
+                                       sima= sa->spacedata.first;
+                                       
+                                       /* makes ESC go back to prev space */
+                                       sima->flag |= SI_PREVSPACE;
+                               }
+                       }
                }
-       }
-       
+       }       
        sima= sa->spacedata.first;
        
        /* get the correct image, and scale it */
        sima->image= BKE_image_verify_viewer(IMA_TYPE_R_RESULT, "Render Result");
        
-       if(G.displaymode==2) { // XXX
-               if(sa->full==0) {
-                       sima->flag |= SI_FULLWINDOW;
+//     if(G.displaymode==2) { // XXX
+               if(sa->full) {
+                       sima->flag |= SI_FULLWINDOW|SI_PREVSPACE;
                        
-                       ed_screen_fullarea(C, sa);
+//                     ed_screen_fullarea(C, sa);
                }
-       }
+//     }
        
 }
 
@@ -2371,6 +2379,62 @@ static void render_freejob(void *rjv)
        MEM_freeN(rj);
 }
 
+/* str is IMA_RW_MAXTEXT in size */
+static void make_renderinfo_string(RenderStats *rs, Scene *scene, char *str)
+{
+       char info_time_str[32]; // used to be extern to header_info.c
+       uintptr_t mem_in_use, mmap_in_use;
+       float megs_used_memory, mmap_used_memory;
+       char *spos= str;
+       
+       mem_in_use= MEM_get_memory_in_use();
+       mmap_in_use= MEM_get_mapped_memory_in_use();
+       
+       megs_used_memory= (mem_in_use-mmap_in_use)/(1024.0*1024.0);
+       mmap_used_memory= (mmap_in_use)/(1024.0*1024.0);
+       
+       if(scene->lay & 0xFF000000)
+               spos+= sprintf(spos, "Localview | ");
+       else if(scene->r.scemode & R_SINGLE_LAYER)
+               spos+= sprintf(spos, "Single Layer | ");
+       
+       spos+= sprintf(spos, "Fra:%d  Ve:%d Fa:%d ", (scene->r.cfra), rs->totvert, rs->totface);
+       if(rs->tothalo) spos+= sprintf(spos, "Ha:%d ", rs->tothalo);
+       if(rs->totstrand) spos+= sprintf(spos, "St:%d ", rs->totstrand);
+       spos+= sprintf(spos, "La:%d Mem:%.2fM (%.2fM) ", rs->totlamp, megs_used_memory, mmap_used_memory);
+       
+       if(rs->curfield)
+               spos+= sprintf(spos, "Field %d ", rs->curfield);
+       if(rs->curblur)
+               spos+= sprintf(spos, "Blur %d ", rs->curblur);
+       
+       BLI_timestr(rs->lastframetime, info_time_str);
+       spos+= sprintf(spos, "Time:%s ", info_time_str);
+       
+       if(rs->infostr)
+               spos+= sprintf(spos, "| %s ", rs->infostr);
+       
+       /* very weak... but 512 characters is quite safe */
+       if(spos >= str+IMA_RW_MAXTEXT)
+               printf("WARNING! renderwin text beyond limit \n");
+       
+}
+
+static void image_renderinfo_cb(void *rjv, RenderStats *rs)
+{
+       RenderJob *rj= rjv;
+       
+       /* malloc OK here, stats_draw is not in tile threads */
+       if(rj->image->render_text==NULL)
+               rj->image->render_text= MEM_callocN(IMA_RW_MAXTEXT, "rendertext");
+       
+       make_renderinfo_string(rs, rj->scene, rj->image->render_text);
+       
+       /* make jobs timer to send notifier */
+       *(rj->do_update)= 1;
+
+}
+
 /* called inside thread! */
 static void image_rect_update(void *rjv, RenderResult *rr, volatile rcti *renrect)
 {
@@ -2552,6 +2616,8 @@ static int screen_render_invoke(bContext *C, wmOperator *op, wmEvent *event)
        re= RE_NewRender(scene->id.name);
        RE_test_break_cb(re, rj, render_breakjob);
        RE_display_draw_cb(re, rj, image_rect_update);
+       RE_stats_draw_cb(re, rj, image_renderinfo_cb);
+       
        rj->re= re;
        G.afbreek= 0;
        
@@ -2626,6 +2692,48 @@ void SCREEN_OT_render_view_cancel(struct wmOperatorType *ot)
        ot->poll= ED_operator_image_active;
 }
 
+/* *********************** show render viewer *************** */
+
+static int render_view_show_exec(bContext *C, wmOperator *unused)
+{
+       ScrArea *sa= find_area_showing_r_result(C);
+       
+       /* determine if render already shows */
+       if(sa) {
+               SpaceImage *sima= sa->spacedata.first;
+               
+               if(sima->flag & SI_PREVSPACE) {
+                       sima->flag &= ~SI_PREVSPACE;
+                       
+                       if(sima->flag & SI_FULLWINDOW) {
+                               sima->flag &= ~SI_FULLWINDOW;
+                               ED_screen_full_prevspace(C);
+                       }
+                       else if(sima->next) {
+                               ED_area_newspace(C, sa, sima->next->spacetype);
+                               ED_area_tag_redraw(sa);
+                       }
+               }
+       }
+       else {
+               screen_set_image_output(C);
+       }
+       
+       return OPERATOR_FINISHED;
+}
+
+void SCREEN_OT_render_view_show(struct wmOperatorType *ot)
+{
+       /* identifiers */
+       ot->name= "Show/Hide Render View";
+       ot->idname= "SCREEN_OT_render_view_show";
+       
+       /* api callbacks */
+       ot->exec= render_view_show_exec;
+       ot->poll= ED_operator_screenactive;
+}
+
+
 
 /* ****************  Assigning operatortypes to global list, adding handlers **************** */
 
@@ -2661,7 +2769,8 @@ void ED_operatortypes_screen(void)
        /* render */
        WM_operatortype_append(SCREEN_OT_render);
        WM_operatortype_append(SCREEN_OT_render_view_cancel);
-       
+       WM_operatortype_append(SCREEN_OT_render_view_show);
+
        /* tools shared by more space types */
        WM_operatortype_append(ED_OT_undo);
        WM_operatortype_append(ED_OT_redo);     
@@ -2722,6 +2831,7 @@ void ED_keymap_screen(wmWindowManager *wm)
        /* render */
        WM_keymap_add_item(keymap, "SCREEN_OT_render", F12KEY, KM_PRESS, 0, 0);
        WM_keymap_add_item(keymap, "SCREEN_OT_render_view_cancel", ESCKEY, KM_PRESS, 0, 0);
+       WM_keymap_add_item(keymap, "SCREEN_OT_render_view_show", F11KEY, KM_PRESS, 0, 0);
        
        /* frame offsets & play */
        keymap= WM_keymap_listbase(wm, "Frames", 0, 0);
index e61931f2fad849a49b976d4047192fc70af8cb18..e5d74e6dddd1873f41b0585b8289ff3bcc333c15 100644 (file)
@@ -127,14 +127,13 @@ static void image_verify_buffer_float(SpaceImage *sima, ImBuf *ibuf)
        }
 }
 
-static void draw_render_info(SpaceImage *sima, ARegion *ar)
+static void draw_render_info(Image *ima, ARegion *ar)
 {
        rcti rect;
        float colf[3];
        int showspare= 0; // XXX BIF_show_render_spare();
-       char *str= "render text"; // XXX BIF_render_text();
        
-       if(str==NULL)
+       if(ima->render_text==NULL)
                return;
        
        rect= ar->winrct;
@@ -152,10 +151,10 @@ static void draw_render_info(SpaceImage *sima, ARegion *ar)
 
        if(showspare) {
                UI_DrawString(12, rect.ymin + 5, "(Previous)");
-               UI_DrawString(72, rect.ymin + 5, str);
+               UI_DrawString(72, rect.ymin + 5, ima->render_text);
        }
        else
-               UI_DrawString(12, rect.ymin + 5, str);
+               UI_DrawString(12, rect.ymin + 5, ima->render_text);
 }
 
 void draw_image_info(ARegion *ar, int channels, int x, int y, char *cp, float *fp, int *zp, float *zpf)
@@ -685,8 +684,8 @@ void draw_image_main(SpaceImage *sima, ARegion *ar, Scene *scene)
        draw_image_paint_helpers(sima, ar, scene, zoomx, zoomy);
 
        /* render info */
-       if(ibuf && show_render)
-               draw_render_info(sima, ar);
+       if(ibuf && ima && show_render)
+               draw_render_info(ima, ar);
 
        /* XXX integrate this code */
 #if 0
index 371b0d7595187dee8e05bceac00050424da9c3c0..65e4be1173db3296bc2b21ccefd535600640af05 100644 (file)
@@ -87,6 +87,9 @@ typedef struct Image {
        struct PackedFile * packedfile;
        struct PreviewImage * preview;
 
+       /* not saved in file, statistics for render result */
+       char *render_text;
+       
        float lastupdate;
        int lastused;
        short animspeed;
@@ -120,5 +123,9 @@ typedef struct Image {
 
 /* ima->type and ima->source moved to BKE_image.h, for API */
 
+/* render_text maxlen */
+#define IMA_RW_MAXTEXT           512
+
+
 #endif
 
index 31724bb5665fde1b38b1cf54c766460def86b600..e9b246a323dac6eb5029f6a2a46fe782c353e4cb 100644 (file)
@@ -218,7 +218,12 @@ typedef struct RenderData {
        short bufflag;
        short quality;
        
-       short rpad, rpad1, rpad2;
+       /**
+        * Render to image editor, fullscreen or to new window.
+        */
+       short displaymode;
+       
+       short rpad1, rpad2;
 
        /**
         * Flags for render settings. Use bit-masking to access the settings.
@@ -652,6 +657,12 @@ typedef struct Scene {
 #define R_TOUCH                        0x800000 /* touch files before rendering */
 #define R_SIMPLIFY             0x1000000
 
+/* displaymode */
+
+#define R_OUTPUT_SCREEN        0
+#define R_OUTPUT_AREA  1
+#define R_OUTPUT_WINDOW        2
+#define R_OUTPUT_FORKED        3
 
 /* filtertype */
 #define R_FILTER_BOX   0
index b363e55ca75c077036f66461c670638692f9aa4f..3cd45bb6dd8cc99ad181a924ab709261a30f3ffb 100644 (file)
@@ -283,7 +283,13 @@ void rna_def_scene_render_data(BlenderRNA *brna)
                {R_PLANES24, "RGB", 0, "RGB", "Images are saved with RGB (color) data"},
                {R_PLANES32, "RGBA", 0, "RGBA", "Images are saved with RGB and Alpha data (if supported)"},
                {0, NULL, 0, NULL, NULL}};
-               
+       
+       static EnumPropertyItem display_mode_items[] ={
+               {R_OUTPUT_SCREEN, "SCREEN", 0, "Full Screen", "Images are rendered in full Screen"},
+               {R_OUTPUT_AREA, "AREA", 0, "Image Editor", "Images are rendered in Image Editor"},
+               {R_OUTPUT_WINDOW, "WINDOW", 0, "New Window", "Images are rendered in new Window"},
+               {0, NULL, 0, NULL, NULL}};
+       
        static EnumPropertyItem octree_resolution_items[] = {
                {64, "OCTREE_RES_64", 0, "64", ""},
                {128, "OCTREE_RES_128", 0, "128", ""},
@@ -841,6 +847,11 @@ void rna_def_scene_render_data(BlenderRNA *brna)
        RNA_def_property_ui_text(prop, "Back Buffer", "Render backbuffer image");
        RNA_def_property_update(prop, NC_SCENE|ND_RENDER_OPTIONS, NULL);
 
+       prop= RNA_def_property(srna, "display_mode", PROP_ENUM, PROP_NONE);
+       RNA_def_property_enum_bitflag_sdna(prop, NULL, "displaymode");
+       RNA_def_property_enum_items(prop, display_mode_items);
+       RNA_def_property_ui_text(prop, "Display", "Select where rendered images will be displayed");
+       
        prop= RNA_def_property(srna, "output_path", PROP_STRING, PROP_DIRPATH);
        RNA_def_property_string_sdna(prop, NULL, "pic");
        RNA_def_property_ui_text(prop, "Output Path", "Directory/name to save animations, # characters defines the position and length of frame numbers.");
index 9cec463193ee77d3c4d62c6bb4aa4e23a49d93d2..330196a7a7381cd2e77d1dae3a84c4b9aafd394e 100644 (file)
@@ -1554,7 +1554,7 @@ void wm_window_keymap(wmWindowManager *wm)
        WM_keymap_verify_item(keymap, "WM_OT_open_mainfile", F1KEY, KM_PRESS, 0, 0);
        WM_keymap_verify_item(keymap, "WM_OT_save_mainfile", WKEY, KM_PRESS, KM_CTRL, 0);
        WM_keymap_verify_item(keymap, "WM_OT_save_as_mainfile", F2KEY, KM_PRESS, 0, 0);
-       WM_keymap_verify_item(keymap, "WM_OT_window_fullscreen_toggle", F11KEY, KM_PRESS, 0, 0);
+       WM_keymap_verify_item(keymap, "WM_OT_window_fullscreen_toggle", F11KEY, KM_PRESS, KM_SHIFT, 0);
        WM_keymap_verify_item(keymap, "WM_OT_exit_blender", QKEY, KM_PRESS, KM_CTRL, 0);
 
        /* debug/testing */