Added WM Jobs manager
- WM can manage threaded jobs for you; just provide a couple
  of components to get it work:
  - customdata, free callback for it
  - timer step, notifier code
  - start callback, update callback
- Once started, each job runs an own timer, and will for
  every time step check necessary updates, or close the
  job when ready. 
- No drawing happens in jobs, that's for notifiers!
- Every job stores an owner pointer, and based on this owner
  it will prevent multiple jobs to enter the stack. 
  Instead it will re-use a running job, signal it to stop
  and allow caller to re-initialize it even.
- Check new wm_jobs.c for more explanation. Jobs API is still
  under construction. 
  Fun: BLI_addtail(&wm->jobs, steve); :)

Put Node shader previews back using wmJobs
- Preview calculating is now fully threaded (1 thread still)
- Thanks to new event system + notifiers, you can see 
  previews update even while dragging sliders!
- Currently it only starts when you change a node setting.

Warning: the thread render shares Node data, so don't delete
nodes while it renders! This topic is on the todo to make safe.

Also:
- bug in region initialize (do_versions) showed channel list in
  node editor wrong.
- flagged the channel list 'hidden' now, it was really in the
  way! This is for later to work on anyway. 
- recoded Render API callbacks so it gets handlers passed on, 
  no globals to use anymore, remember?
- previewrender code gets now so much nicer! Will remove a lot
  of stuff from code soon.
This commit is contained in:
2009-01-22 14:59:49 +00:00
parent a017982074
commit 9cc59fb0c3
38 changed files with 14714 additions and 254 deletions

View File

@@ -47,6 +47,7 @@
#include "BKE_context.h"
#include "BKE_screen.h"
#include "ED_previewrender.h"
#include "ED_space_api.h"
#include "ED_screen.h"
@@ -85,7 +86,7 @@ static SpaceLink *node_new(const bContext *C)
ar->regiontype= RGN_TYPE_CHANNELS;
ar->alignment= RGN_ALIGN_LEFT;
ar->v2d.scroll = (V2D_SCROLL_RIGHT|V2D_SCROLL_BOTTOM);
//ar->v2d.scroll = (V2D_SCROLL_RIGHT|V2D_SCROLL_BOTTOM);
/* main area */
ar= MEM_callocN(sizeof(ARegion), "main area for node");
@@ -134,6 +135,34 @@ static void node_init(struct wmWindowManager *wm, ScrArea *sa)
}
static void node_area_listener(ScrArea *sa, wmNotifier *wmn)
{
/* preview renders */
switch(wmn->category) {
case NC_SCENE:
break;
case NC_MATERIAL:
/* future: add ID check? */
if(wmn->data==ND_SHADING)
ED_area_tag_refresh(sa);
break;
}
}
static void node_area_refresh(const struct bContext *C, struct ScrArea *sa)
{
/* default now: refresh node is starting preview */
SpaceNode *snode= sa->spacedata.first;
if(snode->treetype==NTREE_SHADER) {
if(snode->nodetree) {
ED_preview_shader_job(C, sa, snode->id, 100, 100);
}
}
}
static SpaceLink *node_duplicate(SpaceLink *sl)
{
SpaceNode *snoden= MEM_dupallocN(sl);
@@ -231,9 +260,6 @@ static void node_main_area_listener(ARegion *ar, wmNotifier *wmn)
case NC_MATERIAL:
ED_region_tag_redraw(ar);
break;
case ND_NODES:
ED_region_tag_redraw(ar);
break;
}
}
@@ -269,6 +295,8 @@ void ED_spacetype_node(void)
st->duplicate= node_duplicate;
st->operatortypes= node_operatortypes;
st->keymap= node_keymap;
st->listener= node_area_listener;
st->refresh= node_area_refresh;
st->context= node_context;
/* regions: main window */
@@ -295,7 +323,7 @@ void ED_spacetype_node(void)
/* regions: channels */
art= MEM_callocN(sizeof(ARegionType), "spacetype node region");
art->regionid = RGN_TYPE_CHANNELS;
art->minsizex= 200;
art->minsizex= 100;
art->keymapflag= ED_KEYMAP_UI|ED_KEYMAP_VIEW2D;
art->init= node_channel_area_init;