Merge branch 'blender2.7'
[blender.git] / source / blender / render / intern / include / render_result.h
1 /*
2  * ***** BEGIN GPL LICENSE BLOCK *****
3  *
4  * This program is free software; you can redistribute it and/or
5  * modify it under the terms of the GNU General Public License
6  * as published by the Free Software Foundation; either version 2
7  * of the License, or (at your option) any later version.
8  *
9  * This program is distributed in the hope that it will be useful,
10  * but WITHOUT ANY WARRANTY; without even the implied warranty of
11  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
12  * GNU General Public License for more details.
13  *
14  * You should have received a copy of the GNU General Public License
15  * along with this program; if not, write to the Free Software Foundation,
16  * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
17  *
18  * The Original Code is Copyright (C) 2007 Blender Foundation.
19  * All rights reserved.
20  *
21  * The Original Code is: all of this file.
22  *
23  * Contributor(s): none yet.
24  *
25  * ***** END GPL LICENSE BLOCK *****
26  */
27
28 /** \file blender/render/intern/include/render_result.h
29  *  \ingroup render
30  */
31
32 #ifndef __RENDER_RESULT_H__
33 #define __RENDER_RESULT_H__
34
35 #define PASS_VECTOR_MAX 10000.0f
36
37 #define RR_USE_MEM              0
38 #define RR_USE_EXR              1
39
40 #define RR_ALL_LAYERS   NULL
41 #define RR_ALL_VIEWS    NULL
42
43 struct ImBuf;
44 struct ListBase;
45 struct Render;
46 struct RenderData;
47 struct RenderEngine;
48 struct RenderLayer;
49 struct RenderResult;
50 struct Scene;
51 struct rcti;
52 struct ColorManagedDisplaySettings;
53 struct ColorManagedViewSettings;
54
55 /* New */
56
57 struct RenderResult *render_result_new(struct Render *re,
58         struct rcti *partrct, int crop, int savebuffers, const char *layername, const char *viewname);
59
60 struct RenderResult *render_result_new_from_exr(void *exrhandle, const char *colorspace, bool predivide, int rectx, int recty);
61
62 void render_result_view_new(struct RenderResult *rr, const char *viewname);
63 void render_result_views_new(struct RenderResult *rr, struct RenderData *rd);
64
65 /* Merge */
66
67 void render_result_merge(struct RenderResult *rr, struct RenderResult *rrpart);
68
69 /* Add Passes */
70
71 void render_result_clone_passes(struct Render *re, struct RenderResult *rr, const char *viewname);
72 void render_result_add_pass(struct RenderResult *rr, const char *name, int channels, const char *chan_id, const char *layername, const char *viewname);
73
74 /* Free */
75
76 void render_result_free(struct RenderResult *rr);
77 void render_result_free_list(struct ListBase *lb, struct RenderResult *rr);
78
79 /* Single Layer Render */
80
81 void render_result_single_layer_begin(struct Render *re);
82 void render_result_single_layer_end(struct Render *re);
83
84 /* EXR Tile File Render */
85
86 void render_result_save_empty_result_tiles(struct Render *re);
87 void render_result_exr_file_begin(struct Render *re, struct RenderEngine *engine);
88 void render_result_exr_file_end(struct Render *re, struct RenderEngine *engine);
89
90 /* render pass wrapper for gpencil */
91 struct RenderPass *gp_add_pass(struct RenderResult *rr, struct RenderLayer *rl, int channels, const char *name, const char *viewname);
92
93 void render_result_exr_file_merge(struct RenderResult *rr, struct RenderResult *rrpart, const char *viewname);
94
95 void render_result_exr_file_path(struct Scene *scene, const char *layname, int sample, char *filepath);
96 int render_result_exr_file_read_sample(struct Render *re, int sample, struct RenderEngine *engine);
97 int render_result_exr_file_read_path(struct RenderResult *rr, struct RenderLayer *rl_single, const char *filepath);
98
99 /* EXR cache */
100
101 void render_result_exr_file_cache_write(struct Render *re);
102 bool render_result_exr_file_cache_read(struct Render *re);
103
104 /* Combined Pixel Rect */
105
106 struct ImBuf *render_result_rect_to_ibuf(struct RenderResult *rr, struct RenderData *rd, const int view_id);
107
108 void render_result_rect_fill_zero(struct RenderResult *rr, const int view_id);
109 void render_result_rect_get_pixels(struct RenderResult *rr,
110         unsigned int *rect, int rectx, int recty,
111         const struct ColorManagedViewSettings *view_settings,
112         const struct ColorManagedDisplaySettings *display_settings,
113         const int view_id);
114
115 void render_result_views_shallowcopy(struct RenderResult *dst, struct RenderResult *src);
116 void render_result_views_shallowdelete(struct RenderResult *rr);
117 bool render_result_has_views(struct RenderResult *rr);
118
119 #define FOREACH_VIEW_LAYER_TO_RENDER_BEGIN(re_, iter_)    \
120 {                                                         \
121         int nr_;                                              \
122         ViewLayer *iter_;                                     \
123         for (nr_ = 0, iter_ = (re_)->view_layers.first;       \
124              iter_ != NULL;                                   \
125             iter_ = iter_->next, nr_++)                       \
126         {                                                     \
127                 if (!G.background &&  (re_)->r.scemode & R_SINGLE_LAYER) {  \
128                         if (nr_ != re->active_view_layer) {           \
129                                 continue;                                 \
130                         }                                             \
131                 }                                                 \
132                 else {                                            \
133                         if ((iter_->flag & VIEW_LAYER_RENDER) == 0) { \
134                                 continue;                                 \
135                         }                                             \
136                 }
137
138 #define FOREACH_VIEW_LAYER_TO_RENDER_END                  \
139         }                                                     \
140 } ((void)0)
141
142 #endif /* __RENDER_RESULT_H__ */