diff options
author | Campbell Barton <ideasman42@gmail.com> | 2010-03-08 23:08:04 +0300 |
---|---|---|
committer | Campbell Barton <ideasman42@gmail.com> | 2010-03-08 23:08:04 +0300 |
commit | b356eb6a8bfad738028e67844c7755f5684f7ce3 (patch) | |
tree | 8f25c3ecec179fb6733f8586ef3f9165c4a8f12f /source/blender/blenkernel/intern | |
parent | 187b3bc1eba6822a0fb3b3fc5b5345d2d11ec34c (diff) |
image re-project now uses offscreen render function and has input for render size.
unrelated changes that ended up being more trouble to commit separate...
- removed BLI_split_dirfile(), was nasty, occasionaly modifying the source string, it could create directories and used the $CWD in some cases. was only used in 2 places in filesel.c, if this gives problems can address without bringing back this function.
renamed BLI_split_dirfile_basic --> BLI_split_dirfile
- view3d_operator_needs_opengl was being called for offscreen render when it wasnt needed.
Diffstat (limited to 'source/blender/blenkernel/intern')
-rw-r--r-- | source/blender/blenkernel/intern/image.c | 21 | ||||
-rw-r--r-- | source/blender/blenkernel/intern/pointcache.c | 2 | ||||
-rw-r--r-- | source/blender/blenkernel/intern/sequencer.c | 119 | ||||
-rw-r--r-- | source/blender/blenkernel/intern/sound.c | 2 | ||||
-rw-r--r-- | source/blender/blenkernel/intern/text.c | 4 |
5 files changed, 89 insertions, 59 deletions
diff --git a/source/blender/blenkernel/intern/image.c b/source/blender/blenkernel/intern/image.c index accadb3d434..ac107212e30 100644 --- a/source/blender/blenkernel/intern/image.c +++ b/source/blender/blenkernel/intern/image.c @@ -563,10 +563,8 @@ static ImBuf *add_ibuf_size(int width, int height, char *name, int floatbuf, sho /* adds new image block, creates ImBuf and initializes color */ Image *BKE_add_image_size(int width, int height, char *name, int floatbuf, short uvtestgrid, float color[4]) { - Image *ima; - /* on save, type is changed to FILE in editsima.c */ - ima= image_alloc(name, IMA_SRC_GENERATED, IMA_TYPE_UV_TEST); + Image *ima= image_alloc(name, IMA_SRC_GENERATED, IMA_TYPE_UV_TEST); if (ima) { ImBuf *ibuf; @@ -585,6 +583,23 @@ Image *BKE_add_image_size(int width, int height, char *name, int floatbuf, short return ima; } +/* creates an image image owns the imbuf passed */ +Image *BKE_add_image_imbuf(ImBuf *ibuf) +{ + /* on save, type is changed to FILE in editsima.c */ + char filename[sizeof(ibuf->name)]; + BLI_split_dirfile(ibuf->name, NULL, filename); + Image *ima= image_alloc(filename, IMA_SRC_FILE, IMA_TYPE_IMAGE); + + if (ima) { + BLI_strncpy(ima->name, ibuf->name, FILE_MAX); + image_assign_ibuf(ima, ibuf, IMA_NO_INDEX, 0); + ima->ok= IMA_OK_LOADED; + } + + return ima; +} + /* packs rect from memory as PNG */ void BKE_image_memorypack(Image *ima) { diff --git a/source/blender/blenkernel/intern/pointcache.c b/source/blender/blenkernel/intern/pointcache.c index b1319a81f5d..7ae2898ab8d 100644 --- a/source/blender/blenkernel/intern/pointcache.c +++ b/source/blender/blenkernel/intern/pointcache.c @@ -1060,7 +1060,7 @@ static int ptcache_path(PTCacheID *pid, char *filename) blendfilename= (lib)? lib->filename: G.sce; - BLI_split_dirfile_basic(blendfilename, NULL, file); + BLI_split_dirfile(blendfilename, NULL, file); i = strlen(file); /* remove .blend */ diff --git a/source/blender/blenkernel/intern/sequencer.c b/source/blender/blenkernel/intern/sequencer.c index 98dbf83f032..d3b05cf802c 100644 --- a/source/blender/blenkernel/intern/sequencer.c +++ b/source/blender/blenkernel/intern/sequencer.c @@ -79,6 +79,8 @@ static int seqrecty= 0; #define SELECT 1 ListBase seqbase_clipboard; int seqbase_clipboard_frame; +void *sequencer_view3d_cb= NULL; /* NULL in background mode */ + void printf_strip(Sequence *seq) { @@ -2104,7 +2106,6 @@ static void do_build_seq_ibuf(Scene *scene, Sequence * seq, TStripElem *se, int } else if(seq->type == SEQ_SCENE) { // scene can be NULL after deletions Scene *sce= seq->scene;// *oldsce= scene; Render *re; - RenderResult rres; int have_seq= FALSE; int sce_valid= FALSE; @@ -2130,58 +2131,70 @@ static void do_build_seq_ibuf(Scene *scene, Sequence * seq, TStripElem *se, int if (!sce_valid) { se->ok = STRIPELEM_FAILED; } else if (se->ibuf==NULL && sce_valid) { - int oldcfra; - /* Hack! This function can be called from do_render_seq(), in that case - the seq->scene can already have a Render initialized with same name, - so we have to use a default name. (compositor uses scene name to - find render). - However, when called from within the UI (image preview in sequencer) - we do want to use scene Render, that way the render result is defined - for display in render/imagewindow - - Hmm, don't see, why we can't do that all the time, - and since G.rendering is uhm, gone... (Peter) - */ - - int rendering = 1; - int doseq; - - oldcfra = seq->scene->r.cfra; - - if(rendering) - re= RE_NewRender(" do_build_seq_ibuf", RE_SLOT_DEFAULT); - else - re= RE_NewRender(sce->id.name, RE_SLOT_VIEW); - - /* prevent eternal loop */ - doseq= scene->r.scemode & R_DOSEQ; - scene->r.scemode &= ~R_DOSEQ; - - RE_BlenderFrame(re, sce, NULL, - seq->sfra+se->nr+seq->anim_startofs); - - RE_AcquireResultImage(re, &rres); - - if(rres.rectf) { - se->ibuf= IMB_allocImBuf(rres.rectx, rres.recty, 32, IB_rectfloat, 0); - memcpy(se->ibuf->rect_float, rres.rectf, 4*sizeof(float)*rres.rectx*rres.recty); - if(rres.rectz) { - addzbuffloatImBuf(se->ibuf); - memcpy(se->ibuf->zbuf_float, rres.rectz, sizeof(float)*rres.rectx*rres.recty); + int do_opengl= 0; + if(do_opengl && have_seq==0 && (sequencer_view3d_cb!=NULL)) { + /* opengl offscreen render */ + + /* sequencer_view3d_cb */ + // void (*seq_view3d_cb)(Scene *, int, int, int, int)= sequencer_view3d_cb; + + // seq_view3d_cb(scene, cfra, render_size, seqrectx, seqrecty); + } + else { + RenderResult rres; + int oldcfra; + /* Hack! This function can be called from do_render_seq(), in that case + the seq->scene can already have a Render initialized with same name, + so we have to use a default name. (compositor uses scene name to + find render). + However, when called from within the UI (image preview in sequencer) + we do want to use scene Render, that way the render result is defined + for display in render/imagewindow + + Hmm, don't see, why we can't do that all the time, + and since G.rendering is uhm, gone... (Peter) + */ + + int rendering = 1; + int doseq; + + oldcfra = seq->scene->r.cfra; + + if(rendering) + re= RE_NewRender(" do_build_seq_ibuf", RE_SLOT_DEFAULT); + else + re= RE_NewRender(sce->id.name, RE_SLOT_VIEW); + + /* prevent eternal loop */ + doseq= scene->r.scemode & R_DOSEQ; + scene->r.scemode &= ~R_DOSEQ; + + RE_BlenderFrame(re, sce, NULL, + seq->sfra+se->nr+seq->anim_startofs); + + RE_AcquireResultImage(re, &rres); + + if(rres.rectf) { + se->ibuf= IMB_allocImBuf(rres.rectx, rres.recty, 32, IB_rectfloat, 0); + memcpy(se->ibuf->rect_float, rres.rectf, 4*sizeof(float)*rres.rectx*rres.recty); + if(rres.rectz) { + addzbuffloatImBuf(se->ibuf); + memcpy(se->ibuf->zbuf_float, rres.rectz, sizeof(float)*rres.rectx*rres.recty); + } + } else if (rres.rect32) { + se->ibuf= IMB_allocImBuf(rres.rectx, rres.recty, 32, IB_rect, 0); + memcpy(se->ibuf->rect, rres.rect32, 4*rres.rectx*rres.recty); } - } else if (rres.rect32) { - se->ibuf= IMB_allocImBuf(rres.rectx, rres.recty, 32, IB_rect, 0); - memcpy(se->ibuf->rect, rres.rect32, 4*rres.rectx*rres.recty); - } - RE_ReleaseResultImage(re); - - // BIF_end_render_callbacks(); + RE_ReleaseResultImage(re); + + // BIF_end_render_callbacks(); + + /* restore */ + scene->r.scemode |= doseq; - /* restore */ - scene->r.scemode |= doseq; - - seq->scene->r.cfra = oldcfra; + seq->scene->r.cfra = oldcfra; + } copy_to_ibuf_still(seq, se); @@ -3803,7 +3816,7 @@ Sequence *sequencer_add_image_strip(bContext *C, ListBase *seqbasep, SeqLoadInfo strip->len = seq->len = seq_load->len ? seq_load->len : 1; strip->us= 1; strip->stripdata= se= MEM_callocN(seq->len*sizeof(StripElem), "stripelem"); - BLI_split_dirfile_basic(seq_load->path, strip->dir, se->name); + BLI_split_dirfile(seq_load->path, strip->dir, se->name); seq_load_apply(scene, seq, seq_load); @@ -3853,7 +3866,7 @@ Sequence *sequencer_add_sound_strip(bContext *C, ListBase *seqbasep, SeqLoadInfo strip->stripdata= se= MEM_callocN(seq->len*sizeof(StripElem), "stripelem"); - BLI_split_dirfile_basic(seq_load->path, strip->dir, se->name); + BLI_split_dirfile(seq_load->path, strip->dir, se->name); seq->scene_sound = sound_add_scene_sound(scene, seq, seq_load->start_frame, seq_load->start_frame + strip->len, 0); @@ -3897,7 +3910,7 @@ Sequence *sequencer_add_movie_strip(bContext *C, ListBase *seqbasep, SeqLoadInfo strip->stripdata= se= MEM_callocN(seq->len*sizeof(StripElem), "stripelem"); - BLI_split_dirfile_basic(seq_load->path, strip->dir, se->name); + BLI_split_dirfile(seq_load->path, strip->dir, se->name); calc_sequence_disp(scene, seq); diff --git a/source/blender/blenkernel/intern/sound.c b/source/blender/blenkernel/intern/sound.c index e014b209e07..23df930aa84 100644 --- a/source/blender/blenkernel/intern/sound.c +++ b/source/blender/blenkernel/intern/sound.c @@ -39,6 +39,7 @@ static int force_device = -1; +#ifdef WITH_JACK static void sound_sync_callback(void* data, int mode, float time) { struct Main* bmain = (struct Main*)data; @@ -58,6 +59,7 @@ static void sound_sync_callback(void* data, int mode, float time) scene = scene->id.next; } } +#endif int sound_define_from_str(char *str) { diff --git a/source/blender/blenkernel/intern/text.c b/source/blender/blenkernel/intern/text.c index b58caf14293..a7f80953f22 100644 --- a/source/blender/blenkernel/intern/text.c +++ b/source/blender/blenkernel/intern/text.c @@ -247,7 +247,7 @@ int reopen_text(Text *text) BLI_strncpy(str, text->name, FILE_MAXDIR+FILE_MAXFILE); BLI_convertstringcode(str, G.sce); - BLI_split_dirfile_basic(str, NULL, sfile); + BLI_split_dirfile(str, NULL, sfile); fp= fopen(str, "r"); if(fp==NULL) return 0; @@ -345,7 +345,7 @@ Text *add_text(char *file, const char *relpath) BLI_strncpy(str, file, FILE_MAXDIR+FILE_MAXFILE); if (relpath) /* can be NULL (bg mode) */ BLI_convertstringcode(str, relpath); - BLI_split_dirfile_basic(str, NULL, sfile); + BLI_split_dirfile(str, NULL, sfile); fp= fopen(str, "r"); if(fp==NULL) return NULL; |