Bugfix #4351
ESC wasn't supported for sequence-based rendering yet. Solved it with correctly initializing the sequence render with all render callbacks, including render updates (which it didn't do yet). Cleanup: - Bug in ghostwinlay code: the get_mbut() function reads from the window struct if a mouse is pressed. However, when you press the mouse in the sequencer, which causes a render, this value was hanging because then the active window was a render window. - The new render display options (image window) didn't work for sequence render OK. There was a recursion even, because a sequence draw command calls a render, which in turn now calls redraws.
This commit is contained in:
@@ -30,6 +30,7 @@
|
|||||||
* ***** END GPL/BL DUAL LICENSE BLOCK *****
|
* ***** END GPL/BL DUAL LICENSE BLOCK *****
|
||||||
*/
|
*/
|
||||||
|
|
||||||
|
struct Render;
|
||||||
struct ScrArea;
|
struct ScrArea;
|
||||||
struct RenderStats;
|
struct RenderStats;
|
||||||
|
|
||||||
@@ -51,6 +52,9 @@ void BIF_redraw_render_rect(void);
|
|||||||
void BIF_swap_render_rects(void);
|
void BIF_swap_render_rects(void);
|
||||||
void BIF_toggle_render_display(void);
|
void BIF_toggle_render_display(void);
|
||||||
|
|
||||||
|
void BIF_init_render_callbacks(struct Render *re);
|
||||||
|
void BIF_end_render_callbacks(void);
|
||||||
|
|
||||||
/* should not be here, ~WIP~ */
|
/* should not be here, ~WIP~ */
|
||||||
void make_renderinfo_string(struct RenderStats *rs, char *str);
|
void make_renderinfo_string(struct RenderStats *rs, char *str);
|
||||||
|
|
||||||
|
|||||||
@@ -747,6 +747,7 @@ static void draw_image_seq(ScrArea *sa)
|
|||||||
struct ImBuf *ibuf;
|
struct ImBuf *ibuf;
|
||||||
int x1, y1, rectx, recty;
|
int x1, y1, rectx, recty;
|
||||||
int free_ibuf = 0;
|
int free_ibuf = 0;
|
||||||
|
static int recursive= 0;
|
||||||
float zoom;
|
float zoom;
|
||||||
|
|
||||||
glClearColor(0.0, 0.0, 0.0, 0.0);
|
glClearColor(0.0, 0.0, 0.0, 0.0);
|
||||||
@@ -758,9 +759,26 @@ static void draw_image_seq(ScrArea *sa)
|
|||||||
rectx= (G.scene->r.size*G.scene->r.xsch)/100;
|
rectx= (G.scene->r.size*G.scene->r.xsch)/100;
|
||||||
recty= (G.scene->r.size*G.scene->r.ysch)/100;
|
recty= (G.scene->r.size*G.scene->r.ysch)/100;
|
||||||
|
|
||||||
ibuf= (ImBuf *)give_ibuf_seq(rectx, recty,
|
/* BIG PROBLEM: the give_ibuf_seq() can call a rendering, which in turn calls redraws...
|
||||||
(G.scene->r.cfra), sseq->chanshown);
|
this shouldn't belong in a window drawing....
|
||||||
|
So: solve this once event based.
|
||||||
|
Now we check for recursion, space type and active area again (ton) */
|
||||||
|
|
||||||
|
if(recursive)
|
||||||
|
return;
|
||||||
|
else {
|
||||||
|
recursive= 1;
|
||||||
|
ibuf= (ImBuf *)give_ibuf_seq(rectx, recty, (G.scene->r.cfra), sseq->chanshown);
|
||||||
|
recursive= 0;
|
||||||
|
|
||||||
|
/* HURMF! the give_ibuf_seq can call image display in this window */
|
||||||
|
if(sa->spacetype!=SPACE_SEQ)
|
||||||
|
return;
|
||||||
|
if(sa!=curarea) {
|
||||||
|
areawinset(sa->win);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
if(special_seq_update) {
|
if(special_seq_update) {
|
||||||
se = special_seq_update->curelem;
|
se = special_seq_update->curelem;
|
||||||
if(se) {
|
if(se) {
|
||||||
@@ -801,7 +819,7 @@ static void draw_image_seq(ScrArea *sa)
|
|||||||
/* needed for gla draw */
|
/* needed for gla draw */
|
||||||
glaDefine2DArea(&curarea->winrct);
|
glaDefine2DArea(&curarea->winrct);
|
||||||
glPixelZoom(zoom, zoom);
|
glPixelZoom(zoom, zoom);
|
||||||
|
|
||||||
glaDrawPixelsSafe(x1, y1, ibuf->x, ibuf->y, ibuf->x, GL_RGBA, GL_UNSIGNED_BYTE, ibuf->rect);
|
glaDrawPixelsSafe(x1, y1, ibuf->x, ibuf->y, ibuf->x, GL_RGBA, GL_UNSIGNED_BYTE, ibuf->rect);
|
||||||
|
|
||||||
glPixelZoom(1.0, 1.0);
|
glPixelZoom(1.0, 1.0);
|
||||||
|
|||||||
@@ -450,6 +450,7 @@ void window_set_custom_cursor_ex(Window *win, BCursor *cursor, int useBig) {
|
|||||||
|
|
||||||
void window_make_active(Window *win) {
|
void window_make_active(Window *win) {
|
||||||
if (win != active_gl_window) {
|
if (win != active_gl_window) {
|
||||||
|
win->lmbut= 0; /* keeps hanging when mousepressed while other window opened */
|
||||||
active_gl_window= win;
|
active_gl_window= win;
|
||||||
GHOST_ActivateWindowDrawingContext(win->ghostwin);
|
GHOST_ActivateWindowDrawingContext(win->ghostwin);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1050,7 +1050,6 @@ static void end_test_break_callback()
|
|||||||
- set callbacks
|
- set callbacks
|
||||||
- cleanup
|
- cleanup
|
||||||
*/
|
*/
|
||||||
static void error_cb(char *str){error(str);}
|
|
||||||
|
|
||||||
static void do_render(int anim)
|
static void do_render(int anim)
|
||||||
{
|
{
|
||||||
@@ -1061,24 +1060,9 @@ static void do_render(int anim)
|
|||||||
/* UGLY! we set this flag to prevent renderwindow queue to execute another render */
|
/* UGLY! we set this flag to prevent renderwindow queue to execute another render */
|
||||||
/* is reset in RE_BlenderFrame */
|
/* is reset in RE_BlenderFrame */
|
||||||
G.rendering= 1;
|
G.rendering= 1;
|
||||||
G.afbreek= 0;
|
|
||||||
|
|
||||||
/* set callbacks */
|
/* set render callbacks, also starts ESC timer */
|
||||||
if(G.displaymode!=R_DISPLAYWIN) {
|
BIF_init_render_callbacks(re);
|
||||||
if(render_win)
|
|
||||||
BIF_close_render_display();
|
|
||||||
imagewindow_render_callbacks(re);
|
|
||||||
}
|
|
||||||
else {
|
|
||||||
RE_display_init_cb(re, renderwin_init_display_cb);
|
|
||||||
RE_display_draw_cb(re, renderwin_progress_display_cb);
|
|
||||||
RE_display_clear_cb(re, renderwin_clear_display_cb);
|
|
||||||
RE_stats_draw_cb(re, renderwin_renderinfo_cb);
|
|
||||||
}
|
|
||||||
RE_error_cb(re, error_cb);
|
|
||||||
init_test_break_callback();
|
|
||||||
RE_test_break_cb(re, test_break);
|
|
||||||
RE_timecursor_cb(re, set_timecursor);
|
|
||||||
|
|
||||||
waitcursor(1);
|
waitcursor(1);
|
||||||
if(render_win)
|
if(render_win)
|
||||||
@@ -1110,47 +1094,18 @@ static void do_render(int anim)
|
|||||||
free_filesel_spec(G.scene->r.pic);
|
free_filesel_spec(G.scene->r.pic);
|
||||||
|
|
||||||
G.afbreek= 0;
|
G.afbreek= 0;
|
||||||
end_test_break_callback();
|
BIF_end_render_callbacks();
|
||||||
|
|
||||||
mainwindow_make_active();
|
|
||||||
|
|
||||||
/* after an envmap creation... */
|
/* after an envmap creation... */
|
||||||
// if(R.flag & R_REDRAW_PRV) {
|
// if(R.flag & R_REDRAW_PRV) {
|
||||||
// BIF_preview_changed(ID_TE);
|
// BIF_preview_changed(ID_TE);
|
||||||
// }
|
// }
|
||||||
allqueue(REDRAWBUTSSCENE, 0); // visualize fbuf for example
|
|
||||||
|
|
||||||
scene_update_for_newframe(G.scene, G.scene->lay); // no redraw needed, this restores to view as we left it
|
scene_update_for_newframe(G.scene, G.scene->lay); // no redraw needed, this restores to view as we left it
|
||||||
|
|
||||||
waitcursor(0);
|
waitcursor(0);
|
||||||
}
|
}
|
||||||
|
|
||||||
#if 0
|
|
||||||
/* used for swapping with spare buffer, when images are different size */
|
|
||||||
static void scalefastrect(unsigned int *recto, unsigned int *rectn, int oldx, int oldy, int newx, int newy)
|
|
||||||
{
|
|
||||||
unsigned int *rect, *newrect;
|
|
||||||
int x, y;
|
|
||||||
int ofsx, ofsy, stepx, stepy;
|
|
||||||
|
|
||||||
stepx = (int)((65536.0 * (oldx - 1.0) / (newx - 1.0)) + 0.5);
|
|
||||||
stepy = (int)((65536.0 * (oldy - 1.0) / (newy - 1.0)) + 0.5);
|
|
||||||
ofsy = 32768;
|
|
||||||
newrect= rectn;
|
|
||||||
|
|
||||||
for (y = newy; y > 0 ; y--){
|
|
||||||
rect = recto;
|
|
||||||
rect += (ofsy >> 16) * oldx;
|
|
||||||
ofsy += stepy;
|
|
||||||
ofsx = 32768;
|
|
||||||
for (x = newx ; x>0 ; x--){
|
|
||||||
*newrect++ = rect[ofsx >> 16];
|
|
||||||
ofsx += stepx;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
#endif
|
|
||||||
|
|
||||||
static void renderwin_store_spare(void)
|
static void renderwin_store_spare(void)
|
||||||
{
|
{
|
||||||
RenderResult rres;
|
RenderResult rres;
|
||||||
@@ -1183,18 +1138,51 @@ static void renderwin_store_spare(void)
|
|||||||
|
|
||||||
/* -------------- API: externally called --------------- */
|
/* -------------- API: externally called --------------- */
|
||||||
|
|
||||||
/* not used anywhere ??? */
|
static void error_cb(char *str){error(str);}
|
||||||
#if 0
|
static int esc_timer_set= 0;
|
||||||
void BIF_renderwin_make_active(void)
|
|
||||||
|
/* set callbacks, exported to sequence render too.
|
||||||
|
Only call in foreground (UI) renders. */
|
||||||
|
|
||||||
|
void BIF_init_render_callbacks(Render *re)
|
||||||
{
|
{
|
||||||
if(render_win) {
|
|
||||||
window_make_active(render_win->win);
|
if(G.displaymode!=R_DISPLAYWIN) {
|
||||||
mywinset(2);
|
if(render_win)
|
||||||
|
BIF_close_render_display();
|
||||||
|
imagewindow_render_callbacks(re);
|
||||||
}
|
}
|
||||||
|
else {
|
||||||
|
RE_display_init_cb(re, renderwin_init_display_cb);
|
||||||
|
RE_display_draw_cb(re, renderwin_progress_display_cb);
|
||||||
|
RE_display_clear_cb(re, renderwin_clear_display_cb);
|
||||||
|
RE_stats_draw_cb(re, renderwin_renderinfo_cb);
|
||||||
|
}
|
||||||
|
|
||||||
|
RE_error_cb(re, error_cb);
|
||||||
|
|
||||||
|
G.afbreek= 0;
|
||||||
|
/* start esc timer. ensure it happens once only */
|
||||||
|
if(esc_timer_set==0)
|
||||||
|
init_test_break_callback();
|
||||||
|
esc_timer_set++;
|
||||||
|
|
||||||
|
RE_test_break_cb(re, test_break);
|
||||||
|
RE_timecursor_cb(re, set_timecursor);
|
||||||
|
|
||||||
}
|
}
|
||||||
#endif
|
|
||||||
|
|
||||||
|
/* the init/end callbacks can be called multiple times (sequence render) */
|
||||||
|
void BIF_end_render_callbacks(void)
|
||||||
|
{
|
||||||
|
esc_timer_set--;
|
||||||
|
if(esc_timer_set==0)
|
||||||
|
end_test_break_callback();
|
||||||
|
|
||||||
|
if(render_win)
|
||||||
|
mainwindow_make_active();
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
/* set up display, render an image or scene */
|
/* set up display, render an image or scene */
|
||||||
void BIF_do_render(int anim)
|
void BIF_do_render(int anim)
|
||||||
|
|||||||
@@ -886,7 +886,7 @@ static void do_build_seq_ibuf(Sequence * seq, int cfra)
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else if(seq->type==SEQ_SCENE && se->ibuf==0 && seq->scene) { // scene can be NULL after deletions
|
else if(seq->type==SEQ_SCENE && se->ibuf==NULL && seq->scene) { // scene can be NULL after deletions
|
||||||
int oldcfra = CFRA;
|
int oldcfra = CFRA;
|
||||||
Scene *sce= seq->scene, *oldsce= G.scene;
|
Scene *sce= seq->scene, *oldsce= G.scene;
|
||||||
Render *re= RE_NewRender(sce->id.name);
|
Render *re= RE_NewRender(sce->id.name);
|
||||||
@@ -899,10 +899,12 @@ static void do_build_seq_ibuf(Sequence * seq, int cfra)
|
|||||||
doseq= sce->r.scemode & R_DOSEQ;
|
doseq= sce->r.scemode & R_DOSEQ;
|
||||||
sce->r.scemode &= ~R_DOSEQ;
|
sce->r.scemode &= ~R_DOSEQ;
|
||||||
|
|
||||||
|
BIF_init_render_callbacks(re);
|
||||||
|
|
||||||
/* hrms, set_scene still needed? work on that... */
|
/* hrms, set_scene still needed? work on that... */
|
||||||
set_scene_bg(sce);
|
if(sce!=oldsce) set_scene_bg(sce);
|
||||||
RE_BlenderFrame(re, sce, seq->sfra + se->nr);
|
RE_BlenderFrame(re, sce, seq->sfra + se->nr);
|
||||||
set_scene_bg(oldsce);
|
if(sce!=oldsce) set_scene_bg(oldsce);
|
||||||
|
|
||||||
RE_GetResultImage(re, &rres);
|
RE_GetResultImage(re, &rres);
|
||||||
|
|
||||||
@@ -913,7 +915,9 @@ static void do_build_seq_ibuf(Sequence * seq, int cfra)
|
|||||||
/* not yet */
|
/* not yet */
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
BIF_end_render_callbacks();
|
||||||
|
|
||||||
/* restore */
|
/* restore */
|
||||||
sce->r.scemode |= doseq;
|
sce->r.scemode |= doseq;
|
||||||
|
|
||||||
@@ -1101,7 +1105,6 @@ ImBuf *give_ibuf_seq(int rectx, int recty, int cfra, int chanshown)
|
|||||||
do_seq_test_unref_cfra(ed->seqbasep, cfra);
|
do_seq_test_unref_cfra(ed->seqbasep, cfra);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
if(!seqfirst) return 0;
|
if(!seqfirst) return 0;
|
||||||
if(!seqfirst->curelem) return 0;
|
if(!seqfirst->curelem) return 0;
|
||||||
return seqfirst->curelem->ibuf;
|
return seqfirst->curelem->ibuf;
|
||||||
|
|||||||
Reference in New Issue
Block a user