Render API: add self.report() function for RenderEngine, for reporting warnings and...
authorBrecht Van Lommel <brechtvanlommel@pandora.be>
Tue, 17 May 2011 15:20:12 +0000 (15:20 +0000)
committerBrecht Van Lommel <brechtvanlommel@pandora.be>
Tue, 17 May 2011 15:20:12 +0000 (15:20 +0000)
source/blender/editors/render/render_internal.c
source/blender/editors/render/render_update.c
source/blender/makesrna/intern/rna_render.c
source/blender/render/extern/include/RE_engine.h
source/blender/render/extern/include/RE_pipeline.h
source/blender/render/intern/include/render_types.h
source/blender/render/intern/pipeline/engine.c
source/blender/render/intern/source/pipeline.c
source/creator/creator.c

index 7f90e298504c2b8fad9e32c21002a22bd48eaad6..bde1591b35904a2ef63108c446958da5ddc688bd 100644 (file)
@@ -446,11 +446,15 @@ 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, camera_override, 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, 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);
 
@@ -591,10 +595,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->camera_override, 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->camera_override, rj->lay, rj->scene->r.cfra, rj->write_still);
+
+       RE_SetReports(rj->re, NULL);
 }
 
 static void render_endjob(void *rjv)
index c795c35e9d42f09bba039e13cd1996ec7e3bd602..6548bdb37a93e63f541489c6deebb1b526006ed7 100644 (file)
@@ -43,6 +43,8 @@
 #include "DNA_view3d_types.h"
 #include "DNA_world_types.h"
 
+#include "BLI_utildefines.h"
+
 #include "BKE_context.h"
 #include "BKE_depsgraph.h"
 #include "BKE_icons.h"
index ed7e99b9cb5fced98c0a30d76bf43462278d785e..9c7076012ce1cb8f167fc0d352a6668f9d935e7e 100644 (file)
@@ -32,6 +32,7 @@
 #include "DNA_scene_types.h"
 
 #include "RNA_define.h"
+#include "RNA_enum_types.h"
 
 #include "rna_internal.h"
 
@@ -373,6 +374,12 @@ static void rna_def_render_engine(BlenderRNA *brna)
        prop= RNA_def_string(func, "info", "", 0, "Info", "");
        RNA_def_property_flag(prop, PROP_REQUIRED);
 
+       func= RNA_def_function(srna, "report", "RE_engine_report");
+       prop= RNA_def_enum_flag(func, "type", wm_report_items, 0, "Type", "");
+       RNA_def_property_flag(prop, PROP_REQUIRED);
+       prop= RNA_def_string(func, "message", "", 0, "Report Message", "");
+       RNA_def_property_flag(prop, PROP_REQUIRED);
+
        /* registration */
        RNA_define_verify_sdna(0);
 
index e6680386064c18e618100aa1bb3585d4f41a3545..82a421e85498a143e774d681804a115611f45a61 100644 (file)
@@ -99,6 +99,7 @@ LIBEXPORT void RE_engine_end_result(RenderEngine *engine, struct RenderResult *r
 
 LIBEXPORT int RE_engine_test_break(RenderEngine *engine);
 LIBEXPORT void RE_engine_update_stats(RenderEngine *engine, const char *stats, const char *info);
+LIBEXPORT void RE_engine_report(RenderEngine *engine, int type, const char *msg);
 
 int RE_engine_render(struct Render *re, int do_all);
 
index 08b083111d59c3bfead5e278822b319c7e2af616..2e70d8110e20132151b23fece521c76dbc0516dc 100644 (file)
@@ -214,7 +214,10 @@ void RE_TileProcessor(struct Render *re);
 
 /* only RE_NewRender() needed, main Blender render calls */
 void RE_BlenderFrame(struct Render *re, struct Main *bmain, struct Scene *scene, struct SceneRenderLayer *srl, struct Object *camera_override, unsigned int lay, int frame, const short write_still);
-void RE_BlenderAnim(struct Render *re, struct Main *bmain, struct Scene *scene, struct Object *camera_override, unsigned int lay, int sfra, int efra, int tfra, struct ReportList *reports);
+void RE_BlenderAnim(struct Render *re, struct Main *bmain, struct Scene *scene, struct Object *camera_override, unsigned int lay, int sfra, int efra, int tfra);
+
+/* error reporting */
+void RE_SetReports(struct Render *re, struct ReportList *reports);
 
 /* main preview render call */
 void RE_PreviewRender(struct Render *re, struct Main *bmain, struct Scene *scene);
index cf16211b6d1baeb1d928aeeb9227304a624b4e0c..30b8930eb5237190930c66b2c6bfc4850617b432 100644 (file)
@@ -60,6 +60,7 @@ struct RenderBuckets;
 struct ObjectInstanceRen;
 struct RayObject;
 struct RayFace;
+struct ReportList;
 struct Main;
 
 #define TABLEINITSIZE 1024
@@ -256,6 +257,8 @@ struct Render
        void *erh;
        
        RenderStats i;
+
+       struct ReportList *reports;
 };
 
 /* ------------------------------------------------------------------------- */
index f6c9c326240acbf3f9c94946b3aef3e935c0700b..91463ffb428580b3cab2cb0089077b2db7441695 100644 (file)
@@ -209,6 +209,11 @@ void RE_engine_update_stats(RenderEngine *engine, const char *stats, const char
        re->i.statstr= NULL;
 }
 
+void RE_engine_report(RenderEngine *engine, int type, const char *msg)
+{
+       BKE_report(engine->re->reports, type, msg);
+}
+
 /* Render */
 
 int RE_engine_render(Render *re, int do_all)
index f73065f649b1f7d33279589c78119a408fa44bf1..ebc5794881f4642087fb56e04868e446841aa395 100644 (file)
@@ -128,7 +128,7 @@ Render R;
 
 /* ********* alloc and free ******** */
 
-static int do_write_image_or_movie(Render *re, Scene *scene, bMovieHandle *mh, ReportList *reports, const char *name_override);
+static int do_write_image_or_movie(Render *re, Scene *scene, bMovieHandle *mh, const char *name_override);
 
 static volatile int g_break= 0;
 static int thread_break(void *UNUSED(arg))
@@ -2911,6 +2911,11 @@ static int render_initialize_from_main(Render *re, Main *bmain, Scene *scene, Sc
        return 1;
 }
 
+void RE_SetReports(Render *re, ReportList *reports)
+{
+       re->reports= reports;
+}
+
 /* general Blender frame render call */
 void RE_BlenderFrame(Render *re, Main *bmain, Scene *scene, SceneRenderLayer *srl, Object *camera_override, unsigned int lay, int frame, const short write_still)
 {
@@ -2933,7 +2938,7 @@ void RE_BlenderFrame(Render *re, Main *bmain, Scene *scene, SceneRenderLayer *sr
                                BKE_makepicstring(name, scene->r.pic, scene->r.cfra, scene->r.imtype, scene->r.scemode & R_EXTENSION, FALSE);
        
                                /* reports only used for Movie */
-                               do_write_image_or_movie(re, scene, NULL, NULL, name);
+                               do_write_image_or_movie(re, scene, NULL, name);
                        }
                }
        }
@@ -2942,7 +2947,7 @@ void RE_BlenderFrame(Render *re, Main *bmain, Scene *scene, SceneRenderLayer *sr
        G.rendering= 0;
 }
 
-static int do_write_image_or_movie(Render *re, Scene *scene, bMovieHandle *mh, ReportList *reports, const char *name_override)
+static int do_write_image_or_movie(Render *re, Scene *scene, bMovieHandle *mh, const char *name_override)
 {
        char name[FILE_MAX];
        RenderResult rres;
@@ -2960,7 +2965,7 @@ static int do_write_image_or_movie(Render *re, Scene *scene, bMovieHandle *mh, R
                        dofree = 1;
                }
                RE_ResultGet32(re, (unsigned int *)rres.rect32);
-               ok= mh->append_movie(&re->r, scene->r.cfra, rres.rect32, rres.rectx, rres.recty, reports);
+               ok= mh->append_movie(&re->r, scene->r.cfra, rres.rect32, rres.rectx, rres.recty, re->reports);
                if(dofree) {
                        MEM_freeN(rres.rect32);
                }
@@ -3033,7 +3038,7 @@ static int do_write_image_or_movie(Render *re, Scene *scene, bMovieHandle *mh, R
 }
 
 /* saves images to disk */
-void RE_BlenderAnim(Render *re, Main *bmain, Scene *scene, Object *camera_override, unsigned int lay, int sfra, int efra, int tfra, ReportList *reports)
+void RE_BlenderAnim(Render *re, Main *bmain, Scene *scene, Object *camera_override, unsigned int lay, int sfra, int efra, int tfra)
 {
        bMovieHandle *mh= BKE_get_movie_handle(scene->r.imtype);
        int cfrao= scene->r.cfra;
@@ -3046,21 +3051,21 @@ void RE_BlenderAnim(Render *re, Main *bmain, Scene *scene, Object *camera_overri
        /* ugly global still... is to prevent renderwin events and signal subsurfs etc to make full resol */
        /* is also set by caller renderwin.c */
        G.rendering= 1;
-       
+
        if(BKE_imtype_is_movie(scene->r.imtype))
-               if(!mh->start_movie(scene, &re->r, re->rectx, re->recty, reports))
+               if(!mh->start_movie(scene, &re->r, re->rectx, re->recty, re->reports))
                        G.afbreek= 1;
 
        if (mh->get_next_frame) {
                while (!(G.afbreek == 1)) {
-                       int nf = mh->get_next_frame(&re->r, reports);
+                       int nf = mh->get_next_frame(&re->r, re->reports);
                        if (nf >= 0 && nf >= scene->r.sfra && nf <= scene->r.efra) {
                                scene->r.cfra = re->r.cfra = nf;
                                
                                do_render_all_options(re);
 
                                if(re->test_break(re->tbh) == 0) {
-                                       if(!do_write_image_or_movie(re, scene, mh, reports, NULL))
+                                       if(!do_write_image_or_movie(re, scene, mh, NULL))
                                                G.afbreek= 1;
                                }
                        } else {
@@ -3115,7 +3120,7 @@ void RE_BlenderAnim(Render *re, Main *bmain, Scene *scene, Object *camera_overri
                        
                        if(re->test_break(re->tbh) == 0) {
                                if(!G.afbreek)
-                                       if(!do_write_image_or_movie(re, scene, mh, reports, NULL))
+                                       if(!do_write_image_or_movie(re, scene, mh, NULL))
                                                G.afbreek= 1;
                        }
                        else
index 18097f352575bb3d493297ee757b248e29baa645..1a486313c92e81e3ff8aacad0047e94ee39f171c 100644 (file)
@@ -782,7 +782,9 @@ static int render_frame(int argc, const char **argv, void *data)
 
                        frame = MIN2(MAXFRAME, MAX2(MINAFRAME, frame));
 
-                       RE_BlenderAnim(re, bmain, scene, NULL, scene->lay, frame, frame, scene->r.frame_step, &reports);
+                       RE_SetReports(re, &reports);
+                       RE_BlenderAnim(re, bmain, scene, NULL, scene->lay, frame, frame, scene->r.frame_step);
+                       RE_SetReports(re, NULL);
                        return 1;
                } else {
                        printf("\nError: frame number must follow '-f / --render-frame'.\n");
@@ -803,7 +805,9 @@ static int render_animation(int UNUSED(argc), const char **UNUSED(argv), void *d
                Render *re= RE_NewRender(scene->id.name);
                ReportList reports;
                BKE_reports_init(&reports, RPT_PRINT);
-               RE_BlenderAnim(re, bmain, scene, NULL, scene->lay, scene->r.sfra, scene->r.efra, scene->r.frame_step, &reports);
+               RE_SetReports(re, &reports);
+               RE_BlenderAnim(re, bmain, scene, NULL, scene->lay, scene->r.sfra, scene->r.efra, scene->r.frame_step);
+               RE_SetReports(re, NULL);
        } else {
                printf("\nError: no blend loaded. cannot use '-a'.\n");
        }