[Bf-blender-cvs] SVN commit: /data/svn/bf-blender [43177] trunk/blender/source/blender/ render: Code refactoring: split render result related functions into separate file.

Brecht Van Lommel brechtvanlommel at pandora.be
Thu Jan 5 18:50:19 CET 2012


Revision: 43177
          http://projects.blender.org/scm/viewvc.php?view=rev&root=bf-blender&revision=43177
Author:   blendix
Date:     2012-01-05 17:50:09 +0000 (Thu, 05 Jan 2012)
Log Message:
-----------
Code refactoring: split render result related functions into separate file.

Modified Paths:
--------------
    trunk/blender/source/blender/render/CMakeLists.txt
    trunk/blender/source/blender/render/extern/include/RE_pipeline.h
    trunk/blender/source/blender/render/intern/include/renderpipeline.h
    trunk/blender/source/blender/render/intern/source/external_engine.c
    trunk/blender/source/blender/render/intern/source/pipeline.c
    trunk/blender/source/blender/render/intern/source/rayshade.c
    trunk/blender/source/blender/render/intern/source/rendercore.c
    trunk/blender/source/blender/render/intern/source/zbuf.c

Added Paths:
-----------
    trunk/blender/source/blender/render/intern/include/render_result.h
    trunk/blender/source/blender/render/intern/source/render_result.c

Modified: trunk/blender/source/blender/render/CMakeLists.txt
===================================================================
--- trunk/blender/source/blender/render/CMakeLists.txt	2012-01-05 17:39:30 UTC (rev 43176)
+++ trunk/blender/source/blender/render/CMakeLists.txt	2012-01-05 17:50:09 UTC (rev 43177)
@@ -66,6 +66,7 @@
 	intern/source/pointdensity.c
 	intern/source/rayshade.c
 	intern/source/rendercore.c
+	intern/source/render_result.c
 	intern/source/render_texture.c
 	intern/source/renderdatabase.c
 	intern/source/shadbuf.c
@@ -96,6 +97,7 @@
 	intern/include/rayintersection.h
 	intern/include/raycounter.h
 	intern/include/render_types.h
+	intern/include/render_result.h
 	intern/include/rendercore.h
 	intern/include/renderdatabase.h
 	intern/include/renderpipeline.h

Modified: trunk/blender/source/blender/render/extern/include/RE_pipeline.h
===================================================================
--- trunk/blender/source/blender/render/extern/include/RE_pipeline.h	2012-01-05 17:39:30 UTC (rev 43176)
+++ trunk/blender/source/blender/render/extern/include/RE_pipeline.h	2012-01-05 17:50:09 UTC (rev 43177)
@@ -182,9 +182,6 @@
 /* obligatory initialize call, disprect is optional */
 void RE_InitState (struct Render *re, struct Render *source, struct RenderData *rd, struct SceneRenderLayer *srl, int winx, int winy, rcti *disprect);
 
-/* use this to change disprect of active render */
-void RE_SetDispRect (struct Render *re, rcti *disprect);
-
 /* set up the viewplane/perspective matrix, three choices */
 struct Object *RE_GetCamera(struct Render *re); /* return camera override if set */
 void RE_SetCamera(struct Render *re, struct Object *camera);

Added: trunk/blender/source/blender/render/intern/include/render_result.h
===================================================================
--- trunk/blender/source/blender/render/intern/include/render_result.h	                        (rev 0)
+++ trunk/blender/source/blender/render/intern/include/render_result.h	2012-01-05 17:50:09 UTC (rev 43177)
@@ -0,0 +1,94 @@
+/*
+ * ***** 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) 2007 Blender Foundation.
+ * All rights reserved.
+ *
+ * The Original Code is: all of this file.
+ *
+ * Contributor(s): none yet.
+ *
+ * ***** END GPL LICENSE BLOCK *****
+ */
+
+/** \file blender/render/intern/include/render_result.h
+ *  \ingroup render
+ */
+
+#ifndef RENDER_RESULT_H
+#define RENDER_RESULT_H
+
+#define PASS_VECTOR_MAX	10000.0f
+
+#define RR_USE_MEM		0
+#define RR_USE_EXR		1
+
+struct ImBuf;
+struct ListBase;
+struct Render;
+struct RenderData;
+struct RenderLayer;
+struct RenderResult;
+struct Scene;
+struct rcti;
+
+/* New */
+
+struct RenderResult *render_result_new(struct Render *re,
+	struct rcti *partrct, int crop, int savebuffers);
+struct RenderResult *render_result_new_full_sample(struct Render *re,
+	struct ListBase *lb, struct rcti *partrct, int crop, int savebuffers);
+
+struct RenderResult *render_result_new_from_exr(void *exrhandle, int rectx, int recty);
+
+/* Merge */
+
+void render_result_merge(struct RenderResult *rr, struct RenderResult *rrpart);
+
+/* Free */
+
+void render_result_free(struct RenderResult *rr);
+void render_result_free_list(struct ListBase *lb, struct RenderResult *rr);
+
+/* Single Layer Render */
+
+void render_result_single_layer_begin(struct Render *re);
+void render_result_single_layer_end(struct Render *re);
+
+/* EXR Tile File Render */
+
+void render_result_exr_file_begin(struct Render *re);
+void render_result_exr_file_end(struct Render *re);
+
+void render_result_exr_file_merge(struct RenderResult *rr, struct RenderResult *rrpart);
+
+void render_result_exr_file_path(struct Scene *scene, int sample, char *filepath);
+int render_result_exr_file_read(struct Render *re, int sample);
+int render_result_exr_file_read_path(struct RenderResult *rr, const char *filepath);
+
+/* Combined Pixel Rect */
+
+struct ImBuf *render_result_rect_to_ibuf(struct RenderResult *rr, struct RenderData *rd);
+void render_result_rect_from_ibuf(struct RenderResult *rr, struct RenderData *rd,
+	struct ImBuf *ibuf);
+
+void render_result_rect_fill_zero(struct RenderResult *rr);
+void render_result_rect_get_pixels(struct RenderResult *rr, struct RenderData *rd,
+	unsigned int *rect, int rectx, int recty);
+
+#endif /* RENDER_RESULT_H */
+

Modified: trunk/blender/source/blender/render/intern/include/renderpipeline.h
===================================================================
--- trunk/blender/source/blender/render/intern/include/renderpipeline.h	2012-01-05 17:39:30 UTC (rev 43176)
+++ trunk/blender/source/blender/render/intern/include/renderpipeline.h	2012-01-05 17:50:09 UTC (rev 43177)
@@ -33,22 +33,12 @@
 #ifndef PIPELINE_H
 #define PIPELINE_H
 
-struct ListBase;
 struct Render;
-struct RenderResult;
 struct RenderLayer;
-struct rcti;
+struct RenderResult;
 
 struct RenderLayer *render_get_active_layer(struct Render *re, struct RenderResult *rr);
 float panorama_pixel_rot(struct Render *re);
 
-#define PASS_VECTOR_MAX	10000.0f
-
-#define RR_USEMEM	0
-
-struct RenderResult *new_render_result(struct Render *re, struct rcti *partrct, int crop, int savebuffers);
-void merge_render_result(struct RenderResult *rr, struct RenderResult *rrpart);
-void free_render_result(struct ListBase *lb, struct RenderResult *rr);
-
 #endif /* PIPELINE_H */
 

Modified: trunk/blender/source/blender/render/intern/source/external_engine.c
===================================================================
--- trunk/blender/source/blender/render/intern/source/external_engine.c	2012-01-05 17:39:30 UTC (rev 43176)
+++ trunk/blender/source/blender/render/intern/source/external_engine.c	2012-01-05 17:50:09 UTC (rev 43177)
@@ -54,7 +54,7 @@
 #include "RE_pipeline.h"
 
 #include "render_types.h"
-#include "renderpipeline.h"
+#include "render_result.h"
 
 /* Render Engine Types */
 
@@ -168,7 +168,7 @@
 	disprect.ymin= y;
 	disprect.ymax= y+h;
 
-	result= new_render_result(re, &disprect, 0, RR_USEMEM);
+	result= render_result_new(re, &disprect, 0, RR_USE_MEM);
 	BLI_addtail(&engine->fullresult, result);
 	
 	result->tilerect.xmin += re->disprect.xmin;
@@ -198,7 +198,7 @@
 
 	/* merge. on break, don't merge in result for preview renders, looks nicer */
 	if(!(re->test_break(re->tbh) && (re->r.scemode & R_PREVIEWBUTS)))
-		merge_render_result(re->result, result);
+		render_result_merge(re->result, result);
 
 	/* draw */
 	if(!re->test_break(re->tbh)) {
@@ -207,7 +207,7 @@
 	}
 
 	/* free */
-	free_render_result(&engine->fullresult, result);
+	render_result_free_list(&engine->fullresult, result);
 }
 
 /* Cancel */
@@ -286,8 +286,9 @@
 	/* create render result */
 	BLI_rw_mutex_lock(&re->resultmutex, THREAD_LOCK_WRITE);
 	if(re->result==NULL || !(re->r.scemode & R_PREVIEWBUTS)) {
-		RE_FreeRenderResult(re->result);
-		re->result= new_render_result(re, &re->disprect, 0, 0);
+		if(re->result)
+			render_result_free(re->result);
+		re->result= render_result_new(re, &re->disprect, 0, 0);
 	}
 	BLI_rw_mutex_unlock(&re->resultmutex);
 	
@@ -316,7 +317,7 @@
 	if(type->render)
 		type->render(engine, re->scene);
 
-	free_render_result(&engine->fullresult, engine->fullresult.first);
+	render_result_free_list(&engine->fullresult, engine->fullresult.first);
 
 	RE_engine_free(engine);
 

Modified: trunk/blender/source/blender/render/intern/source/pipeline.c
===================================================================
--- trunk/blender/source/blender/render/intern/source/pipeline.c	2012-01-05 17:39:30 UTC (rev 43176)
+++ trunk/blender/source/blender/render/intern/source/pipeline.c	2012-01-05 17:50:09 UTC (rev 43177)
@@ -78,6 +78,7 @@
 #include "RE_pipeline.h"
 
 /* internal */
+#include "render_result.h"
 #include "render_types.h"
 #include "renderpipeline.h"
 #include "renderdatabase.h"
@@ -184,347 +185,9 @@
 
 void RE_FreeRenderResult(RenderResult *res)
 {
-	if(res==NULL) return;
-
-	while(res->layers.first) {
-		RenderLayer *rl= res->layers.first;
-		
-		if(rl->rectf) MEM_freeN(rl->rectf);
-		/* acolrect and scolrect are optionally allocated in shade_tile, only free here since it can be used for drawing */
-		if(rl->acolrect) MEM_freeN(rl->acolrect);
-		if(rl->scolrect) MEM_freeN(rl->scolrect);
-		
-		while(rl->passes.first) {
-			RenderPass *rpass= rl->passes.first;
-			if(rpass->rect) MEM_freeN(rpass->rect);
-			BLI_remlink(&rl->passes, rpass);
-			MEM_freeN(rpass);
-		}
-		BLI_remlink(&res->layers, rl);
-		MEM_freeN(rl);
-	}
-	
-	if(res->rect32)
-		MEM_freeN(res->rect32);
-	if(res->rectz)
-		MEM_freeN(res->rectz);
-	if(res->rectf)
-		MEM_freeN(res->rectf);
-	if(res->text)
-		MEM_freeN(res->text);
-	
-	MEM_freeN(res);
+	render_result_free(res);
 }
 
-/* version that's compatible with fullsample buffers */
-void free_render_result(ListBase *lb, RenderResult *rr)
-{
-	RenderResult *rrnext;
-	
-	for(; rr; rr= rrnext) {
-		rrnext= rr->next;
-		
-		if(lb && lb->first)
-			BLI_remlink(lb, rr);
-		
-		RE_FreeRenderResult(rr);
-	}
-}
-
-
-/* all layers except the active one get temporally pushed away */
-static void push_render_result(Render *re)
-{
-	BLI_rw_mutex_lock(&re->resultmutex, THREAD_LOCK_WRITE);
-
-	/* officially pushed result should be NULL... error can happen with do_seq */
-	RE_FreeRenderResult(re->pushedresult);
-	
-	re->pushedresult= re->result;
-	re->result= NULL;
-
-	BLI_rw_mutex_unlock(&re->resultmutex);
-}
-
-/* if scemode is R_SINGLE_LAYER, at end of rendering, merge the both render results */
-static void pop_render_result(Render *re)
-{
-	if(re->result==NULL) {
-		printf("pop render result error; no current result!\n");
-		return;
-	}
-
-	if(re->pushedresult) {
-		BLI_rw_mutex_lock(&re->resultmutex, THREAD_LOCK_WRITE);
-

@@ Diff output truncated at 10240 characters. @@


More information about the Bf-blender-cvs mailing list