2.5
authorTon Roosendaal <ton@blender.org>
Wed, 4 Feb 2009 17:40:50 +0000 (17:40 +0000)
committerTon Roosendaal <ton@blender.org>
Wed, 4 Feb 2009 17:40:50 +0000 (17:40 +0000)
Render back! And not only back, even full threaded now. :)
Current state is unfinished, but too much fun to not to
commit for review and test!

WARNING: because render is in a threaded job, it will
use data as can be edited in the UI. That'll crash in many
cases of course... the idea is to limit UI usage to viewing
stuff, especially for the Image Window to inspect layers
or zoom in/out.

What works now;
- F12 render (no anim)
- ESC from render
- ESC pushes back temporary Image Window
- Render to ImageWindow or full-screen.
- Executing composites, and edit composites after render.

Note that the UI is 100% responsive in a render, you can
switch screens, slide area dividers around, or even load
a new file during render. :) It's quite stable even.

I'll collect all crash reports especially to get a good
picture of where the protection is required at least.

Also added: XKey "Delete Objects", to get things crash...
unfortunately it didn't for me.

26 files changed:
source/Makefile
source/blender/blenloader/intern/readfile.c
source/blender/editors/animation/anim_deps.c
source/blender/editors/curve/editcurve.c
source/blender/editors/include/ED_anim_api.h
source/blender/editors/include/ED_image.h
source/blender/editors/include/ED_screen.h
source/blender/editors/object/object_edit.c
source/blender/editors/object/object_intern.h
source/blender/editors/object/object_ops.c
source/blender/editors/screen/Makefile
source/blender/editors/screen/SConscript
source/blender/editors/screen/screen_edit.c
source/blender/editors/screen/screen_intern.h
source/blender/editors/screen/screen_ops.c
source/blender/editors/space_api/spacetypes.c
source/blender/editors/space_file/file_draw.c
source/blender/editors/space_image/image_draw.c
source/blender/editors/space_image/image_render.c
source/blender/editors/space_info/info_header.c
source/blender/editors/space_info/space_info.c
source/blender/editors/space_node/node_edit.c
source/blender/render/intern/source/envmap.c
source/blender/render/intern/source/pipeline.c
source/blender/windowmanager/intern/wm_event_system.c
source/blender/windowmanager/intern/wm_init_exit.c

index 3ffc9fd..d9dd291 100644 (file)
@@ -232,7 +232,6 @@ PULIB += $(OCGDIR)/blender/ed_file/libed_file.a
 PULIB += $(OCGDIR)/blender/ed_info/libed_info.a
 PULIB += $(OCGDIR)/blender/ed_buttons/libed_buttons.a
 PULIB += $(OCGDIR)/blender/ed_node/libed_node.a
-PULIB += $(OCGDIR)/blender/ed_image/libed_image.a
 PULIB += $(OCGDIR)/blender/ed_graph/libed_graph.a
 PULIB += $(OCGDIR)/blender/ed_outliner/libed_outliner.a
 PULIB += $(OCGDIR)/blender/ed_time/libed_time.a
@@ -248,8 +247,9 @@ PULIB += $(OCGDIR)/blender/ed_physics/libed_physics.a
 PULIB += $(OCGDIR)/blender/ed_animation/libed_animation.a
 PULIB += $(OCGDIR)/blender/ed_transform/libed_transform.a
 PULIB += $(OCGDIR)/blender/ed_util/libed_util.a
-PULIB += $(OCGDIR)/blender/ed_uvedit/libed_uvedit.a
 PULIB += $(OCGDIR)/blender/ed_datafiles/libed_datafiles.a
+PULIB += $(OCGDIR)/blender/ed_image/libed_image.a
+PULIB += $(OCGDIR)/blender/ed_uvedit/libed_uvedit.a
 PULIB += $(OCGDIR)/blender/ed_screen/libed_screen.a
 PULIB += $(OCGDIR)/blender/windowmanager/libwindowmanager.a
 PULIB += $(OCGDIR)/blender/python/$(DEBUG_DIR)libpython.a
index 5dab59d..40561a1 100644 (file)
@@ -3672,6 +3672,17 @@ static void direct_link_object(FileData *fd, Object *ob)
 
 /* ************ READ SCENE ***************** */
 
+/* patch for missing scene IDs, can't be in do-versions */
+static void composite_patch(bNodeTree *ntree, Scene *scene)
+{
+       bNode *node;
+       
+       for(node= ntree->nodes.first; node; node= node->next)
+               if(node->id==NULL && node->type==CMP_NODE_R_LAYERS)
+                       node->id= &scene->id;
+}
+
+
 static void lib_link_scene(FileData *fd, Main *main)
 {
        Scene *sce;
@@ -3736,8 +3747,10 @@ static void lib_link_scene(FileData *fd, Main *main)
                        
                        lib_link_scriptlink(fd, &sce->id, &sce->scriptlink);
                        
-                       if(sce->nodetree)
+                       if(sce->nodetree) {
                                lib_link_ntree(fd, &sce->id, sce->nodetree);
+                               composite_patch(sce->nodetree, sce);
+                       }
                        
                        for(srl= sce->r.layers.first; srl; srl= srl->next) {
                                srl->mat_override= newlibadr_us(fd, sce->id.lib, srl->mat_override);
index f8e6cd2..ab3e40e 100644 (file)
 #include "DNA_armature_types.h"
 #include "DNA_object_types.h"
 #include "DNA_scene_types.h"
-#include "DNA_screen_types.h"
-#include "DNA_space_types.h"
-#include "DNA_texture_types.h"
-#include "DNA_view3d_types.h"
-#include "DNA_windowmanager_types.h"
 
 #include "BLI_blenlib.h"
 
 #include "BKE_action.h"
 #include "BKE_context.h"
 #include "BKE_depsgraph.h"
-#include "BKE_global.h"
-#include "BKE_scene.h"
 #include "BKE_main.h"
-#include "BKE_node.h"
+#include "BKE_scene.h"
 #include "BKE_utildefines.h"
 
 #include "RNA_access.h"
 #include "WM_types.h"
 
 /* ***************** depsgraph calls and anim updates ************* */
-
-static unsigned int screen_view3d_layers(bScreen *screen)
-{
-       if(screen) {
-               unsigned int layer= screen->scene->lay; /* as minimum this */
-               ScrArea *sa;
-               
-               /* get all used view3d layers */
-               for(sa= screen->areabase.first; sa; sa= sa->next) {
-                       if(sa->spacetype==SPACE_VIEW3D)
-                               layer |= ((View3D *)sa->spacedata.first)->lay;
-               }
-               return layer;
-       }
-       return 0;
-}
+/* ***************** only these can be called from editors ******** */
 
 /* generic update flush, reads from context Screen (layers) and scene */
 /* this is for compliancy, later it can do all windows etc */
@@ -86,7 +64,7 @@ void ED_anim_dag_flush_update(const bContext *C)
        Scene *scene= CTX_data_scene(C);
        bScreen *screen= CTX_wm_screen(C);
        
-       DAG_scene_flush_update(scene, screen_view3d_layers(screen), 0);
+       DAG_scene_flush_update(scene, ED_screen_view3d_layers(screen), 0);
 }
 
 /* flushes changes from object to all relations in scene */
@@ -95,46 +73,10 @@ void ED_anim_object_flush_update(const bContext *C, Object *ob)
        Scene *scene= CTX_data_scene(C);
        bScreen *screen= CTX_wm_screen(C);
        
-       DAG_object_update_flags(scene, ob, screen_view3d_layers(screen));
+       DAG_object_update_flags(scene, ob, ED_screen_view3d_layers(screen));
 }
 
 
-/* results in fully updated anim system */
-/* in future sound should be on WM level, only 1 sound can play! */
-void ED_update_for_newframe(const bContext *C, int mute)
-{
-       bScreen *screen= CTX_wm_screen(C);
-       Scene *scene= screen->scene;
-       
-       //extern void audiostream_scrub(unsigned int frame);    /* seqaudio.c */
-       
-       /* this function applies the changes too */
-       /* XXX future: do all windows */
-       scene_update_for_newframe(scene, screen_view3d_layers(screen)); /* BKE_scene.h */
-       
-       //if ( (CFRA>1) && (!mute) && (scene->audio.flag & AUDIO_SCRUB)) 
-       //      audiostream_scrub( CFRA );
-       
-       /* 3d window, preview */
-       //BIF_view3d_previewrender_signal(curarea, PR_DBASE|PR_DISPRECT);
-       
-       /* all movie/sequence images */
-       //BIF_image_update_frame();
-       
-       /* composite */
-       if(scene->use_nodes && scene->nodetree)
-               ntreeCompositTagAnimated(scene->nodetree);
-       
-       /* update animated texture nodes */
-       {
-               Tex *tex;
-               for(tex= G.main->tex.first; tex; tex= tex->id.next)
-                       if( tex->use_nodes && tex->nodetree ) {
-                               ntreeTexTagAnimated( tex->nodetree );
-                       }
-       }
-}
-
 /* **************************** animation tool notifiers ******************************** */
 
 /* Send notifiers on behalf of animation editing tools, based on various context info 
index 075b104..4962a23 100644 (file)
@@ -66,6 +66,9 @@
 #include "BKE_object.h"
 #include "BKE_utildefines.h"
 
+#include "WM_api.h"
+#include "WM_types.h"
+
 #include "ED_anim_api.h"
 #include "ED_keyframes_edit.h"
 #include "ED_object.h"
@@ -2759,7 +2762,7 @@ void addsegment_nurb(Scene *scene)
 
 void mouse_nurb(bContext *C, short mval[2], int extend)
 {
-       Object *obedit= CTX_data_edit_object(C); // XXX
+       Object *obedit= CTX_data_edit_object(C); 
        ListBase *editnurb= curve_get_editcurve(obedit);
        Curve *cu= obedit->data;
        ViewContext vc;
@@ -2812,7 +2815,7 @@ void mouse_nurb(bContext *C, short mval[2], int extend)
 
        }
 
-//     rightmouse_transform();
+       WM_event_add_notifier(C, NC_OBJECT|ND_GEOM_SELECT, obedit);
        
        if(nu!=get_actNurb(obedit)) {
                set_actNurb(obedit, nu);
index ee9f0a5..c028738 100644 (file)
@@ -304,12 +304,10 @@ void ANIM_nla_mapping_apply_fcurve(struct Object *ob, struct FCurve *fcu, short
 
 /* --------- anim_deps.c, animation updates -------- */
 
-       /* generic update flush, reads from Context screen (layers) and scene */
+       /* generic update flush, does tagged objects only, reads from Context screen (layers) and scene */
 void ED_anim_dag_flush_update(const struct bContext *C);
        /* only flush object */
 void ED_anim_object_flush_update(const struct bContext *C, struct Object *ob);
-       /* flush + do the actual update for all involved objects */
-void ED_update_for_newframe(const struct bContext *C, int mute);
 
 /* pose <-> action syncing */
 void ANIM_action_to_pose_sync(struct Object *ob);
index ac73aa1..84225d8 100644 (file)
 #define ED_IMAGE_H
 
 struct SpaceImage;
+struct bContext;
 
 /* space_image.c, exported for transform */
 struct Image *ED_space_image(struct SpaceImage *sima);
 void ED_space_image_size(struct SpaceImage *sima, int *width, int *height);
 void ED_space_image_uv_aspect(struct SpaceImage *sima, float *aspx, float *aspy);
 
+/* image_render.c, export for screen_ops.c, render operator */
+void ED_space_image_output(struct bContext *C);
+
 #endif /* ED_IMAGE_H */
 
index 00740b2..068c0c8 100644 (file)
@@ -84,6 +84,9 @@ void  ED_screen_animation_timer(struct bContext *C, int enable);
 void   ED_screen_full_newspace(struct bContext *C, ScrArea *sa, int type);
 void   ED_screen_full_prevspace(struct bContext *C);
 
+/* anim */
+void   ED_update_for_newframe(const struct bContext *C, int mute);
+unsigned int ED_screen_view3d_layers(struct bScreen *screen);
 
 void   ED_operatortypes_screen(void);
 void   ED_keymap_screen(struct wmWindowManager *wm);
@@ -104,6 +107,7 @@ int         ED_operator_buttons_active(struct bContext *C);
 int            ED_operator_node_active(struct bContext *C);
 int            ED_operator_ipo_active(struct bContext *C);
 int            ED_operator_sequencer_active(struct bContext *C);
+int            ED_operator_image_active(struct bContext *C);
 
 int            ED_operator_object_active(struct bContext *C);
 int            ED_operator_editmesh(struct bContext *C);
index ca600f0..fde60ad 100644 (file)
@@ -526,70 +526,53 @@ void ED_base_object_free_and_unlink(Scene *scene, Base *base)
        MEM_freeN(base);
 }
 
-void delete_obj(Scene *scene, View3D *v3d, int ok)
+static int object_delete_exec(bContext *C, wmOperator *op)
 {
-       Base *base, *nbase;
+       Scene *scene= CTX_data_scene(C);
        int islamp= 0;
        
-       if(scene->obedit) return; // XXX get from context
-       if(scene->id.lib) return;
-
-       for(base= FIRSTBASE; base; base= nbase) {
-               nbase= base->next;
-
-               if(TESTBASE(v3d, base)) { 
-                       if(ok==0) {
-                               int shift= 0; // XXX
-                               /* Shift Del is global delete */
-                               if (shift) {
-                                       if(!okee("Erase selected Object(s) Globally")) return;
-                                       ok= 2;
-                               } else {
-                                       if(!okee("Erase selected Object(s)")) return;
-                                       ok= 1;
-                               }
-                       }
-                       
-//                     ED_view3d_exit_paint_modes(C);
+       if(CTX_data_edit_object(C)) 
+               return OPERATOR_CANCELLED;
+       
+       ED_view3d_exit_paint_modes(C);
 
-                       if(base->object->type==OB_LAMP) islamp= 1;
+       CTX_DATA_BEGIN(C, Base*, base, selected_editable_bases) {
 
-                       if (ok==2) {
-                               Scene *scene; 
-                               Base *base_other;
-                               
-                               for (scene= G.main->scene.first; scene; scene= scene->id.next) {
-                                       if (scene != scene && !(scene->id.lib)) {
-                                               base_other= object_in_scene( base->object, scene );
-                                               if (base_other) {
-                                                       ED_base_object_free_and_unlink( scene, base_other );
-                                               }
-                                       }
-                               }
-                       }
-                       
-                       /* remove from current scene only */
-                       ED_base_object_free_and_unlink(scene, base);
-               }
+               if(base->object->type==OB_LAMP) islamp= 1;
+               
+               /* remove from current scene only */
+               ED_base_object_free_and_unlink(scene, base);
        }
+       CTX_DATA_END;
 
        if(islamp) reshadeall_displist(scene);  /* only frees displist */
-
-// XXX redraw_test_buttons(OBACT);
-       allqueue(REDRAWVIEW3D, 0);
-       allqueue (REDRAWACTION, 0);
-       allqueue(REDRAWIPO, 0);
-       allqueue(REDRAWDATASELECT, 0);
-//     allspace(OOPS_TEST, 0);
-       allqueue(REDRAWOOPS, 0);
-       allqueue(REDRAWACTION, 0);
-       allqueue(REDRAWNLA, 0);
        
        DAG_scene_sort(scene);
-       ED_anim_dag_flush_update(C);    
+       ED_anim_dag_flush_update(C);
+       
+       WM_event_add_notifier(C, NC_SCENE|ND_OB_ACTIVE, CTX_data_scene(C));
+       
+       return OPERATOR_FINISHED;
+}
 
+void OBJECT_OT_delete(wmOperatorType *ot)
+{
+       
+       /* identifiers */
+       ot->name= "Delete Objects";
+       ot->idname= "OBJECT_OT_delete";
+       
+       /* api callbacks */
+       ot->invoke= WM_operator_confirm;
+       ot->exec= object_delete_exec;
+       ot->poll= ED_operator_scene_editable;
+       
+       /* flags */
+       ot->flag= OPTYPE_REGISTER|OPTYPE_UNDO;
+       
 }
 
+
 static void single_object_users__forwardModifierLinks(void *userData, Object *ob, Object **obpoin)
 {
        ID_NEW(*obpoin);
index 9abc896..e7d75e8 100644 (file)
@@ -65,6 +65,7 @@ void OBJECT_OT_set_center(struct wmOperatorType *ot);
 void OBJECT_OT_make_dupli_real(struct wmOperatorType *ot);
 void OBJECT_OT_object_add(struct wmOperatorType *ot);
 void OBJECT_OT_add_duplicate(struct wmOperatorType *ot);
+void OBJECT_OT_delete(struct wmOperatorType *ot);
 
 void OBJECT_OT_mesh_add(struct wmOperatorType *ot);
 void OBJECT_OT_curve_add(struct wmOperatorType *ot);
index 7001295..0139c2b 100644 (file)
@@ -89,7 +89,8 @@ void ED_operatortypes_object(void)
        WM_operatortype_append(GROUP_OT_group_remove);
        WM_operatortype_append(GROUP_OT_objects_add_active);
        WM_operatortype_append(GROUP_OT_objects_remove_active);
-       
+
+       WM_operatortype_append(OBJECT_OT_delete);
        WM_operatortype_append(OBJECT_OT_mesh_add);
        WM_operatortype_append(OBJECT_OT_curve_add);
        WM_operatortype_append(OBJECT_OT_object_add);
@@ -127,6 +128,7 @@ void ED_keymap_object(wmWindowManager *wm)
        WM_keymap_verify_item(keymap, "OBJECT_OT_clear_restrictview", HKEY, KM_PRESS, KM_ALT, 0);
        WM_keymap_verify_item(keymap, "OBJECT_OT_set_restrictview", HKEY, KM_PRESS, 0, 0);
        
+       WM_keymap_verify_item(keymap, "OBJECT_OT_delete", XKEY, KM_PRESS, 0, 0);
        WM_keymap_verify_item(keymap, "OBJECT_OT_primitive_add", AKEY, KM_PRESS, KM_SHIFT, 0);
        WM_keymap_verify_item(keymap, "OBJECT_OT_add_duplicate", DKEY, KM_PRESS, KM_SHIFT, 0);
        
index 1960ff2..d18d15d 100644 (file)
@@ -48,6 +48,7 @@ CPPFLAGS += -I../../makesdna
 CPPFLAGS += -I../../makesrna
 CPPFLAGS += -I../../imbuf
 CPPFLAGS += -I../../python
+CPPFLAGS += -I../../render/extern/include
 CPPFLAGS += -I$(NAN_GUARDEDALLOC)/include
 
 # own include 
index 8c7107b..c291533 100644 (file)
@@ -5,6 +5,7 @@ sources = env.Glob('*.c')
 
 incs = '../include ../../blenlib ../../blenkernel ../../makesdna ../../imbuf'
 incs += ' ../../blenloader ../../windowmanager ../../python ../../makesrna'
+incs += ' ../../render/extern/include'
 incs += ' #/intern/guardedalloc #/extern/glew/include #intern/bmfont'
 
 defs = ''
index 4ee92ef..0b3c617 100644 (file)
@@ -31,6 +31,7 @@
 #include "DNA_vec_types.h"
 #include "DNA_scene_types.h"
 #include "DNA_screen_types.h"
+#include "DNA_texture_types.h"
 
 #include "BLI_blenlib.h"
 
@@ -38,7 +39,9 @@
 #include "BKE_global.h"
 #include "BKE_library.h"
 #include "BKE_main.h"
+#include "BKE_node.h"
 #include "BKE_screen.h"
+#include "BKE_scene.h"
 #include "BKE_utildefines.h"
 
 #include "BIF_gl.h"
@@ -1225,10 +1228,9 @@ void ed_screen_set(bContext *C, bScreen *sc)
 }
 
 /* this function toggles: if area is full then the parent will be restored */
-void ed_screen_fullarea(bContext *C)
+void ed_screen_fullarea(bContext *C, ScrArea *sa)
 {
        bScreen *sc, *oldscreen;
-       ScrArea *sa= CTX_wm_area(C);
        
        if(sa==NULL) {
                return;
@@ -1260,7 +1262,7 @@ void ed_screen_fullarea(bContext *C)
                                // in autoplay screens the headers are disabled by 
                                // default. So use the old headertype instead
                        
-                       area_copy_data(old, CTX_wm_area(C), 1); /*  1 = swap spacelist */
+                       area_copy_data(old, sa, 1);     /*  1 = swap spacelist */
                        
                        old->full= NULL;
                        
@@ -1280,8 +1282,8 @@ void ed_screen_fullarea(bContext *C)
                oldscreen= CTX_wm_screen(C);
 
                /* is there only 1 area? */
-               if(oldscreen->areabase.first==CTX_wm_screen(C)->areabase.last) return;
-               if(CTX_wm_area(C)->spacetype==SPACE_INFO) return;
+               if(oldscreen->areabase.first==oldscreen->areabase.last) return;
+               if(sa->spacetype==SPACE_INFO) return;
                
                oldscreen->full = SCREENFULL;
                
@@ -1297,9 +1299,9 @@ void ed_screen_fullarea(bContext *C)
 
                /* copy area */
                newa= newa->prev;
-               area_copy_data(newa, CTX_wm_area(C), 1);        /* 1 = swap spacelist */
+               area_copy_data(newa, sa, 1);    /* 1 = swap spacelist */
 
-               CTX_wm_area(C)->full= oldscreen;
+               sa->full= oldscreen;
                newa->full= oldscreen;
                newa->next->full= oldscreen;
 
@@ -1316,8 +1318,9 @@ void ed_screen_fullarea(bContext *C)
 void ED_screen_full_newspace(bContext *C, ScrArea *sa, int type)
 {
        if(sa->full==0)
-               ed_screen_fullarea(C);
+               ed_screen_fullarea(C, sa);
 
+       /* CTX_wm_area(C) is new area */
        ED_area_newspace(C, CTX_wm_area(C), type);
 }
 
@@ -1328,7 +1331,7 @@ void ED_screen_full_prevspace(bContext *C)
        ED_area_prevspace(C);
        
        if(sa->full)
-               ed_screen_fullarea(C);
+               ed_screen_fullarea(C, sa);
 }
 
 void ED_screen_animation_timer(bContext *C, int enable)
@@ -1345,3 +1348,57 @@ void ED_screen_animation_timer(bContext *C, int enable)
                screen->animtimer= WM_event_add_window_timer(win, TIMER0, (1.0/FPS));
 }
 
+unsigned int ED_screen_view3d_layers(bScreen *screen)
+{
+       if(screen) {
+               unsigned int layer= screen->scene->lay; /* as minimum this */
+               ScrArea *sa;
+               
+               /* get all used view3d layers */
+               for(sa= screen->areabase.first; sa; sa= sa->next) {
+                       if(sa->spacetype==SPACE_VIEW3D)
+                               layer |= ((View3D *)sa->spacedata.first)->lay;
+               }
+               return layer;
+       }
+       return 0;
+}
+
+
+/* results in fully updated anim system */
+/* in future sound should be on WM level, only 1 sound can play! */
+void ED_update_for_newframe(const bContext *C, int mute)
+{
+       bScreen *screen= CTX_wm_screen(C);
+       Scene *scene= screen->scene;
+       
+       //extern void audiostream_scrub(unsigned int frame);    /* seqaudio.c */
+       
+       /* this function applies the changes too */
+       /* XXX future: do all windows */
+       scene_update_for_newframe(scene, ED_screen_view3d_layers(screen)); /* BKE_scene.h */
+       
+       //if ( (CFRA>1) && (!mute) && (scene->audio.flag & AUDIO_SCRUB)) 
+       //      audiostream_scrub( CFRA );
+       
+       /* 3d window, preview */
+       //BIF_view3d_previewrender_signal(curarea, PR_DBASE|PR_DISPRECT);
+       
+       /* all movie/sequence images */
+       //BIF_image_update_frame();
+       
+       /* composite */
+       if(scene->use_nodes && scene->nodetree)
+               ntreeCompositTagAnimated(scene->nodetree);
+       
+       /* update animated texture nodes */
+       {
+               Tex *tex;
+               for(tex= G.main->tex.first; tex; tex= tex->id.next)
+                       if( tex->use_nodes && tex->nodetree ) {
+                               ntreeTexTagAnimated( tex->nodetree );
+                       }
+       }
+}
+
+
index 862c434..3389079 100644 (file)
@@ -53,7 +53,7 @@ ScrEdge               *screen_find_active_scredge(bScreen *sc, int mx, int my);
 AZone          *is_in_area_actionzone(ScrArea *sa, int x, int y);
 
 void           ed_screen_set(bContext *C, bScreen *sc);
-void           ed_screen_fullarea(bContext *C);
+void           ed_screen_fullarea(bContext *C, ScrArea *sa);
 
 /* screen_context.c */
 void ed_screen_context(const bContext *C, bContextDataMember member, bContextDataResult *result);
index 759fc1f..e689920 100644 (file)
 #include "BLI_blenlib.h"
 #include "BLI_editVert.h"
 
+#include "DNA_armature_types.h"
+#include "DNA_image_types.h"
+#include "DNA_object_types.h"
+#include "DNA_mesh_types.h"
+#include "DNA_curve_types.h"
+#include "DNA_scene_types.h"
+
+#include "BKE_blender.h"
 #include "BKE_context.h"
 #include "BKE_customdata.h"
+#include "BKE_global.h"
+#include "BKE_image.h"
 #include "BKE_idprop.h"
 #include "BKE_library.h"
 #include "BKE_main.h"
 #include "BKE_screen.h"
 #include "BKE_utildefines.h"
 
-#include "DNA_armature_types.h"
-#include "DNA_object_types.h"
-#include "DNA_mesh_types.h"
-#include "DNA_curve_types.h"
-#include "DNA_scene_types.h"
-
 #include "WM_api.h"
 #include "WM_types.h"
 
-#include "ED_markers.h"
 #include "ED_util.h"
 #include "ED_screen.h"
 #include "ED_screen_types.h"
 
+#include "RE_pipeline.h"
+#include "IMB_imbuf.h"
+#include "IMB_imbuf_types.h"
+
 #include "RNA_access.h"
 #include "RNA_define.h"
 
@@ -153,6 +160,11 @@ int ED_operator_sequencer_active(bContext *C)
        return ed_spacetype_test(C, SPACE_SEQ);
 }
 
+int ED_operator_image_active(bContext *C)
+{
+       return ed_spacetype_test(C, SPACE_IMAGE);
+}
+
 int ED_operator_object_active(bContext *C)
 {
        return NULL != CTX_data_active_object(C);
@@ -1042,7 +1054,7 @@ void SCREEN_OT_screen_set(wmOperatorType *ot)
 /* function to be called outside UI context, or for redo */
 static int screen_full_area_exec(bContext *C, wmOperator *op)
 {
-       ed_screen_fullarea(C);
+       ed_screen_fullarea(C, CTX_wm_area(C));
        return OPERATOR_FINISHED;
 }
 
@@ -1797,6 +1809,319 @@ void SCREEN_OT_border_select(wmOperatorType *ot)
 }
 #endif
 
+/* ****************************** render invoking ***************** */
+
+/* set callbacks, exported to sequence render too. 
+Only call in foreground (UI) renders. */
+
+/* returns biggest area that is not uv/image editor. Note that it uses buttons */
+/* window as the last possible alternative.                                                                       */
+static ScrArea *biggest_non_image_area(bContext *C)
+{
+       bScreen *sc= CTX_wm_screen(C);
+       ScrArea *sa, *big= NULL;
+       int size, maxsize= 0, bwmaxsize= 0;
+       short foundwin= 0;
+       
+       for(sa= sc->areabase.first; sa; sa= sa->next) {
+               if(sa->winx > 10 && sa->winy > 10) {
+                       size= sa->winx*sa->winy;
+                       if(sa->spacetype == SPACE_BUTS) {
+                               if(foundwin == 0 && size > bwmaxsize) {
+                                       bwmaxsize= size;
+                                       big= sa;        
+                               }
+                       }
+                       else if(sa->spacetype != SPACE_IMAGE && size > maxsize) {
+                               maxsize= size;
+                               big= sa;
+                               foundwin= 1;
+                       }
+               }
+       }
+       
+       return big;
+}
+
+static ScrArea *biggest_area(bContext *C)
+{
+       bScreen *sc= CTX_wm_screen(C);
+       ScrArea *sa, *big= NULL;
+       int size, maxsize= 0;
+       
+       for(sa= sc->areabase.first; sa; sa= sa->next) {
+               size= sa->winx*sa->winy;
+               if(size > maxsize) {
+                       maxsize= size;
+                       big= sa;
+               }
+       }
+       return big;
+}
+
+
+static ScrArea *find_area_showing_r_result(bContext *C)
+{
+       bScreen *sc= CTX_wm_screen(C);
+       ScrArea *sa;
+       SpaceImage *sima;
+       
+       /* find an imagewindow showing render result */
+       for(sa=sc->areabase.first; sa; sa= sa->next) {
+               if(sa->spacetype==SPACE_IMAGE) {
+                       sima= sa->spacedata.first;
+                       if(sima->image && sima->image->type==IMA_TYPE_R_RESULT)
+                               break;
+               }
+       }
+       return sa;
+}
+
+static void screen_set_image_output(bContext *C)
+{
+       ScrArea *sa;
+       SpaceImage *sima;
+       
+       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;
+                       
+                       ed_screen_fullarea(C, sa);
+               }
+       }
+       
+}
+
+/* executes blocking render */
+static int screen_render_exec(bContext *C, wmOperator *op)
+{
+       Scene *scene= CTX_data_scene(C);
+       Render *re= RE_GetRender(scene->id.name);
+       
+       if(re==NULL) {
+               re= RE_NewRender(scene->id.name);
+       }
+       RE_test_break_cb(re, NULL, (int (*)(void *)) blender_test_break);
+       
+       if(RNA_boolean_get(op->ptr, "anim"))
+               RE_BlenderAnim(re, scene, scene->r.sfra, scene->r.efra, scene->frame_step);
+       else
+               RE_BlenderFrame(re, scene, scene->r.cfra);
+       
+       // no redraw needed, we leave state as we entered it
+       ED_update_for_newframe(C, 1);
+       
+       WM_event_add_notifier(C, NC_SCENE|ND_RENDER_RESULT, scene);
+
+       return OPERATOR_FINISHED;
+}
+
+typedef struct RenderJob {
+       Scene *scene;
+       Render *re;
+       wmWindow *win;
+       int anim;
+       short *stop;
+       short *do_update;
+} RenderJob;
+
+static void render_freejob(void *rjv)
+{
+       RenderJob *rj= rjv;
+       
+       MEM_freeN(rj);
+}
+
+/* called inside thread! */
+static void image_rect_update(void *rjv, RenderResult *rr, volatile rcti *rect)
+{
+       /* rect null means per tile */
+       if(rect==NULL) {
+               RenderJob *rj= rjv;
+               ScrArea *sa;
+               
+               // XXX validate window?
+               
+               /* find an imagewindow showing render result */
+               for(sa= rj->win->screen->areabase.first; sa; sa= sa->next) {
+                       if(sa->spacetype==SPACE_IMAGE) {
+                               SpaceImage *sima= sa->spacedata.first;
+                               
+                               if(sima->image && sima->image->type==IMA_TYPE_R_RESULT) {
+                                       /* force refresh */
+                                       sima->pad= 1; // XXX temp
+                                       *(rj->do_update)= 1;
+                               }
+                       }
+               }
+       }
+}
+
+static void render_startjob(void *rjv, short *stop, short *do_update)
+{
+       RenderJob *rj= rjv;
+       
+       rj->stop= stop;
+       rj->do_update= do_update;
+       
+       if(rj->anim)
+               RE_BlenderAnim(rj->re, rj->scene, rj->scene->r.sfra, rj->scene->r.efra, rj->scene->frame_step);
+       else
+               RE_BlenderFrame(rj->re, rj->scene, rj->scene->r.cfra);
+}
+
+/* called by render, check job 'stop' value or the global */
+static int render_breakjob(void *rjv)
+{
+       RenderJob *rj= rjv;
+       
+       if(G.afbreek)
+               return 1;
+       if(rj->stop && *(rj->stop))
+               return 1;
+       return 0;
+}
+
+/* using context, starts job */
+static int screen_render_invoke(bContext *C, wmOperator *op, wmEvent *event)
+{
+       /* new render clears all callbacks */
+       Scene *scene= CTX_data_scene(C);
+       Render *re;
+       wmJob *steve;
+       RenderJob *rj;
+       Image *ima;
+       
+       /* only one job at a time */
+       if(WM_jobs_test(CTX_wm_manager(C), scene))
+               return OPERATOR_CANCELLED;
+       
+       /* handle UI stuff */
+       WM_cursor_wait(1);
+       
+       // get editmode results, sculpt mode results (no set sculptmode in end!)
+       // store spare
+       // get view3d layer, local layer, make this nice api call to render
+       // store spare
+       
+       /* ensure at least 1 area shows result */
+       screen_set_image_output(C);
+
+       /* job custom data */
+       rj= MEM_callocN(sizeof(RenderJob), "render job");
+       rj->scene= scene;
+       rj->win= CTX_wm_window(C);
+       rj->anim= RNA_boolean_get(op->ptr, "anim");
+       
+       /* setup job */
+       steve= WM_jobs_get(CTX_wm_manager(C), CTX_wm_window(C), scene);
+       WM_jobs_customdata(steve, rj, render_freejob);
+       WM_jobs_timer(steve, 0.2, NC_SCENE|ND_RENDER_RESULT, 0);
+       WM_jobs_callbacks(steve, render_startjob, NULL, NULL);
+       
+       /* get a render result image, and make sure it is clean */
+       ima= BKE_image_verify_viewer(IMA_TYPE_R_RESULT, "Render Result");
+       BKE_image_signal(ima, NULL, IMA_SIGNAL_FREE);
+          
+       /* setup new render */
+       re= RE_NewRender(scene->id.name);
+       RE_test_break_cb(re, rj, render_breakjob);
+       RE_display_draw_cb(re, rj, image_rect_update);
+       rj->re= re;
+       G.afbreek= 0;
+       
+       //      BKE_report in render!
+       //      RE_error_cb(re, error_cb);
+
+       WM_jobs_start(steve);
+       
+       G.afbreek= 0;
+       
+       WM_cursor_wait(0);
+       WM_event_add_notifier(C, NC_SCENE|ND_RENDER_RESULT, scene);
+
+       return OPERATOR_FINISHED;
+}
+
+
+/* contextual render, using current scene, view3d? */
+void SCREEN_OT_render(wmOperatorType *ot)
+{
+       /* identifiers */
+       ot->name= "Render";
+       ot->idname= "SCREEN_OT_render";
+       
+       /* api callbacks */
+       ot->invoke= screen_render_invoke;
+       ot->exec= screen_render_exec;
+       
+       ot->poll= ED_operator_screenactive;
+       
+       RNA_def_int(ot->srna, "layers", 0, 0, INT_MAX, "Layers", "", 0, INT_MAX);
+       RNA_def_boolean(ot->srna, "anim", 0, "Animation", "");
+}
+
+/* *********************** cancel render viewer *************** */
+
+static int render_view_cancel_exec(bContext *C, wmOperator *unused)
+{
+       ScrArea *sa= CTX_wm_area(C);
+       SpaceImage *sima= sa->spacedata.first;
+       
+       if(sima->flag & SI_PREVSPACE) {
+               sima->flag &= ~SI_PREVSPACE;
+               ED_area_prevspace(C);
+       }
+       else if(sima->flag & SI_FULLWINDOW) {
+               sima->flag &= ~SI_FULLWINDOW;
+               ED_screen_full_prevspace(C);
+       }
+       
+       return OPERATOR_FINISHED;
+}
+
+void SCREEN_OT_render_view_cancel(struct wmOperatorType *ot)
+{
+       /* identifiers */
+       ot->name= "Cancel Render View";
+       ot->idname= "SCREEN_OT_render_view_cancel";
+       
+       /* api callbacks */
+       ot->exec= render_view_cancel_exec;
+       ot->poll= ED_operator_image_active;
+}
+
+
 /* ****************  Assigning operatortypes to global list, adding handlers **************** */
 
 /* called in spacetypes.c */
@@ -1823,10 +2148,13 @@ void ED_operatortypes_screen(void)
        WM_operatortype_append(SCREEN_OT_frame_offset);
        WM_operatortype_append(SCREEN_OT_animation_play);
        
+       /* render */
+       WM_operatortype_append(SCREEN_OT_render);
+       WM_operatortype_append(SCREEN_OT_render_view_cancel);
+       
        /* tools shared by more space types */
        WM_operatortype_append(ED_OT_undo);
-       WM_operatortype_append(ED_OT_redo);
-       ED_marker_operatortypes();      
+       WM_operatortype_append(ED_OT_redo);     
        
 }
 
@@ -1869,9 +2197,9 @@ void ED_keymap_screen(wmWindowManager *wm)
        WM_keymap_add_item(keymap, "ED_OT_redo", ZKEY, KM_PRESS, KM_SHIFT|KM_CTRL, 0);
        WM_keymap_add_item(keymap, "ED_OT_redo", ZKEY, KM_PRESS, KM_SHIFT|KM_OSKEY, 0);
                                                  
-       /* screen level global keymaps */
-       // err...
-       ED_marker_keymap(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);
        
        /* frame offsets */
        keymap= WM_keymap_listbase(wm, "Frames", 0, 0);
index f31512f..86d2984 100644 (file)
@@ -43,6 +43,7 @@
 #include "ED_armature.h"
 #include "ED_curve.h"
 #include "ED_mesh.h"
+#include "ED_markers.h"
 #include "ED_object.h"
 #include "ED_sculpt.h"
 #include "ED_screen.h"
@@ -83,6 +84,7 @@ void ED_spacetypes_init(void)
        ED_operatortypes_uvedit();
        ED_operatortypes_curve();
        ED_operatortypes_armature();
+       ED_marker_operatortypes();
        
        ui_view2d_operatortypes();
        
@@ -108,7 +110,8 @@ void ED_spacetypes_keymap(wmWindowManager *wm)
        ED_keymap_uvedit(wm);
        ED_keymap_curve(wm);
        ED_keymap_armature(wm);
-       
+       ED_marker_keymap(wm);
+
        UI_view2d_keymap(wm);
 
        spacetypes = BKE_spacetypes_list();
index ac05471..d3f30d4 100644 (file)
@@ -488,10 +488,10 @@ void file_draw_list(const bContext *C, ARegion *ar)
                if (params->active_file == i) {
                        if (file->flags & ACTIVE) colorid= TH_HILITE;
                        else colorid = TH_BACK;
-                       draw_tile(sx, sy-3, sfile->tile_w, sfile->tile_h, colorid,20);
+                       draw_tile(sx-2, sy-3, sfile->tile_w+2, sfile->tile_h, colorid,20);
                } else if (file->flags & ACTIVE) {
                        colorid = TH_HILITE;
-                       draw_tile(sx, sy-3, sfile->tile_w, sfile->tile_h, colorid,0);
+                       draw_tile(sx-2, sy-3, sfile->tile_w+2, sfile->tile_h, colorid,0);
                } else {
                        /*
                        colorid = TH_PANEL;
index 99869ba..6238774 100644 (file)
@@ -121,6 +121,10 @@ static void image_verify_buffer_float(SpaceImage *sima, ImBuf *ibuf)
                        else 
                                IMB_rect_from_float(ibuf);
                }
+               else if(sima->pad) {
+                       sima->pad= 0; // XXX temp for render updates!
+                       IMB_rect_from_float(ibuf);
+               }
        }
 }
 
@@ -667,6 +671,8 @@ void draw_image_main(SpaceImage *sima, ARegion *ar, Scene *scene)
        }
 #endif
 
+       /* put scene context variable in iuser */
+       sima->iuser.scene= scene;
        /* retrieve the image and information about it */
        ima= get_space_image(sima);
        ibuf= get_space_image_buffer(sima);
index 637d4b9..381e122 100644 (file)
@@ -26,6 +26,7 @@
  */
 
 #include <stdlib.h>
+#include <stdio.h>
 
 #include "DNA_image_types.h"
 #include "DNA_screen_types.h"
 #include "BKE_context.h"
 #include "BKE_global.h"
 #include "BKE_image.h"
+#include "BKE_screen.h"
 
 #include "BIF_gl.h"
 #include "BIF_glutil.h"
 
+#include "ED_screen.h"
+
 #include "RE_pipeline.h"
 
+#include "WM_api.h"
+
 #define HEADER_HEIGHT 18
 
 /* *********************** render callbacks ***************** */
@@ -48,9 +54,9 @@
 static ScrArea *image_area= NULL;
 
 /* can get as well the full picture, as the parts while rendering */
-static void imagewindow_progress(ScrArea *sa, RenderResult *rr, volatile rcti *renrect)
+/* XXX will be obsolete, here for reference now */
+void imagewindow_progress(SpaceImage *sima, RenderResult *rr, volatile rcti *renrect)
 {
-       SpaceImage *sima= sa->spacedata.first;
        float x1, y1, *rectf= NULL;
        unsigned int *rect32= NULL;
        int ymin, ymax, xmin, xmax;
@@ -119,171 +125,6 @@ static void imagewindow_progress(ScrArea *sa, RenderResult *rr, volatile rcti *r
        
 }
 
-/* in render window; display a couple of scanlines of rendered image */
-/* NOTE: called while render, so no malloc allowed! */
-static void imagewindow_progress_display_cb(void *handle, RenderResult *rr, volatile rcti *rect)
-{
-       if (image_area) {
-               imagewindow_progress(image_area, rr, rect);
-
-               /* no screen_swapbuffers, prevent any other window to draw */
-               // XXX myswapbuffers();
-       }
-}
-
-/* unused, init_display_cb is called on each render */
-static void imagewindow_clear_display_cb(void *handle, RenderResult *rr)
-{
-       if (image_area) {
-       }
-}
-
-/* returns biggest area that is not uv/image editor. Note that it uses buttons */
-/* window as the last possible alternative.                                                                       */
-static ScrArea *biggest_non_image_area(bContext *C)
-{
-       bScreen *sc= CTX_wm_screen(C);
-       ScrArea *sa, *big= NULL;
-       int size, maxsize= 0, bwmaxsize= 0;
-       short foundwin= 0;
-       
-       for(sa= sc->areabase.first; sa; sa= sa->next) {
-               if(sa->winx > 10 && sa->winy > 10) {
-                       size= sa->winx*sa->winy;
-                       if(sa->spacetype == SPACE_BUTS) {
-                               if(foundwin == 0 && size > bwmaxsize) {
-                                       bwmaxsize= size;
-                                       big= sa;        
-                               }
-                       }
-                       else if(sa->spacetype != SPACE_IMAGE && size > maxsize) {
-                               maxsize= size;
-                               big= sa;
-                               foundwin= 1;
-                       }
-               }
-       }
-               
-       return big;
-}
-
-static ScrArea *biggest_area(bContext *C)
-{
-       bScreen *sc= CTX_wm_screen(C);
-       ScrArea *sa, *big= NULL;
-       int size, maxsize= 0;
-       
-       for(sa= sc->areabase.first; sa; sa= sa->next) {
-               size= sa->winx*sa->winy;
-               if(size > maxsize) {
-                       maxsize= size;
-                       big= sa;
-               }
-       }
-       return big;
-}
-
-
-/* if R_DISPLAYIMAGE
-      use Image Window showing Render Result
-         else: turn largest non-image area into Image Window (not to frustrate texture or composite usage)
-         else: then we use Image Window anyway...
-   if R_DISPSCREEN
-      make a new temp fullscreen area with Image Window
-*/
-
-static ScrArea *find_area_showing_r_result(bContext *C)
-{
-       bScreen *sc= CTX_wm_screen(C);
-       ScrArea *sa;
-       SpaceImage *sima;
-       
-       /* find an imagewindow showing render result */
-       for(sa=sc->areabase.first; sa; sa= sa->next) {
-               if(sa->spacetype==SPACE_IMAGE) {
-                       sima= sa->spacedata.first;
-                       if(sima->image && sima->image->type==IMA_TYPE_R_RESULT)
-                               break;
-               }
-       }
-       return sa;
-}
-
-static ScrArea *imagewindow_set_render_display(bContext *C)
-{
-       ScrArea *sa;
-       SpaceImage *sima;
-       
-       sa= find_area_showing_r_result(C);
-       
-       if(sa==NULL) {
-               /* find largest open non-image area */
-               sa= biggest_non_image_area(C);
-               if(sa) {
-                       // XXX newspace(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(0) { // XXX G.displaymode==R_DISPLAYSCREEN) {
-               if(sa->full==0) {
-                       sima->flag |= SI_FULLWINDOW;
-                       /* fullscreen works with lousy curarea */
-                       // XXX curarea= sa;
-                       // XXX area_fullscreen();
-                       // XXX sa= curarea;
-               }
-       }
-       
-       return sa;
-}
-
-static void imagewindow_init_display_cb(void *handle, RenderResult *rr)
-{
-       bContext *C= NULL; // XXX
-
-       image_area= imagewindow_set_render_display(C);
-       
-       if(image_area) {
-               SpaceImage *sima= image_area->spacedata.first;
-               
-               // XXX areawinset(image_area->win);
-               
-               /* calc location using original size (tiles don't tell) */
-               sima->centx= (image_area->winx - sima->zoom*(float)rr->rectx)/2.0f;
-               sima->centy= (image_area->winy - sima->zoom*(float)rr->recty)/2.0f;
-               
-               sima->centx-= sima->zoom*sima->xof;
-               sima->centy-= sima->zoom*sima->yof;
-               
-               // XXX drawimagespace(image_area, sima);
-               // XXX if(image_area->headertype) scrarea_do_headdraw(image_area);
-
-               /* no screen_swapbuffers, prevent any other window to draw */
-               // XXX myswapbuffers();
-               
-               // XXX allqueue(REDRAWIMAGE, 0);        /* redraw in end */
-       }
-}
 
 /* coming from BIF_toggle_render_display() */
 void imagewindow_toggle_render(bContext *C)
@@ -306,7 +147,7 @@ void imagewindow_toggle_render(bContext *C)
                // XXX addqueue(sa->win, ESCKEY, 1);    /* also returns from fullscreen */
        }
        else {
-               sa= imagewindow_set_render_display(C);
+//             sa= imagewindow_set_render_display(C);
                // XXX scrarea_queue_headredraw(sa);
                // XXX scrarea_queue_winredraw(sa);
        }
@@ -325,12 +166,12 @@ static void imagewindow_renderinfo_cb(void *handle, RenderStats *rs)
        }
 }
 
-void imagewindow_render_callbacks(Render *re)
+void ED_space_image_render_callbacks(bContext *C, Render *re)
 {
-       /* XXX fill in correct handler */
-       RE_display_init_cb(re, NULL, imagewindow_init_display_cb);
-       RE_display_draw_cb(re, NULL, imagewindow_progress_display_cb);
-       RE_display_clear_cb(re, NULL, imagewindow_clear_display_cb);
-       RE_stats_draw_cb(re, NULL, imagewindow_renderinfo_cb);  
+       
+//     RE_display_init_cb(re, C, imagewindow_init_display_cb);
+//     RE_display_draw_cb(re, C, imagewindow_progress_display_cb);
+//     RE_display_clear_cb(re, C, imagewindow_clear_display_cb);
+       RE_stats_draw_cb(re, C, imagewindow_renderinfo_cb);     
 }
 
index 0a6ff9e..59e30d8 100644 (file)
@@ -39,6 +39,7 @@
 #include "BLI_blenlib.h"
 
 #include "BKE_context.h"
+#include "BKE_global.h"
 #include "BKE_screen.h"
 
 #include "ED_screen.h"
 
 /* ************************ header area region *********************** */
 
+#define B_STOPRENDER 1
+
 static void do_viewmenu(bContext *C, void *arg, int event)
 {
-       
 }
 
 static uiBlock *dummy_viewmenu(bContext *C, ARegion *ar, void *arg_unused)
@@ -95,6 +97,9 @@ static uiBlock *dummy_viewmenu(bContext *C, ARegion *ar, void *arg_unused)
 static void do_info_buttons(bContext *C, void *arg, int event)
 {
        switch(event) {
+               case B_STOPRENDER:
+                       G.afbreek= 1;
+                       break;
        }
 }
 
@@ -139,13 +144,14 @@ void info_header_buttons(const bContext *C, ARegion *ar)
                xmax= GetButStringLength("Help");
                uiDefPulldownBut(block, dummy_viewmenu, NULL, "Help",   xco, yco, xmax-3, 22, "");
                xco+= xmax;
-               
-               
-               
        }
        
        uiBlockSetEmboss(block, UI_EMBOSS);
 
+       if(WM_jobs_test(CTX_wm_manager(C), CTX_data_scene(C))) {
+               uiDefIconTextBut(block, BUT, B_STOPRENDER, ICON_REC, "Render", xco+5,yco,75,19, NULL, 0.0f, 0.0f, 0, 0, "Stop rendering");
+       }
+       
        /* always as last  */
        UI_view2d_totRect_set(&ar->v2d, xco+XIC+80, ar->v2d.tot.ymax-ar->v2d.tot.ymin);
        
index 7ee6d67..8b01080 100644 (file)
@@ -192,6 +192,17 @@ static void info_main_area_listener(ARegion *ar, wmNotifier *wmn)
        /* context changes */
 }
 
+static void info_header_listener(ARegion *ar, wmNotifier *wmn)
+{
+       /* context changes */
+       switch(wmn->category) {
+               case NC_SCENE:
+                       if(wmn->data==ND_RENDER_RESULT)
+                               ED_region_tag_redraw(ar);
+       }
+       
+}
+
 /* only called once, from space/spacetypes.c */
 void ED_spacetype_info(void)
 {
@@ -222,7 +233,7 @@ void ED_spacetype_info(void)
        art->regionid = RGN_TYPE_HEADER;
        art->minsizey= HEADERY;
        art->keymapflag= ED_KEYMAP_UI|ED_KEYMAP_VIEW2D;
-       
+       art->listener= info_header_listener;
        art->init= info_header_area_init;
        art->draw= info_header_area_draw;
        
index fe5d196..46242b7 100644 (file)
@@ -513,7 +513,7 @@ void node_composit_default(Scene *sce)
        out= nodeAddNodeType(sce->nodetree, CMP_NODE_COMPOSITE, NULL, NULL);
        out->locx= 300.0f; out->locy= 400.0f;
        
-       in= nodeAddNodeType(sce->nodetree, CMP_NODE_R_LAYERS, NULL, NULL);
+       in= nodeAddNodeType(sce->nodetree, CMP_NODE_R_LAYERS, NULL, &sce->id);
        in->locx= 10.0f; in->locy= 400.0f;
        nodeSetActive(sce->nodetree, in);
        
index de09d8f..a57e38f 100644 (file)
@@ -142,7 +142,9 @@ static Render *envmap_render_copy(Render *re, EnvMap *env)
        
        /* callbacks */
        envre->display_draw= re->display_draw;
+       envre->ddh= re->ddh;
        envre->test_break= re->test_break;
+       envre->tbh= re->tbh;
        
        /* and for the evil stuff; copy the database... */
        envre->totvlak= re->totvlak;
index 70f03fa..b271af0 100644 (file)
@@ -1013,6 +1013,10 @@ Render *RE_NewRender(const char *name)
                strncpy(re->name, name, RE_MAXNAME);
        }
        
+       /* prevent UI to draw old results immediately */
+       RE_FreeRenderResult(re->result);
+       re->result= NULL;
+       
        /* set default empty callbacks */
        re->display_init= result_nothing;
        re->display_clear= result_nothing;
@@ -1948,8 +1952,11 @@ static void render_scene(Render *re, Scene *sce, int cfra)
 
        /* copy callbacks */
        resc->display_draw= re->display_draw;
+       resc->ddh= re->ddh;
        resc->test_break= re->test_break;
+       resc->tbh= re->tbh;
        resc->stats_draw= re->stats_draw;
+       resc->sdh= re->sdh;
        
        do_render_fields_blur_3d(resc);
 }
index 6bcca9e..7c9e0d9 100644 (file)
@@ -47,7 +47,6 @@
 #include "BKE_report.h"
 #include "BKE_utildefines.h"
 
-#include "ED_anim_api.h"
 #include "ED_screen.h"
 #include "ED_space_api.h"
 #include "ED_util.h"
index 654555f..5fe4639 100644 (file)
@@ -213,7 +213,7 @@ void WM_exit(bContext *C)
        BPY_end_python();
 #endif
        
-//     fastshade_free_render();        /* shaded view */
+       fastshade_free_render();        /* shaded view */
        ED_preview_free_dbase();        /* frees a Main dbase, before free_blender! */
        free_blender();                         /* blender.c, does entire library and spacetypes */
 //     free_matcopybuf();