rename RNA_property_is_set() --> RNA_struct_property_is_set() in preperation to add...
[blender.git] / source / blender / editors / render / render_internal.c
index 857a36c3029d8fc782b6816ae3b36e41bb8f0d5d..e35df2177612d92f1d346e9329790ff61481155f 100644 (file)
@@ -1,6 +1,4 @@
 /*
- * $Id$
- *
  * ***** BEGIN GPL LICENSE BLOCK *****
  *
  * This program is free software; you can redistribute it and/or
@@ -54,6 +52,7 @@
 #include "BKE_report.h"
 #include "BKE_sequencer.h"
 #include "BKE_screen.h"
+#include "BKE_scene.h"
 
 #include "WM_api.h"
 #include "WM_types.h"
 
 #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;
+       float *rectf= NULL;
        int ymin, ymax, xmin, xmax;
-       int rymin, rxmin;
-       char *rectc;
+       int rymin, rxmin, predivide, profile_from;
+       unsigned char *rectc;
 
        /* if renrect argument, we only refresh scanlines */
        if(renrect) {
@@ -94,7 +90,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;
@@ -139,300 +136,85 @@ void image_buffer_rect_update(Scene *scene, RenderResult *rr, ImBuf *ibuf, volat
                imb_addrectImBuf(ibuf);
        
        rectf+= 4*(rr->rectx*ymin + xmin);
-       rectc= (char *)(ibuf->rect + ibuf->x*rymin + rxmin);
-       
-       /* 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;
-
-                       /* 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;
-                                       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]);
-                               }
-                       }
-                       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]);
-                               }
-                       }
-                       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);
+       rectc= (unsigned char*)(ibuf->rect + ibuf->x*rymin + rxmin);
 
-               sa= CTX_wm_area(C);
+       if(scene && (scene->r.color_mgt_flag & R_COLOR_MANAGEMENT)) {
+               profile_from= IB_PROFILE_LINEAR_RGB;
+               predivide= (scene->r.color_mgt_flag & R_COLOR_MANAGEMENT_PREDIVIDE);
        }
-       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 */
-                       ;
-               }
-
+       else {
+               profile_from= IB_PROFILE_SRGB;
+               predivide= 0;
        }
 
+       IMB_buffer_byte_from_float(rectc, rectf,
+               4, ibuf->dither, IB_PROFILE_SRGB, profile_from, predivide,
+               xmax, ymax, ibuf->x, rr->rectx);
 }
 
-
 /* ****************************** 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)
+static void screen_render_scene_layer_set(wmOperator *op, Main *mainp, Scene **scene, SceneRenderLayer **srl)
 {
-       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;
-}
+       /* single layer re-render */
+       if(RNA_struct_property_is_set(op->ptr, "scene")) {
+               Scene *scn;
+               char scene_name[MAX_ID_NAME-2];
 
+               RNA_string_get(op->ptr, "scene", scene_name);
+               scn = (Scene *)BLI_findstring(&mainp->scene, scene_name, offsetof(ID, name) + 2);
+               
+               if (scn) {
+                       /* camera switch wont have updated */
+                       scn->r.cfra= (*scene)->r.cfra;
+                       scene_camera_switch_update(scn);
 
-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;
-                       }
+                       *scene = scn;
                }
-               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(RNA_struct_property_is_set(op->ptr, "layer")) {
+               SceneRenderLayer *rl;
+               char rl_name[RE_MAXNAME];
 
-#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;
-               }
+               RNA_string_get(op->ptr, "layer", rl_name);
+               rl = (SceneRenderLayer *)BLI_findstring(&(*scene)->r.layers, rl_name, offsetof(SceneRenderLayer, name));
+               
+               if (rl)
+                       *srl = rl;
        }
-       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)
 {
        Scene *scene= CTX_data_scene(C);
-       Render *re= RE_NewRender(scene->id.name);
+       SceneRenderLayer *srl= NULL;
+       Render *re;
        Image *ima;
        View3D *v3d= CTX_wm_view3d(C);
        Main *mainp= CTX_data_main(C);
-       unsigned int lay= (v3d)? v3d->lay: scene->lay;
+       unsigned int lay;
        const short is_animation= RNA_boolean_get(op->ptr, "animation");
        const short is_write_still= RNA_boolean_get(op->ptr, "write_still");
+       struct Object *camera_override= v3d ? V3D_CAMERA_LOCAL(v3d) : NULL;
 
-       if(!is_animation && is_write_still && BKE_imtype_is_movie(scene->r.imtype)) {
-               BKE_report(op->reports, RPT_ERROR, "Can't write a single file with an animation format selected.");
+       /* custom scene and single layer re-render */
+       screen_render_scene_layer_set(op, mainp, &scene, &srl);
+
+       if(!is_animation && is_write_still && BKE_imtype_is_movie(scene->r.im_format.imtype)) {
+               BKE_report(op->reports, RPT_ERROR, "Can't write a single file with an animation format selected");
                return OPERATOR_CANCELLED;
        }
 
-       if(re==NULL) {
-               re= RE_NewRender(scene->id.name);
-       }
-       
+       re= RE_NewRender(scene->id.name);
+       lay= (v3d)? v3d->lay: scene->lay;
+
        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);
@@ -444,10 +226,14 @@ static int screen_render_exec(bContext *C, wmOperator *op)
           since sequence rendering can call that recursively... (peter) */
        seq_stripelem_cache_cleanup();
 
+       RE_SetReports(re, op->reports);
+
        if(is_animation)
-               RE_BlenderAnim(re, mainp, scene, lay, scene->r.sfra, scene->r.efra, scene->r.frame_step, op->reports);
+               RE_BlenderAnim(re, mainp, scene, camera_override, lay, scene->r.sfra, scene->r.efra, scene->r.frame_step);
        else
-               RE_BlenderFrame(re, mainp, scene, NULL, lay, scene->r.cfra, is_write_still);
+               RE_BlenderFrame(re, mainp, scene, srl, camera_override, lay, scene->r.cfra, is_write_still);
+
+       RE_SetReports(re, NULL);
 
        // no redraw needed, we leave state as we entered it
        ED_update_for_newframe(mainp, scene, CTX_wm_screen(C), 1);
@@ -463,6 +249,7 @@ typedef struct RenderJob {
        Render *re;
        wmWindow *win;
        SceneRenderLayer *srl;
+       struct Object *camera_override;
        int lay;
        short anim, write_still;
        Image *image;
@@ -505,10 +292,13 @@ static void make_renderinfo_string(RenderStats *rs, Scene *scene, char *str)
                spos+= sprintf(spos, "%s ", rs->statstr);
        }
        else {
-               spos+= sprintf(spos, "Fra:%d  Ve:%d Fa:%d ", (scene->r.cfra), rs->totvert, rs->totface);
+               spos+= sprintf(spos, "Fra:%d  ", (scene->r.cfra));
+               if(rs->totvert) spos+= sprintf(spos, "Ve:%d ", rs->totvert);
+               if(rs->totface) spos+= sprintf(spos, "Fa:%d ", rs->totface);
                if(rs->tothalo) spos+= sprintf(spos, "Ha:%d ", rs->tothalo);
                if(rs->totstrand) spos+= sprintf(spos, "St:%d ", rs->totstrand);
-               spos+= sprintf(spos, "La:%d Mem:%.2fM (%.2fM, peak %.2fM) ", rs->totlamp, megs_used_memory, mmap_used_memory, megs_peak_memory);
+               if(rs->totlamp) spos+= sprintf(spos, "La:%d ", rs->totlamp);
+               spos+= sprintf(spos, "Mem:%.2fM (%.2fM, peak %.2fM) ", megs_used_memory, mmap_used_memory, megs_peak_memory);
 
                if(rs->curfield)
                        spos+= sprintf(spos, "Field %d ", rs->curfield);
@@ -519,6 +309,9 @@ static void make_renderinfo_string(RenderStats *rs, Scene *scene, char *str)
        BLI_timestr(rs->lastframetime, info_time_str);
        spos+= sprintf(spos, "Time:%s ", info_time_str);
 
+       if(rs->curfsa)
+               spos+= sprintf(spos, "| Full Sample %d ", rs->curfsa);
+       
        if(rs->infostr && rs->infostr[0])
                spos+= sprintf(spos, "| %s ", rs->infostr);
 
@@ -555,8 +348,12 @@ static void render_progress_update(void *rjv, float progress)
 {
        RenderJob *rj= rjv;
        
-       if (rj->progress)
+       if(rj->progress && *rj->progress != progress) {
                *rj->progress = progress;
+
+               /* make jobs timer to send notifier */
+               *(rj->do_update)= 1;
+       }
 }
 
 static void image_rect_update(void *rjv, RenderResult *rr, volatile rcti *renrect)
@@ -588,10 +385,14 @@ static void render_startjob(void *rjv, short *stop, short *do_update, float *pro
        rj->do_update= do_update;
        rj->progress= progress;
 
+       RE_SetReports(rj->re, rj->reports);
+
        if(rj->anim)
-               RE_BlenderAnim(rj->re, rj->main, rj->scene, rj->lay, rj->scene->r.sfra, rj->scene->r.efra, rj->scene->r.frame_step, rj->reports);
+               RE_BlenderAnim(rj->re, rj->main, rj->scene, rj->camera_override, rj->lay, rj->scene->r.sfra, rj->scene->r.efra, rj->scene->r.frame_step);
        else
-               RE_BlenderFrame(rj->re, rj->main, rj->scene, rj->srl, rj->lay, rj->scene->r.cfra, rj->write_still);
+               RE_BlenderFrame(rj->re, rj->main, rj->scene, rj->srl, rj->camera_override, rj->lay, rj->scene->r.cfra, rj->write_still);
+
+       RE_SetReports(rj->re, NULL);
 }
 
 static void render_endjob(void *rjv)
@@ -610,13 +411,13 @@ static void render_endjob(void *rjv)
                ED_update_for_newframe(G.main, rj->scene, rj->win->screen, 1);
        
        /* XXX above function sets all tags in nodes */
-       ntreeClearTags(rj->scene->nodetree);
+       ntreeCompositClearTags(rj->scene->nodetree);
        
        /* potentially set by caller */
        rj->scene->r.scemode &= ~R_NO_FRAME_UPDATE;
        
        if(rj->srl) {
-               NodeTagIDChanged(rj->scene->nodetree, &rj->scene->id);
+               nodeUpdateID(rj->scene->nodetree, &rj->scene->id);
                WM_main_add_notifier(NC_NODE|NA_EDITED, rj->scene);
        }
        
@@ -678,17 +479,19 @@ static int screen_render_invoke(bContext *C, wmOperator *op, wmEvent *event)
        int jobflag;
        const short is_animation= RNA_boolean_get(op->ptr, "animation");
        const short is_write_still= RNA_boolean_get(op->ptr, "write_still");
+       struct Object *camera_override= v3d ? V3D_CAMERA_LOCAL(v3d) : NULL;
+       const char *name;
        
        /* only one render job at a time */
        if(WM_jobs_test(CTX_wm_manager(C), scene))
                return OPERATOR_CANCELLED;
 
-       if(!RE_is_rendering_allowed(scene, op->reports, render_error_reports)) {
+       if(!RE_is_rendering_allowed(scene, camera_override, op->reports)) {
                return OPERATOR_CANCELLED;
        }
 
-       if(!is_animation && is_write_still && BKE_imtype_is_movie(scene->r.imtype)) {
-               BKE_report(op->reports, RPT_ERROR, "Can't write a single file with an animation format selected.");
+       if(!is_animation && is_write_still && BKE_imtype_is_movie(scene->r.im_format.imtype)) {
+               BKE_report(op->reports, RPT_ERROR, "Can't write a single file with an animation format selected");
                return OPERATOR_CANCELLED;
        }       
        
@@ -727,28 +530,15 @@ 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;
        
-       /* single layer re-render */
-       if(RNA_property_is_set(op->ptr, "layer")) {
-               SceneRenderLayer *rl;
-               Scene *scn;
-               char scene_name[19], rl_name[RE_MAXNAME];
+       /* custom scene and single layer re-render */
+       screen_render_scene_layer_set(op, mainp, &scene, &srl);
 
-               RNA_string_get(op->ptr, "layer", rl_name);
-               RNA_string_get(op->ptr, "scene", scene_name);
-
-               scn = (Scene *)BLI_findstring(&mainp->scene, scene_name, offsetof(ID, name) + 2);
-               rl = (SceneRenderLayer *)BLI_findstring(&scene->r.layers, rl_name, offsetof(SceneRenderLayer, name));
-               
-               if (scn && rl) {
-                       scene = scn;
-                       srl = rl;
-               }
+       if(RNA_struct_property_is_set(op->ptr, "layer"))
                jobflag |= WM_JOB_SUSPEND;
-       }
 
        /* job custom data */
        rj= MEM_callocN(sizeof(RenderJob), "render job");
@@ -756,6 +546,7 @@ static int screen_render_invoke(bContext *C, wmOperator *op, wmEvent *event)
        rj->scene= scene;
        rj->win= CTX_wm_window(C);
        rj->srl = srl;
+       rj->camera_override = camera_override;
        rj->lay = (v3d)? v3d->lay: scene->lay;
        rj->anim= is_animation;
        rj->write_still= is_write_still && !is_animation;
@@ -764,7 +555,10 @@ static int screen_render_invoke(bContext *C, wmOperator *op, wmEvent *event)
        rj->reports= op->reports;
 
        /* setup job */
-       steve= WM_jobs_get(CTX_wm_manager(C), CTX_wm_window(C), scene, "Render", jobflag);
+       if(RE_seq_render_active(scene, &scene->r)) name= "Sequence Render";
+       else name= "Render";
+
+       steve= WM_jobs_get(CTX_wm_manager(C), CTX_wm_window(C), scene, name, jobflag);
        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, render_endjob);
@@ -786,8 +580,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);
@@ -804,7 +596,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)
 {
@@ -822,123 +613,7 @@ void RENDER_OT_render(wmOperatorType *ot)
 
        RNA_def_boolean(ot->srna, "animation", 0, "Animation", "Render files from the animation range of this scene");
        RNA_def_boolean(ot->srna, "write_still", 0, "Write Image", "Save rendered the image to the output path (used only when animation is disabled)");
-       RNA_def_string(ot->srna, "layer", "", RE_MAXNAME, "Render Layer", "Single render layer to re-render");
-       RNA_def_string(ot->srna, "scene", "", 19, "Scene", "Re-render single layer in this scene");
+       RNA_def_string(ot->srna, "layer", "", RE_MAXNAME, "Render Layer", "Single render layer to re-render (used only when animation is disabled)");
+       RNA_def_string(ot->srna, "scene", "", MAX_ID_NAME-2, "Scene", "Scene to render, current scene if not specified");
 }
 
-/* ****************************** opengl render *************************** */
-
-
-/* *********************** cancel render viewer *************** */
-
-static int render_view_cancel_exec(bContext *C, wmOperator *UNUSED(unused))
-{
-       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(unused), 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;
-}