Render API: some code refactoring related to errors and render view.

This commit is contained in:
Brecht Van Lommel
2011-05-18 10:01:41 +00:00
parent dd85722678
commit a0ba4a771f
8 changed files with 423 additions and 416 deletions

View File

@@ -42,6 +42,7 @@ set(SRC
render_preview.c
render_shading.c
render_update.c
render_view.c
render_intern.h
)

View File

@@ -65,13 +65,16 @@ void TEXTURE_OT_envmap_clear(struct wmOperatorType *ot);
void TEXTURE_OT_envmap_clear_all(struct wmOperatorType *ot);
/* render_internal.c */
void RENDER_OT_view_show(struct wmOperatorType *ot);
void RENDER_OT_render(struct wmOperatorType *ot);
void RENDER_OT_view_cancel(struct wmOperatorType *ot);
/*render_opengl.c uses these */
/* render_opengl.c uses this */
void image_buffer_rect_update(struct Scene *scene, struct RenderResult *rr, struct ImBuf *ibuf, volatile struct rcti *renrect);
void screen_set_image_output(struct bContext *C, int mx, int my);
/* render_view.c */
void render_view_open(struct bContext *C, int mx, int my);
void RENDER_OT_view_show(struct wmOperatorType *ot);
void RENDER_OT_view_cancel(struct wmOperatorType *ot);
/* render_opengl.c */
void RENDER_OT_opengl(struct wmOperatorType *ot);

View File

@@ -73,17 +73,14 @@
#include "render_intern.h"
static ScrArea *biggest_area(bContext *C);
static ScrArea *biggest_non_image_area(bContext *C);
static ScrArea *find_area_showing_r_result(bContext *C, wmWindow **win);
static ScrArea *find_area_image_empty(bContext *C);
/* Render Callbacks */
/* called inside thread! */
void image_buffer_rect_update(Scene *scene, RenderResult *rr, ImBuf *ibuf, volatile rcti *renrect)
{
float x1, y1, *rectf= NULL;
int ymin, ymax, xmin, xmax;
int rymin, rxmin;
int rymin, rxmin, do_color_management;
char *rectc;
/* if renrect argument, we only refresh scanlines */
@@ -95,7 +92,8 @@ void image_buffer_rect_update(Scene *scene, RenderResult *rr, ImBuf *ibuf, volat
/* xmin here is first subrect x coord, xmax defines subrect width */
xmin = renrect->xmin + rr->crop;
xmax = renrect->xmax - xmin + rr->crop;
if (xmax<2) return;
if(xmax<2)
return;
ymin= renrect->ymin + rr->crop;
ymax= renrect->ymax - ymin + rr->crop;
@@ -141,275 +139,56 @@ void image_buffer_rect_update(Scene *scene, RenderResult *rr, ImBuf *ibuf, volat
rectf+= 4*(rr->rectx*ymin + xmin);
rectc= (char *)(ibuf->rect + ibuf->x*rymin + rxmin);
do_color_management = (scene && (scene->r.color_mgt_flag & R_COLOR_MANAGEMENT));
/* XXX make nice consistent functions for this */
if (scene && (scene->r.color_mgt_flag & R_COLOR_MANAGEMENT)) {
for(y1= 0; y1<ymax; y1++) {
float *rf= rectf;
float srgb[3];
char *rc= rectc;
const float dither = ibuf->dither / 255.0f;
for(y1= 0; y1<ymax; y1++) {
float *rf= rectf;
float srgb[3];
char *rc= rectc;
const float dither = ibuf->dither / 255.0f;
/* XXX temp. because crop offset */
if( rectc >= (char *)(ibuf->rect)) {
for(x1= 0; x1<xmax; x1++, rf += 4, rc+=4) {
/* XXX temp. because crop offset */
if(rectc >= (char *)(ibuf->rect)) {
for(x1= 0; x1<xmax; x1++, rf += 4, rc+=4) {
/* color management */
if(do_color_management) {
srgb[0]= linearrgb_to_srgb(rf[0]);
srgb[1]= linearrgb_to_srgb(rf[1]);
srgb[2]= linearrgb_to_srgb(rf[2]);
}
else {
copy_v3_v3(srgb, rf);
}
/* dither */
if(dither != 0.0f) {
const float d = (BLI_frand()-0.5f)*dither;
srgb[0]= d + linearrgb_to_srgb(rf[0]);
srgb[1]= d + linearrgb_to_srgb(rf[1]);
srgb[2]= d + linearrgb_to_srgb(rf[2]);
rc[0]= FTOCHAR(srgb[0]);
rc[1]= FTOCHAR(srgb[1]);
rc[2]= FTOCHAR(srgb[2]);
rc[3]= FTOCHAR(rf[3]);
srgb[0] += d;
srgb[1] += d;
srgb[2] += d;
}
}
rectf += 4*rr->rectx;
rectc += 4*ibuf->x;
}
} else {
for(y1= 0; y1<ymax; y1++) {
float *rf= rectf;
char *rc= rectc;
float rgb[3];
const float dither = ibuf->dither / 255.0f;
/* XXX temp. because crop offset */
if( rectc >= (char *)(ibuf->rect)) {
for(x1= 0; x1<xmax; x1++, rf += 4, rc+=4) {
const float d = (BLI_frand()-0.5f)*dither;
rgb[0] = d + rf[0];
rgb[1] = d + rf[1];
rgb[2] = d + rf[2];
rc[0]= FTOCHAR(rgb[0]);
rc[1]= FTOCHAR(rgb[1]);
rc[2]= FTOCHAR(rgb[2]);
rc[3]= FTOCHAR(rf[3]);
}
/* write */
rc[0]= FTOCHAR(srgb[0]);
rc[1]= FTOCHAR(srgb[1]);
rc[2]= FTOCHAR(srgb[2]);
rc[3]= FTOCHAR(rf[3]);
}
rectf += 4*rr->rectx;
rectc += 4*ibuf->x;
}
}
rectf += 4*rr->rectx;
rectc += 4*ibuf->x;
}
}
/* new window uses x,y to set position */
void screen_set_image_output(bContext *C, int mx, int my)
{
wmWindow *win= CTX_wm_window(C);
Scene *scene= CTX_data_scene(C);
ScrArea *sa= NULL;
SpaceImage *sima;
int area_was_image=0;
if(scene->r.displaymode==R_OUTPUT_NONE)
return;
if(scene->r.displaymode==R_OUTPUT_WINDOW) {
rcti rect;
int sizex, sizey;
sizex= 10 + (scene->r.xsch*scene->r.size)/100;
sizey= 40 + (scene->r.ysch*scene->r.size)/100;
/* arbitrary... miniature image window views don't make much sense */
if(sizex < 320) sizex= 320;
if(sizey < 256) sizey= 256;
/* XXX some magic to calculate postition */
rect.xmin= mx + win->posx - sizex/2;
rect.ymin= my + win->posy - sizey/2;
rect.xmax= rect.xmin + sizex;
rect.ymax= rect.ymin + sizey;
/* changes context! */
WM_window_open_temp(C, &rect, WM_WINDOW_RENDER);
sa= CTX_wm_area(C);
}
else if(scene->r.displaymode==R_OUTPUT_SCREEN) {
if (CTX_wm_area(C) && CTX_wm_area(C)->spacetype == SPACE_IMAGE)
area_was_image = 1;
/* this function returns with changed context */
ED_screen_full_newspace(C, CTX_wm_area(C), SPACE_IMAGE);
sa= CTX_wm_area(C);
}
if(!sa) {
sa= find_area_showing_r_result(C, &win);
if(sa==NULL)
sa= find_area_image_empty(C);
/* if area found in other window, we make that one show in front */
if(win && win!=CTX_wm_window(C))
wm_window_raise(win);
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 we're rendering to full screen, set appropriate hints on image editor
* so it can restore properly on pressing esc */
if(sa->full) {
sima->flag |= SI_FULLWINDOW;
/* Tell the image editor to revert to previous space in space list on close
* _only_ if it wasn't already an image editor when the render was invoked */
if (area_was_image == 0)
sima->flag |= SI_PREVSPACE;
else {
/* Leave it alone so the image editor will just go back from
* full screen to the original tiled setup */
;
}
}
}
/* ****************************** 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 > 30 && sa->winy > 30) {
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, wmWindow **win)
{
wmWindowManager *wm= CTX_wm_manager(C);
ScrArea *sa = NULL;
SpaceImage *sima;
/* find an imagewindow showing render result */
for(*win=wm->windows.first; *win; *win= (*win)->next) {
for(sa= (*win)->screen->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;
}
}
if(sa)
break;
}
return sa;
}
static ScrArea *find_area_image_empty(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)
break;
}
}
return sa;
}
#if 0 // XXX not used
static ScrArea *find_empty_image_area(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)
break;
}
}
return sa;
}
#endif // XXX not used
static void render_error_reports(void *reports, const char *str)
{
BKE_report(reports, RPT_ERROR, str);
}
/* executes blocking render */
static int screen_render_exec(bContext *C, wmOperator *op)
{
@@ -428,13 +207,8 @@ static int screen_render_exec(bContext *C, wmOperator *op)
return OPERATOR_CANCELLED;
}
if(re==NULL) {
re= RE_NewRender(scene->id.name);
}
G.afbreek= 0;
RE_test_break_cb(re, NULL, (int (*)(void *)) blender_test_break);
RE_error_cb(re, op->reports, render_error_reports);
ima= BKE_image_verify_viewer(IMA_TYPE_R_RESULT, "Render Result");
BKE_image_signal(ima, NULL, IMA_SIGNAL_FREE);
@@ -562,7 +336,7 @@ static void render_progress_update(void *rjv, float progress)
{
RenderJob *rj= rjv;
if (rj->progress)
if(rj->progress)
*rj->progress = progress;
}
@@ -695,7 +469,7 @@ static int screen_render_invoke(bContext *C, wmOperator *op, wmEvent *event)
if(WM_jobs_test(CTX_wm_manager(C), scene))
return OPERATOR_CANCELLED;
if(!RE_is_rendering_allowed(scene, camera_override, op->reports, render_error_reports)) {
if(!RE_is_rendering_allowed(scene, camera_override, op->reports)) {
return OPERATOR_CANCELLED;
}
@@ -739,7 +513,7 @@ static int screen_render_invoke(bContext *C, wmOperator *op, wmEvent *event)
// store spare
/* ensure at least 1 area shows result */
screen_set_image_output(C, event->x, event->y);
render_view_open(C, event->x, event->y);
jobflag= WM_JOB_EXCL_RENDER|WM_JOB_PRIORITY|WM_JOB_PROGRESS;
@@ -803,8 +577,6 @@ static int screen_render_invoke(bContext *C, wmOperator *op, wmEvent *event)
rj->re= re;
G.afbreek= 0;
RE_error_cb(re, op->reports, render_error_reports);
WM_jobs_start(CTX_wm_manager(C), steve);
WM_cursor_wait(0);
@@ -821,7 +593,6 @@ static int screen_render_invoke(bContext *C, wmOperator *op, wmEvent *event)
return OPERATOR_RUNNING_MODAL;
}
/* contextual render, using current scene, view3d? */
void RENDER_OT_render(wmOperatorType *ot)
{
@@ -843,119 +614,3 @@ void RENDER_OT_render(wmOperatorType *ot)
RNA_def_string(ot->srna, "scene", "", MAX_ID_NAME-2, "Scene", "Re-render single layer in this scene");
}
/* ****************************** opengl render *************************** */
/* *********************** cancel render viewer *************** */
static int render_view_cancel_exec(bContext *C, wmOperator *UNUSED(op))
{
wmWindow *win= CTX_wm_window(C);
ScrArea *sa= CTX_wm_area(C);
SpaceImage *sima= sa->spacedata.first;
/* test if we have a temp screen in front */
if(CTX_wm_window(C)->screen->temp) {
wm_window_lower(CTX_wm_window(C));
return OPERATOR_FINISHED;
}
/* determine if render already shows */
else if(sima->flag & SI_PREVSPACE) {
sima->flag &= ~SI_PREVSPACE;
if(sima->flag & SI_FULLWINDOW) {
sima->flag &= ~SI_FULLWINDOW;
ED_screen_full_prevspace(C, sa);
}
else
ED_area_prevspace(C, sa);
return OPERATOR_FINISHED;
}
else if(sima->flag & SI_FULLWINDOW) {
sima->flag &= ~SI_FULLWINDOW;
ED_screen_full_toggle(C, win, sa);
return OPERATOR_FINISHED;
}
return OPERATOR_PASS_THROUGH;
}
void RENDER_OT_view_cancel(struct wmOperatorType *ot)
{
/* identifiers */
ot->name= "Cancel Render View";
ot->description= "Cancel show render view";
ot->idname= "RENDER_OT_view_cancel";
/* api callbacks */
ot->exec= render_view_cancel_exec;
ot->poll= ED_operator_image_active;
}
/* *********************** show render viewer *************** */
static int render_view_show_invoke(bContext *C, wmOperator *UNUSED(op), wmEvent *event)
{
wmWindow *wincur = CTX_wm_window(C);
/* test if we have currently a temp screen active */
if(wincur->screen->temp) {
wm_window_lower(wincur);
}
else {
wmWindow *win, *winshow;
ScrArea *sa= find_area_showing_r_result(C, &winshow);
/* is there another window showing result? */
for(win= CTX_wm_manager(C)->windows.first; win; win= win->next) {
if(win->screen->temp || (win==winshow && winshow!=wincur)) {
wm_window_raise(win);
return OPERATOR_FINISHED;
}
}
/* determine if render already shows */
if(sa) {
/* but don't close it when rendering */
if(!G.rendering) {
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, sa);
}
else if(sima->next) {
/* workaround for case of double prevspace, render window
with a file browser on top of it (same as in ED_area_prevspace) */
if(sima->next->spacetype == SPACE_FILE && sima->next->next)
ED_area_newspace(C, sa, sima->next->next->spacetype);
else
ED_area_newspace(C, sa, sima->next->spacetype);
ED_area_tag_redraw(sa);
}
}
}
}
else {
screen_set_image_output(C, event->x, event->y);
}
}
return OPERATOR_FINISHED;
}
void RENDER_OT_view_show(struct wmOperatorType *ot)
{
/* identifiers */
ot->name= "Show/Hide Render View";
ot->description= "Toggle show render view";
ot->idname= "RENDER_OT_view_show";
/* api callbacks */
ot->invoke= render_view_show_invoke;
ot->poll= ED_operator_screenactive;
}

View File

@@ -527,7 +527,7 @@ static int screen_opengl_render_invoke(bContext *C, wmOperator *op, wmEvent *eve
}
oglrender= op->customdata;
screen_set_image_output(C, event->x, event->y);
render_view_open(C, event->x, event->y);
WM_event_add_modal_handler(C, op);
oglrender->timer= WM_event_add_timer(CTX_wm_manager(C), CTX_wm_window(C), TIMER, 0.01f);

View File

@@ -0,0 +1,359 @@
/*
* $Id$
*
* ***** BEGIN GPL LICENSE BLOCK *****
*
* This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License
* as published by the Free Software Foundation; either version 2
* of the License, or (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software Foundation,
* Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
*
* The Original Code is Copyright (C) 2008 Blender Foundation.
* All rights reserved.
*
*
* ***** END GPL LICENSE BLOCK *****
*/
/** \file blender/editors/render/render_view.c
* \ingroup edrend
*/
#include <string.h>
#include <stddef.h>
#include "MEM_guardedalloc.h"
#include "BLI_blenlib.h"
#include "BLI_utildefines.h"
#include "DNA_scene_types.h"
#include "BKE_blender.h"
#include "BKE_context.h"
#include "BKE_image.h"
#include "BKE_global.h"
#include "BKE_main.h"
#include "BKE_node.h"
#include "BKE_report.h"
#include "BKE_screen.h"
#include "WM_api.h"
#include "WM_types.h"
#include "ED_screen.h"
#include "wm_window.h"
#include "render_intern.h"
/*********************** utilities for finding areas *************************/
/* 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 > 30 && sa->winy > 30) {
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, wmWindow **win)
{
wmWindowManager *wm= CTX_wm_manager(C);
ScrArea *sa = NULL;
SpaceImage *sima;
/* find an imagewindow showing render result */
for(*win=wm->windows.first; *win; *win= (*win)->next) {
for(sa= (*win)->screen->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;
}
}
if(sa)
break;
}
return sa;
}
static ScrArea *find_area_image_empty(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)
break;
}
}
return sa;
}
/********************** open image editor for render *************************/
/* new window uses x,y to set position */
void render_view_open(bContext *C, int mx, int my)
{
wmWindow *win= CTX_wm_window(C);
Scene *scene= CTX_data_scene(C);
ScrArea *sa= NULL;
SpaceImage *sima;
int area_was_image=0;
if(scene->r.displaymode==R_OUTPUT_NONE)
return;
if(scene->r.displaymode==R_OUTPUT_WINDOW) {
rcti rect;
int sizex, sizey;
sizex= 10 + (scene->r.xsch*scene->r.size)/100;
sizey= 40 + (scene->r.ysch*scene->r.size)/100;
/* arbitrary... miniature image window views don't make much sense */
if(sizex < 320) sizex= 320;
if(sizey < 256) sizey= 256;
/* XXX some magic to calculate postition */
rect.xmin= mx + win->posx - sizex/2;
rect.ymin= my + win->posy - sizey/2;
rect.xmax= rect.xmin + sizex;
rect.ymax= rect.ymin + sizey;
/* changes context! */
WM_window_open_temp(C, &rect, WM_WINDOW_RENDER);
sa= CTX_wm_area(C);
}
else if(scene->r.displaymode==R_OUTPUT_SCREEN) {
if (CTX_wm_area(C) && CTX_wm_area(C)->spacetype == SPACE_IMAGE)
area_was_image = 1;
/* this function returns with changed context */
ED_screen_full_newspace(C, CTX_wm_area(C), SPACE_IMAGE);
sa= CTX_wm_area(C);
}
if(!sa) {
sa= find_area_showing_r_result(C, &win);
if(sa==NULL)
sa= find_area_image_empty(C);
/* if area found in other window, we make that one show in front */
if(win && win!=CTX_wm_window(C))
wm_window_raise(win);
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 we're rendering to full screen, set appropriate hints on image editor
* so it can restore properly on pressing esc */
if(sa->full) {
sima->flag |= SI_FULLWINDOW;
/* Tell the image editor to revert to previous space in space list on close
* _only_ if it wasn't already an image editor when the render was invoked */
if (area_was_image == 0)
sima->flag |= SI_PREVSPACE;
else {
/* Leave it alone so the image editor will just go back from
* full screen to the original tiled setup */
;
}
}
}
/*************************** cancel render viewer **********************/
static int render_view_cancel_exec(bContext *C, wmOperator *UNUSED(op))
{
wmWindow *win= CTX_wm_window(C);
ScrArea *sa= CTX_wm_area(C);
SpaceImage *sima= sa->spacedata.first;
/* test if we have a temp screen in front */
if(CTX_wm_window(C)->screen->temp) {
wm_window_lower(CTX_wm_window(C));
return OPERATOR_FINISHED;
}
/* determine if render already shows */
else if(sima->flag & SI_PREVSPACE) {
sima->flag &= ~SI_PREVSPACE;
if(sima->flag & SI_FULLWINDOW) {
sima->flag &= ~SI_FULLWINDOW;
ED_screen_full_prevspace(C, sa);
}
else
ED_area_prevspace(C, sa);
return OPERATOR_FINISHED;
}
else if(sima->flag & SI_FULLWINDOW) {
sima->flag &= ~SI_FULLWINDOW;
ED_screen_full_toggle(C, win, sa);
return OPERATOR_FINISHED;
}
return OPERATOR_PASS_THROUGH;
}
void RENDER_OT_view_cancel(struct wmOperatorType *ot)
{
/* identifiers */
ot->name= "Cancel Render View";
ot->description= "Cancel show render view";
ot->idname= "RENDER_OT_view_cancel";
/* api callbacks */
ot->exec= render_view_cancel_exec;
ot->poll= ED_operator_image_active;
}
/************************* show render viewer *****************/
static int render_view_show_invoke(bContext *C, wmOperator *UNUSED(op), wmEvent *event)
{
wmWindow *wincur = CTX_wm_window(C);
/* test if we have currently a temp screen active */
if(wincur->screen->temp) {
wm_window_lower(wincur);
}
else {
wmWindow *win, *winshow;
ScrArea *sa= find_area_showing_r_result(C, &winshow);
/* is there another window showing result? */
for(win= CTX_wm_manager(C)->windows.first; win; win= win->next) {
if(win->screen->temp || (win==winshow && winshow!=wincur)) {
wm_window_raise(win);
return OPERATOR_FINISHED;
}
}
/* determine if render already shows */
if(sa) {
/* but don't close it when rendering */
if(!G.rendering) {
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, sa);
}
else if(sima->next) {
/* workaround for case of double prevspace, render window
with a file browser on top of it (same as in ED_area_prevspace) */
if(sima->next->spacetype == SPACE_FILE && sima->next->next)
ED_area_newspace(C, sa, sima->next->next->spacetype);
else
ED_area_newspace(C, sa, sima->next->spacetype);
ED_area_tag_redraw(sa);
}
}
}
}
else {
render_view_open(C, event->x, event->y);
}
}
return OPERATOR_FINISHED;
}
void RENDER_OT_view_show(struct wmOperatorType *ot)
{
/* identifiers */
ot->name= "Show/Hide Render View";
ot->description= "Toggle show render view";
ot->idname= "RENDER_OT_view_show";
/* api callbacks */
ot->invoke= render_view_show_invoke;
ot->poll= ED_operator_screenactive;
}

View File

@@ -241,7 +241,6 @@ void RE_stats_draw_cb (struct Render *re, void *handle, void (*f)(void *handle,
void RE_progress_cb (struct Render *re, void *handle, void (*f)(void *handle, float));
void RE_draw_lock_cb (struct Render *re, void *handle, void (*f)(void *handle, int));
void RE_test_break_cb (struct Render *re, void *handle, int (*f)(void *handle));
void RE_error_cb (struct Render *re, void *handle, void (*f)(void *handle, const char *str));
/* should move to kernel once... still unsure on how/where */
float RE_filter_value(int type, float x);
@@ -263,7 +262,7 @@ void RE_DataBase_GetView(struct Render *re, float mat[][4]);
void RE_GetCameraWindow(struct Render *re, struct Object *camera, int frame, float mat[][4]);
struct Scene *RE_GetScene(struct Render *re);
int RE_is_rendering_allowed(struct Scene *scene, struct Object *camera_override, void *erh, void (*error)(void *handle, const char *str));
int RE_is_rendering_allowed(struct Scene *scene, struct Object *camera_override, struct ReportList *reports);
#endif /* RE_PIPELINE_H */

View File

@@ -253,9 +253,6 @@ struct Render
int (*test_break)(void *handle);
void *tbh;
void (*error)(void *handle, const char *str);
void *erh;
RenderStats i;
struct ReportList *reports;

View File

@@ -141,7 +141,6 @@ static void result_nothing(void *UNUSED(arg), RenderResult *UNUSED(rr)) {}
static void result_rcti_nothing(void *UNUSED(arg), RenderResult *UNUSED(rr), volatile struct rcti *UNUSED(rect)) {}
static void stats_nothing(void *UNUSED(arg), RenderStats *UNUSED(rs)) {}
static void float_nothing(void *UNUSED(arg), float UNUSED(val)) {}
static void print_error(void *UNUSED(arg), const char *str) {printf("ERROR: %s\n", str);}
static int default_break(void *UNUSED(arg)) {return G.afbreek == 1;}
static void stats_background(void *UNUSED(arg), RenderStats *rs)
@@ -1200,13 +1199,12 @@ void RE_InitRenderCB(Render *re)
re->display_draw= result_rcti_nothing;
re->progress= float_nothing;
re->test_break= default_break;
re->error= print_error;
if(G.background)
re->stats_draw= stats_background;
else
re->stats_draw= stats_nothing;
/* clear callback handles */
re->dih= re->dch= re->ddh= re->sdh= re->prh= re->tbh= re->erh= NULL;
re->dih= re->dch= re->ddh= re->sdh= re->prh= re->tbh= NULL;
}
/* only call this while you know it will remove the link too */
@@ -1261,7 +1259,7 @@ void RE_InitState(Render *re, Render *source, RenderData *rd, SceneRenderLayer *
if(re->rectx < 2 || re->recty < 2 || (BKE_imtype_is_movie(rd->imtype) &&
(re->rectx < 16 || re->recty < 16) )) {
re->error(re->erh, "Image too small");
BKE_report(re->reports, RPT_ERROR, "Image too small");
re->ok= 0;
return;
}
@@ -1427,11 +1425,6 @@ void RE_test_break_cb(Render *re, void *handle, int (*f)(void *handle))
re->test_break= f;
re->tbh= handle;
}
void RE_error_cb(Render *re, void *handle, void (*f)(void *handle, const char *str))
{
re->error= f;
re->erh= handle;
}
/* ********* add object data (later) ******** */
@@ -2715,14 +2708,14 @@ static int check_valid_camera(Scene *scene, Object *camera_override)
return 1;
}
int RE_is_rendering_allowed(Scene *scene, Object *camera_override, void *erh, void (*error)(void *handle, const char *str))
int RE_is_rendering_allowed(Scene *scene, Object *camera_override, ReportList *reports)
{
SceneRenderLayer *srl;
if(scene->r.mode & R_BORDER) {
if(scene->r.border.xmax <= scene->r.border.xmin ||
scene->r.border.ymax <= scene->r.border.ymin) {
error(erh, "No border area selected.");
BKE_report(reports, RPT_ERROR, "No border area selected.");
return 0;
}
}
@@ -2733,13 +2726,13 @@ int RE_is_rendering_allowed(Scene *scene, Object *camera_override, void *erh, vo
scene_unique_exr_name(scene, str, 0);
if (BLI_is_writable(str)==0) {
error(erh, "Can not save render buffers, check the temp default path");
BKE_report(reports, RPT_ERROR, "Can not save render buffers, check the temp default path");
return 0;
}
/* no fullsample and edge */
if((scene->r.scemode & R_FULL_SAMPLE) && (scene->r.mode & R_EDGE)) {
error(erh, "Full Sample doesn't support Edge Enhance");
BKE_report(reports, RPT_ERROR, "Full Sample doesn't support Edge Enhance");
return 0;
}
@@ -2753,7 +2746,7 @@ int RE_is_rendering_allowed(Scene *scene, Object *camera_override, void *erh, vo
bNode *node;
if(ntree==NULL) {
error(erh, "No Nodetree in Scene");
BKE_report(reports, RPT_ERROR, "No Nodetree in Scene");
return 0;
}
@@ -2762,13 +2755,13 @@ int RE_is_rendering_allowed(Scene *scene, Object *camera_override, void *erh, vo
break;
if(node==NULL) {
error(erh, "No Render Output Node in Scene");
BKE_report(reports, RPT_ERROR, "No Render Output Node in Scene");
return 0;
}
if(scene->r.scemode & R_FULL_SAMPLE) {
if(composite_needs_render(scene)==0) {
error(erh, "Full Sample AA not supported without 3d rendering");
BKE_report(reports, RPT_ERROR, "Full Sample AA not supported without 3d rendering");
return 0;
}
}
@@ -2777,7 +2770,7 @@ int RE_is_rendering_allowed(Scene *scene, Object *camera_override, void *erh, vo
/* check valid camera, without camera render is OK (compo, seq) */
if(!check_valid_camera(scene, camera_override)) {
error(erh, "No camera");
BKE_report(reports, RPT_ERROR, "No camera");
return 0;
}
@@ -2787,7 +2780,7 @@ int RE_is_rendering_allowed(Scene *scene, Object *camera_override, void *erh, vo
/* forbidden combinations */
if(scene->r.mode & R_PANORAMA) {
if(scene->r.mode & R_ORTHO) {
error(erh, "No Ortho render possible for Panorama");
BKE_report(reports, RPT_ERROR, "No Ortho render possible for Panorama");
return 0;
}
}
@@ -2803,13 +2796,13 @@ int RE_is_rendering_allowed(Scene *scene, Object *camera_override, void *erh, vo
if(!(srl->layflag & SCE_LAY_DISABLE))
break;
if(srl==NULL) {
error(erh, "All RenderLayers are disabled");
BKE_report(reports, RPT_ERROR, "All RenderLayers are disabled");
return 0;
}
/* renderer */
if(!ELEM(scene->r.renderer, R_INTERN, R_YAFRAY)) {
error(erh, "Unknown render engine set");
BKE_report(reports, RPT_ERROR, "Unknown render engine set");
return 0;
}